|
|
|
@ -14,7 +14,7 @@ |
|
|
|
/// limitations under the License.
|
|
|
|
///
|
|
|
|
|
|
|
|
import { Component, forwardRef, Input } from '@angular/core'; |
|
|
|
import { Component, forwardRef, Input, OnChanges, SimpleChanges } from '@angular/core'; |
|
|
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; |
|
|
|
import { coerceBoolean } from '@shared/decorators/coercion'; |
|
|
|
import { SubscriptSizing, MatFormFieldAppearance } from '@angular/material/form-field'; |
|
|
|
@ -30,7 +30,7 @@ import { MqttVersionTranslation, MqttVersion } from '@shared/models/mqtt.models' |
|
|
|
multi: true |
|
|
|
}] |
|
|
|
}) |
|
|
|
export class MqttVersionSelectComponent implements ControlValueAccessor { |
|
|
|
export class MqttVersionSelectComponent implements ControlValueAccessor, OnChanges { |
|
|
|
|
|
|
|
@Input() |
|
|
|
disabled: boolean; |
|
|
|
@ -41,7 +41,10 @@ export class MqttVersionSelectComponent implements ControlValueAccessor { |
|
|
|
@Input() |
|
|
|
appearance: MatFormFieldAppearance = 'fill'; |
|
|
|
|
|
|
|
mqttVersions = Object.values(MqttVersion); |
|
|
|
@Input() |
|
|
|
excludeVersions: MqttVersion[]; |
|
|
|
|
|
|
|
mqttVersions = Object.values(MqttVersion); |
|
|
|
mqttVersionTranslation = MqttVersionTranslation; |
|
|
|
modelValue: MqttVersion; |
|
|
|
|
|
|
|
@ -54,6 +57,20 @@ export class MqttVersionSelectComponent implements ControlValueAccessor { |
|
|
|
constructor() { |
|
|
|
} |
|
|
|
|
|
|
|
ngOnChanges(changes: SimpleChanges): void { |
|
|
|
for (const propName of Object.keys(changes)) { |
|
|
|
const change = changes[propName]; |
|
|
|
if (propName === 'excludeVersions' && change.currentValue !== change.previousValue) { |
|
|
|
const excludeVersions = change.currentValue; |
|
|
|
if (excludeVersions?.length) { |
|
|
|
this.mqttVersions = Object.values(MqttVersion).filter(v => !excludeVersions.includes(v)); |
|
|
|
} else { |
|
|
|
this.mqttVersions = Object.values(MqttVersion); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
registerOnChange(fn: any): void { |
|
|
|
this.propagateChange = fn; |
|
|
|
} |
|
|
|
|