Browse Source

[PROD-3656] [FIX] refactoring

pull/11012/head
mpetrov 2 years ago
parent
commit
bcffa86ca3
  1. 5
      ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector-templates.component.html
  2. 10
      ui-ngx/src/app/shared/pipe/key-value-not-empty.pipe.ts
  3. 6
      ui-ngx/src/app/shared/shared.module.ts

5
ui-ngx/src/app/modules/home/components/widget/lib/gateway/gateway-service-rpc-connector-templates.component.html

@ -32,13 +32,12 @@
</mat-expansion-panel-header>
<ng-container
*ngFor="let config of template.config | keyvalue : originalOrder"
*ngFor="let config of template.config | keyValueIsNotEmpty | keyvalue : originalOrder"
[ngTemplateOutlet]="RPCTemplateRef"
[ngTemplateOutletContext]="{ $implicit: config, innerValue: false }">
</ng-container>
<ng-template #RPCTemplateRef let-config let-innerValue='innerValue'>
<div *ngIf="config.value | isExist"
[fxLayout]="isObject(config.value) ? 'column': 'row'"
<div [fxLayout]="isObject(config.value) ? 'column': 'row'"
[fxLayoutAlign]="!isObject(config.value) ? 'space-between center' : ''"
[ngStyle]="{'padding-left': innerValue ? '16px': '0'}"
class="rpc-params-row">

10
ui-ngx/src/app/shared/pipe/is-exist.pipe.ts → ui-ngx/src/app/shared/pipe/key-value-not-empty.pipe.ts

@ -17,10 +17,12 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'isExist'
name: 'keyValueIsNotEmpty'
})
export class IsExistPipe implements PipeTransform {
transform(value: unknown): boolean {
return value !== null && value !== undefined;
export class KeyValueIsNotEmptyPipe implements PipeTransform {
transform(obj: Record<string, unknown>): Record<string, unknown> {
return Object.fromEntries(
Object.entries(obj).filter(([_, value]) => value !== null && value !== undefined)
);
}
}

6
ui-ngx/src/app/shared/shared.module.ts

@ -219,7 +219,7 @@ import { ImageGalleryDialogComponent } from '@shared/components/image/image-gall
import { RuleChainSelectPanelComponent } from '@shared/components/rule-chain/rule-chain-select-panel.component';
import { WidgetButtonComponent } from '@shared/components/button/widget-button.component';
import { HexInputComponent } from '@shared/components/color-picker/hex-input.component';
import { IsExistPipe } from "@shared/pipe/is-exist.pipe";
import { KeyValueIsNotEmptyPipe } from "@shared/pipe/key-value-not-empty.pipe";
export function MarkedOptionsFactory(markedOptionsService: MarkedOptionsService) {
return markedOptionsService;
@ -367,7 +367,7 @@ export function MarkedOptionsFactory(markedOptionsService: MarkedOptionsService)
ShortNumberPipe,
SelectableColumnsPipe,
KeyboardShortcutPipe,
IsExistPipe,
KeyValueIsNotEmptyPipe,
TbJsonToStringDirective,
JsonObjectEditDialogComponent,
HistorySelectorComponent,
@ -621,7 +621,7 @@ export function MarkedOptionsFactory(markedOptionsService: MarkedOptionsService)
SafePipe,
ShortNumberPipe,
SelectableColumnsPipe,
IsExistPipe,
KeyValueIsNotEmptyPipe,
RouterModule,
TranslateModule,
JsonObjectEditDialogComponent,

Loading…
Cancel
Save