From 9b07c109696d1f57a0732cba92213a8fabf5bbc3 Mon Sep 17 00:00:00 2001 From: Kelani Tolulope Date: Tue, 17 Oct 2023 12:37:44 +0100 Subject: [PATCH] apply review changes --- client/web/compose/src/views/Admin/Charts/Edit.vue | 8 +++----- client/web/compose/src/views/Admin/Modules/Edit.vue | 12 +++++------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/client/web/compose/src/views/Admin/Charts/Edit.vue b/client/web/compose/src/views/Admin/Charts/Edit.vue index a10b53b03c..00f2bcec73 100644 --- a/client/web/compose/src/views/Admin/Charts/Edit.vue +++ b/client/web/compose/src/views/Admin/Charts/Edit.vue @@ -615,18 +615,16 @@ export default { this.processing = false }, - handleSave ({ closeOnSuccess = false, chart } = {}) { + handleSave ({ closeOnSuccess = false, chart = this.chart } = {}) { /** * Pass a special tag alongside payload that * instructs store layer to add content-language header to the API request */ const resourceTranslationLanguage = this.currentLanguage - const selectedChart = chart || this.chart + const c = Object.assign({}, chart, resourceTranslationLanguage) - const c = Object.assign({}, selectedChart, resourceTranslationLanguage) - - if (selectedChart.chartID === NoID) { + if (chart.chartID === NoID) { this.createChart(c).then(({ chartID }) => { this.toastSuccess(this.$t('notification:chart.saved')) this.initialChartState = cloneDeep(chartConstructor(this.chart)) diff --git a/client/web/compose/src/views/Admin/Modules/Edit.vue b/client/web/compose/src/views/Admin/Modules/Edit.vue index 8b83a8eacf..a8082e5af6 100644 --- a/client/web/compose/src/views/Admin/Modules/Edit.vue +++ b/client/web/compose/src/views/Admin/Modules/Edit.vue @@ -762,7 +762,7 @@ export default { this.module.config = { ...this.module.config, ...changes } }, - handleSave ({ closeOnSuccess = false, module } = {}) { + handleSave ({ closeOnSuccess = false, module = this.module } = {}) { /** * Pass a special tag alongside payload that * instructs store layer to add content-language header to the API request @@ -770,13 +770,11 @@ export default { const resourceTranslationLanguage = this.currentLanguage this.processing = true - const selectedModule = module || this.module - - if (selectedModule.moduleID === NoID) { + if (module.moduleID === NoID) { // Filter out record fields that reference this not yet created module let fields = [] const toBeUpdatedFields = [] - selectedModule.fields.forEach(f => { + module.fields.forEach(f => { if (f.kind === 'Record' && f.options.moduleID === '-1') { toBeUpdatedFields.push(f) } else { @@ -786,7 +784,7 @@ export default { // If such fields exist , after module is created add fields, map moduleID and update module // Unfortunately this ruins the initial field order, but we can improve this later - this.createModule({ ...selectedModule, fields, resourceTranslationLanguage }).then(async module => { + this.createModule({ ...module, fields, resourceTranslationLanguage }).then(async module => { if (toBeUpdatedFields.length) { fields = [ ...module.fields, @@ -813,7 +811,7 @@ export default { this.processing = false }) } else { - this.updateModule({ ...selectedModule, resourceTranslationLanguage }).then(module => { + this.updateModule({ ...module, resourceTranslationLanguage }).then(module => { this.module = new compose.Module({ ...module }, this.namespace) this.initialModuleState = this.module.clone()