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(); this.initFilters();
}, },
mounted() { mounted() {
debugger;
let that = this; let that = this;
// force to open case // force to open case
this.openDefaultCase(); this.openDefaultCase();
// define sort event // define sort event
Event.$on("vue-tables.todo.sorted", function(data) { 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: { watch: {
columns: function(val) { 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) { 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: { computed: {
@@ -595,9 +618,7 @@ export default {
dt = that.formatDataResponse(response.data.data); dt = that.formatDataResponse(response.data.data);
that.cardColumns = columns; that.cardColumns = columns;
if (that.isFistTime) { if (that.isFistTime) {
that.columns = that.getTableColumns(columns); that.columns = that.settings && that.settings.columns ? that.settings.columns : that.getTableColumns(columns);
that.isFistTime = false;
} }
resolutionFunc({ resolutionFunc({
data: dt, data: dt,

View File

@@ -24,7 +24,7 @@
:pageUri="pageUri" :pageUri="pageUri"
:name="pageName" :name="pageName"
:defaultOption="defaultOption" :defaultOption="defaultOption"
:settings="config.setting[page]" :settings="settings"
:filters="filters" :filters="filters"
:data="pageData" :data="pageData"
@onSubmitFilter="onSubmitFilter" @onSubmitFilter="onSubmitFilter"
@@ -35,6 +35,7 @@
@onUpdateFilters="onUpdateFilters" @onUpdateFilters="onUpdateFilters"
@cleanDefaultOption="cleanDefaultOption" @cleanDefaultOption="cleanDefaultOption"
@updateUserSettings="updateUserSettings" @updateUserSettings="updateUserSettings"
@updateSettings="updateSettings"
></component> ></component>
</div> </div>
</div> </div>
@@ -111,7 +112,8 @@ export default {
CASES_FOLDERS: "my-documents" CASES_FOLDERS: "my-documents"
}, },
defaultOption: window.config.defaultOption || '', defaultOption: window.config.defaultOption || '',
pageData: {} pageData: {},
settings: {}
}; };
}, },
mounted() { mounted() {
@@ -124,8 +126,10 @@ export default {
parseInt(window.config.FORMATS.casesListRefreshTime) * 1000 parseInt(window.config.FORMATS.casesListRefreshTime) * 1000
); );
// adding eventBus listener // adding eventBus listener
eventBus.$on('sort-menu', (data) => { 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) => { eventBus.$on('home-update-page', (data) => {
that.onUpdatePage(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 * Set default cases menu option
*/ */
@@ -243,8 +281,9 @@ export default {
} else { } else {
this.page = "MyCases"; this.page = "MyCases";
} }
this.settings = this.config.setting[this.page];
this.lastPage = this.page; this.lastPage = this.page;
}, },
/** /**
* Do a mapping of vue view for menus * Do a mapping of vue view for menus
* @returns array * @returns array
@@ -369,6 +408,7 @@ export default {
this.pageId = null; this.pageId = null;
this.pageUri = item.item.href; this.pageUri = item.item.href;
this.page = item.item.page || "MyCases"; this.page = item.item.page || "MyCases";
this.settings = this.config.setting[this.page];
if (!this.menuMap[item.item.id]) { if (!this.menuMap[item.item.id]) {
this.page = "custom-case-list"; this.page = "custom-case-list";
this.pageData = { this.pageData = {
@@ -378,7 +418,13 @@ export default {
pageIcon: item.item.icon, pageIcon: item.item.icon,
customListId: item.item.id 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 if (this.page === this.lastPage
&& this.$refs["component"] && this.$refs["component"]
&& this.$refs["component"].updateView) { && this.$refs["component"].updateView) {