Skip to content
Snippets Groups Projects
form-trigo.ts 1.65 KiB
import { IObservable } from "jalhyd";

import { FormulaireBase } from "./form-base";
import { FieldSet } from "../../fieldset";
import { FormResultFixedVar } from "../form-result-fixedvar";

/**
 * Formulaire pour les fonctions trigonométriques
 */
export class FormulaireTrigo extends FormulaireBase {

    /** id of select configuring operation */
    private _operationSelectId: string;

    /** id of select configuring unit */
    private _unitSelectId: string;

    protected parseOptions(json: {}) {
        super.parseOptions(json);
        this._operationSelectId = this.getOption(json, "operationSelectId");
        this._unitSelectId = this.getOption(json, "unitSelectId");
    }

    public afterParseFieldset(fs: FieldSet) {
        if (this._operationSelectId) {
            const sel = fs.getFormulaireNodeById(this._operationSelectId);
            if (sel) {
                fs.properties.addObserver(this);
            }
        }
        if (this._unitSelectId) {
            const sel = fs.getFormulaireNodeById(this._unitSelectId);
            if (sel) {
                fs.properties.addObserver(this);
            }
        }
    }

    // interface Observer

    public update(sender: IObservable, data: any) {
        super.update(sender, data);
        if (data.action === "propertyChange") {
            /* if (data.name === "gridType") {
                this.reset();
                // Inclined grids have more input fields (OEntH and cIncl)
                this.getFieldsetById("fs_grille").updateFields();
                // Alpha and Beta are not always shown
                this.getFieldsetById("fs_plan").updateFields();
            } */
        }
    }
}