PMCORE-3252: (custom cases list) columns settings was not saved for a final user

This commit is contained in:
Rodrigo Quelca
2021-08-30 22:48:33 +00:00
parent d6aae5e289
commit e9f32179ae
2 changed files with 78 additions and 11 deletions

View File

@@ -455,20 +455,43 @@ export default {
this.initFilters();
},
mounted() {
debugger;
let that = this;
// force to open case
this.openDefaultCase();
// define sort event
Event.$on("vue-tables.todo.sorted", function(data) {
that.$emit("updateUserSettings", "orderBy", data);
that.$emit("updateSettings", {
data: data,
key: "orderBy",
parent: that.data.pageParent,
type: "custom",
id: that.data.customListId
});
});
},
watch: {
columns: function(val) {
//TODO update settings
if (this.isFistTime) {
this.isFistTime = false;
} else {
this.$emit("updateSettings", {
data: val,
key: "columns",
parent: this.data.pageParent,
type: "custom",
id: this.data.customListId
});
}
},
filters: function(val) {
this.$emit("updateUserSettings", "filters", val);
this.$emit("updateSettings", {
data: val,
key: "filters",
parent: this.data.pageParent,
type: "custom",
id: this.data.customListId
});
},
},
computed: {
@@ -595,9 +618,7 @@ export default {
dt = that.formatDataResponse(response.data.data);
that.cardColumns = columns;
if (that.isFistTime) {
that.columns = that.getTableColumns(columns);
that.isFistTime = false;
that.columns = that.settings && that.settings.columns ? that.settings.columns : that.getTableColumns(columns);
}
resolutionFunc({
data: dt,

View File

@@ -24,7 +24,7 @@
:pageUri="pageUri"
:name="pageName"
:defaultOption="defaultOption"
:settings="config.setting[page]"
:settings="settings"
:filters="filters"
:data="pageData"
@onSubmitFilter="onSubmitFilter"
@@ -35,6 +35,7 @@
@onUpdateFilters="onUpdateFilters"
@cleanDefaultOption="cleanDefaultOption"
@updateUserSettings="updateUserSettings"
@updateSettings="updateSettings"
></component>
</div>
</div>
@@ -111,7 +112,8 @@ export default {
CASES_FOLDERS: "my-documents"
},
defaultOption: window.config.defaultOption || '',
pageData: {}
pageData: {},
settings: {}
};
},
mounted() {
@@ -125,7 +127,9 @@ export default {
);
// adding eventBus listener
eventBus.$on('sort-menu', (data) => {
that.updateUserSettings('customCasesList', data);
let newData = [];
data.forEach(item => newData.push({id: item.id}));
that.updateUserSettings('customCasesList', newData);
});
eventBus.$on('home-update-page', (data) => {
that.onUpdatePage(data);
@@ -230,6 +234,40 @@ export default {
});
}
},
/**
* Update the user config service
* @param {object} params
*/
updateSettings (params){
if (params.type === "custom") {
if (!this.config.setting[params.parent]) {
this.config.setting[params.parent] = {};
}
if (!this.config.setting[params.parent]["customCaseList"]) {
this.config.setting[params.parent]["customCaseList"] = {};
}
if (!this.config.setting[params.parent].customCaseList[params.id]) {
this.config.setting[params.parent].customCaseList[params.id] = {}
}
this.config.setting[params.parent].customCaseList[params.id][params.key] = params.data;
} else {
if (!this.config.setting[this.page]) {
this.config.setting[this.page] = {};
}
this.config.setting[this.page][params.key] = data;
}
api.config
.put(this.config)
.then((response) => {
if (response.data) {
//TODO success response
}
})
.catch((e) => {
console.error(e);
});
},
/**
* Set default cases menu option
*/
@@ -243,6 +281,7 @@ export default {
} else {
this.page = "MyCases";
}
this.settings = this.config.setting[this.page];
this.lastPage = this.page;
},
/**
@@ -369,6 +408,7 @@ export default {
this.pageId = null;
this.pageUri = item.item.href;
this.page = item.item.page || "MyCases";
this.settings = this.config.setting[this.page];
if (!this.menuMap[item.item.id]) {
this.page = "custom-case-list";
this.pageData = {
@@ -378,7 +418,13 @@ export default {
pageIcon: item.item.icon,
customListId: item.item.id
}
if (this.config.setting[item.item.page] && this.config.setting[item.item.page]["customCaseList"]) {
this.settings = this.config.setting[item.item.page]["customCaseList"][item.item.id];
} else {
this.settings = {};
}
}
if (this.page === this.lastPage
&& this.$refs["component"]
&& this.$refs["component"].updateView) {