Files
luos/resources/assets/js/home/Inbox/defaultMixins.js

174 lines
4.4 KiB
JavaScript
Raw Normal View History

2021-07-22 19:33:43 +00:00
import _ from "lodash";
2021-07-08 20:20:05 +00:00
import api from "../../api/index";
2021-07-08 15:00:07 +00:00
export default {
data() {
let that = this;
return {
typeView: this.settings && this.settings.view && this.settings.view.typeView
2021-09-23 18:09:33 +00:00
? this.settings.view.typeView
: "GRID",
2021-07-22 19:33:43 +00:00
random: 1,
2021-07-08 15:00:07 +00:00
dataMultiviewHeader: {
actions: [
{
id: "view-grid",
title: "Grid",
onClick(action) {
that.typeView = "GRID";
2021-09-23 18:09:33 +00:00
that.updateRootSettings("view", {
typeView: that.typeView
});
2021-07-08 15:00:07 +00:00
},
icon: "fas fa-table",
},
{
id: "view-list",
title: "List",
onClick(action) {
that.typeView = "LIST";
2021-09-23 18:09:33 +00:00
that.updateRootSettings("view", {
typeView: that.typeView
});
2021-07-08 15:00:07 +00:00
},
icon: "fas fa-list",
},
{
id: "view-card",
title: "Card",
onClick(action) {
that.typeView = "CARD";
2021-09-23 18:09:33 +00:00
that.updateRootSettings("view", {
typeView: that.typeView
});
2021-07-08 15:00:07 +00:00
},
icon: "fas fa-th",
},
],
2021-07-08 20:20:05 +00:00
},
2021-07-21 15:09:39 +00:00
optionsVueView: {
2021-07-08 20:20:05 +00:00
limit: 10,
2021-08-30 20:12:26 +00:00
dblClick: (event, item, options) => {
2021-07-21 15:09:39 +00:00
this.openCase(item);
2021-07-13 15:10:59 +00:00
},
headings: {
case_number: this.$i18n.t("ID_MYCASE_NUMBER"),
thread_title: this.$i18n.t('ID_CASE_THREAD_TITLE'),
2021-11-30 17:10:36 +00:00
process_category: this.$i18n.t("ID_CATEGORY_PROCESS"),
2021-12-13 20:52:21 +00:00
process_name: this.$i18n.t("ID_PROCESS_NAME"),
2021-07-13 15:10:59 +00:00
task: this.$i18n.t("ID_TASK"),
send_by: this.$i18n.t("ID_SEND_BY"),
2021-07-13 15:10:59 +00:00
current_user: this.$i18n.t("ID_CURRENT_USER"),
due_date: this.$i18n.t("ID_DUE_DATE"),
delegation_date: this.$i18n.t("ID_DELEGATION_DATE"),
priority: this.$i18n.t("ID_PRIORITY")
},
columns: [
"case_number",
"thread_title",
"process_category",
2021-12-13 20:52:21 +00:00
"process_name",
2021-07-13 15:10:59 +00:00
"due_date",
"delegation_date",
"priority",
"task",
"send_by",
2021-07-13 15:10:59 +00:00
],
requestFunction(data) {
2022-04-18 14:49:20 +00:00
return that.getCasesViewMore(data);
2021-07-13 15:10:59 +00:00
},
requestFunctionViewMore(data) {
2021-07-21 15:09:39 +00:00
return that.getCasesViewMore(data);
2021-07-08 20:20:05 +00:00
}
2021-07-08 15:00:07 +00:00
}
}
},
created: function () {
},
methods: {
2021-07-13 15:10:59 +00:00
/**
* Get cases for Vue Card View
*/
2021-07-21 15:09:39 +00:00
getCasesViewMore(data) {
2021-07-13 15:10:59 +00:00
let that = this,
dt,
paged,
limit = data.limit,
start = data.page === 1 ? 0 : limit * (data.page - 1),
filters = {};
filters = {
2021-08-30 20:12:26 +00:00
limit: limit,
offset: start
2021-07-13 15:10:59 +00:00
};
_.forIn(this.filters, function (item, key) {
2021-08-30 20:12:26 +00:00
if (filters && item.value) {
filters[item.filterVar] = item.value;
}
2021-07-13 15:10:59 +00:00
});
return new Promise((resolutionFunc, rejectionFunc) => {
api.cases
.todo(filters)
.then((response) => {
dt = that.formatDataResponse(response.data.data);
resolutionFunc({
data: dt,
count: response.data.total,
});
})
.catch((e) => {
rejectionFunc(e);
});
});
},
2021-07-22 19:33:43 +00:00
/**
* Format columns for custom columns
* @param {*} headings
* @returns
*/
formatColumnSettings(headings) {
2021-08-30 20:12:26 +00:00
let res = [];
_.forEach(headings, function (value, key) {
if (key != "actions") {
res.push({ value, key });
2021-07-22 19:33:43 +00:00
}
});
2021-07-22 19:39:12 +00:00
return res;
},
2021-07-22 19:33:43 +00:00
/**
* Formating the columns selected
* @param {*} columns
* @returns
*/
formatColumnSelected(columns) {
let cols = _.clone(columns);
cols.pop();
return cols;
},
/**
* Event handler when update the settings columns
* @param {*} columns
*/
onUpdateColumnSettings(columns) {
let cols = columns;
2021-08-30 20:12:26 +00:00
if (_.findIndex(cols, 'actions') == -1) {
2021-07-22 19:33:43 +00:00
cols.push("actions");
}
this.columns = cols;
this.random = _.random(0, 10000000000);
2021-09-23 18:09:33 +00:00
},
/**
* Update settings for user
* @param {string} key
* @param {*} data
*/
updateRootSettings(key, data) {
this.$emit("updateSettings", {
data: data,
key: key,
page: "inbox",
type: "normal",
id: this.id
});
2021-07-22 19:33:43 +00:00
}
2021-07-08 15:00:07 +00:00
}
2021-07-13 15:17:06 +00:00
}