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> </mat-expansion-panel-header>
<ng-container <ng-container
*ngFor="let config of template.config | keyvalue : originalOrder" *ngFor="let config of template.config | keyValueIsNotEmpty | keyvalue : originalOrder"
[ngTemplateOutlet]="RPCTemplateRef" [ngTemplateOutlet]="RPCTemplateRef"
[ngTemplateOutletContext]="{ $implicit: config, innerValue: false }"> [ngTemplateOutletContext]="{ $implicit: config, innerValue: false }">
</ng-container> </ng-container>
<ng-template #RPCTemplateRef let-config let-innerValue='innerValue'> <ng-template #RPCTemplateRef let-config let-innerValue='innerValue'>
<div *ngIf="config.value | isExist" <div [fxLayout]="isObject(config.value) ? 'column': 'row'"
[fxLayout]="isObject(config.value) ? 'column': 'row'"
[fxLayoutAlign]="!isObject(config.value) ? 'space-between center' : ''" [fxLayoutAlign]="!isObject(config.value) ? 'space-between center' : ''"
[ngStyle]="{'padding-left': innerValue ? '16px': '0'}" [ngStyle]="{'padding-left': innerValue ? '16px': '0'}"
class="rpc-params-row"> 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'; import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ @Pipe({
name: 'isExist' name: 'keyValueIsNotEmpty'
}) })
export class IsExistPipe implements PipeTransform { export class KeyValueIsNotEmptyPipe implements PipeTransform {
transform(value: unknown): boolean { transform(obj: Record<string, unknown>): Record<string, unknown> {
return value !== null && value !== undefined; 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 { RuleChainSelectPanelComponent } from '@shared/components/rule-chain/rule-chain-select-panel.component';
import { WidgetButtonComponent } from '@shared/components/button/widget-button.component'; import { WidgetButtonComponent } from '@shared/components/button/widget-button.component';
import { HexInputComponent } from '@shared/components/color-picker/hex-input.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) { export function MarkedOptionsFactory(markedOptionsService: MarkedOptionsService) {
return markedOptionsService; return markedOptionsService;
@ -367,7 +367,7 @@ export function MarkedOptionsFactory(markedOptionsService: MarkedOptionsService)
ShortNumberPipe, ShortNumberPipe,
SelectableColumnsPipe, SelectableColumnsPipe,
KeyboardShortcutPipe, KeyboardShortcutPipe,
IsExistPipe, KeyValueIsNotEmptyPipe,
TbJsonToStringDirective, TbJsonToStringDirective,
JsonObjectEditDialogComponent, JsonObjectEditDialogComponent,
HistorySelectorComponent, HistorySelectorComponent,
@ -621,7 +621,7 @@ export function MarkedOptionsFactory(markedOptionsService: MarkedOptionsService)
SafePipe, SafePipe,
ShortNumberPipe, ShortNumberPipe,
SelectableColumnsPipe, SelectableColumnsPipe,
IsExistPipe, KeyValueIsNotEmptyPipe,
RouterModule, RouterModule,
TranslateModule, TranslateModule,
JsonObjectEditDialogComponent, JsonObjectEditDialogComponent,

Loading…
Cancel
Save