TD-455: Fix cash field (#164)

This commit is contained in:
Rinat Arsaev 2022-11-17 16:21:54 +06:00 committed by GitHub
parent 7136470378
commit de37cc1054
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 47 additions and 35 deletions

3
.gitignore vendored
View File

@ -48,4 +48,5 @@ Thumbs.db
# Env and configs
.env*
/src/assets/*Config*.json
/src/assets/appConfig*.json
/src/assets/authConfig*.json

View File

@ -1,32 +1,16 @@
# Control Center
## Installation
Admin Dashboard
## ⚙️ Installation
1. Add environment and configurations:
- `.env`
```env
PROXY_TARGET="https://<URL>"
```
- `src/assets/appConfig.json`:
```json
{
"fileStorageEndpoint": "https://<URL>",
"constants": {
"currencies": [{ "source": "<ID>", "currency": "USD" }]
}
}
```
- `src/assets/authConfig.json`:
```json
{
"realm": "internal",
"auth-server-url": "https://<URL>",
"ssl-required": "external",
"resource": "control-center",
"public-client": true
}
```
- [`.env`](./_.env)
- [`src/assets/appConfig.json`](./src/assets/_appConfig.json)
- [`src/assets/authConfig.json`](./src/assets/_authConfig.json)
You can copy from examples like this one: [`_appConfig.json`](./src/assets/_appConfig.json)
2. Install packages
```sh
@ -37,11 +21,11 @@
Running in stage mode needs files:
- `env.stage`
- `.env.stage`
- `src/assets/appConfig.stage.json`
- `src/assets/authConfig.stage.json`
## Usage
## 🚀 Launch
1. Start
```sh
@ -55,3 +39,10 @@ If you want to develop a library, then it's better to start building library sep
npm run dev
npm run dev-libs
```
## 👩‍💻 Development
### Console Utilities
- `ccSwitchLogging()` - Enable/disable logging requests to the console
- `ccGetMyRoles()` - Display your roles from the token

1
_.env Normal file
View File

@ -0,0 +1 @@
PROXY_TARGET="https://control-center.sample.vality.dev"

View File

@ -6,7 +6,7 @@
"postinstall": "ngcc",
"start": "concurrently -n LIB,APP -c magenta,cyan npm:dev-libs \"sleep 0.5 && npm run dev\"",
"dev": "ng serve --proxy-config proxy.conf.js --port 4200",
"stage": "cross-env NODE_ENV=stage npm run dev -- --configuration=stage",
"stage": "cross-env NODE_ENV=stage ng serve --proxy-config proxy.conf.js --port 4201 --configuration=stage",
"dev-libs": "ng build ng-core --watch",
"build-app": "ng build --extra-webpack-config webpack.extra.js",
"build-libs": "ng build ng-core",

View File

@ -14,7 +14,7 @@
<div *ngIf="item.current$ | async as current" class="cc-body-1">
<cc-json-viewer
*ngIf="current.value$ | async; else empty"
*ngIf="!(current.isEmpty$ | async); else empty"
[data]="current.data$ | async"
[extension]="current.extension$ | async"
[extensions]="extensions"

View File

@ -33,7 +33,10 @@ export class MetadataViewItem {
if (data?.trueTypeNode?.data?.objectType === 'enum')
return (
(data.trueTypeNode.data as MetadataFormData<ValueType, 'enum'>).ast.items.find(
(i) => i.value === value
(i, idx) => {
if ('value' in i) return i.value === value;
return idx === value;
}
).name ?? value
);
if (data?.objectType === 'union' && isEmpty(getEntries(value)?.[0]?.[1]))
@ -41,6 +44,7 @@ export class MetadataViewItem {
return value;
})
);
isEmpty$ = this.renderValue$.pipe(map((value) => isEmpty(value)));
items$: Observable<MetadataViewItem[]> = this.createItems().pipe(
shareReplay({ refCount: true, bufferSize: 1 })

View File

@ -62,7 +62,7 @@ export class DomainMetadataFormExtensionsService {
currency: { symbolic_code: cash.currencyCode },
}
: null,
outputToInternal: (cash: Cash) =>
outputToInternal: (cash: Cash): CashField =>
cash
? {
amount: toMajor(
@ -73,7 +73,7 @@ export class DomainMetadataFormExtensionsService {
cash.currency.symbolic_code
)?.data?.exponent
),
currency: cash.currency.symbolic_code,
currencyCode: cash.currency.symbolic_code,
}
: null,
},

View File

@ -0,0 +1,9 @@
{
"fileStorageEndpoint": "https://files.sample.vality.dev",
"constants": {
"currencies": [
{ "source": "RUB_ID", "currency": "RUB" },
{ "source": "USD_ID", "currency": "USD" }
]
}
}

View File

@ -0,0 +1,7 @@
{
"realm": "internal",
"auth-server-url": "https://auth.vality.dev/auth/",
"ssl-required": "external",
"resource": "control-center",
"public-client": true
}

View File

@ -1,6 +1,6 @@
import { getCurrencySymbol } from '@angular/common';
import { Component, Input, Injector, Inject, LOCALE_ID, OnInit } from '@angular/core';
import { Validator, ValidationErrors, FormControl, FormBuilder } from '@angular/forms';
import { Validator, ValidationErrors, FormControl } from '@angular/forms';
import { createMask } from '@ngneat/input-mask';
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
import { FormComponentSuperclass } from '@s-libs/ng-core';
@ -67,8 +67,7 @@ export class CashFieldComponent extends FormComponentSuperclass<Cash> implements
constructor(
injector: Injector,
@Inject(LOCALE_ID) private _locale: string,
private domainStoreService: DomainStoreService,
private fb: FormBuilder
private domainStoreService: DomainStoreService
) {
super(injector);
}