Skip to content
Snippets Groups Projects
Commit 3f7817ae authored by AUBRY JEAN-PASCAL's avatar AUBRY JEAN-PASCAL
Browse files

fix: implements select field line component and field set component to ...

fix: implements select field line component and field set component  to  enable or disable calculate button when species are selected or not
Refs  #637
parent aa6c3b69
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"
......@@ -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)="cancelValue($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,33 @@ export class SelectFieldLineComponent implements OnInit {
return this._select.getValue();
}
public onValueChange($event) {
this.selectedValue = $event.value
this.valueChanged.emit(this.selectedValue)
}
public cancelValue($event): any {
this.selectedValue = [];
this.valueChanged.emit(this.selectedValue)
// this.validChange.emit(false)
$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);
}
......
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