diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/install-form-renderer/install-form-renderer.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/install-form-renderer/install-form-renderer.component.html index b7d1b7a978..4a05e40f1a 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/install-form-renderer/install-form-renderer.component.html +++ b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/install-form-renderer/install-form-renderer.component.html @@ -42,16 +42,16 @@ @for (field of row.fields; track field.key) {
- +
} } @else { - + } @for (field of row.fields; track field.key) { - @if (hasHintBox(field)) { + @if (row.hasHintBox && field.helpPopupId) {
{{ helpTextOf(field) }}
- + @if (isSecretWidget(field)) { {{ field.label }} } @case (FormFieldType.SELECT) { - {{ field.label }} @@ -96,7 +96,7 @@ {{ opt.label }} } - @if (helpTextOf(field) && !hasHintBox(field)) { + @if (helpTextOf(field) && !(row.hasHintBox && field.helpPopupId)) { {{ helpTextOf(field) }} } @if (formGroup.controls[field.key]?.hasError('required')) { @@ -105,7 +105,7 @@ } @case (FormFieldType.STRING_AUTOCOMPLETE) { - {{ field.label }} {{ opt.label }} } - @if (helpTextOf(field) && !hasHintBox(field)) { + @if (helpTextOf(field) && !(row.hasHintBox && field.helpPopupId)) { {{ helpTextOf(field) }} } @if (formGroup.controls[field.key]?.hasError('required')) { @@ -131,7 +131,7 @@ } @case (FormFieldType.PASSWORD) { - {{ field.label }} autorenew } - @if (helpTextOf(field) && !hasHintBox(field)) { + @if (helpTextOf(field) && !(row.hasHintBox && field.helpPopupId)) { {{ helpTextOf(field) }} } @if (formGroup.controls[field.key]?.hasError('required')) { @@ -165,13 +165,13 @@ } @case (FormFieldType.INTEGER) { - {{ field.label }} - @if (helpTextOf(field) && !hasHintBox(field)) { + @if (helpTextOf(field) && !(row.hasHintBox && field.helpPopupId)) { {{ helpTextOf(field) }} } @if (formGroup.controls[field.key]?.hasError('required')) { @@ -186,7 +186,7 @@ } @default { - {{ field.label }} autorenew } - @if (helpTextOf(field) && !hasHintBox(field)) { + @if (helpTextOf(field) && !(row.hasHintBox && field.helpPopupId)) { {{ helpTextOf(field) }} } @if (formGroup.controls[field.key]?.hasError('required')) { diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/install-form-renderer/install-form-renderer.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/install-form-renderer/install-form-renderer.component.ts index fedef617df..e1c525c770 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/install-form-renderer/install-form-renderer.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/install-form-renderer/install-form-renderer.component.ts @@ -9,9 +9,14 @@ import { generateSecret } from '@core/utils'; const DEFAULT_RANDOM_SIZE = 20; -/** Fields shown on one line. */ +/** + * Fields shown on one line. When one of them has a help popup (outside review mode), the row shows + * the field's hint in a box under it, next to the popup trigger, and its fields don't reserve space + * for a hint or an error, so the box sits right under them. + */ interface FormRow { fields: FormFieldDefinition[]; + hasHintBox: boolean; } /** Consecutive rows of one group, shown in a panel with the group as its title; no title for ungrouped fields. */ @@ -53,7 +58,6 @@ export class InstallFormRendererComponent implements OnChanges { sections: FormSection[] = []; // The same for the fields of the collapsed Advanced settings panel advancedSections: FormSection[] = []; - private rowOf = new Map(); private focusedControl: AbstractControl | null = null; private keepFocusedError = false; @@ -81,8 +85,8 @@ export class InstallFormRendererComponent implements OnChanges { } ngOnChanges(changes: SimpleChanges): void { - if (changes.fields) { - this.rowOf.clear(); + // The hint boxes depend on reviewMode too + if (changes.fields || changes.reviewMode) { const fields = this.fields ?? []; this.sections = this.buildSections(fields.filter(field => field.section !== 'advanced')); this.advancedSections = this.buildSections(fields.filter(field => field.section === 'advanced')); @@ -108,12 +112,13 @@ export class InstallFormRendererComponent implements OnChanges { } const rows = sections[sections.length - 1].rows; const last = rows[rows.length - 1]; + const hasHintBox = !!field.helpPopupId && !this.reviewMode; if (field.row && last?.fields[0].row === field.row) { last.fields.push(field); + last.hasHintBox ||= hasHintBox; } else { - rows.push({ fields: [field] }); + rows.push({ fields: [field], hasHintBox }); } - this.rowOf.set(field.key, rows[rows.length - 1]); previous = field; } return sections; @@ -158,19 +163,6 @@ export class InstallFormRendererComponent implements OnChanges { return field.validators?.[0]?.message || 'Invalid format'; } - /** Fields with a help popup show their hint in a box under the row, with the popup trigger. */ - hasHintBox(field: FormFieldDefinition): boolean { - return !!field.helpPopupId && !this.reviewMode; - } - - /** - * True for the fields of a row that has a hint box. They don't reserve space for a hint or an - * error, so the box sits right under them. - */ - isInHintBoxRow(field: FormFieldDefinition): boolean { - return !!this.rowOf.get(field.key)?.fields.some(f => this.hasHintBox(f)); - } - /** True when the field fails a validator other than required and pattern (one the dialog added). */ hasFieldError(field: FormFieldDefinition): boolean { const errors = this.formGroup.controls[field.key]?.errors; diff --git a/ui-ngx/src/app/shared/models/iot-hub/device-package.models.ts b/ui-ngx/src/app/shared/models/iot-hub/device-package.models.ts index d45e5d1964..a717d97a0d 100644 --- a/ui-ngx/src/app/shared/models/iot-hub/device-package.models.ts +++ b/ui-ngx/src/app/shared/models/iot-hub/device-package.models.ts @@ -279,7 +279,7 @@ export interface FormFieldDefinition { // (tb-secret-key-input); false / undefined → render the typed widget. secretSupport?: boolean; secretType?: SecretType; - // Fields with the same group get one header above the first of them + // Consecutive fields with the same group are shown in one panel titled with the group group?: string; readOnly?: boolean; // Shown inside the empty field; the label then always stays above it