diff --git a/package-lock.json b/package-lock.json index b2750c39f..322624234 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3079,6 +3079,11 @@ "integrity": "sha1-3vHxyl1gWdJKdm5YeULCEQbOEnU=", "dev": true }, + "downloadjs": { + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/downloadjs/-/downloadjs-1.4.7.tgz", + "integrity": "sha1-9p+W+UDg0FU9rCkROYZaPNAQHjw=" + }, "duplexify": { "version": "3.7.1", "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", diff --git a/resources/assets/js/admin/settings/customCaseList/Api/CaseList.js b/resources/assets/js/admin/settings/customCaseList/Api/CaseList.js index 889f9c753..552e5dcaf 100644 --- a/resources/assets/js/admin/settings/customCaseList/Api/CaseList.js +++ b/resources/assets/js/admin/settings/customCaseList/Api/CaseList.js @@ -65,6 +65,15 @@ class caseListApi extends Api { data: data }); } + updateCaseList(data) { + return this.put({ + service: "PUT_CASE_LIST", + keys: { + id: data.id + }, + data: data + }); + } } let api = new caseListApi(Services); diff --git a/resources/assets/js/admin/settings/customCaseList/Api/Services.js b/resources/assets/js/admin/settings/customCaseList/Api/Services.js index e8eb7e5a0..e6cc594f4 100644 --- a/resources/assets/js/admin/settings/customCaseList/Api/Services.js +++ b/resources/assets/js/admin/settings/customCaseList/Api/Services.js @@ -4,5 +4,6 @@ export default { CASE_LIST_UNASSIGNED: "/caseList/unassigned", CASE_LIST_PAUSED: "/caseList/paused", REPORT_TABLES: "/caseList/report-tables", - CASE_LIST: "/caseList" + CASE_LIST: "/caseList", + PUT_CASE_LIST: "/caseList/{id}" }; diff --git a/resources/assets/js/admin/settings/customCaseList/CaseListSketch.vue b/resources/assets/js/admin/settings/customCaseList/CaseListSketch.vue index ed5c77a17..105522531 100644 --- a/resources/assets/js/admin/settings/customCaseList/CaseListSketch.vue +++ b/resources/assets/js/admin/settings/customCaseList/CaseListSketch.vue @@ -75,7 +75,7 @@ > - + +
+ + + +
- +
@@ -187,7 +198,7 @@ > + + +
@@ -280,9 +303,10 @@ export default { isSelectedCaseList: false, pmTablesOptions: [], checkedRows: [], + enabledFilterRows: [], closedRows: [], checkedRowsCaseList: [], - columns: ["selected", "name", "field", "type", "source"], + columns: ["selected", "name", "field", "type", "source", "action"], //data: utils.getData(), data: [], options: { @@ -291,11 +315,14 @@ export default { field: this.$i18n.t("ID_FIELD"), type: this.$i18n.t("ID_TYPE"), source: this.$i18n.t("ID_SOURCE"), + action: "", }, sortable: [], filterable: true, - columnsDisplay: { - type: "desktop", + perPage: 1000, + perPageValues: [], + texts: { + count: "", }, }, dataCaseList: [], @@ -339,10 +366,35 @@ export default { mounted() { this.defaultCaseList = Api.getDefault(this.module.key); this.dataCaseList = this.defaultCaseList; + if(this.params.id) { + this.editMode(); + } + }, methods: { + /** + * Edit mode handler + * prepare the datato be rendered + */ + editMode(){ + let that = this; + this.pmTable = { + label: this.params.tableName, + value: this.params.tableUid + } + this.data =this.params.columns.filter(elem => elem.set === false); + this.dataCaseList =this.params.columns.filter(elem => elem.set === true); + this.dataCaseList.forEach(function (value) { + if (value.enableFilter) { + that.enabledFilterRows.push(value.field); + } + + }); + }, + /** + * Select all checkbox handler into available pm tables column list + */ selectAllAtOnce() { - console.log("isSelected: ", this.isSelected); let length = this.data.length; this.isSelected = !this.isSelected; this.checkedRows = []; @@ -353,6 +405,9 @@ export default { } } }, + /** + * Select all checkbox handler into case list table + */ selectAllAtOnceCaseList() { let length = this.dataCaseList.length; this.isSelectedCaseList = !this.isSelectedCaseList; @@ -364,6 +419,9 @@ export default { } } }, + /** + * Unassign the selected columns from custm list + */ unassignSelected() { let temp; let length = this.checkedRowsCaseList.length; @@ -379,10 +437,19 @@ export default { } this.checkedRowsCaseList = []; }, + /** + * Unassign all columns from custom list + */ unassignAll() { this.data = [...this.data, ...this.dataCaseList]; + this.data.forEach(function (element) { + element.set = false; + }); this.dataCaseList = []; }, + /** + * Assign the selected row to custom list + */ assignSelected() { let temp; let length = this.checkedRows.length; @@ -396,24 +463,40 @@ export default { } this.checkedRows = []; }, + /** + * Assign all columns to custom list + */ assignAll() { this.dataCaseList = [...this.dataCaseList, ...this.data]; + this.dataCaseList.forEach(function (element) { + element.set = true; + }); this.data = []; }, + /** + * On select icon handler + */ onSelectIcon(data) { - console.log(data); - // this.params.iconList = data; + this.params.iconList = data; }, + /** + * On change color handler + */ onChangeColor(color) { - console.log(color); - this.menuColor = color; + this.params.iconColor = color; }, + /** + * On change color screen handler + */ + onChangeColorScreen(color) { + this.params.iconColorScreen = color; + }, + /** + * On Cancel event handler + */ onCancel() { this.$emit("closeSketch"); }, - onChange(e) { - console.log(e); - }, /** * Find asynchronously in the server * @param {string} query - string from the text field @@ -438,15 +521,23 @@ export default { this.isLoading = false; }) - .catch((e) => { + .catch((err) => { console.error(err); }); }, + /** + * On select event handler in multiselect component + * @param {object} option + */ onSelect(option) { this.checkedRows = []; this.data = option.fields; this.dataCaseList = this.defaultCaseList; }, + /** + * On remove row event handler + * @param {object} row + */ onRemoveRow(row) { var temp = this.dataCaseList.find((x) => x.field === row.field); if (temp) { @@ -457,6 +548,23 @@ export default { }); } }, + /** + * On remove row event handler + * @param {object} row + */ + onAddRow(row) { + var temp = this.data.find((x) => x.field === row.field); + if (temp) { + temp["set"] = true; + this.dataCaseList.push(temp); + this.data = this.data.filter((item) => { + return item.field != row.field; + }); + } + }, + /** + * On submit event handler + */ onSubmit() { this.isValidName = true; this.isValidTable = true; @@ -469,20 +577,53 @@ export default { return; } this.params.tableUid = this.pmTable.value; - this.params.columns = this.dataCaseList; + this.params.columns = [...this.preparePostColumns(this.dataCaseList), ...this.preparePostColumns(this.data)]; this.params.type = this.module.key; this.params.userId = window.config.userId; - Api.createCaseList(this.params) - .then((response) => { - this.$emit("closeSketch"); - - }) - .catch((e) => { - console.error(err); - }); - + if (this.params.id) { + delete this.params["tableName"]; + Api.updateCaseList(this.params) + .then((response) => { + this.$emit("closeSketch"); + + }) + .catch((err) => { + console.error(err); + }); + } else { + Api.createCaseList(this.params) + .then((response) => { + this.$emit("closeSketch"); + + }) + .catch((err) => { + console.error(err); + }); + } }, - onReset() {}, + /** + * Prepares columns data to be sended to the server + * @param {array} collection + */ + preparePostColumns(collection){ + let temp = []; + collection.forEach(function (value) { + temp.push({ + field: value.field, + enableFilter: value.enableFilter || false, + set: value.set || false + }) + }); + return temp; + }, + /** + * Tongle filter switcher + * @param {string} field + */ + onTongleFilter(field){ + let objIndex = this.dataCaseList.findIndex((obj => obj.field === field)); + this.dataCaseList[objIndex].enableFilter = !this.dataCaseList[objIndex].enableFilter + } }, }; diff --git a/resources/assets/js/admin/settings/customCaseList/Tables.vue b/resources/assets/js/admin/settings/customCaseList/Tables.vue index 10558a51d..d02c764e0 100644 --- a/resources/assets/js/admin/settings/customCaseList/Tables.vue +++ b/resources/assets/js/admin/settings/customCaseList/Tables.vue @@ -188,7 +188,19 @@ export default { }, editCustomCaseList(data) { - + this.$emit("showSketch", { + id: data.id, + name: data.name, + description: data.description, + tableUid: data.tableUid, + tableName: data.tableName, + iconList: data.iconList, + iconColor: data.iconColor, + iconColorScreen: data.iconColorScreen, + columns: data.columns, + enableFilter: data.enableFilter, + type: this.module + }); }, /** * Export the Custom Case List in a json