Skip to content
Snippets Groups Projects
Commit 4db05c4c authored by David Dorchies's avatar David Dorchies
Browse files

Merge branch...

Merge branch '637-verificateur-la-verification-ne-devrait-pas-etre-possible-quand-aucune-espece-n-est-selectionnee' into 'devel'

Resolve "Vérificateur: la vérification ne devrait pas être possible quand aucune espèce n'est sélectionnée"

Closes #637

See merge request !236
parents 0425770c a8c0cd16
No related branches found
No related tags found
2 merge requests!252release: version 4.18.0,!236Resolve "Vérificateur: la vérification ne devrait pas être possible quand aucune espèce n'est sélectionnée"
Pipeline #154236 passed
......@@ -45,7 +45,7 @@
(inputChange)=onInputChange($event) (tabPressed)="onTabPressed($event)">
</param-field-line>
<select-field-line *ngIf="isSelectField(p)" [_select]=p>
<select-field-line *ngIf="isSelectField(p)" [_select]=p (valueChanged)=onSelectLineChanged($event)>
</select-field-line>
</ng-template>
</mat-card-content>
......@@ -268,6 +268,14 @@ export class FieldSetComponent implements DoCheck {
this.updateValidity(true);
}
/**
* réception d'un événement de validité de SelectFieldLineComponent
*/
public onSelectLineChanged(value:any) {
this.updateValidity(true);
}
/**
* réception d'un événement de changement de valeur d'un input
*/
......
<mat-form-field>
<mat-select [id]="selectId" [placeholder]="label" [(value)]="selectedValue" [multiple]="isMultiple">
<mat-select [id]="selectId" [placeholder]="label" [(value)]="selectedValue" [multiple]="isMultiple" (selectionChange) ="onValueChange($event)">
<mat-select-trigger *ngIf="isMultiple">
{{ selectedValue && selectedValue[0] ? entryLabel(selectedValue[0]) : '' }}
<span *ngIf="selectedValue?.length > 1" class="multiple-selection-label">
......@@ -11,7 +11,7 @@
</mat-option>
</mat-select>
<button mat-button *ngIf="showClearButton" matSuffix mat-icon-button aria-label="Clear"
(click)="selectedValue=[]; $event.stopPropagation()">
(click)="emptySelectedList($event)">
<mat-icon>close</mat-icon>
</button>
<div *ngIf="enableHelpButton" class="overlap-select">
......
import { Component } from "@angular/core";
import { Component, EventEmitter, Output } from "@angular/core";
import { IObservable, Observer } from "jalhyd";
import { I18nService } from "../../services/internationalisation.service";
import { ChartType } from "../../results/chart-type";
......@@ -16,6 +16,9 @@ import { decodeHtml } from "../../util/util";
export class ChartTypeSelectComponent implements IObservable {
private _select: SelectFieldChartType;
@Output()
private valueChanged = new EventEmitter();
constructor(private intlService: I18nService) {
this._select = new SelectFieldChartType(undefined, this.intlService);
this._select.afterParseConfig(); // fill entries, set default value
......@@ -65,6 +68,10 @@ export class ChartTypeSelectComponent implements IObservable {
return this._select.multiple;
}
public onValueChange($event) {
this.selectedValue = $event.value
this.valueChanged.emit(this.selectedValue)
}
// interface IObservable
/**
......
import { Component, Input, OnInit } from "@angular/core";
import { Component, DoCheck, EventEmitter, Input, OnInit, Output } from "@angular/core";
import { SelectField } from "../../formulaire/elements/select/select-field";
import { SelectEntry } from "../../formulaire/elements/select/select-entry";
......@@ -21,17 +21,23 @@ export class SelectFieldLineComponent implements OnInit {
@Input()
private _select: SelectField;
/**
* événément de changement de valeur d'un select
*/
@Output()
private valueChanged = new EventEmitter();
public constructor(
private i18nService: I18nService,
private appSetupService: ApplicationSetupService
) {}
public get selectId() {
return this._select.id;
}
public get isMultiple(): boolean {
return this._select.multiple;
return this._select.multiple;
}
public get entries(): SelectEntry[] {
......@@ -53,10 +59,32 @@ export class SelectFieldLineComponent implements OnInit {
return this._select.getValue();
}
public onValueChange($event: any) {
this.selectedValue = $event.value
this.valueChanged.emit(this.selectedValue)
}
public emptySelectedList($event:any) {
this.selectedValue = [];
this.valueChanged.emit(this.selectedValue)
$event.stopPropagation();
}
public get isValid(): boolean {
return (this._select.getValue() !== undefined);
if(this._select.getValue() !== undefined) {
if(Object.keys(this._select.getValue()).length > 0) {
return true;
}
else {
return false
}
}
else {
return false
}
}
public set selectedValue(v: SelectEntry | SelectEntry[]) {
this._select.setValue(v);
}
......
......@@ -16,6 +16,7 @@ import { SelectField } from "./select-field";
export class SelectFieldSpeciesList extends SelectField {
constructor(parent: FormulaireNode) {
super(parent);
this._messageWhenEmpty = "INFO_VERIF_SELECT_SPECIES_FIRST";
this._multiple = true;
}
......
......@@ -82,7 +82,7 @@ export abstract class SelectField extends Field {
|| (
!Array.isArray(previousSelectedEntry)
&& !Array.isArray(v)
&& previousSelectedEntry.id !== v.id
&& previousSelectedEntry?.id !== v?.id
)
|| (
Array.isArray(previousSelectedEntry)
......@@ -292,9 +292,14 @@ export abstract class SelectField extends Field {
return this._entriesBaseId;
}
public isEmptySelectField() {
return this._selectedEntry !== undefined && Object.keys(this._selectedEntry).length === 0;
}
public get messageWhenEmpty(): string {
let msg: string;
if (this._selectedEntry === undefined && this._messageWhenEmpty) {
if ((this._selectedEntry === undefined && this._messageWhenEmpty) || this.isEmptySelectField()) {
msg = ServiceFactory.i18nService.localizeText(this._messageWhenEmpty);
}
return msg;
......
......@@ -664,6 +664,7 @@
"INFO_TRIGO_DESCRIPTION": "cosinus sinus tangent arc maths mathematics",
"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_SELECT_SPECIES_FIRST": "Select first one or several fish species",
"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",
......
......@@ -665,6 +665,7 @@
"INFO_TRIGO_DESCRIPTION": "cosinus sinus tangente arc maths mathématiques",
"INFO_TRIGO_TITRE_COURT": "F. trigo.",
"INFO_VERIF_CREATE_PASS_FRIST": "Créer d'abord une passe à bassins, à ralentisseurs, ou à macrorugosités",
"INFO_VERIF_SELECT_SPECIES_FIRST": "Selectionner d'abord une ou plusieurs espèces",
"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",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment