Fix saving of blank checklist on item sidebar [SCI-10031]

This commit is contained in:
Martin Artnik 2024-01-16 15:59:21 +01:00
parent d0ecfe53dc
commit 7be280e6e1
2 changed files with 37 additions and 40 deletions

View file

@ -559,39 +559,36 @@ export default {
if (this.defaultColumns?.name) { if (this.defaultColumns?.name) {
this.defaultColumns.name = ''; this.defaultColumns.name = '';
} }
$.ajax({ axios.get(
method: 'GET', repositoryRowUrl,
url: repositoryRowUrl, { my_module_id: this.myModuleId }
data: { my_module_id: this.myModuleId }, ).then((response) => {
dataType: 'json', const result = response.data;
success: (result) => { this.repositoryRowId = result.id;
this.repositoryRowId = result.id; this.repository = result.repository;
this.repository = result.repository; this.optionsPath = result.options_path;
this.optionsPath = result.options_path; this.updatePath = result.update_path;
this.updatePath = result.update_path; this.defaultColumns = result.default_columns;
this.defaultColumns = result.default_columns; this.parentsCount = result.relationships.parents_count;
this.parentsCount = result.relationships.parents_count; this.childrenCount = result.relationships.children_count;
this.childrenCount = result.relationships.children_count; this.parents = result.relationships.parents;
this.parents = result.relationships.parents; this.children = result.relationships.children;
this.children = result.relationships.children; this.customColumns = result.custom_columns;
this.customColumns = result.custom_columns; this.assignedModules = result.assigned_modules;
this.assignedModules = result.assigned_modules; this.permissions = result.permissions;
this.permissions = result.permissions; this.actions = result.actions;
this.actions = result.actions; this.icons = result.icons;
this.icons = result.icons; this.dataLoading = false;
this.dataLoading = false; this.notification = result.notification;
this.notification = result.notification; this.$nextTick(() => {
this.$nextTick(() => { this.generateBarCode(this.defaultColumns.code);
this.generateBarCode(this.defaultColumns.code);
// if scrollTop was provided, scroll to it // if scrollTop was provided, scroll to it
this.$nextTick(() => { this.$refs.bodyWrapper.scrollTop = scrollTop; }); this.$nextTick(() => { this.$refs.bodyWrapper.scrollTop = scrollTop; });
}); });
}, }).catch(() => {
error: () => { this.loadingError = true;
this.loadingError = true; this.dataLoading = false;
this.dataLoading = false;
}
}); });
}, },
reload() { reload() {
@ -618,17 +615,16 @@ export default {
return this.assignedModules.total_assigned_size - this.assignedModules.viewable_modules.length; return this.assignedModules.total_assigned_size - this.assignedModules.viewable_modules.length;
}, },
update(params) { update(params) {
$.ajax({ axios.put(
method: 'PUT', this.updatePath,
url: this.updatePath, {
dataType: 'json',
data: {
id: this.id, id: this.id,
...params ...params
} }
}).done((response) => { ).then((response) => {
if (response) { const result = response.data;
this.customColumns = this.customColumns.map((col) => (col.id === response.id ? { ...col, ...response } : col)); if (result) {
this.customColumns = this.customColumns.map((col) => (col.id === result.id ? { ...col, ...result } : col));
if ($('.dataTable.repository-dataTable')[0]) $('.dataTable.repository-dataTable').DataTable().ajax.reload(null, false); if ($('.dataTable.repository-dataTable')[0]) $('.dataTable.repository-dataTable').DataTable().ajax.reload(null, false);
} }
}); });

View file

@ -8,6 +8,7 @@
@change="changeSelected" @change="changeSelected"
@update="update" @update="update"
:initialSelectedValues="selectedValues" :initialSelectedValues="selectedValues"
:shouldUpdateWithoutValues="true"
:withButtons="true" :withButtons="true"
:withEditCursor="true" :withEditCursor="true"
ref="ChecklistSelector" ref="ChecklistSelector"