Skip to content
Snippets Groups Projects
Commit 11ccee87 authored by mathias.chouet's avatar mathias.chouet
Browse files

Simplified form results reset

parent ff288621
No related branches found
No related tags found
2 merge requests!108Resolve "Simplifier les composants de résultats",!93Resolve "Ajout du module Prébarrage"
......@@ -20,7 +20,7 @@ export class CalculatorResultsComponent implements AfterViewChecked {
@Inject(forwardRef(() => GenericCalculatorComponent)) private calculatorComponent: GenericCalculatorComponent
) { }
// @TODO this system is sh*tty !
// @TODO @Input() ?
public set formulaire(f: FormulaireDefinition) {
this._formulaire = f;
}
......@@ -33,10 +33,6 @@ export class CalculatorResultsComponent implements AfterViewChecked {
return r;
}
public updateView() {
console.log("UPDATE VIEW (disabled)");
}
public ngAfterViewChecked() {
this.afterViewChecked.emit();
}
......
......@@ -388,10 +388,6 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
this.appComponent.showProgressBar = true;
this._computeClicked = true;
this.showPBInputData = false;
// send resetForm to clear log
this._formulaire.notifyObservers({
"action": "resetForm",
}, this._formulaire);
// calculate module
setTimeout(() => {
this._formulaire.doCompute();
......@@ -443,22 +439,6 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
}
}
private setForm(f: FormulaireDefinition) {
if (this._formulaire !== undefined) {
this._formulaire.removeObserver(this);
}
this._formulaire = f;
if (this._formulaire !== undefined) {
this._formulaire.addObserver(this);
}
}
private updateFormulaireResults(uid: string) {
if (this._formulaire.uid === uid) {
this.resultsComponent.updateView();
}
}
// interface Observer
update(sender: any, data: any): void {
......@@ -466,22 +446,13 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
switch (data["action"]) {
case "currentFormChanged":
const uid: string = data["formId"];
this.setForm(this.formulaireService.getFormulaireFromId(uid));
this._formulaire = (this.formulaireService.getFormulaireFromId(uid));
this.resultsComponent.formulaire = this._formulaire;
this._calculatorNameComponent.model = this._formulaire;
// reload localisation in all cases (it does not eat bread)
this.formulaireService.updateFormulaireLocalisation(this._formulaire);
break;
}
} else if (sender instanceof FormulaireDefinition) {
let f: FormulaireDefinition;
switch (data["action"]) {
case "resetForm": // réinitialisation du formulaire
case "resultsUpdated":
f = sender as FormulaireDefinition;
this.updateFormulaireResults(f.uid);
break;
}
}
}
......@@ -557,8 +528,6 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
*/
public onInputChange(event: any) {
this._formulaire.resetResults([], (event ? event.symbol : undefined));
// to refresh log components, that are fed manually (!)
this.resultsComponent.updateView();
}
/**
......@@ -604,8 +573,6 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
// show proper form (actually subform elements) or proper results,
// depending on what was clicked
(this._formulaire as FormulairePrebarrage).nodeSelected(event.node);
// refresh results component
this.resultsComponent.updateView();
}
public openHelp() {
......
......@@ -37,7 +37,6 @@ export class PabResultsComponent extends ResultsComponentDirective {
if (rs.length > 0 && rs[0] instanceof PabResults) {
this._pabResults = rs[0] as PabResults;
}
// this.updateView();
}
private mergeGlobalLog(result: Result, log: cLog) {
......
......@@ -30,7 +30,6 @@ export class PbResultsComponent {
this._pbResults = r as PrebarrageResults;
}
}
// this.updateView();
}
public get pbResults() {
......
......@@ -146,7 +146,6 @@ export class RemousResultsComponent extends ResultsComponentDirective {
}
}
}
// this.updateView();
}
public get log(): cLog {
......
......@@ -37,7 +37,6 @@ export class SectionResultsComponent extends ResultsComponentDirective {
}
}
}
// this.updateView();
this.drawSectionCanvas();
}
......
......@@ -317,12 +317,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
}
}
protected notifyReset() {
this.notifyObservers({
"action": "resetForm"
}, this);
}
/**
* Forwards Nub's progress updated notification.
* Used by CalculatorComponent to update progress bar
......@@ -337,8 +331,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
*/
public reset() {
this.resetResults([], undefined, true);
// prévenir les composants qu'il faut détecter les changements
this.notifyReset();
}
/**
......@@ -499,10 +491,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
public doCompute() {
// calculate module
this.compute();
// refresh results
this.notifyObservers({
"action": "resultsUpdated",
}, this);
}
public resetFormResults() {}
......
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