Skip to content

Commit

Permalink
apply review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kelanik8 committed Oct 19, 2023
1 parent 78a8dc1 commit c053f6c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
18 changes: 10 additions & 8 deletions client/web/compose/src/views/Admin/Charts/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -660,14 +660,16 @@ export default {
chart.name = `${this.chart.name} (copy)`
chart.handle = `${this.chart.handle}_copy`
this.$router.push({
name: 'admin.charts.create',
params: {
chartID: NoID,
category: this.category || 'generic',
chart,
},
})
const resourceTranslationLanguage = this.currentLanguage
const c = Object.assign({}, chart, resourceTranslationLanguage)
this.createChart(c).then(({ chartID }) => {
this.toastSuccess(this.$t('notification:chart.saved'))
this.initialChartState = cloneDeep(chartConstructor(this.chart))
this.$router.push({ name: 'admin.charts.edit', params: { chartID: chartID } })
}).catch(this.toastErrorHandler(this.$t('notification:chart.saveFailed')))
},
redirect () {
Expand Down
36 changes: 35 additions & 1 deletion client/web/compose/src/views/Admin/Modules/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,41 @@ export default {
module.name = `${this.module.name} (copy)`
module.handle = `${this.module.handle}_copy`
this.$router.push({ name: 'admin.modules.create', params: { module, moduleID: NoID } })
const resourceTranslationLanguage = this.currentLanguage
this.processing = true
// Filter out record fields that reference this not yet created module
let fields = []
const toBeUpdatedFields = []
module.fields.forEach(f => {
if (f.kind === 'Record' && f.options.moduleID === '-1') {
toBeUpdatedFields.push(f)
} else {
fields.push(f)
}
})
// 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({ ...module, fields, resourceTranslationLanguage }).then(async module => {
if (toBeUpdatedFields.length) {
fields = [
...module.fields,
...toBeUpdatedFields.map(f => {
f.options.moduleID = module.moduleID
return f
}),
]
module = await this.updateModule({ ...module, fields })
}
this.toastSuccess(this.$t('notification:module.created'))
this.$router.push({ name: 'admin.modules.edit', params: { moduleID: module.moduleID } })
}).catch(this.toastErrorHandler(this.$t('notification:module.saveFailed')))
.finally(() => {
this.processing = false
})
},
async fetchConnection (connectionID) {
Expand Down

0 comments on commit c053f6c

Please sign in to comment.