Skip to content

Commit

Permalink
fix: strip empty components
Browse files Browse the repository at this point in the history
  • Loading branch information
JackScanlon committed Feb 13, 2025
1 parent f79aff2 commit 2b28fe9
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2265,6 +2265,21 @@ export default class ConceptCreator {
// Create or update the concept given the editor data
let index = this.data.findIndex(item => item.concept_id == data.concept_id && item.concept_version_id == data.concept_version_id);
let isNew = index < 0;

const components = data?.components;
for (let i = components.length; i > 0; --i) {
const component = components[i - 1];
if (!component.is_new || component.imported) {
continue;
}

const invalidCodes = !Array.isArray(component.codes) || component.codes.length < 1;
const isEmptySource = !invalidCodes && (typeof component.source !== 'string' || isStringEmpty(component.source) || component.source.length < 3);
if (invalidCodes || isEmptySource) {
components.splice(i, 1);
}
}

if (isNew) {
this.data.push(data);
} else {
Expand Down

0 comments on commit 2b28fe9

Please sign in to comment.