Browse Source

refactor(iot-hub): build the form rows and the unmasked passwords in one ngOnChanges block

pull/16376/head
dpinkevych 1 month ago
parent
commit
ce741cf2de
  1. 16
      ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/install-form-renderer/install-form-renderer.component.ts

16
ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/install-form-renderer/install-form-renderer.component.ts

@ -54,11 +54,15 @@ export class InstallFormRendererComponent implements OnChanges {
readonly FormFieldType = FormFieldType;
ngOnChanges(changes: SimpleChanges): void {
// The hint boxes depend on reviewMode too
// The hint boxes and the unmasked passwords depend on reviewMode too
if (changes.fields || changes.reviewMode) {
this.sections = [];
this.passwordVisible = {};
let previous: FormFieldDefinition | undefined;
for (const field of this.fields ?? []) {
if (this.reviewMode && field.type === FormFieldType.PASSWORD) {
this.passwordVisible[field.key] = true;
}
if (!previous || field.group !== previous.group) {
this.sections.push({ title: field.group, rows: [] });
}
@ -74,16 +78,6 @@ export class InstallFormRendererComponent implements OnChanges {
previous = field;
}
}
if (changes.fields || changes.reviewMode) {
this.passwordVisible = {};
if (this.reviewMode) {
for (const f of this.fields) {
if (f.type === FormFieldType.PASSWORD) {
this.passwordVisible[f.key] = true;
}
}
}
}
}
togglePasswordVisible(key: string): void {

Loading…
Cancel
Save