diff --git a/resources/assets/js/api/Custom.js b/resources/assets/js/api/Custom.js new file mode 100644 index 000000000..13bde0259 --- /dev/null +++ b/resources/assets/js/api/Custom.js @@ -0,0 +1,58 @@ +import axios from "axios"; +import ApiInstance from "./Api.js"; +import Services from "./Services"; +let Api = new ApiInstance( Services ); + +export let custom = { + inbox(data) { + let service = "INBOX_CUSTOM_LIST", + keys = {}, + params; + keys["id"] = data.id, + params = data.filters; + return Api.post({ + service, + data: params, + keys + }); + }, + draft(data) { + let service = "INBOX_CUSTOM_LIST", + keys = {}, + params; + service = "DRAFT_CUSTOM_LIST"; + keys["id"] = data.id; + params = data.filters; + return Api.post({ + service, + data: params, + keys + }); + }, + paused(data) { + let service = "INBOX_CUSTOM_LIST", + keys = {}, + params; + service = "PAUSED_CUSTOM_LIST"; + keys["id"] = data.id; + params = data.filters; + return Api.post({ + service, + data: params, + keys + }); + }, + unassigned(data) { + let service = "INBOX_CUSTOM_LIST", + keys = {}, + params; + service = "UNASSIGNED_CUSTOM_LIST"; + keys["id"] = data.id; + params = data.filters; + return Api.post({ + service, + data: params, + keys + }); + } +}; \ No newline at end of file diff --git a/resources/assets/js/api/index.js b/resources/assets/js/api/index.js index d6a313f69..256538f9b 100644 --- a/resources/assets/js/api/index.js +++ b/resources/assets/js/api/index.js @@ -5,7 +5,7 @@ import { config } from "./Config"; import { caseNotes } from "./CaseNotes"; import { process } from "./Process"; import { filters } from "./Filters"; - +import { custom } from "./Custom"; export default { menu, @@ -14,5 +14,6 @@ export default { process, caseNotes, filters, - config + config, + custom }; \ No newline at end of file diff --git a/resources/assets/js/components/search/CustomFilter.vue b/resources/assets/js/components/search/CustomFilter.vue new file mode 100644 index 000000000..a637a8244 --- /dev/null +++ b/resources/assets/js/components/search/CustomFilter.vue @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + {{ title }} + + + + + + + + + + + + + + + + {{ tagContent(tag) }} + + + + + + + + + + + + + + diff --git a/resources/assets/js/components/search/popovers/DateTime.vue b/resources/assets/js/components/search/popovers/DateTime.vue new file mode 100644 index 000000000..499dc36be --- /dev/null +++ b/resources/assets/js/components/search/popovers/DateTime.vue @@ -0,0 +1,88 @@ + + + + + {{ info.detail }} + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/assets/js/components/search/popovers/String.vue b/resources/assets/js/components/search/popovers/String.vue new file mode 100644 index 000000000..7c7215300 --- /dev/null +++ b/resources/assets/js/components/search/popovers/String.vue @@ -0,0 +1,84 @@ + + + + + + {{ info.detail }} + + + + + + + + + +| + + diff --git a/resources/assets/js/home/CustomCaseList/CustomCaseList.vue b/resources/assets/js/home/CustomCaseList/CustomCaseList.vue index e8b32fdbb..027ce6ad1 100644 --- a/resources/assets/js/home/CustomCaseList/CustomCaseList.vue +++ b/resources/assets/js/home/CustomCaseList/CustomCaseList.vue @@ -4,10 +4,11 @@ - @@ -310,7 +311,7 @@ import ModalNewRequest from "../ModalNewRequest.vue"; import ModalUnpauseCase from "../modal/ModalUnpauseCase.vue"; import ModalClaimCase from "../modal/ModalClaimCase.vue"; import TaskCell from "../../components/vuetable/TaskCell.vue"; -import CasesFilter from "../../components/search/CasesFilter"; +import CustomFilter from "../../components/search/CustomFilter"; import api from "../../api/index"; import utils from "../../utils/utils"; import MultiviewHeader from "../../components/headers/MultiviewHeader.vue"; @@ -334,7 +335,7 @@ export default { ModalUnpauseCase, ModalClaimCase, TaskCell, - CasesFilter, + CustomFilter, MultiviewHeader, VueCardView, VueListView, @@ -377,10 +378,7 @@ export default { this.$refs["newRequest"].show(); }, }, - filters: - this.settings && this.settings.filters - ? this.settings.filters - : {}, + filters: {}, defaultColumns: [ "case_number", "case_title", @@ -471,6 +469,196 @@ export default { icon: this.data.pageIcon, color: this.data.color }, + itemMap: { + case_number: "caseNumber", + case_title: "caseTitle", + delegation_date: "delegationDate", + send_by: "bySendBy", + process_name: "processName" + }, + customItems:{ + VARCHAR: { + group: "radio", + type: "VARCHAR", + id: "string", + title: `${this.$i18n.t("ID_FILTER")}:`, + optionLabel: "", + tagPrefix: "", + detail: "", + tagText: "", + placeholder: "", + items: [ + { + id: "", + value: "", + }, + ], + autoShow: true, + makeTagText: function (params, data) { + return `${this.tagPrefix} ${data[0].value}`; + }, + }, + DATETIME: { + group: "radio", + type: "DATETIME", + id: "datetime", + title: `${this.$i18n.t('ID_FILTER')}:`, + optionLabel: "", + detail: "", + tagText: "", + tagPrefix: "", + items:[ + { + id: "", + value: "" + } + ], + makeTagText: function (params, data) { + let temp = data[0].value.split(","); + return `${this.tagPrefix} ${temp[0]} - ${temp[1]} `; + } + } + }, + filterItems:[], + availableItems: { + caseNumber: { + group: "radio", + type: "CaseNumber", + id: "caseNumber", + title: `${this.$i18n.t("ID_FILTER")}: ${this.$i18n.t( + "ID_BY_CASE_NUMBER" + )}`, + optionLabel: this.$i18n.t("ID_BY_CASE_NUMBER"), + detail: this.$i18n.t("ID_PLEASE_SET_THE_CASE_NUMBER_TO_BE_SEARCHED"), + tagText: "", + tagPrefix: this.$i18n.t("ID_SEARCH_BY_CASE_NUMBER"), + items: [ + { + id: "filterCases", + value: "", + }, + ], + autoShow: true, + makeTagText: function (params, data) { + return `${params.tagPrefix}: ${data[0].value}`; + }, + }, + caseTitle: { + group: "radio", + type: "CaseTitle", + id: "caseTitle", + title: `${this.$i18n.t("ID_FILTER")}: ${this.$i18n.t( + "ID_BY_CASE_TITLE" + )}`, + optionLabel: this.$i18n.t("ID_BY_CASE_TITLE"), + tagPrefix: this.$i18n.t("ID_SEARCH_BY_CASE_TITLE"), + detail: "", + tagText: "", + items: [ + { + id: "caseTitle", + value: "", + }, + ], + autoShow: true, + makeTagText: function (params, data) { + return `${this.tagPrefix} ${data[0].value}`; + }, + }, + delegationDate: { + group: "radio", + type: "DateFilter", + id: "delegationDate", + title: `${this.$i18n.t('ID_FILTER')}: ${this.$i18n.t('ID_BY_DELEGATION_DATE')}`, + optionLabel: this.$i18n.t('ID_BY_DELEGATION_DATE'), + detail: this.$i18n.t('ID_PLEASE_SELECT_THE_DELEGATION_DATE_TO_BE_SEARCHED'), + tagText: "", + tagPrefix: this.$i18n.t('ID_SEARCH_BY_DELEGATION_DATE'), + items:[ + { + id: "delegateFrom", + value: "", + label: this.$i18n.t('ID_FROM_DELEGATION_DATE') + }, + { + id: "delegateTo", + value: "", + label: this.$i18n.t('ID_TO_DELEGATION_DATE') + } + ], + makeTagText: function (params, data) { + return `${params.tagPrefix} ${data[0].value} - ${data[1].value}`; + } + }, + bySendBy: { + group: "radio", + type: "CurrentUser", + id: "bySendBy", + title: `${this.$i18n.t('ID_FILTER')}: ${this.$i18n.t('ID_BY_SEND_BY')}`, + optionLabel: this.$i18n.t('ID_BY_SEND_BY'), + detail: this.$i18n.t('ID_PLEASE_SELECT_USER_NAME_TO_BE_SEARCHED'), + placeholder: this.$i18n.t('ID_USER_NAME'), + tagText: "", + tagPrefix: this.$i18n.t('ID_SEARCH_BY_SEND_BY'), + items:[ + { + id: "sendBy", + value: "", + options: [], + placeholder: this.$i18n.t('ID_USER_NAME') + } + ], + makeTagText: function (params, data) { + return `${params.tagPrefix} : ${data[0].label || ''}`; + } + }, + taskTitle: { + group: "radio", + type: "TaskTitle", + id: "taskTitle", + title: `${this.$i18n.t("ID_FILTER")}: ${this.$i18n.t( + "ID_TASK_NAME" + )}`, + optionLabel: this.$i18n.t("ID_BY_TASK"), + detail: "", + tagText: "", + tagPrefix: this.$i18n.t("ID_SEARCH_BY_TASK_NAME"), + autoShow: true, + items: [ + { + id: "task", + value: "", + options: [], + placeholder: this.$i18n.t("ID_TASK_NAME"), + }, + ], + makeTagText: function (params, data) { + return `${this.tagPrefix}: ${data[0].label || ""}`; + }, + }, + processName: { + group: "checkbox", + type: "ProcessName", + id: "processName", + title: `${this.$i18n.t('ID_FILTER')}: ${this.$i18n.t('ID_BY_PROCESS_NAME')}`, + optionLabel: this.$i18n.t('ID_BY_PROCESS_NAME'), + detail: "", + tagText: "", + tagPrefix: this.$i18n.t('ID_SEARCH_BY_PROCESS_NAME'), + autoShow: false, + items:[ + { + id: "process", + value: "", + options: [], + placeholder: this.$i18n.t('ID_PROCESS_NAME') + } + ], + makeTagText: function (params, data) { + return `${this.tagPrefix} ${data[0].options && data[0].options.label || ''}`; + } + } + } }; }, created() { @@ -605,31 +793,54 @@ export default { limit: limit, offset: start, }; - _.forIn(this.filters, function(item, key) { - if (filters && item.value) { - filters[item.filterVar] = item.value; - } - }); + if (_.isEmpty(that.filters) && this.data.settings) { + _.forIn(this.data.settings.filters, function(item, key) { + if (filters && item.value) { + filters[item.filterVar] = item.value; + } + }); + } else { + _.forIn(this.filters, function(item, key) { + if (filters && item.value) { + filters[item.filterVar] = item.value; + } + }); + } sort = that.prepareSortString(data); if (sort) { filters["sort"] = sort; } return new Promise((resolutionFunc, rejectionFunc) => { - api.cases[that.data.pageParent] + api.custom[that.data.pageParent] ({ id, filters, }) .then((response) => { - let tmp, columns; - - columns = response.data.columns.map((item) => { - return item.field; + let tmp, + columns = [], + product, + newItems = []; + that.filterItems = []; + response.data.columns.forEach((item) => { + if (item.enableFilter) { + if (that.availableItems[that.itemMap[item.field]]) { + newItems.push(that.availableItems[that.itemMap[item.field]]); + } else { + product = this.filterItemFactory(item) + if (product) { + newItems.push(product); + } + } + } + columns.push(item.field); }); + that.filterItems = newItems; that.settingOptions = that.formatColumnSettings(columns); dt = that.formatDataResponse(response.data.data); that.cardColumns = columns; if (that.isFistTime) { + that.filters = that.settings && that.settings.filters ? that.settings.filters : {}; that.columns = that.settings && that.settings.columns ? that.settings.columns : that.getTableColumns(columns); } resolutionFunc({ @@ -642,6 +853,28 @@ export default { }); }); }, + /** + * Create a filter item dinamically + * @param {object} item + * @returns {object|boolean} + */ + filterItemFactory(item) { + let product; + if (item.type === "DATETIME") { + product= {...this.customItems["DATETIME"]}; + } else { + product = {...this.customItems["VARCHAR"]}; + } + product.title += " " + item.name; + product.id = item.field; + product.optionLabel = item.name; + product.tagPrefix = item.name; + if (product.items && product.items[0]) { + product.items[0].id = item.field; + } + product.placeholder = ""; + return product; + }, /** * Prepare sort string to be sended in the service * @param {object} data @@ -818,6 +1051,7 @@ export default { * update view in component */ updateView(newData) { + let newCriteria = []; this.isFistTime = true; this.typeView = "GRID"; // force to update component id @@ -830,10 +1064,15 @@ export default { icon: newData.pageIcon, color: newData.color } - this.filters = newData.settings && newData.settings.filters ? newData.settings.filters : {}; + this.data.settings = newData.settings; + this.filters = {}; } if (this.typeView === "GRID" && this.$refs["vueTable"]) { - this.$refs["vueTable"].getData(); + if (newData.settings && newData.settings.orderBy) { + this.$refs["vueTable"].setOrder(newData.settings.orderBy.column, newData.settings.orderBy.ascending); + } else { + this.$refs["vueTable"].setOrder(false); + } } if (this.typeView === "CARD" && this.$refs["vueCardView"]) { this.$refs["vueCardView"].getData(); diff --git a/resources/assets/js/home/CustomCaseList/defaultMixins.js b/resources/assets/js/home/CustomCaseList/defaultMixins.js index 8ec583439..f3234b2c6 100644 --- a/resources/assets/js/home/CustomCaseList/defaultMixins.js +++ b/resources/assets/js/home/CustomCaseList/defaultMixins.js @@ -83,17 +83,34 @@ export default { dt, typeList = that.data.pageParent == "inbox"? "todo": that.data.pageParent, start = 0, + paged, limit = data.limit, - filters = {}; + filters = {}, + id = this.data.customListId; filters = { - paged: "0," + limit, + paged: paged, + limit: limit, + offset: start, }; - - _.forIn(this.filters, function (item, key) { - filters[item.filterVar] = item.value; - }); + if (_.isEmpty(that.filters) && this.data.settings) { + _.forIn(this.data.settings.filters, function(item, key) { + if (filters && item.value) { + filters[item.filterVar] = item.value; + } + }); + } else { + _.forIn(this.filters, function(item, key) { + if (filters && item.value) { + filters[item.filterVar] = item.value; + } + }); + } return new Promise((resolutionFunc, rejectionFunc) => { - api.cases[typeList](filters) + api.custom[that.data.pageParent] + ({ + id, + filters, + }) .then((response) => { dt = that.formatDataResponse(response.data.data); resolutionFunc({
{{ info.detail }}