Skip to content

Commit

Permalink
Reusables: changes in Concept Sets tab do not reflect in the design …
Browse files Browse the repository at this point in the history
…dropdowns #2689 (#2690)
  • Loading branch information
anton-abushkevich authored Mar 31, 2022
1 parent e23f8d0 commit efe5768
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions js/pages/reusables/components/tabs/reusable-design.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,19 @@ define([
this.censoringEventExpression = this.design().censoringEventExpression;

this.csAndParams = ko.observableArray(
ko.unwrap(this.design().conceptSets).concat(this.design().parameters()
.filter(p => p.type === ReusablesService.PARAMETER_TYPE.CONCEPT_SET)
.map(p => p.data))
ko.unwrap(this.design().conceptSets).concat(this.getParameters())
);
this.csAndParams.subscribe((newArray) => {
this.design().conceptSets(newArray.filter(cs => cs.id >= 0));
let newConceptSets = newArray.filter(cs => cs.id >= 0);
if (newConceptSets.length !== this.design().conceptSets().length) {
this.design().conceptSets(newConceptSets);
}
});
this.design().conceptSets.subscribe((newArray) => {
let oldConceptSets = this.csAndParams().filter(item => item.id >= 0);
if (oldConceptSets.length !== newArray.length) {
this.csAndParams(newArray.concat(this.getParameters()));
}
});

this.parametersTableOptions = params.tableOptions || commonUtils.getTableOptions('S');
Expand Down Expand Up @@ -121,8 +128,15 @@ define([
this.csAndParams.push(reusableParameter.data);
}

getParameters() {
return this.design().parameters()
.filter(p => p.type === ReusablesService.PARAMETER_TYPE.CONCEPT_SET)
.map(p => p.data);
}

removeParameter(p) {
this.design().parameters.remove(p);
this.csAndParams(this.csAndParams().filter(item => item.id !== -p.id));
}
}

Expand Down

0 comments on commit efe5768

Please sign in to comment.