Skip to content
Snippets Groups Projects
Commit 2c0dccc2 authored by Mathias Chouet's avatar Mathias Chouet
Browse files

[WIP] GUI for Verificateur

parent 86b30a07
No related branches found
No related tags found
No related merge requests found
Pipeline #137822 passed
[
{
"id": "fs_pass",
"type": "fieldset",
"fields": [
{
"id": "select_target_pass",
"type": "select_reference",
"reference": "nub",
"source": "verificateur_target"
},
{
"type": "select",
"id": "select_pab_jet_type",
"property": "pabJetType",
"default": "SURFACE"
}
]
},
{
"id": "fs_species",
"type": "fieldset",
"fields": [
{
"type": "select",
"id": "select_species_list",
"property": "speciesList",
"default": "SPECIES_1"
}
]
},
{
"type": "options",
"selectIds": [ "select_pab_jet_type" ],
"targetPassSelectId": "select_target_pass",
"speciesListSelectId": "select_species_list",
"help": "verification/verificateur.html"
}
]
{
"fs_pass": "Fish pass parameters",
"select_target_pass": "Fish pass to verify",
"select_pab_jet_type": "Jet type (PAB)",
"select_pab_jet_type_0": "Diving",
"select_pab_jet_type_1": "Surface",
"fs_species": "Species parameters",
"select_species_list": "Species groups"
}
{
"fs_pass": "Paramètres de la passe",
"select_target_pass": "Passe à vérifier",
"select_pab_jet_type": "Type de jet (PAB)",
"select_pab_jet_type_0": "Plongeant",
"select_pab_jet_type_1": "Surface",
"fs_species": "Paramètres des espèces",
"select_species_list": "Groupes d'espèces"
}
import { IObservable, Nub } from "jalhyd";
import { SelectFieldNub } from "../elements/select-field-nub";
import { FormulaireFixedVar } from "./form-fixedvar";
/**
* Formulaire pour les Vérificateurs
*/
export class FormulaireVerificateur extends FormulaireFixedVar {
/** id of select configuring target pass Nub */
private _targetPassSelectId: string;
/** id of select configuring list of species */
private _speciesListSelectId: string;
protected parseOptions(json: {}) {
super.parseOptions(json);
this._targetPassSelectId = this.getOption(json, "targetPassSelectI");
this._speciesListSelectId = this.getOption(json, "speciesListSelectId");
}
protected completeParse(json: {}, firstNotif: boolean = true) {
super.completeParse(json);
if (this._targetPassSelectId) {
const sel = this.getFormulaireNodeById(this._targetPassSelectId);
if (sel) {
sel.addObserver(this);
if (firstNotif) {
// force 1st observation
(sel as SelectFieldNub).notifySelectValueChanged();
}
}
}
if (this._speciesListSelectId) {
const sel = this.getFormulaireNodeById(this._speciesListSelectId);
/* if (sel) {
sel.addObserver(this);
if (firstNotif) {
// force 1st observation
(sel as SelectFieldNub).notifySelectValueChanged();
}
} */
}
}
// interface Observer
public update(sender: IObservable, data: any) {
// copied from FormDefinition, to avoid calling super.update()
if (sender instanceof Nub) {
switch (data.action) {
case "resultUpdated":
// forward Nub results update notification to FormCompute objects
this.reaffectResultComponents();
break;
}
}
// copied from FormFixedVar, to avoid calling super.update()
if (data.action === "propertyChange") {
this.reset();
}
if (sender instanceof SelectFieldNub) {
if (data.action === "select") {
// update Verificateur property: Pass to check
this._currentNub.properties.setPropValue("nubToVerify", data.value.value);
// @TODO refresh jet type selector
}
}/* else if (sender instanceof SelectField) {
if (sender.id === "select_target_result") {
// refresh parameters selector
this.refreshParameterEntries();
}
} */
}
/**
* Re-populate searched parameter selector with fresh entries
*/
/* private refreshParameterEntries() {
const pSel = this.getFormulaireNodeById(this._speciesListSelectId) as SelectFieldParameter;
if (pSel) {
pSel.updateEntries();
// reflect changes in GUI
const inputYtarget = this.getFormulaireNodeById("Ytarget") as NgParameter;
inputYtarget.notifyValueModified(this);
}
} */
}
...@@ -3,7 +3,7 @@ import { SelectEntry } from "./select-entry"; ...@@ -3,7 +3,7 @@ import { SelectEntry } from "./select-entry";
import { ServiceFactory } from "../../services/service-factory"; import { ServiceFactory } from "../../services/service-factory";
import { decodeHtml } from "../../util"; import { decodeHtml } from "../../util";
import { Session, Solveur } from "jalhyd"; import { Session, Solveur, FishPass, CalculatorType } from "jalhyd";
/** /**
* A select field that populates itself with references to Nubs * A select field that populates itself with references to Nubs
...@@ -24,11 +24,12 @@ export class SelectFieldNub extends SelectFieldReference { ...@@ -24,11 +24,12 @@ export class SelectFieldNub extends SelectFieldReference {
* Populates entries with available references * Populates entries with available references
*/ */
protected populate() { protected populate() {
const fs = ServiceFactory.instance.formulaireService;
let candidateNubs: any[];
switch (this._source) { switch (this._source) {
case "solveur_target": // Solveur, module cible (à calculer) case "solveur_target": // Solveur, module cible (à calculer)
// find all Nubs having at least one link to another Nub's result // find all Nubs having at least one link to another Nub's result
const fs = ServiceFactory.instance.formulaireService; candidateNubs =
const candidateNubs =
Session.getInstance().getDownstreamNubs().concat( Session.getInstance().getDownstreamNubs().concat(
Session.getInstance().getUpstreamNubsHavingExtraResults() Session.getInstance().getUpstreamNubsHavingExtraResults()
).filter( ).filter(
...@@ -50,6 +51,25 @@ export class SelectFieldNub extends SelectFieldReference { ...@@ -50,6 +51,25 @@ export class SelectFieldNub extends SelectFieldReference {
} }
} }
break; break;
case "verificateur_target": // Vérificateur, passe cible (à vérifier)
// find all Nubs of type FishPass
candidateNubs = Session.getInstance().getAllNubs().filter((element, index, self) => {
return (
(element instanceof FishPass)
&& element.calcType !== CalculatorType.Par // ParSimulation extends Par @TODO find something better
);
});
for (const cn of candidateNubs) {
const nub = fs.getFormulaireFromId(cn.uid);
if (nub) {
const label = nub.calculatorName + " (" + fs.getLocalisedTitleFromCalculatorType(nub.calculatorType) + ")";
this.addEntry(new SelectEntry(this._entriesBaseId + cn.uid, cn.uid, decodeHtml(label)));
} else {
// silent fail, this Verificateur nub was probably loaded before all the candidate nubs are done loading
}
}
break;
} }
} }
......
...@@ -40,6 +40,7 @@ import { AppComponent } from "../app.component"; ...@@ -40,6 +40,7 @@ import { AppComponent } from "../app.component";
import { FormulaireSPP } from "../formulaire/definition/form-spp"; import { FormulaireSPP } from "../formulaire/definition/form-spp";
import { FormulaireFixedVar } from "../formulaire/definition/form-fixedvar"; import { FormulaireFixedVar } from "../formulaire/definition/form-fixedvar";
import { FormulaireSection } from "../formulaire/definition/form-section"; import { FormulaireSection } from "../formulaire/definition/form-section";
import { FormulaireVerificateur } from '../formulaire/definition/form-verificateur';
@Injectable() @Injectable()
export class FormulaireService extends Observable { export class FormulaireService extends Observable {
...@@ -307,6 +308,10 @@ export class FormulaireService extends Observable { ...@@ -307,6 +308,10 @@ export class FormulaireService extends Observable {
f = new FormulaireSPP(); f = new FormulaireSPP();
break; break;
case CalculatorType.Verificateur:
f = new FormulaireVerificateur();
break;
default: default:
f = new FormulaireFixedVar(); f = new FormulaireFixedVar();
} }
......
...@@ -144,9 +144,9 @@ ...@@ -144,9 +144,9 @@
"INFO_ENUM_STRUCTUREFLOWREGIME_1": "Partially submerged", "INFO_ENUM_STRUCTUREFLOWREGIME_1": "Partially submerged",
"INFO_ENUM_STRUCTUREFLOWREGIME_2": "Submerged", "INFO_ENUM_STRUCTUREFLOWREGIME_2": "Submerged",
"INFO_ENUM_STRUCTUREFLOWREGIME_3": "Zero flow", "INFO_ENUM_STRUCTUREFLOWREGIME_3": "Zero flow",
"INFO_ENUM_STRUCTUREJETTYPE_0": "Not applicable", "INFO_ENUM_STRUCTUREJETTYPE_0": "Diving",
"INFO_ENUM_STRUCTUREJETTYPE_1": "Diving", "INFO_ENUM_STRUCTUREJETTYPE_1": "Surface",
"INFO_ENUM_STRUCTUREJETTYPE_2": "Surface", "INFO_ENUM_STRUCTUREJETTYPE_2": "Not applicable",
"INFO_CHART_BUTTON_TITLE_RESET_ZOOM": "Restore default zoom", "INFO_CHART_BUTTON_TITLE_RESET_ZOOM": "Restore default zoom",
"INFO_CHART_BUTTON_TITLE_EXPORT_IMAGE": "Save picture", "INFO_CHART_BUTTON_TITLE_EXPORT_IMAGE": "Save picture",
"INFO_CHART_BUTTON_TITLE_ENTER_FS": "Display fullscreen", "INFO_CHART_BUTTON_TITLE_ENTER_FS": "Display fullscreen",
......
...@@ -144,9 +144,9 @@ ...@@ -144,9 +144,9 @@
"INFO_ENUM_STRUCTUREFLOWREGIME_1": "Partiellement noyé", "INFO_ENUM_STRUCTUREFLOWREGIME_1": "Partiellement noyé",
"INFO_ENUM_STRUCTUREFLOWREGIME_2": "Noyé", "INFO_ENUM_STRUCTUREFLOWREGIME_2": "Noyé",
"INFO_ENUM_STRUCTUREFLOWREGIME_3": "Débit nul", "INFO_ENUM_STRUCTUREFLOWREGIME_3": "Débit nul",
"INFO_ENUM_STRUCTUREJETTYPE_0": "Sans objet", "INFO_ENUM_STRUCTUREJETTYPE_0": "Plongeant",
"INFO_ENUM_STRUCTUREJETTYPE_1": "Plongeant", "INFO_ENUM_STRUCTUREJETTYPE_1": "De surface",
"INFO_ENUM_STRUCTUREJETTYPE_2": "De surface", "INFO_ENUM_STRUCTUREJETTYPE_2": "Sans objet",
"INFO_CHART_BUTTON_TITLE_RESET_ZOOM": "Réinitialiser le zoom", "INFO_CHART_BUTTON_TITLE_RESET_ZOOM": "Réinitialiser le zoom",
"INFO_CHART_BUTTON_TITLE_EXPORT_IMAGE": "Enregistrer l'image", "INFO_CHART_BUTTON_TITLE_EXPORT_IMAGE": "Enregistrer l'image",
"INFO_CHART_BUTTON_TITLE_ENTER_FS": "Afficher en plein écran", "INFO_CHART_BUTTON_TITLE_ENTER_FS": "Afficher en plein écran",
......
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