Skip to content

Commit

Permalink
Fixed update of mapped non-standard counts, isolated initial state fr…
Browse files Browse the repository at this point in the history
…om being changed via observables
  • Loading branch information
oleg-odysseus authored and alex-odysseus committed Nov 12, 2024
1 parent 75d85c6 commit de5145a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 14 additions & 0 deletions js/pages/concept-sets/components/tabs/manual-mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ define([
return momentApi.formatDateTimeWithFormat(date, momentApi.ISO_DATE_FORMAT);
}


deepClone(obj) {
return JSON.parse(JSON.stringify(obj));
}

mapAllSelectedToGivenStandardConcept() {

if (!this.currentConcept || typeof this.currentConcept.CONCEPT_ID === 'undefined') {
Expand All @@ -206,6 +211,14 @@ define([
let resultConceptSetItemsWithoutMappedNonStandardConcepts = this.resultConceptSetItems().filter(item => !selectedNonStandardConcepts.some(selectedConcept => selectedConcept.CONCEPT_ID === item.concept.CONCEPT_ID));
this.resultConceptSetItems(resultConceptSetItemsWithoutMappedNonStandardConcepts);

//Remove selected concepts from mapped_from of remaining standard concepts
this.standardConceptsWithCounterparts().forEach(standardConcept => {
const clonedData = this.deepClone(standardConcept.mapped_from);
standardConcept.mapped_from = clonedData.filter(
id => !selectedNonStandardConcepts.map(concept => concept.CONCEPT_ID).includes(id)
);
});

// Add current standard concept to resultConceptSetItems if not already present
if (!this.resultConceptSetItems().some(item => item.concept.CONCEPT_ID === standardConceptId)) {
this.resultConceptSetItems().push({
Expand All @@ -225,6 +238,7 @@ define([
console.log("Mapping complete: Selected non-standard concepts have been mapped to the current standard concept.");
}


async loadIncludedSourceCodes() {
this.loadingIncludedSourceCodes(true);

Expand Down
6 changes: 3 additions & 3 deletions js/pages/concept-sets/components/tabs/resolve-mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ define([

countMappedNonStandard(concept) {
if (concept.mapped_from) {
return concept.mapped_from.length;
return concept.mapped_from.length.toString();
}
return 0;
return "0";
}

deepClone(item) {
Expand Down Expand Up @@ -325,7 +325,7 @@ define([
let standardForNonStandardWithMappings = await this.loadRelatedStandardConceptsWithMapping(this.initialIncludedConcepts());
// Set the data avoiding duplicates
this.standardConceptsWithCounterparts(standardForNonStandardWithMappings);
this.initialStandardConceptsWithCounterparts(standardForNonStandardWithMappings);
this.initialStandardConceptsWithCounterparts(this.deepClone(standardForNonStandardWithMappings));
} catch (err) {
console.error("Error loading standard counterparts:", err);
} finally {
Expand Down

0 comments on commit de5145a

Please sign in to comment.