diff --git a/src/app/calculators/verificateur/config.json b/src/app/calculators/verificateur/config.json index ad7798eaa3249f38eb6f2a982fd813ce5a04ee82..438d2bf32cc332050660af1651db011636be0891 100644 --- a/src/app/calculators/verificateur/config.json +++ b/src/app/calculators/verificateur/config.json @@ -6,7 +6,8 @@ { "id": "select_target_pass", "type": "select_custom", - "source": "verificateur_target" + "source": "verificateur_target", + "messageWhenEmpty": "INFO_VERIF_CREATE_PASS_FRIST" } ] }, diff --git a/src/app/components/generic-select/generic-select.component.html b/src/app/components/generic-select/generic-select.component.html index 5dcaf95e7f8ff6c617cd2d2792c395720602f020..9c6880e13e8913f9b7ff1d8073d4df4f5df4ddd0 100644 --- a/src/app/components/generic-select/generic-select.component.html +++ b/src/app/components/generic-select/generic-select.component.html @@ -20,4 +20,7 @@ help </mat-icon> </div> -</mat-form-field> \ No newline at end of file +</mat-form-field> +<div *ngIf="messageWhenEmpty" class="message-when-empty"> + {{ messageWhenEmpty }} +</div> \ No newline at end of file diff --git a/src/app/components/select-field-line/select-field-line.component.scss b/src/app/components/select-field-line/select-field-line.component.scss index 2bd3e276513fd91a95e1933a69abe14f054c4fe8..92327696435c625fdda147240428e1e5ede6d298 100644 --- a/src/app/components/select-field-line/select-field-line.component.scss +++ b/src/app/components/select-field-line/select-field-line.component.scss @@ -13,3 +13,8 @@ mat-form-field { } } } + +.message-when-empty { + color: #af1280; // like mat-error + font-weight: 500; +} diff --git a/src/app/components/select-field-line/select-field-line.component.ts b/src/app/components/select-field-line/select-field-line.component.ts index b438c0256a1cbb02c0ae95cdf675dff11bd4cc71..eccc37a991e5cdb7462c7f1ec2caddcb3c2ddb5e 100644 --- a/src/app/components/select-field-line/select-field-line.component.ts +++ b/src/app/components/select-field-line/select-field-line.component.ts @@ -46,6 +46,10 @@ export class SelectFieldLineComponent implements OnInit { return this._select.entries; } + public get messageWhenEmpty(): string { + return this._select.messageWhenEmpty; + } + protected entryLabel(entry: SelectEntry): string { return decodeHtml(entry.label); } diff --git a/src/app/formulaire/elements/select-field.ts b/src/app/formulaire/elements/select-field.ts index 0884f25641cb3a37472be53baa6f0d928a7453fe..d003d2a6d36f30d495dd7de200e4c1e0b0a96fae 100644 --- a/src/app/formulaire/elements/select-field.ts +++ b/src/app/formulaire/elements/select-field.ts @@ -35,9 +35,15 @@ export class SelectField extends Field { /** if true, select box is grayed out */ public disabled = false; - /** soruce identifier for populating with available values */ + /** source identifier for populating with available values */ protected source: string; + /** + * message to display below the select field when no option is selected, + * if this message is defined and not empty + */ + protected _messageWhenEmpty: string; + constructor(parent: FormulaireNode) { super(parent); this.clearEntries(); @@ -63,6 +69,14 @@ export class SelectField extends Field { return this._multiple; } + public get messageWhenEmpty(): string { + let msg: string; + if (this._selectedEntry === undefined && this._messageWhenEmpty) { + msg = ServiceFactory.i18nService.localizeText(this._messageWhenEmpty); + } + return msg; + } + public clearEntries() { this._entries = []; } @@ -145,6 +159,7 @@ export class SelectField extends Field { this._helpLink = field["help"]; this._associatedProperty = field["property"]; this._defaultValue = field["default"]; + this._messageWhenEmpty = field["messageWhenEmpty"]; if (field["multiple"] !== undefined) { this._multiple = field["multiple"]; } diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index acbc4c1501bac560a985122e6d8a3223e51bb0e3..d65e11830a6bee55b56b3874e4f75bf6e7d0e69f 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -606,6 +606,7 @@ "INFO_TRIGO_TITRE": "Trigonometric function", "INFO_TRIGO_DESCRIPTION": "cosinus sinus tangent arc", "INFO_TRIGO_TITRE_COURT": "Trigo. f.", + "INFO_VERIF_CREATE_PASS_FRIST": "Create first a fish ladder, a baffle fishway or a rock-ramp fishpass", "INFO_VERIF_OK": "Crossing criteria are met for all species", "INFO_VERIF_VARYING_OK": "Crossing criteria are met for all species and all pass modalities", "WARNING_VERIF_OK_BUT": "Crossing criteria are met for all species, but there are warnings", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index 2fe2697aaa909d0f891524bba0fede5a4fbe4684..6804b1975c2f457efe07baba54274fb0bf3be14c 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -607,6 +607,7 @@ "INFO_TRIGO_TITRE": "Fonction trigonométrique", "INFO_TRIGO_DESCRIPTION": "cosinus sinus tangente arc", "INFO_TRIGO_TITRE_COURT": "F. trigo.", + "INFO_VERIF_CREATE_PASS_FRIST": "Créer d'abord une passe à bassins, à ralentisseurs, ou à macrorugosités", "INFO_VERIF_OK": "Les critères de franchissement sont remplis pour toutes les espèces", "INFO_VERIF_VARYING_OK": "Les critères de franchissement sont remplis pour toutes les espèces et toutes les modalités de la passe", "WARNING_VERIF_OK_BUT": "Les critères de franchissement sont remplis pour toutes les espèces, mais il y a des avertissements",