PMCORE-3343:No sorting option for Advanced Search PMCORE_3.7.0 build

This commit is contained in:
Rodrigo Quelca
2021-09-20 13:24:24 +00:00
parent afa1dc5e21
commit 50ff97d73c

View File

@@ -120,6 +120,11 @@ export default {
filtersModel: {}, filtersModel: {},
filterHeader: "STARTED_BY_ME", filterHeader: "STARTED_BY_ME",
headers: [], headers: [],
columMap: {
case_number: "APP_NUMBER",
case_title: "DEL_TITLE",
process_name: "PRO_TITLE",
},
newCase: { newCase: {
title: this.$i18n.t("ID_NEW_CASE"), title: this.$i18n.t("ID_NEW_CASE"),
class: "btn-success", class: "btn-success",
@@ -172,7 +177,7 @@ export default {
programmatic: false, programmatic: false,
}, },
sortable: [], sortable: [],
orderBy: {}, sortable: ["case_number"],
requestFunction(data) { requestFunction(data) {
return this.$parent.$parent.getCasesForVueTable(data); return this.$parent.$parent.getCasesForVueTable(data);
}, },
@@ -222,7 +227,8 @@ export default {
paged, paged,
limit = data.limit, limit = data.limit,
filters = {}, filters = {},
start = data.page === 1 ? 0 : limit * (data.page - 1); start = data.page === 1 ? 0 : limit * (data.page - 1),
sort = "";
paged = start + "," + limit ; paged = start + "," + limit ;
filters = { filters = {
limit: limit, limit: limit,
@@ -233,6 +239,11 @@ export default {
filters[item.filterVar] = item.value; filters[item.filterVar] = item.value;
} }
}); });
sort = that.prepareSortString(data);
if (sort) {
filters["sort"] = sort;
}
return new Promise((resolutionFunc, rejectionFunc) => { return new Promise((resolutionFunc, rejectionFunc) => {
api.cases api.cases
.search(filters) .search(filters)
@@ -251,6 +262,20 @@ export default {
}); });
}); });
}, },
/**
* Prepare sort string to be sended in the service
* @param {object} data
* @returns {string}
*/
prepareSortString(data) {
let sort = "";
if (data.orderBy && this.columMap[data.orderBy]) {
sort = `${this.columMap[data.orderBy]},${
data.ascending === 1 ? "ASC" : "DESC"
}`;
}
return sort;
},
/** /**
* Format the service response * Format the service response
*/ */