Commit 75fa28f6fd92d986873010c7ce4b04932bed6e85
1 parent
327607e8
New Feature add the Select input on multiple input widget
Showing
2 changed files
with
29 additions
and
1 deletions
... | ... | @@ -104,6 +104,24 @@ |
104 | 104 | </mat-error> |
105 | 105 | </mat-form-field> |
106 | 106 | </div> |
107 | + <div class="input-field" *ngIf="key.settings.dataKeyValueType === 'select'"> | |
108 | + <mat-form-field class="mat-block"> | |
109 | + <mat-label>{{key.label}}</mat-label> | |
110 | + <mat-select formControlName="{{key.formId}}" | |
111 | + [required]="key.settings.required" | |
112 | + (focus)="key.isFocused = true;" | |
113 | + (blur)="key.isFocused = false; inputChanged(source, key)"> | |
114 | + <mat-option *ngFor="let option of key.settings.selectOptions" | |
115 | + [value]="option.value !== 'null' ? option.value : null" | |
116 | + [disabled]="key.settings.isEditable === 'readonly'"> | |
117 | + {{ getCustomTranslationText(option.label ? option.label : option.value) }} | |
118 | + </mat-option> | |
119 | + </mat-select> | |
120 | + <mat-error *ngIf="multipleInputFormGroup.get(key.formId).hasError('required')"> | |
121 | + {{ getErrorMessageText(key.settings, 'required') }} | |
122 | + </mat-error> | |
123 | + </mat-form-field> | |
124 | + </div> | |
107 | 125 | </div> |
108 | 126 | </div> |
109 | 127 | </fieldset> | ... | ... |
... | ... | @@ -41,7 +41,7 @@ type FieldAlignment = 'row' | 'column'; |
41 | 41 | type MultipleInputWidgetDataKeyType = 'server' | 'shared' | 'timeseries'; |
42 | 42 | type MultipleInputWidgetDataKeyValueType = 'string' | 'double' | 'integer' | |
43 | 43 | 'booleanCheckbox' | 'booleanSwitch' | |
44 | - 'dateTime' | 'date' | 'time'; | |
44 | + 'dateTime' | 'date' | 'time' | 'select'; | |
45 | 45 | type MultipleInputWidgetDataKeyEditableType = 'editable' | 'disabled' | 'readonly'; |
46 | 46 | |
47 | 47 | interface MultipleInputWidgetSettings { |
... | ... | @@ -58,9 +58,15 @@ interface MultipleInputWidgetSettings { |
58 | 58 | attributesShared?: boolean; |
59 | 59 | } |
60 | 60 | |
61 | +interface MultipleInputWidgetSelectOption { | |
62 | + value: string; | |
63 | + label: string; | |
64 | +} | |
65 | + | |
61 | 66 | interface MultipleInputWidgetDataKeySettings { |
62 | 67 | dataKeyType: MultipleInputWidgetDataKeyType; |
63 | 68 | dataKeyValueType: MultipleInputWidgetDataKeyValueType; |
69 | + selectOptions: MultipleInputWidgetSelectOption[]; | |
64 | 70 | required: boolean; |
65 | 71 | isEditable: MultipleInputWidgetDataKeyEditableType; |
66 | 72 | disabledOnDataKey: string; |
... | ... | @@ -445,6 +451,10 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni |
445 | 451 | return messageText; |
446 | 452 | } |
447 | 453 | |
454 | + public getCustomTranslationText(value): string { | |
455 | + return this.utils.customTranslation(value, value); | |
456 | + } | |
457 | + | |
448 | 458 | public visibleKeys(source: MultipleInputWidgetSource): MultipleInputWidgetDataKey[] { |
449 | 459 | return source.keys.filter(key => !key.settings.dataKeyHidden); |
450 | 460 | } | ... | ... |