diff --git a/src/components/import/ImportFile.vue b/src/components/import/ImportFile.vue index 0075c424f..932f6741f 100644 --- a/src/components/import/ImportFile.vue +++ b/src/components/import/ImportFile.vue @@ -39,35 +39,6 @@ class="is-size-6"> {{ importStatus }}

-
-

-
- Found {{ importDuplicates.length }} instance{{ importDuplicates.length > 1 ? 's' : '' }} of duplicate competencies with different CTIDs. -
- For each instance, choose whether to upload all or select a single CTID. -

-
-
- {{ '(' + set.lines + ') ' + set.competencyText }}{{ set.codedNotation ? '(' + set.codedNotation + ')' : '' }} -
- - -
-
-
-
-
-
-
@@ -208,6 +179,43 @@ + +
+
+
+ Found {{ duplicateSets.length }} instance{{ duplicateSets.length > 1 ? 's' : '' }} of duplicate competencies with different CTIDs. +
+ For each instance, choose whether to upload all or select a single CTID. +
+
+
+
+ {{ set.competencyText }} +
+
+ {{ "ceasn:codedNotation: " + set.codedNotation }} +
+
+ {{ set.lines }} +
+
+
+ + +
+
+
+
{ - const foundIndex = setsOfDuplicates.findIndex((set) => (set.competencyText === duplicate.competencyText) && (set.codedNotation === duplicate.codedNotation)); - console.log(duplicate); - console.log(foundIndex); - if (foundIndex >= 0) { - setsOfDuplicates[foundIndex].lines += ', ' + duplicate.line; - setsOfDuplicates[foundIndex].duplicates.push({ - ctid: duplicate.ctid, - id: duplicate.id - }); - } else { - setsOfDuplicates.push({ - competencyText: duplicate.competencyText, - codedNotation: duplicate.codedNotation, - lines: 'Line ' + duplicate.line, - duplicates: [ - { - ctid: 'upload all' - }, - { - ctid: duplicate.ctid - } - ] - }); - } - }); - console.log(setsOfDuplicates); - return setsOfDuplicates; - }, importFileType: function() { return this.$store.getters['app/importFileType']; }, @@ -438,6 +415,9 @@ export default { importIdColumn: function() { return this.$store.getters['app/importIdColumn']; }, + importDuplicates: function() { + return this.$store.getters['app/importDuplicates']; + }, importSourceColumn: { get() { return this.$store.getters['app/importSourceColumn']; @@ -492,7 +472,7 @@ export default { x: false, y: true }; - + this.updateDuplicateSkips(); if (this.importFileType === 'csv') { // prepare csv this.$store.commit('app/importFrameworkName', this.optionImportFrameworkName); @@ -533,10 +513,55 @@ export default { } } }, - removeDuplicate: function(index) { + findDuplicateSets: function() { + // Separate duplicates by competencyText and codedNotation + this.duplicateSets = []; const duplicates = this.$store.getters['app/importDuplicates']; - duplicates.splice(index, 1); - this.$store.commit('app/importDuplicates', duplicates); + duplicates.forEach((duplicate) => { + const foundIndex = this.duplicateSets.findIndex((set) => (set.competencyText === duplicate.competencyText) && (set.codedNotation === duplicate.codedNotation)); + if (foundIndex >= 0) { + this.duplicateSets[foundIndex].lines += ', ' + duplicate.line; + this.duplicateSets[foundIndex].duplicates.push({ + ctid: duplicate.ctid, + id: duplicate.id + }); + } else { + this.duplicateSets.push({ + competencyText: duplicate.competencyText, + codedNotation: duplicate.codedNotation, + lines: 'Lines ' + duplicate.line, + duplicates: [ + { + ctid: 'upload all' + }, + { + ctid: duplicate.ctid + } + ] + }); + } + }); + this.selectedDuplicateOption = []; + this.duplicateSets.forEach(() => { + this.selectedDuplicateOption.push('upload all'); + }); + }, + updateDuplicateSkips: function() { + let skip = []; + this.selectedDuplicateOption.forEach((set, i) => { + if (set !== 'upload all') { + this.duplicateSets[i].duplicates.forEach((duplicate) => { + if (duplicate.ctid !== set && !duplicate.ctid.includes('upload all')) { + skip.push(duplicate.ctid); + if (duplicate.replaceWith) { + // Replace all instances of duplicate.ctid with duplicate.replaceWith in import file + } + } + }); + } + }); + this.duplicateSets = []; + this.$store.commit('app/importSkip', skip); } }, watch: { @@ -566,6 +591,9 @@ export default { }, importTargetColumn: function() { this.csvRelationDetails.targetColumn.value = this.importTargetColumn; + }, + importDuplicates: function() { + this.findDuplicateSets(); } } }; diff --git a/src/mixins/import.js b/src/mixins/import.js index 25ff97a60..ba7ce4d0e 100644 --- a/src/mixins/import.js +++ b/src/mixins/import.js @@ -181,6 +181,8 @@ export default { this.$store.commit('app/importStatus', ''); this.$store.commit('app/importFeedback', ''); this.$store.commit('app/importFileType', ''); + this.$store.commit('app/importDuplicates', []); + this.$store.commit('app/importSkip', []); if (this.caseDocs) { this.caseDocs = []; } @@ -589,8 +591,7 @@ export default { if (EcIdentityManager.default.ids.length > 0) { ceo = EcIdentityManager.default.ids[0]; } let me = this; me.$store.commit('app/importAllowCancel', true); - let duplicates = this.$store.getters['app/importDuplicates']; - let skip = duplicates.map((element) => { return element.ctid; }); + let skip = this.$store.getters['app/importSkip']; CTDLASNCSVImport.importFrameworksAndCompetencies(me.repo, me.importFile[0], function(frameworks, competencies, relations) { me.$store.commit('app/importAllowCancel', false); for (var i = 0; i < frameworks.length; i++) { diff --git a/src/store/modules/app.js b/src/store/modules/app.js index 547df735a..f666565a4 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -54,6 +54,7 @@ const state = { errors: [], // erorrs from the code or from the api feedback: '', // additional information duplicates: [], + skip: [], framework: null, serverUrl: '', url: '', @@ -171,6 +172,7 @@ const mutations = { errors: [], // erorrs from the code or from the api feedback: '', // additional information duplicates: [], + skip: [], framework: null, serverUrl: '', url: '', @@ -222,6 +224,9 @@ const mutations = { importDuplicates: function(state, val) { state.import.duplicates = val; }, + importSkip: function(state, val) { + state.import.skip = val; + }, importFramework: function(state, val) { state.import.framework = val; }, @@ -371,6 +376,8 @@ const actions = { commit('importAllowCancel', false); commit('importFeedback', ''); commit('importFileType', ''); + commit('importDuplicates', []); + commit('importSkip', []); }, refreshDirectories: function({commit}) { let directories = []; @@ -460,6 +467,9 @@ const getters = { importDuplicates: state => { return state.import.duplicates; }, + importSkip: state => { + return state.import.skip; + }, importFramework: state => { return state.import.framework; },