Skip to content
Snippets Groups Projects
Commit 2027509e authored by François Grand's avatar François Grand
Browse files

refactor: SelectField: remove _entryMap member

parent a32d39d4
No related branches found
No related tags found
1 merge request!224Resolve "Utiliser des identifiants symboliques plutôt que numériques dans les fichiers"
......@@ -36,11 +36,6 @@ export abstract class SelectField extends Field {
*/
protected _messageWhenEmpty: string;
/**
* map id <-> select entry
*/
protected _entryMap: { [key: string]: SelectEntry } = {};
constructor(parent: FormulaireNode) {
super(parent);
this.clearEntries();
......@@ -237,14 +232,21 @@ export abstract class SelectField extends Field {
}
protected createOrGetEntry(id: string, val: any, lbl?: string): SelectEntry {
let res: SelectEntry = this._entryMap[id];
let res = this.getEntryFromId(id);
if (res === undefined) {
res = new SelectEntry(id, val, lbl);
this._entryMap[id] = res;
}
return res;
}
private getEntryFromId(id: string) {
for (const se of this._entries) {
if (se.id === id)
return se;
}
return undefined;
}
public getEntryFromValue(val: any): SelectEntry {
for (const se of this._entries) {
if (se.value === val) {
......
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