Merge branch 'feature/PMCORE-3049' of https://bitbucket.org/colosa/processmaker into taskmetrics

This commit is contained in:
Henry Jordan
2021-08-24 18:58:37 +00:00
57 changed files with 1700 additions and 209 deletions

View File

@@ -10,7 +10,7 @@
</template>
<b-container fluid>
<p>
{{ $t("ID_ARE_YOU_SURE_DELETE_CUSTOM_CASE_LIST") }}
{{ $t("ID_ARE_YOU_SURE_DELETE_CUSTOM_CASE_LIST", {'CUSTOM_NAME': data.name}) }}
</p>
</b-container>
<div class="modal-footer">
@@ -40,7 +40,9 @@ export default {
name: "ModalDeleteCaseList",
data() {
return {
data: null
data: {
name: null
}
}
},
methods: {

View File

@@ -0,0 +1,187 @@
<template>
<div>
<b-modal
ref="modal-import"
hide-footer
size="md"
>
<template v-slot:modal-title>
{{ $t('ID_IMPORT_CUSTOM_CASE_LIST') }}
</template>
<b-container fluid>
<div v-if="!caseListDuplicate">
{{ $t('ID_PLEASE_ADD_THE_CUSTOM_LIST_FILE_TO_BE_UPLOADED') }}
</div>
<div v-if="caseListDuplicate">
{{ message }}
</div>
<div>
<b-form-file
v-model="fileCaseList"
:state="validFile"
ref="file-input"
:disabled="caseListDuplicate"
></b-form-file>
</div>
<p>
</p>
</b-container>
<div class="modal-footer">
<div class="float-right">
<b-button
variant="danger"
data-dismiss="modal"
@click="hide"
>
{{ $t("ID_CANCEL") }}
</b-button>
<b-button
variant="success"
v-if="!caseListDuplicate"
@click="importCustomCaseList"
>
{{ $t("ID_SAVE") }}
</b-button>
<b-button
variant="info"
v-if="caseListDuplicate"
@click="continueImport()"
>
{{ $t("ID_CONTINUE") }}
</b-button>
</div>
</div>
</b-modal>
<!-- pmTable does not exist in the workspace -->
<b-modal
size="md"
ok-only
:ok-title="$t('ID_CLOSE')"
ok-variant="danger"
v-model="pmTableNoExist"
>
<template v-slot:modal-title>
{{ $t('ID_IMPORT_CUSTOM_CASE_LIST') }}
</template>
<b-container fluid>
<div>
{{ message }}
</div>
</b-container>
</b-modal>
<!-- pmTable incomplete columns for custom case list -->
<b-modal
hide-footer
size="md"
v-model="pmTableNoFields"
>
<template v-slot:modal-title>
{{ $t('ID_IMPORT_CUSTOM_CASE_LIST') }}
</template>
<b-container fluid>
<div>
{{ message }}
</div>
</b-container>
<div class="modal-footer">
<div class="float-right">
<b-button
variant="danger"
data-dismiss="modal"
@click="close"
>
{{ $t("ID_CLOSE") }}
</b-button>
<b-button
variant="info"
@click="continueImport"
>
{{ $t("ID_CONTINUE") }}
</b-button>
</div>
</div>
</b-modal>
</div>
</template>
<script>
import api from "./../settings/customCaseList/Api/CaseList";
export default {
name: "ModalImport",
data() {
return {
data: [],
validFile: null,
fileCaseList: null,
caseListDuplicate: false,
pmTableNoFields: false,
pmTableNoExist: false,
message: ''
}
},
methods: {
show() {
this.caseListDuplicate = false;
this.$refs["modal-import"].show();
},
close() {
this.pmTableNoFields = false;
},
hide() {
this.caseListDuplicate = false;
this.$refs["modal-import"].hide();
},
importCustomCaseList() {
let that = this;
this.data.file = this.fileCaseList;
api.importCaseList(this.data)
.then((response) => {
switch (response.data.status) {
case 'tableNotExist': // pmTable does not exist
that.pmTableNoExist = true;
that.message = response.data.message
that.$refs["modal-import"].hide();
break;
case 'duplicateName': // Custom Case List duplicate
that.caseListDuplicate = true;
that.message = response.data.message
that.validFile = null;
break;
case 'invalidFields': // pmTable differentes columns
that.pmTableNoFields = true;
that.message = response.data.message
that.$refs["modal-import"].hide();
break;
default: // import without error
that.$refs["modal-import"].hide();
that.$parent.$refs["table"].getData();
break;
}
})
.catch((e) => {
console.error(e);
});
},
continueImport() {
let that = this;
this.data.file = this.fileCaseList;
if (this.pmTableNoFields) {
this.data.continue = 'invalidFields';
}
if (this.caseListDuplicate) {
this.data.continue = 'duplicateName';
}
api.importCaseList(this.data)
.then((response) => {
if (response.status === 200) {
that.$refs["modal-import"].hide();
that.$parent.$refs["table"].getData();
}
})
.catch((e) => {
console.error(e);
});
}
}
}
</script>

View File

@@ -56,8 +56,13 @@ class caseListApi extends Api {
keys: {}
});
}
getDefault(module){
return Defaults[module]
getDefault(type){
return this.get({
service: 'DEFAULT_COLUMNS',
keys: {
type: type
}
});
}
createCaseList(data) {
return this.post({
@@ -74,6 +79,20 @@ class caseListApi extends Api {
data: data
});
}
importCaseList(data) {
let formData = new FormData();
formData.append('file_content', data.file);
if (data.continue) {
formData.append(data.continue, 'continue');
}
return this.post({
service: "IMPOR_CASE_LIST",
data: formData,
headers:{
'Content-Type': 'multipart/form-data'
},
})
}
}
let api = new caseListApi(Services);

View File

@@ -5,5 +5,7 @@ export default {
CASE_LIST_PAUSED: "/caseList/paused",
REPORT_TABLES: "/caseList/report-tables",
CASE_LIST: "/caseList",
PUT_CASE_LIST: "/caseList/{id}"
DEFAULT_COLUMNS: "/caseList/{type}/default-columns",
PUT_CASE_LIST: "/caseList/{id}",
IMPOR_CASE_LIST: "/caseList/import"
};

View File

@@ -7,7 +7,7 @@
<b-row>
<b-col cols="6">
<b-row>
<b-col>
<b-col cols="6">
<b-form-group
id="nameLabel"
:label="$t('ID_NAME')"
@@ -28,7 +28,7 @@
</b-form-invalid-feedback>
</b-form-group>
</b-col>
<b-col>
<b-col cols="6">
<div :class="{ invalid: isValidTable === false }">
<label>{{ $t("ID_PM_TABLE") }}</label>
<multiselect
@@ -237,18 +237,34 @@
:checked="props.row.selected"
:value="props.row.field"
/>
<b-form-checkbox
slot="enableFilter"
slot-scope="props"
v-model="enabledFilterRows"
@change="onTongleFilter(props.row.field)"
name="check-button"
:checked="props.row.enableFilter"
:value="props.row.field"
switch
>
</b-form-checkbox>
<div slot="enableFilter" slot-scope="props">
<b-row>
<b-col cols="6">
<i
ref="iconClose"
class="fas fa-info-circle"
:id="`popover-1-${props.row.field}`"
></i>
<b-popover
:target="`popover-1-${props.row.field}`"
placement="top"
triggers="hover focus"
:content="searchInfoContent(props.row)"
></b-popover>
</b-col>
<b-col cols="6">
<b-form-checkbox
v-model="enabledFilterRows"
@change="onTongleFilter(props.row.field)"
name="check-button"
:checked="props.row.enableFilter"
:value="props.row.field"
switch
>
</b-form-checkbox>
</b-col>
</b-row>
</div>
<div slot="action" slot-scope="props">
<b-button
variant="light"
@@ -339,8 +355,8 @@ export default {
name: this.$i18n.t("ID_NAME"),
field: this.$i18n.t("ID_FIELD"),
type: this.$i18n.t("ID_TYPE"),
typeOfSearching: this.$i18n.t("ID_TYPE_OF_SEARCHING"),
enableSearchFilter: this.$i18n.t("ID_ENABLE_SEARCH_FILTER"),
typeSearch: this.$i18n.t("ID_TYPE_OF_SEARCHING"),
enableFilter: this.$i18n.t("ID_ENABLE_SEARCH_FILTER"),
action: "",
},
filterable: false,
@@ -351,7 +367,7 @@ export default {
count: "",
},
},
defaultCaseList: null,
defaultCaseList: [],
isValidName: null,
isValidTable: null,
pmTable: null
@@ -363,14 +379,36 @@ export default {
},
},
mounted() {
this.defaultCaseList = Api.getDefault(this.module.key);
this.dataCaseList = this.defaultCaseList;
this.getDefaultColumns(this.module.key);
if(this.params.id) {
this.editMode();
}
},
methods: {
/**
* Prepare search popover info
* @param {object} row
* @returns {string}
*/
searchInfoContent(row) {
let info = this.$i18n.t("ID_THE_SEARCH_WILL_BE_FROM");
switch (row.type) {
case 'integer':
info += " " + this.$i18n.t("ID_A_RANGE_OF_VALUES");
break;
case 'string':
info += " " + this.$i18n.t("ID_A_TEXT_SEARCH");
break;
case 'date':
info += " " + this.$i18n.t("ID_DATE_TO_DATE");
break;
default:
info = this.$i18n.t("ID_NO_SEARCHING_METHOD");
}
return info;
},
/**
* Edit mode handler
* prepare the datato be rendered
@@ -584,9 +622,9 @@ export default {
Api.updateCaseList(this.params)
.then((response) => {
this.$emit("closeSketch");
})
.catch((err) => {
this.makeToast('danger', this.$i18n.t('ID_ERROR'), err.response.statusText);
console.error(err);
});
} else {
@@ -596,6 +634,7 @@ export default {
})
.catch((err) => {
this.makeToast('danger',this.$i18n.t('ID_ERROR') ,err.response.statusText);
console.error(err);
});
}
@@ -622,7 +661,37 @@ export default {
onTongleFilter(field){
let objIndex = this.dataCaseList.findIndex((obj => obj.field === field));
this.dataCaseList[objIndex].enableFilter = !this.dataCaseList[objIndex].enableFilter
}
},
/**
* Make the toast component
* @param {string} variant
* @param {string} title
* @param {string} message
*/
makeToast(variant = null, title, message) {
this.$bvToast.toast(message, {
title: `${title || variant}`,
variant: variant,
solid: true
})
},
/**
* Get default Columns
* @param {string} type
*/
getDefaultColumns(type) {
let that = this;
Api.getDefault(type)
.then((response) => {
if (!that.params.columns) {
that.dataCaseList = response.data;
}
that.defaultCaseList = response.data;
})
.catch((e) => {
console.error(e);
})
}
},
};
</script>

View File

@@ -2,6 +2,7 @@
<div id="people">
<ModalDeleteCaseList ref="modal-delete-list"></ModalDeleteCaseList>
<ModalPreview ref="modal-preview"></ModalPreview>
<ModalImport ref="modal-import"></ModalImport>
<button-fleft :data="newList"></button-fleft>
<button-fleft :data="importList"></button-fleft>
<v-server-table
@@ -29,6 +30,7 @@ import utils from "../../../utils/utils";
import OwnerCell from "../../../components/vuetable/OwnerCell";
import ModalDeleteCaseList from "./../../Modals/ModalDeleteCaseList.vue";
import ModalPreview from "./../../Modals/ModalPreview.vue";
import ModalImport from "./../../Modals/ModalImport.vue";
import download from "downloadjs";
export default {
@@ -40,6 +42,7 @@ export default {
OwnerCell,
ModalDeleteCaseList,
ModalPreview,
ModalImport,
},
data() {
return {
@@ -69,7 +72,7 @@ export default {
title: this.$i18n.t("Import List"),
class: "btn-success",
onClick: () => {
//TODO button
this.importCustomCaseList();
}
},
columns: [
@@ -235,8 +238,32 @@ export default {
*/
downloadCaseList(data) {
var fileName = data.name,
typeMime = "text/plain";
download(JSON.stringify(data), fileName + ".json", typeMime);
typeMime = "text/plain",
dataExport = [];
dataExport = this.filterDataToExport(data);
download(JSON.stringify(dataExport), fileName + ".json", typeMime);
},
/**
* Filter the sensible information to export
* @param {Array} data
*/
filterDataToExport(data) {
var dataExport = [];
dataExport.push({
type: data['type'],
name: data['name'],
description: data['description'],
tableUid: data['tableUid'],
tableName: data['tableName'],
columns: data['columns'],
userId: data['userId'],
iconList: data['iconList'],
iconColor: data['iconColor'],
iconColorScreen: data['iconColorScreen'],
createDate: data['createDate'],
updateDate: data['updateDate']
});
return dataExport;
},
/**
* Show options in the ellipsis
@@ -282,6 +309,14 @@ export default {
}
}
},
importCustomCaseList() {
this.$refs["modal-import"].show();
}
}
};
</script>
</script>
<style>
.float-right {
padding-left: 1.5%;
}
</style>

View File

@@ -6,7 +6,11 @@
:class="item.class"
v-bind="item.attributes"
>
{{ item.title }} <b-icon icon="pie-chart-fill"></b-icon>
{{ item.title }}
<b-icon
:icon="item.icon || ''"
@click="item.onClick(item) || function() {}"
></b-icon>
</div>
<div
v-else-if="!isItemHidden"
@@ -50,7 +54,6 @@
isMobileItem
"
>
<sidebar-menu-badge v-if="item.badge" :badge="item.badge" />
<div
v-if="itemHasChild"
class="vsm--arrow"
@@ -141,7 +144,7 @@
<template #modal-footer="{ cancel }">
<b-button size="sm" variant="danger" @click="cancel()">
Cancel
{{ $t("ID_CLOSE") }}
</b-button>
</template>
</b-modal>
@@ -154,6 +157,7 @@ import draggable from "vuedraggable";
import CustomSidebarMenuLink from "./CustomSidebarMenuLink";
import CustomSidebarMenuIcon from "./CustomSidebarMenuIcon";
import CustomTooltip from "./../utils/CustomTooltip.vue";
import eventBus from "./../../home/EventBus/eventBus";
export default {
name: "CustomSidebarMenuItem",
@@ -203,7 +207,7 @@ export default {
draggable,
CustomSidebarMenuLink,
CustomSidebarMenuIcon,
CustomTooltip
CustomTooltip,
},
data() {
return {
@@ -213,7 +217,7 @@ export default {
itemHover: false,
exactActive: false,
active: false,
titleHover: '',
titleHover: "",
};
},
computed: {
@@ -257,7 +261,18 @@ export default {
return !!(this.item.child && this.item.child.length > 0);
},
isItemHidden() {
return false;
if (this.isCollapsed) {
if (
this.item.hidden &&
this.item.hiddenOnCollapse === undefined
) {
return true;
} else {
return this.item.hiddenOnCollapse === true;
}
} else {
return this.item.hidden === true;
}
},
},
watch: {
@@ -362,7 +377,7 @@ export default {
);
},
/**
* Ensurre if the link exact is active
* Ensurre if the link exact is active
* @param {object} item
* @return {boolean}
*/
@@ -374,7 +389,6 @@ export default {
*/
initState() {
this.initActiveState();
this.initShowState();
},
/**
* Initalize the active state of the menu item
@@ -384,7 +398,7 @@ export default {
this.exactActive = this.isLinkExactActive(this.item);
},
/**
* Initialize and show active state menu item
* Initialize and show active state menu item
*/
initShowState() {
if (!this.itemHasChild || this.showChild) return;
@@ -404,9 +418,11 @@ export default {
checkMove: function(e) {
let aux = this.item.child.splice(e.newIndex, 1);
this.item.child.splice(e.newIndex, 0, aux[0]);
this.emitItemUpdate(this.item, this.item);
eventBus.$emit("sort-menu", this.item.child);
},
/**
* Click event Handler
* Click event Handler
* @param {object} event
*/
clickEvent(event) {
@@ -476,13 +492,16 @@ export default {
if (this.hover) return;
if (!this.isCollapsed || !this.isFirstLevel || this.isMobileItem)
return;
this.$emit("unset-mobile-item", true);
this.$parent.$emit("unset-mobile-item", true);
setTimeout(() => {
if (this.mobileItem !== this.item) {
this.$emit("set-mobile-item", { item: this.item, itemEl });
if (this.$parent.mobileItem !== this.item) {
this.$parent.$emit("set-mobile-item", {
item: this.item,
itemEl,
});
}
if (event.type === "click" && !this.itemHasChild) {
this.$emit("unset-mobile-item", false);
this.$parent.$emit("unset-mobile-item", false);
}
}, 0);
},

View File

@@ -214,7 +214,10 @@ export default {
handler(newVal, oldVal) {
this.searchTags = [];
this.selected = [];
this.setFilters(newVal);
if (newVal.length) {
this.setFilters(newVal, oldVal);
this.searchClickHandler();
}
}
}
},
@@ -272,17 +275,20 @@ export default {
* Set Filters and make the tag labels
* @param {object} filters json to manage the query
*/
setFilters(filters) {
setFilters(filters, oldVal) {
let self = this;
_.forEach(filters, function (item, key) {
let component = _.find(self.filterItems, function (o) {
return o.id === item.fieldId;
});
if (component) {
self.searchTags.push(component.id);
self.selected = component.id;
self.itemModel[component.id] = component;
self.itemModel[component.id].autoShow = typeof item.autoShow !== "undefined" ? item.autoShow : true
self.searchTags.push(component.id);
self.selected.push(component.id);
self.itemModel[component.id] = component;
self.itemModel[component.id].autoShow = typeof item.autoShow !== "undefined" ? item.autoShow : true;
if (oldVal && !oldVal.length) {
self.updateSearchTag(item);
}
}
if(item.fieldId === "processName") {
self.searchTags.push(self.processName.id);

View File

@@ -1,21 +1,14 @@
<template>
<span
:id="data.id"
:id="`label-${data.id}`"
@mouseover="hoverHandler"
v-b-tooltip.hover
:title="labelTooltip"
@mouseleave="unhoverHandler"
>
{{ data.title }}
<b-tooltip
:target="data.id"
triggers="hoverHandler"
:show.sync="show"
>
{{ labelTooltip }}
</b-tooltip>
<b-tooltip :target="`label-${data.id}`" :ref="`tooltip-${data.id}`">
{{ labelTooltip }}
</b-tooltip>
</span>
</template>
<script>
@@ -29,43 +22,44 @@ export default {
data() {
return {
labelTooltip: "",
hovering: "",
show: false,
menuMap: {
CASES_INBOX: "inbox",
CASES_DRAFT: "draft",
CASES_PAUSED: "paused",
CASES_SELFSERVICE: "unassigned"
}
}
CASES_SELFSERVICE: "unassigned",
todo: "inbox",
draft: "draft",
paused: "paused",
unassigned: "unassigned",
},
};
},
methods: {
/**
* Delay the hover event
*/
hoverHandler() {
this.hovering = setTimeout(() => { this.setTooltip() }, 3000);
this.setTooltip();
},
/**
* Reset the delay and hide the tooltip
*/
unhoverHandler() {
let key = `tooltip-${this.data.id}`;
this.labelTooltip = "";
this.show = false;
clearTimeout(this.hovering);
this.$refs[key].$emit("close");
},
/**
* Set the label to show in the tooltip
*/
setTooltip() {
let that = this;
api.menu
.getTooltip(that.menuMap[that.data.id])
.then((response) => {
that.labelTooltip = response.data.label;
that.show = true;
});
api.menu.getTooltip(that.data.id).then((response) => {
let key = `tooltip-${that.data.id}`;
that.labelTooltip = response.data.label;
that.$refs[key].$emit("open");
});
},
}
}
},
};
</script>

View File

@@ -1,17 +1,19 @@
<template>
<font-awesome-icon v-if="props.sortable" :icon="icon" class="fa-pull-right"/>
<i v-if="props.sortable" :class="icon"></i>
</template>
<script>
export default {
name: "VtSortControl",
props: ['props'],
computed: {
icon() {
// if not sorted return base icon
if (!this.props.sortStatus.sorted) return 'sort';
// return sort direction icon
return this.props.sortStatus.asc ? 'sort-amount-up' : 'sort-amount-down';
}
}
}
</script>
export default {
name: "VtSortControl",
props: ["props"],
computed: {
icon() {
// if not sorted return base icon
if (!this.props.sortStatus.sorted) return "fas fa-sort";
// return sort direction icon
return this.props.sortStatus.asc
? "fas fa-sort-amount-up"
: "fas fa-sort-amount-down";
},
},
};
</script>

View File

@@ -221,8 +221,11 @@ export default {
limit = data.limit,
filters = {},
start = data.page === 1 ? 0 : limit * (data.page - 1);
paged = start + "," + limit;
filters["paged"] = paged;
paged = start + "," + limit ;
filters = {
limit: limit,
offset: start
};
_.forIn(this.filters, function (item, key) {
if(filters && item.value) {
filters[item.filterVar] = item.value;

View File

@@ -48,9 +48,15 @@
<b-button
v-if="props.row.STATUS === 'OPEN'"
@click="onClick(props)"
variant="outline-primary"
variant="outline-success"
>{{ $t("ID_CONTINUE") }}</b-button
>
<b-button
v-if="props.row.STATUS === 'PAUSED'"
@click="onClickUnpause(props)"
variant="outline-primary"
>{{ $t("ID_UNPAUSE") }}</b-button
>
</div>
</v-server-table>
</div>
@@ -428,6 +434,9 @@ export default {
that.dataComments.noPerms = response.data.noPerms || 0;
})
.catch((err) => {
if (err.response.data) {
that.showAlert(err.response.data.error.message, "danger");
}
throw new Error(err);
});
},
@@ -576,6 +585,18 @@ export default {
this.$emit("onUpdatePage", "XCase");
}
},
/**
* Unpause click handler
*
* @param {object} data
*/
onClickUnpause(data) {
Api.cases.unpause(data.row).then((response) => {
if (response.statusText === "OK") {
this.$refs["vueTable"].getData();
}
});
},
/**
* Claim case
*

View File

@@ -418,12 +418,10 @@ export default {
start = data.page === 1 ? 0 : limit * (data.page - 1),
filters = {},
sort = "";
paged = start + "," + limit;
filters = {
paged: paged,
limit: limit,
offset: start
};
_.forIn(this.filters, function (item, key) {
if(filters && item.value) {
filters[item.filterVar] = item.value;

View File

@@ -0,0 +1,4 @@
import Vue from 'vue'
const eventBus = new Vue()
export default eventBus

View File

@@ -26,7 +26,7 @@
:defaultOption="defaultOption"
:settings="config.setting[page]"
:filters="filters"
@onSubmitFilter="onSubmitFilter"
@onSubmitFilter="onSubmitFilter"
@onRemoveFilter="onRemoveFilter"
@onUpdatePage="onUpdatePage"
@onUpdateDataCase="onUpdateDataCase"
@@ -34,15 +34,16 @@
@onUpdateFilters="onUpdateFilters"
@cleanDefaultOption="cleanDefaultOption"
@updateUserSettings="updateUserSettings"
></component>
></component>
</div>
</div>
</template>
<script>
import CustomSidebar from "./../components/menu/CustomSidebar";
import CustomSidebarMenuItem from "./../components/menu/CustomSidebarMenuItem";
import MyCases from "./MyCases/MyCases.vue";
import MyDocuments from "./MyDocuments";
import Todo from "./Inbox/Todo.vue";
import Inbox from "./Inbox/Inbox.vue";
import Paused from "./Paused/Paused.vue";
import Draft from "./Draft/Draft.vue";
import Unassigned from "./Unassigned/Unassigned.vue";
@@ -55,7 +56,7 @@ import AdvancedSearch from "./AdvancedSearch/AdvancedSearch.vue";
import LegacyFrame from "./LegacyFrame";
import api from "./../api/index";
import eventBus from './EventBus/eventBus'
export default {
name: "Home",
components: {
@@ -66,7 +67,7 @@ export default {
BatchRouting,
TaskReassignments,
XCase,
Todo,
Inbox,
Draft,
Paused,
Unassigned,
@@ -91,14 +92,14 @@ export default {
filters: null,
config: {
id: window.config.userId || "1",
name: "home",
name: "userConfig",
setting: {}
},
menuMap: {
CASES_MY_CASES: "MyCases",
CASES_SENT: "MyCases",
CASES_SEARCH: "advanced-search",
CASES_INBOX: "todo",
CASES_INBOX: "inbox",
CASES_DRAFT: "draft",
CASES_PAUSED: "paused",
CASES_SELFSERVICE: "unassigned",
@@ -110,14 +111,18 @@ export default {
};
},
mounted() {
let that = this;
this.onResize();
this.getMenu();
this.getUserSettings();
this.listenerIframe();
window.setInterval(
this.setCounter,
parseInt(window.config.FORMATS.casesListRefreshTime) * 1000
);
// adding eventBus listener
eventBus.$on('sort-menu', (data) => {
that.updateUserSettings('customCasesList', data);
});
},
methods: {
/**
@@ -134,7 +139,7 @@ export default {
eventer(messageEvent, function(e) {
if ( e.data === "redirect=todo" || e.message === "redirect=todo"){
that.page = "todo";
that.page = "inbox";
}
if ( e.data === "update=debugger" || e.message === "update=debugger"){
if(that.$refs["component"].updateView){
@@ -168,10 +173,11 @@ export default {
name: this.config.name
})
.then((response) => {
if (response.data) {
this.config = response.data;
} else {
if(response.data && response.data.status === 404) {
this.createUserSettings();
} else if (response.data) {
this.config = response.data;
this.getMenu();
}
})
.catch((e) => {
@@ -183,10 +189,7 @@ export default {
*/
createUserSettings() {
api.config
.post({
...this.configParams,
...{setting: '{}'}
})
.post(this.config)
.then((response) => {
if (response.data) {
this.config = response.data;
@@ -248,9 +251,82 @@ export default {
} else if (newData[i].href) {
newData[i].id = "LegacyFrame";
}
// Tasks group need pie chart icon
if (data[i].header && data[i].id === "FOLDERS") {
data[i] = {
component: CustomSidebarMenuItem,
props: {
isCollapsed: this.collapsed? true: false,
item: {
header: data[i].header,
title: data[i].title,
hiddenOnCollapse: data[i].hiddenOnCollapse,
icon: 'pie-chart-fill',
onClick: function (item) {
// TODO click evet handler
}
}
}
}
}
if (data[i].id === "inbox" || data[i].id === "draft"
|| data[i].id === "paused" || data[i].id === "unassigned") {
data[i]["child"] = this.sortCustomCasesList(
data[i].customCasesList,
this.config.setting[this.page] &&
this.config.setting[this.page].customCasesList
? this.config.setting[this.page].customCasesList
: []
);
data[i]["sortable"] = data[i].customCasesList.length > 1;
data[i]["sortIcon"] = "gear-fill";
data[i] = {
component: CustomSidebarMenuItem,
props: {
isCollapsed: this.collapsed? true: false,
item: data[i]
}
};
}
}
return newData;
},
/**
* Sort the custom case list menu items
* @param {array} list
* @param {array} ref
* @returns {array}
*/
sortCustomCasesList(list, ref) {
let item,
newList = [],
temp = [];
if (ref && ref.length) {
ref.forEach(function (menu) {
item = list.find(x => x.id === menu.id);
if (item) {
newList.push(item);
}
})
} else {
return list;
}
temp = list.filter(this.comparerById(newList));
return [...newList, ...temp];
},
/**
* Util to compare an array by id
* @param {array} otherArray
* @returns {object}
*/
comparerById(otherArray){
return function(current){
return otherArray.filter(function(other){
return other.id == current.id
}).length == 0;
}
},
/**
* Set a default icon if the item doesn't have one
*/
@@ -282,8 +358,8 @@ export default {
this.pageId = null;
this.pageUri = item.item.href;
this.page = item.item.id || "MyCases";
if (this.page === this.lastPage
&& this.$refs["component"]
if (this.page === this.lastPage
&& this.$refs["component"]
&& this.$refs["component"].updateView) {
this.$refs["component"].updateView();
}

View File

@@ -7,7 +7,7 @@
<ModalReassignCase ref="modal-reassign-case"></ModalReassignCase>
<CasesFilter
:filters="filters"
:title="$t('ID_CASES_STATUS_TO_DO')"
:title="$t('ID_INBOX')"
:icon="icon"
@onRemoveFilter="onRemoveFilter"
@onUpdateFilters="onUpdateFilters"
@@ -232,7 +232,7 @@ import { Event } from 'vue-tables-2';
import CurrentUserCell from "../../components/vuetable/CurrentUserCell.vue";
export default {
name: "Todo",
name: "Inbox",
mixins: [defaultMixins],
components: {
HeaderCounter,
@@ -463,11 +463,10 @@ export default {
start = data.page === 1 ? 0 : limit * (data.page - 1),
filters = {},
sort = "";
paged = start + "," + limit;
filters = {
paged: paged,
}
limit: limit,
offset: start
};
_.forIn(this.filters, function (item, key) {
if(filters && item.value) {
filters[item.filterVar] = item.value;

View File

@@ -368,10 +368,10 @@ export default {
start = data.page === 1 ? 0 : limit * (data.page - 1),
filters = {},
sort = "";
paged = start + "," + limit;
filters = {
filter: that.filterHeader,
paged: paged,
limit: limit,
offset: start
};
_.forIn(this.filters, function(item, key) {
if (filters && item.value) {

View File

@@ -461,12 +461,10 @@ export default {
start = data.page === 1 ? 0 : limit * (data.page - 1),
filters = {},
sort = "";
paged = start + "," + limit;
filters = {
paged: paged,
limit: limit,
offset: start
};
_.forIn(this.filters, function (item, key) {
if(filters && item.value) {
filters[item.filterVar] = item.value;

View File

@@ -427,12 +427,10 @@ export default {
start = data.page === 1 ? 0 : limit * (data.page - 1),
filters = {},
sort = "";
paged = start + "," + limit;
filters = {
paged: paged,
limit: limit,
offset: start
};
_.forIn(this.filters, function (item, key) {
if(filters && item.value) {
filters[item.filterVar] = item.value;

View File

@@ -9,15 +9,12 @@ import VtSortControl from './../components/vuetable/extends/VtSortControl';
import SettingsPopover from "../components/vuetable/SettingsPopover.vue";
import Sortable from 'sortablejs';
import "@fortawesome/fontawesome-free/css/all.css";
import "@fortawesome/fontawesome-free/js/all.js";
import 'bootstrap/dist/css/bootstrap-grid.css';
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap-vue/dist/bootstrap-vue.css';
import VueApexCharts from 'vue-apexcharts'
import 'bootstrap-vue/dist/bootstrap-vue.css'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import Home from "./Home";
Vue.use(VueApexCharts);
@@ -26,7 +23,6 @@ Vue.use(VueSidebarMenu);
Vue.use(BootstrapVue);
Vue.use(BootstrapVueIcons);
Vue.use(VueI18n);
Vue.component('font-awesome-icon', FontAwesomeIcon);
Vue.use(ServerTable, {}, false, 'bootstrap3', {
tableHeading: VtTableHeadingCustom,

View File

@@ -76,7 +76,6 @@
width: 30px;
text-align: center;
border-radius: 3px;
margin-top: 8px;
margin-right: 0px;
margin-left: 10px;
}

View File

@@ -96,9 +96,9 @@ class CasesMenuHighlightTest extends TestCase
// Check if the object is valid
$this->assertNotEmpty($result);
$this->assertArrayHasKey('item', $result[0]);
$this->assertArrayHasKey('highlight', $result[0]);
$this->assertEquals('CASES_SELFSERVICE', $result[0]['item']);
$this->assertEquals(true, $result[0]['highlight']);
$this->assertArrayHasKey('item', $result[7]);
$this->assertArrayHasKey('highlight', $result[7]);
$this->assertEquals('CASES_SELFSERVICE', $result[7]['item']);
$this->assertEquals(true, $result[7]['highlight']);
}
}

View File

@@ -42,6 +42,18 @@ class CasesListTest extends TestCase
return $delegation;
}
/**
* This test construct
*
* @covers \ProcessMaker\BusinessModel\Cases\CasesList::__construct()
* @test
*/
public function it_test_construct()
{
$casesList = new CasesList();
$this->assertInstanceOf(CasesList::class, $casesList);
}
/**
* This test getAllCounters
*
@@ -57,4 +69,29 @@ class CasesListTest extends TestCase
$this->assertArrayHasKey('CASES_INBOX', $result);
$this->assertArrayHasKey('CASES_DRAFT', $result);
}
/**
* This test getAllCounters
*
* @covers \ProcessMaker\BusinessModel\Cases\CasesList::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\BatchRouting::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\Canceled::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\Completed::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::atLeastOne()
* @test
*/
public function it_return_at_least_one()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$count = new CasesList();
$result = $count->atLeastOne($delegation->USR_UID);
$this->assertNotEmpty($result);
$firstItem = head($result);
$this->assertArrayHasKey('item', $firstItem);
$this->assertArrayHasKey('highlight', $firstItem);
}
}

View File

@@ -2,6 +2,8 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use DateInterval;
use Datetime;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Draft;
@@ -766,4 +768,116 @@ class DraftTest extends TestCase
$this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
$this->assertEquals(3, $res['total']);
}
/**
* This tests the getCasesRisk() method with on time filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCasesRisk()
* @test
*/
public function it_tests_get_cases_risk_on_time()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff1Day = new DateInterval('P1D');
$diff2Days = new DateInterval('P2D');
$process = factory(Process::class)->create();
$user = factory(User::class)->create();
$application = factory(Application::class, 14)->states('draft')->create([
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[0]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[0]->APP_UID,
'APP_NUMBER' => $application[0]->APP_NUMBER,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $date->add($diff1Day),
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setUserUid($user->USR_ID);
$res = $draft->getCasesRisk($process->PRO_ID);
$this->assertCount(1, $res);
}
/**
* This tests the getCasesRisk() method with at risk filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCasesRisk()
* @test
*/
public function it_tests_get_cases_risk_at_risk()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$process = factory(Process::class)->create();
$user = factory(User::class)->create();
$application = factory(Application::class, 14)->states('draft')->create([
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[0]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[0]->APP_UID,
'APP_NUMBER' => $application[0]->APP_NUMBER,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setUserUid($user->USR_ID);
$res = $draft->getCasesRisk($process->PRO_ID, null, null, 'AT_RISK');
$this->assertCount(1, $res);
}
/**
* This tests the getCasesRisk() method with overdue filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCasesRisk()
* @test
*/
public function it_tests_get_cases_risk_overdue()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$process = factory(Process::class)->create();
$user = factory(User::class)->create();
$application = factory(Application::class, 14)->states('draft')->create([
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[0]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[0]->APP_UID,
'APP_NUMBER' => $application[0]->APP_NUMBER,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->sub($diff2Days)
]);
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setUserUid($user->USR_ID);
$res = $draft->getCasesRisk($process->PRO_ID, null, null, 'OVERDUE');
$this->assertCount(1, $res);
}
}

View File

@@ -2,6 +2,8 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use DateInterval;
use Datetime;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Inbox;
@@ -659,4 +661,98 @@ class InboxTest extends TestCase
$this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
$this->assertEquals(3, $res['total']);
}
/**
* This tests the getCasesRisk() method with on time filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCasesRisk()
* @test
*/
public function it_tests_get_cases_risk_on_time()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff1Day = new DateInterval('P1D');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process = factory(Process::class)->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $date->add($diff1Day),
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$inbox = new Inbox();
$inbox->setUserId($user->USR_ID);
$inbox->setUserUid($user->USR_UID);
$res = $inbox->getCasesRisk($process->PRO_ID);
$this->assertCount(1, $res);
}
/**
* This tests the getCasesRisk() method with at risk filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCasesRisk()
* @test
*/
public function it_tests_get_cases_risk_at_risk()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process = factory(Process::class)->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$inbox = new Inbox();
$inbox->setUserId($user->USR_ID);
$inbox->setUserUid($user->USR_UID);
$res = $inbox->getCasesRisk($process->PRO_ID, null, null, "AT_RISK");
$this->assertCount(1, $res);
}
/**
* This tests the getCasesRisk() method with overdue filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCasesRisk()
* @test
*/
public function it_tests_get_cases_risk_overdue()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process = factory(Process::class)->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->sub($diff2Days)
]);
$inbox = new Inbox();
$inbox->setUserId($user->USR_ID);
$inbox->setUserUid($user->USR_UID);
$res = $inbox->getCasesRisk($process->PRO_ID, null, null, "OVERDUE");
$this->assertCount(1, $res);
}
}

View File

@@ -2,6 +2,8 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use DateInterval;
use Datetime;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Paused;
@@ -653,4 +655,215 @@ class PausedTest extends TestCase
$this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
$this->assertEquals(3, $res['total']);
}
/**
* It tests the getCasesRisk() method with the ontime filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCasesRisk()
* @test
*/
public function it_should_test_get_cases_risk_on_time()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff1Day = new DateInterval('P1D');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create();
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'TAS_TYPE' => 'NORMAL'
]);
$application1 = factory(Application::class)->create();
factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_PREVIOUS' => 0,
'DEL_INDEX' => 1,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $date->add($diff1Day),
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$delegation1 = factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $date->add($diff1Day),
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
factory(AppDelay::class)->create([
'APP_DELEGATION_USER' => $user->USR_UID,
'PRO_UID' => $process1->PRO_UID,
'APP_NUMBER' => $delegation1->APP_NUMBER,
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
'APP_DISABLE_ACTION_USER' => 0,
'APP_TYPE' => 'PAUSE'
]);
$this->createMultiplePaused(3, 2, $user);
$paused = new Paused();
$paused->setUserId($user->USR_ID);
$paused->setUserUid($user->USR_UID);
$res = $paused->getCasesRisk($process1->PRO_ID);
$this->assertCount(1, $res);
}
/**
* It tests the getCasesRisk() method with the at risk filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCasesRisk()
* @test
*/
public function it_should_test_get_cases_risk_at_risk()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create();
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'TAS_TYPE' => 'NORMAL'
]);
$application1 = factory(Application::class)->create();
factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_PREVIOUS' => 0,
'DEL_INDEX' => 1,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$delegation1 = factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
factory(AppDelay::class)->create([
'APP_DELEGATION_USER' => $user->USR_UID,
'PRO_UID' => $process1->PRO_UID,
'APP_NUMBER' => $delegation1->APP_NUMBER,
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
'APP_DISABLE_ACTION_USER' => 0,
'APP_TYPE' => 'PAUSE'
]);
$this->createMultiplePaused(3, 2, $user);
$paused = new Paused();
$paused->setUserId($user->USR_ID);
$paused->setUserUid($user->USR_UID);
$res = $paused->getCasesRisk($process1->PRO_ID, null, null, 'AT_RISK');
$this->assertCount(1, $res);
}
/**
* It tests the getCasesRisk() method with the overdue filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCasesRisk()
* @test
*/
public function it_should_test_get_cases_risk_overdue()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create();
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'TAS_TYPE' => 'NORMAL'
]);
$application1 = factory(Application::class)->create();
factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_PREVIOUS' => 0,
'DEL_INDEX' => 1,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->sub($diff2Days)
]);
$delegation1 = factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->sub($diff2Days)
]);
factory(AppDelay::class)->create([
'APP_DELEGATION_USER' => $user->USR_UID,
'PRO_UID' => $process1->PRO_UID,
'APP_NUMBER' => $delegation1->APP_NUMBER,
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
'APP_DISABLE_ACTION_USER' => 0,
'APP_TYPE' => 'PAUSE'
]);
$this->createMultiplePaused(3, 2, $user);
$paused = new Paused();
$paused->setUserId($user->USR_ID);
$paused->setUserUid($user->USR_UID);
$res = $paused->getCasesRisk($process1->PRO_ID, null, null, 'OVERDUE');
$this->assertCount(1, $res);
}
}

View File

@@ -2,6 +2,8 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use DateInterval;
use Datetime;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Unassigned;
@@ -723,4 +725,149 @@ class UnassignedTest extends TestCase
$this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
$this->assertEquals(0, $res['total']);
}
/**
* It tests the getCasesRisk() method with ontime filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCasesRisk()
* @test
*/
public function it_should_test_get_cases_risk_on_time()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff1Day = new DateInterval('P1D');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create([
'CATEGORY_ID' => 2
]);
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'PRO_ID' => $process1->PRO_ID,
]);
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1,
'TU_TYPE' => 1
]);
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'PRO_ID' => $process1->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $date->add($diff1Day),
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$unassigned = new Unassigned();
$unassigned->setUserId($user->USR_ID);
$unassigned->setUserUid($user->USR_UID);
$res = $unassigned->getCasesRisk($process1->PRO_ID);
$this->assertCount(1, $res);
}
/**
* It tests the getCasesRisk() method with at risk filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCasesRisk()
* @test
*/
public function it_should_test_get_cases_risk_at_risk()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create([
'CATEGORY_ID' => 2
]);
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'PRO_ID' => $process1->PRO_ID,
]);
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1,
'TU_TYPE' => 1
]);
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'PRO_ID' => $process1->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$unassigned = new Unassigned();
$unassigned->setUserId($user->USR_ID);
$unassigned->setUserUid($user->USR_UID);
$res = $unassigned->getCasesRisk($process1->PRO_ID, null, null, 'AT_RISK');
$this->assertCount(1, $res);
}
/**
* It tests the getCasesRisk() method with overdue filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCasesRisk()
* @test
*/
public function it_should_test_get_cases_risk_overdue()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create([
'CATEGORY_ID' => 2
]);
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'PRO_ID' => $process1->PRO_ID,
]);
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1,
'TU_TYPE' => 1
]);
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'PRO_ID' => $process1->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->sub($diff2Days)
]);
$unassigned = new Unassigned();
$unassigned->setUserId($user->USR_ID);
$unassigned->setUserUid($user->USR_UID);
$res = $unassigned->getCasesRisk($process1->PRO_ID, null, null, 'OVERDUE');
$this->assertCount(1, $res);
}
}

View File

@@ -281,15 +281,17 @@ class CaseListTest extends TestCase
*/
public function it_should_test_import()
{
$additionalTables = factory(AdditionalTables::class)->create();
$data = [
'type' => 'inbox',
'name' => 'test1',
'description' => 'my description',
'tableUid' => '',
'tableUid' => $additionalTables->ADD_TAB_UID,
'columns' => [],
'iconList' => 'deafult.png',
'iconColor' => 'red',
'iconColorScreen' => 'blue'
'iconColorScreen' => 'blue',
'tableName' => $additionalTables->ADD_TAB_NAME
];
$json = json_encode($data);
$tempFile = sys_get_temp_dir() . '/test_' . random_int(10000, 99999);
@@ -300,7 +302,10 @@ class CaseListTest extends TestCase
'error' => 0
]
];
$request_data = [];
$request_data = [
'invalidFields' => 'continue',
'duplicateName' => 'continue'
];
$ownerId = 1;
$result = CaseList::import($request_data, $ownerId);

View File

@@ -2,6 +2,8 @@
namespace Tests\unit\workflow\src\ProcessMaker\Model;
use DateInterval;
use Datetime;
use G;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
@@ -446,7 +448,16 @@ class DelegationTest extends TestCase
*/
public function it_return_scope_at_risk()
{
$table = factory(Delegation::class)->states('closed')->create();
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$table = factory(Delegation::class)->create([
'DEL_THREAD_STATUS' => 'CLOSED',
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$this->assertCount(1, $table->atRisk($table->DEL_DELEGATE_DATE)->get());
}
@@ -458,7 +469,16 @@ class DelegationTest extends TestCase
*/
public function it_return_scope_overdue()
{
$table = factory(Delegation::class)->states('closed')->create();
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$table = factory(Delegation::class)->create([
'DEL_THREAD_STATUS' => 'CLOSED',
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->sub($diff2Days)
]);
$this->assertCount(1, $table->overdue($table->DEL_DELEGATE_DATE)->get());
}

View File

@@ -73,7 +73,7 @@ class StepTriggerMapBuilder
$tMap->addPrimaryKey('ST_TYPE', 'StType', 'string', CreoleTypes::VARCHAR, true, 20);
$tMap->addColumn('ST_CONDITION', 'StCondition', 'string', CreoleTypes::VARCHAR, true, 255);
$tMap->addColumn('ST_CONDITION', 'StCondition', 'string', CreoleTypes::LONGVARCHAR, true, null);
$tMap->addColumn('ST_POSITION', 'StPosition', 'int', CreoleTypes::INTEGER, true, null);

Some files were not shown because too many files have changed in this diff Show More