UI: Refactoring widget action use signal input additionalWidgetActionTypes
This commit is contained in:
parent
d92d32eec0
commit
d28f372d93
@ -37,7 +37,7 @@
|
||||
<div translate>widget-config.action</div>
|
||||
<mat-form-field class="flex-1" appearance="outline" subscriptSizing="dynamic">
|
||||
<mat-select required formControlName="type" placeholder="{{ 'widget-config.set' | translate }}">
|
||||
<mat-option *ngFor="let actionType of widgetActionTypes" [value]="actionType">
|
||||
<mat-option *ngFor="let actionType of actionTypes()" [value]="actionType">
|
||||
{{ widgetActionTypeTranslations.get(widgetActionType[actionType]) | translate }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
|
||||
@ -26,7 +26,7 @@ import {
|
||||
ValidatorFn,
|
||||
Validators
|
||||
} from '@angular/forms';
|
||||
import { Component, ElementRef, forwardRef, Input, OnInit, ViewChild } from '@angular/core';
|
||||
import { Component, computed, ElementRef, forwardRef, input, Input, OnInit, ViewChild } from '@angular/core';
|
||||
import {
|
||||
MapItemType,
|
||||
mapItemTypeTranslationMap,
|
||||
@ -102,19 +102,16 @@ export class WidgetActionComponent implements ControlValueAccessor, OnInit, Vali
|
||||
@Input()
|
||||
actionNames: string[];
|
||||
|
||||
@Input()
|
||||
set additionalWidgetActionTypes(value: WidgetActionType[]) {
|
||||
if (this.widgetActionFormGroup && !widgetActionTypes.includes(this.widgetActionFormGroup.get('type').value)) {
|
||||
this.widgetActionFormGroup.get('type').setValue(WidgetActionType.doNothing);
|
||||
}
|
||||
if (value?.length) {
|
||||
this.widgetActionTypes = widgetActionTypes.concat(value);
|
||||
} else {
|
||||
this.widgetActionTypes = widgetActionTypes;
|
||||
}
|
||||
}
|
||||
additionalWidgetActionTypes = input<WidgetActionType[]>(null);
|
||||
|
||||
actionTypes = computed(() => {
|
||||
const predefinedActionTypes = widgetActionTypes;
|
||||
if (this.additionalWidgetActionTypes()?.length) {
|
||||
return predefinedActionTypes.concat(this.additionalWidgetActionTypes());
|
||||
}
|
||||
return predefinedActionTypes;
|
||||
});
|
||||
|
||||
widgetActionTypes = widgetActionTypes;
|
||||
widgetActionTypeTranslations = widgetActionTypeTranslationMap;
|
||||
widgetActionType = WidgetActionType;
|
||||
|
||||
@ -191,9 +188,6 @@ export class WidgetActionComponent implements ControlValueAccessor, OnInit, Vali
|
||||
).subscribe(() => {
|
||||
this.widgetActionUpdated();
|
||||
});
|
||||
if (this.additionalWidgetActionTypes) {
|
||||
this.widgetActionTypes = this.widgetActionTypes.concat(this.additionalWidgetActionTypes);
|
||||
}
|
||||
}
|
||||
|
||||
writeValue(widgetAction?: WidgetAction): void {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user