From f85fada6a190f49b08c87ebb0a659681192d9259 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Wed, 17 Jul 2024 11:30:17 +0300 Subject: [PATCH 1/7] UI: Improvment for generator node --- ui-ngx/src/app/core/http/entity.service.ts | 3 +++ .../entity/entity-autocomplete.component.ts | 2 ++ .../components/entity/entity-select.component.html | 5 +++-- .../components/entity/entity-select.component.ts | 5 +++-- .../src/app/shared/components/js-func.component.html | 1 + .../app/shared/components/script-lang.component.html | 7 ++++--- .../app/shared/components/script-lang.component.scss | 11 +++++++++++ .../app/shared/components/script-lang.component.ts | 5 +++++ ui-ngx/src/app/shared/models/entity-type.models.ts | 10 +++++++++- ui-ngx/src/assets/locale/locale.constant-en_US.json | 2 ++ 10 files changed, 43 insertions(+), 8 deletions(-) diff --git a/ui-ngx/src/app/core/http/entity.service.ts b/ui-ngx/src/app/core/http/entity.service.ts index b5b2b0e796..35bcc1a614 100644 --- a/ui-ngx/src/app/core/http/entity.service.ts +++ b/ui-ngx/src/app/core/http/entity.service.ts @@ -756,6 +756,9 @@ export class EntityService { } } if (allowedEntityTypes && allowedEntityTypes.length) { + if (allowedEntityTypes.includes(AliasEntityType.CURRENT_RULE_NODE)) { + entityTypes.push(AliasEntityType.CURRENT_RULE_NODE); + } for (let index = entityTypes.length - 1; index >= 0; index--) { if (allowedEntityTypes.indexOf(entityTypes[index]) === -1) { entityTypes.splice(index, 1); diff --git a/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts b/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts index b55f01a7ae..071559f234 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts +++ b/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts @@ -414,6 +414,8 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit } else { return EntityType.CUSTOMER; } + } else if (entityType === AliasEntityType.CURRENT_RULE_NODE) { + return EntityType.RULE_NODE; } return entityType; } diff --git a/ui-ngx/src/app/shared/components/entity/entity-select.component.html b/ui-ngx/src/app/shared/components/entity/entity-select.component.html index 783febec7e..b3d68a5610 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-select.component.html +++ b/ui-ngx/src/app/shared/components/entity/entity-select.component.html @@ -15,7 +15,7 @@ limitations under the License. --> -
+
diff --git a/ui-ngx/src/app/shared/components/entity/entity-select.component.ts b/ui-ngx/src/app/shared/components/entity/entity-select.component.ts index 5c63f81cb4..06212236a7 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-select.component.ts +++ b/ui-ngx/src/app/shared/components/entity/entity-select.component.ts @@ -15,7 +15,7 @@ /// import { AfterViewInit, Component, forwardRef, Input, OnInit } from '@angular/core'; -import { ControlValueAccessor, UntypedFormBuilder, UntypedFormGroup, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { ControlValueAccessor, NG_VALUE_ACCESSOR, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; import { TranslateService } from '@ngx-translate/core'; @@ -145,7 +145,8 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte if (this.modelValue.entityType === AliasEntityType.CURRENT_TENANT || this.modelValue.entityType === AliasEntityType.CURRENT_USER - || this.modelValue.entityType === AliasEntityType.CURRENT_USER_OWNER) { + || this.modelValue.entityType === AliasEntityType.CURRENT_USER_OWNER + || this.modelValue.entityType === AliasEntityType.CURRENT_RULE_NODE) { this.modelValue.id = NULL_UUID; } else if (this.modelValue.entityType === AliasEntityType.CURRENT_CUSTOMER && !this.modelValue.id) { this.modelValue.id = NULL_UUID; diff --git a/ui-ngx/src/app/shared/components/js-func.component.html b/ui-ngx/src/app/shared/components/js-func.component.html index 66bced8adf..5bea273153 100644 --- a/ui-ngx/src/app/shared/components/js-func.component.html +++ b/ui-ngx/src/app/shared/components/js-func.component.html @@ -24,6 +24,7 @@ {{ functionLabel }} + diff --git a/ui-ngx/src/app/shared/components/script-lang.component.html b/ui-ngx/src/app/shared/components/script-lang.component.html index 8887f9d7c3..dfe313bbfc 100644 --- a/ui-ngx/src/app/shared/components/script-lang.component.html +++ b/ui-ngx/src/app/shared/components/script-lang.component.html @@ -16,10 +16,11 @@ -->
- {{ 'rulenode.script-lang-tbel' | translate }} - {{ 'rulenode.script-lang-java-script' | translate }} + + {{ (shortLang ? 'rulenode.script-lang-java-script-short' : 'rulenode.script-lang-java-script') | translate }} +
diff --git a/ui-ngx/src/app/shared/components/script-lang.component.scss b/ui-ngx/src/app/shared/components/script-lang.component.scss index b36f22c95e..f92f63a53b 100644 --- a/ui-ngx/src/app/shared/components/script-lang.component.scss +++ b/ui-ngx/src/app/shared/components/script-lang.component.scss @@ -14,6 +14,7 @@ * limitations under the License. */ .mat-button-toggle-group.tb-script-lang-toggle-group { + width: 320px; &.mat-button-toggle-group-appearance-standard { border: none; border-radius: 18px; @@ -57,3 +58,13 @@ opacity: .01; } } +.mat-button-toggle-group.tb-script-lang-toggle-group-short { + width: 120px; + .mat-button-toggle { + height: 24px; + } + .mat-button-toggle-appearance-standard .mat-button-toggle-label-content { + line-height: 20px; + font-size: 12px; + } +} diff --git a/ui-ngx/src/app/shared/components/script-lang.component.ts b/ui-ngx/src/app/shared/components/script-lang.component.ts index dd9d995bcc..62658a9412 100644 --- a/ui-ngx/src/app/shared/components/script-lang.component.ts +++ b/ui-ngx/src/app/shared/components/script-lang.component.ts @@ -20,6 +20,7 @@ import { PageComponent } from '@shared/components/page.component'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; import { ScriptLanguage } from '@shared/models/rule-node.models'; +import { coerceBoolean } from '@shared/decorators/coercion'; @Component({ selector: 'tb-script-lang', @@ -43,6 +44,10 @@ export class TbScriptLangComponent extends PageComponent implements ControlValue @Input() disabled: boolean; + @Input() + @coerceBoolean() + shortLang = true; + private propagateChange = null; constructor(protected store: Store, diff --git a/ui-ngx/src/app/shared/models/entity-type.models.ts b/ui-ngx/src/app/shared/models/entity-type.models.ts index 045e95983c..c9740d9ba4 100644 --- a/ui-ngx/src/app/shared/models/entity-type.models.ts +++ b/ui-ngx/src/app/shared/models/entity-type.models.ts @@ -51,7 +51,8 @@ export enum AliasEntityType { CURRENT_CUSTOMER = 'CURRENT_CUSTOMER', CURRENT_TENANT = 'CURRENT_TENANT', CURRENT_USER = 'CURRENT_USER', - CURRENT_USER_OWNER = 'CURRENT_USER_OWNER' + CURRENT_USER_OWNER = 'CURRENT_USER_OWNER', + CURRENT_RULE_NODE = 'CURRENT_RULE_NODE' } export interface EntityTypeTranslation { @@ -323,6 +324,13 @@ export const entityTypeTranslations = new Map Date: Thu, 18 Jul 2024 12:08:14 +0300 Subject: [PATCH 2/7] UI: Fixed boolean default value --- ui-ngx/src/app/shared/components/script-lang.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/shared/components/script-lang.component.ts b/ui-ngx/src/app/shared/components/script-lang.component.ts index 62658a9412..5bc1460cd2 100644 --- a/ui-ngx/src/app/shared/components/script-lang.component.ts +++ b/ui-ngx/src/app/shared/components/script-lang.component.ts @@ -46,7 +46,7 @@ export class TbScriptLangComponent extends PageComponent implements ControlValue @Input() @coerceBoolean() - shortLang = true; + shortLang = false; private propagateChange = null; From b62f53415ca78d8ae8ef0b69f82cd88e6f9a5006 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Fri, 19 Jul 2024 17:20:58 +0300 Subject: [PATCH 3/7] UI: Refactoring --- .../components/entity/entity-select.component.html | 5 +---- .../components/entity/entity-select.component.ts | 9 +++++---- .../src/app/shared/components/js-func.component.html | 2 +- .../app/shared/components/script-lang.component.html | 7 ++++--- .../app/shared/components/script-lang.component.scss | 10 ---------- .../src/app/shared/components/script-lang.component.ts | 4 ---- ui-ngx/src/assets/locale/locale.constant-en_US.json | 1 - 7 files changed, 11 insertions(+), 27 deletions(-) diff --git a/ui-ngx/src/app/shared/components/entity/entity-select.component.html b/ui-ngx/src/app/shared/components/entity/entity-select.component.html index b3d68a5610..b4a3a33029 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-select.component.html +++ b/ui-ngx/src/app/shared/components/entity/entity-select.component.html @@ -25,10 +25,7 @@ formControlName="entityType">
diff --git a/ui-ngx/src/app/shared/components/entity/entity-select.component.ts b/ui-ngx/src/app/shared/components/entity/entity-select.component.ts index 06212236a7..eff7f5306f 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-select.component.ts +++ b/ui-ngx/src/app/shared/components/entity/entity-select.component.ts @@ -63,6 +63,10 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte AliasEntityType = AliasEntityType; + entityTypeNullUid: Set = new Set([ + AliasEntityType.CURRENT_TENANT, AliasEntityType.CURRENT_USER, AliasEntityType.CURRENT_USER_OWNER, AliasEntityType.CURRENT_RULE_NODE + ]); + private readonly defaultEntityType: EntityType | AliasEntityType = null; private propagateChange = (v: any) => { }; @@ -143,10 +147,7 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte id: this.modelValue.entityType !== entityType ? null : entityId }; - if (this.modelValue.entityType === AliasEntityType.CURRENT_TENANT - || this.modelValue.entityType === AliasEntityType.CURRENT_USER - || this.modelValue.entityType === AliasEntityType.CURRENT_USER_OWNER - || this.modelValue.entityType === AliasEntityType.CURRENT_RULE_NODE) { + if (this.entityTypeNullUid.has(this.modelValue.entityType)) { this.modelValue.id = NULL_UUID; } else if (this.modelValue.entityType === AliasEntityType.CURRENT_CUSTOMER && !this.modelValue.id) { this.modelValue.id = NULL_UUID; diff --git a/ui-ngx/src/app/shared/components/js-func.component.html b/ui-ngx/src/app/shared/components/js-func.component.html index 5bea273153..082a92b2c1 100644 --- a/ui-ngx/src/app/shared/components/js-func.component.html +++ b/ui-ngx/src/app/shared/components/js-func.component.html @@ -24,7 +24,7 @@ {{ functionLabel }} - + diff --git a/ui-ngx/src/app/shared/components/script-lang.component.html b/ui-ngx/src/app/shared/components/script-lang.component.html index dfe313bbfc..2afa16e743 100644 --- a/ui-ngx/src/app/shared/components/script-lang.component.html +++ b/ui-ngx/src/app/shared/components/script-lang.component.html @@ -16,11 +16,12 @@ -->
- + {{ 'rulenode.script-lang-tbel' | translate }} - {{ (shortLang ? 'rulenode.script-lang-java-script-short' : 'rulenode.script-lang-java-script') | translate }} + {{ 'rulenode.script-lang-java-script' | translate }}
diff --git a/ui-ngx/src/app/shared/components/script-lang.component.scss b/ui-ngx/src/app/shared/components/script-lang.component.scss index f92f63a53b..8e47eac4a2 100644 --- a/ui-ngx/src/app/shared/components/script-lang.component.scss +++ b/ui-ngx/src/app/shared/components/script-lang.component.scss @@ -58,13 +58,3 @@ opacity: .01; } } -.mat-button-toggle-group.tb-script-lang-toggle-group-short { - width: 120px; - .mat-button-toggle { - height: 24px; - } - .mat-button-toggle-appearance-standard .mat-button-toggle-label-content { - line-height: 20px; - font-size: 12px; - } -} diff --git a/ui-ngx/src/app/shared/components/script-lang.component.ts b/ui-ngx/src/app/shared/components/script-lang.component.ts index 5bc1460cd2..65d9ecc876 100644 --- a/ui-ngx/src/app/shared/components/script-lang.component.ts +++ b/ui-ngx/src/app/shared/components/script-lang.component.ts @@ -44,10 +44,6 @@ export class TbScriptLangComponent extends PageComponent implements ControlValue @Input() disabled: boolean; - @Input() - @coerceBoolean() - shortLang = false; - private propagateChange = null; constructor(protected store: Store, diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 0380d1a6be..f1ded7a441 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -4217,7 +4217,6 @@ "invalid-target-rulechain": "Unable to resolve target rule chain!", "test-script-function": "Test script function", "script-lang-java-script": "JavaScript", - "script-lang-java-script-short": "JS", "script-lang-tbel": "TBEL", "message": "Message", "message-type": "Message type", From a19577928f9ac23bc752ddd2613b5e9359d86276 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Fri, 19 Jul 2024 17:22:14 +0300 Subject: [PATCH 4/7] UI: optimize import --- ui-ngx/src/app/shared/components/script-lang.component.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui-ngx/src/app/shared/components/script-lang.component.ts b/ui-ngx/src/app/shared/components/script-lang.component.ts index 65d9ecc876..b3410f1a21 100644 --- a/ui-ngx/src/app/shared/components/script-lang.component.ts +++ b/ui-ngx/src/app/shared/components/script-lang.component.ts @@ -15,12 +15,11 @@ /// import { Component, forwardRef, Input, OnInit, ViewEncapsulation } from '@angular/core'; -import { ControlValueAccessor, UntypedFormBuilder, UntypedFormGroup, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { ControlValueAccessor, NG_VALUE_ACCESSOR, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; import { PageComponent } from '@shared/components/page.component'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; import { ScriptLanguage } from '@shared/models/rule-node.models'; -import { coerceBoolean } from '@shared/decorators/coercion'; @Component({ selector: 'tb-script-lang', From fc80bda9d9b0e23ff3d0e6f5dde69e4f40da71f5 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Mon, 22 Jul 2024 15:04:58 +0300 Subject: [PATCH 5/7] UI:Refactoring --- ui-ngx/src/app/core/http/entity.service.ts | 3 --- .../shared/components/entity/entity-type-select.component.ts | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui-ngx/src/app/core/http/entity.service.ts b/ui-ngx/src/app/core/http/entity.service.ts index 35bcc1a614..b5b2b0e796 100644 --- a/ui-ngx/src/app/core/http/entity.service.ts +++ b/ui-ngx/src/app/core/http/entity.service.ts @@ -756,9 +756,6 @@ export class EntityService { } } if (allowedEntityTypes && allowedEntityTypes.length) { - if (allowedEntityTypes.includes(AliasEntityType.CURRENT_RULE_NODE)) { - entityTypes.push(AliasEntityType.CURRENT_RULE_NODE); - } for (let index = entityTypes.length - 1; index >= 0; index--) { if (allowedEntityTypes.indexOf(entityTypes[index]) === -1) { entityTypes.splice(index, 1); diff --git a/ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts b/ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts index 04754e4a20..3b0dca6e81 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts +++ b/ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts @@ -93,6 +93,9 @@ export class EntityTypeSelectComponent implements ControlValueAccessor, OnInit, this.entityTypes = this.filterAllowedEntityTypes ? this.entityService.prepareAllowedEntityTypesList(this.allowedEntityTypes, this.useAliasEntityTypes) : this.allowedEntityTypes; + if (this.allowedEntityTypes?.length && this.allowedEntityTypes.includes(AliasEntityType.CURRENT_RULE_NODE)) { + this.entityTypes.push(AliasEntityType.CURRENT_RULE_NODE); + } this.entityTypeFormGroup.get('entityType').valueChanges.subscribe( (value) => { let modelValue; From ff01f77f9e60c47dac7af090a7897d8c746943b7 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Mon, 2 Sep 2024 15:27:42 +0300 Subject: [PATCH 6/7] UI: Added additionEntityTypes in entity-select.component and delete CURRENT_RULE_NODE --- .../entity/entity-autocomplete.component.ts | 2 - .../entity/entity-select.component.html | 3 +- .../entity/entity-select.component.ts | 24 ++++++----- .../entity/entity-type-select.component.ts | 40 +++++++++---------- .../app/shared/models/entity-type.models.ts | 10 +---- .../assets/locale/locale.constant-en_US.json | 1 - 6 files changed, 36 insertions(+), 44 deletions(-) diff --git a/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts b/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts index 071559f234..b55f01a7ae 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts +++ b/ui-ngx/src/app/shared/components/entity/entity-autocomplete.component.ts @@ -414,8 +414,6 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit } else { return EntityType.CUSTOMER; } - } else if (entityType === AliasEntityType.CURRENT_RULE_NODE) { - return EntityType.RULE_NODE; } return entityType; } diff --git a/ui-ngx/src/app/shared/components/entity/entity-select.component.html b/ui-ngx/src/app/shared/components/entity/entity-select.component.html index b4a3a33029..7f5c127e00 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-select.component.html +++ b/ui-ngx/src/app/shared/components/entity/entity-select.component.html @@ -22,10 +22,11 @@ [required]="required" [useAliasEntityTypes]="useAliasEntityTypes" [allowedEntityTypes]="allowedEntityTypes" + [additionEntityTypes]="additionEntityTypes" formControlName="entityType"> diff --git a/ui-ngx/src/app/shared/components/entity/entity-select.component.ts b/ui-ngx/src/app/shared/components/entity/entity-select.component.ts index eff7f5306f..5671e9de3b 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-select.component.ts +++ b/ui-ngx/src/app/shared/components/entity/entity-select.component.ts @@ -22,8 +22,8 @@ import { TranslateService } from '@ngx-translate/core'; import { AliasEntityType, EntityType } from '@shared/models/entity-type.models'; import { EntityService } from '@core/http/entity.service'; import { EntityId } from '@shared/models/id/entity-id'; -import { coerceBooleanProperty } from '@angular/cdk/coercion'; import { NULL_UUID } from '@shared/models/id/has-uuid'; +import { coerceBoolean } from '@shared/decorators/coercion'; @Component({ selector: 'tb-entity-select', @@ -47,24 +47,22 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte @Input() useAliasEntityTypes: boolean; - private requiredValue: boolean; - get required(): boolean { - return this.requiredValue; - } @Input() - set required(value: boolean) { - this.requiredValue = coerceBooleanProperty(value); - } + @coerceBoolean() + required: boolean; @Input() disabled: boolean; + @Input() + additionEntityTypes: {[entityType in string]: string} = {}; + displayEntityTypeSelect: boolean; AliasEntityType = AliasEntityType; - entityTypeNullUid: Set = new Set([ - AliasEntityType.CURRENT_TENANT, AliasEntityType.CURRENT_USER, AliasEntityType.CURRENT_USER_OWNER, AliasEntityType.CURRENT_RULE_NODE + entityTypeNullUUID: Set = new Set([ + AliasEntityType.CURRENT_TENANT, AliasEntityType.CURRENT_USER, AliasEntityType.CURRENT_USER_OWNER ]); private readonly defaultEntityType: EntityType | AliasEntityType = null; @@ -110,6 +108,10 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte this.updateView(this.modelValue.entityType, id); } ); + const additionNullUIIDEntityTypes = Object.keys(this.additionEntityTypes) as string[]; + if (additionNullUIIDEntityTypes.length > 0) { + additionNullUIIDEntityTypes.forEach((entityType) => this.entityTypeNullUUID.add(entityType)); + } } ngAfterViewInit(): void { @@ -147,7 +149,7 @@ export class EntitySelectComponent implements ControlValueAccessor, OnInit, Afte id: this.modelValue.entityType !== entityType ? null : entityId }; - if (this.entityTypeNullUid.has(this.modelValue.entityType)) { + if (this.entityTypeNullUUID.has(this.modelValue.entityType)) { this.modelValue.id = NULL_UUID; } else if (this.modelValue.entityType === AliasEntityType.CURRENT_CUSTOMER && !this.modelValue.id) { this.modelValue.id = NULL_UUID; diff --git a/ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts b/ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts index 3b0dca6e81..2405a269b6 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts +++ b/ui-ngx/src/app/shared/components/entity/entity-type-select.component.ts @@ -15,13 +15,13 @@ /// import { AfterViewInit, Component, forwardRef, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; -import { ControlValueAccessor, UntypedFormBuilder, UntypedFormGroup, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { ControlValueAccessor, NG_VALUE_ACCESSOR, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; import { Store } from '@ngrx/store'; import { AppState } from '@app/core/core.state'; import { TranslateService } from '@ngx-translate/core'; import { AliasEntityType, EntityType, entityTypeTranslations } from '@app/shared/models/entity-type.models'; import { EntityService } from '@core/http/entity.service'; -import { coerceBooleanProperty } from '@angular/cdk/coercion'; +import { coerceBoolean } from '@shared/decorators/coercion'; @Component({ selector: 'tb-entity-type-select', @@ -48,28 +48,21 @@ export class EntityTypeSelectComponent implements ControlValueAccessor, OnInit, @Input() filterAllowedEntityTypes = true; - private showLabelValue: boolean; - get showLabel(): boolean { - return this.showLabelValue; - } @Input() - set showLabel(value: boolean) { - this.showLabelValue = coerceBooleanProperty(value); - } + @coerceBoolean() + showLabel: boolean; - private requiredValue: boolean; - get required(): boolean { - return this.requiredValue; - } @Input() - set required(value: boolean) { - this.requiredValue = coerceBooleanProperty(value); - } + @coerceBoolean() + required: boolean; @Input() disabled: boolean; - entityTypes: Array; + @Input() + additionEntityTypes: {[key in string]: string} = {}; + + entityTypes: Array; private propagateChange = (v: any) => { }; @@ -93,8 +86,9 @@ export class EntityTypeSelectComponent implements ControlValueAccessor, OnInit, this.entityTypes = this.filterAllowedEntityTypes ? this.entityService.prepareAllowedEntityTypesList(this.allowedEntityTypes, this.useAliasEntityTypes) : this.allowedEntityTypes; - if (this.allowedEntityTypes?.length && this.allowedEntityTypes.includes(AliasEntityType.CURRENT_RULE_NODE)) { - this.entityTypes.push(AliasEntityType.CURRENT_RULE_NODE); + const additionEntityTypes = Object.keys(this.additionEntityTypes); + if (additionEntityTypes.length > 0) { + this.entityTypes.push(...additionEntityTypes); } this.entityTypeFormGroup.get('entityType').valueChanges.subscribe( (value) => { @@ -116,6 +110,10 @@ export class EntityTypeSelectComponent implements ControlValueAccessor, OnInit, if (propName === 'allowedEntityTypes') { this.entityTypes = this.filterAllowedEntityTypes ? this.entityService.prepareAllowedEntityTypesList(this.allowedEntityTypes, this.useAliasEntityTypes) : this.allowedEntityTypes; + const additionEntityTypes = Object.keys(this.additionEntityTypes); + if (additionEntityTypes.length > 0) { + this.entityTypes.push(...additionEntityTypes); + } const currentEntityType: EntityType | AliasEntityType = this.entityTypeFormGroup.get('entityType').value; if (currentEntityType && !this.entityTypes.includes(currentEntityType)) { this.entityTypeFormGroup.get('entityType').patchValue(null, {emitEvent: true}); @@ -155,7 +153,9 @@ export class EntityTypeSelectComponent implements ControlValueAccessor, OnInit, } displayEntityTypeFn(entityType?: EntityType | AliasEntityType | null): string | undefined { - if (entityType) { + if (this.additionEntityTypes[entityType]) { + return this.additionEntityTypes[entityType]; + } else if (entityType) { return this.translate.instant(entityTypeTranslations.get(entityType as EntityType).type); } else { return ''; diff --git a/ui-ngx/src/app/shared/models/entity-type.models.ts b/ui-ngx/src/app/shared/models/entity-type.models.ts index f2467b9736..51fefefdf2 100644 --- a/ui-ngx/src/app/shared/models/entity-type.models.ts +++ b/ui-ngx/src/app/shared/models/entity-type.models.ts @@ -54,8 +54,7 @@ export enum AliasEntityType { CURRENT_CUSTOMER = 'CURRENT_CUSTOMER', CURRENT_TENANT = 'CURRENT_TENANT', CURRENT_USER = 'CURRENT_USER', - CURRENT_USER_OWNER = 'CURRENT_USER_OWNER', - CURRENT_RULE_NODE = 'CURRENT_RULE_NODE' + CURRENT_USER_OWNER = 'CURRENT_USER_OWNER' } export interface EntityTypeTranslation { @@ -327,13 +326,6 @@ export const entityTypeTranslations = new Map Date: Mon, 2 Sep 2024 15:32:00 +0300 Subject: [PATCH 7/7] UI: Clear code --- .../app/shared/components/entity/entity-select.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/shared/components/entity/entity-select.component.html b/ui-ngx/src/app/shared/components/entity/entity-select.component.html index 7f5c127e00..676294f344 100644 --- a/ui-ngx/src/app/shared/components/entity/entity-select.component.html +++ b/ui-ngx/src/app/shared/components/entity/entity-select.component.html @@ -15,7 +15,7 @@ limitations under the License. --> -
+