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..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 @@ -22,12 +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 5c63f81cb4..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 @@ -15,15 +15,15 @@ /// 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'; 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,22 +47,24 @@ 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; + entityTypeNullUUID: Set = new Set([ + AliasEntityType.CURRENT_TENANT, AliasEntityType.CURRENT_USER, AliasEntityType.CURRENT_USER_OWNER + ]); + private readonly defaultEntityType: EntityType | AliasEntityType = null; private propagateChange = (v: any) => { }; @@ -106,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 { @@ -143,9 +149,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) { + 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 04754e4a20..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,6 +86,10 @@ export class EntityTypeSelectComponent implements ControlValueAccessor, OnInit, 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); + } this.entityTypeFormGroup.get('entityType').valueChanges.subscribe( (value) => { let modelValue; @@ -113,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}); @@ -152,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/components/js-func.component.html b/ui-ngx/src/app/shared/components/js-func.component.html index 66bced8adf..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,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..2afa16e743 100644 --- a/ui-ngx/src/app/shared/components/script-lang.component.html +++ b/ui-ngx/src/app/shared/components/script-lang.component.html @@ -17,9 +17,11 @@ -->
+ formControlName="scriptLang" + aria-label="Script language"> {{ 'rulenode.script-lang-tbel' | translate }} - {{ '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 b36f22c95e..8e47eac4a2 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; 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..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,7 +15,7 @@ /// 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';