PMCORE-2673 'Default Cases menu option' field does not work

fix code style

add legacy frame
This commit is contained in:
Rodrigo Quelca
2021-01-07 16:20:45 +00:00
parent 86ca7b96ea
commit df3265d5b8
5 changed files with 102 additions and 25 deletions

View File

@@ -22,6 +22,7 @@
ref="component" ref="component"
:filters="filters" :filters="filters"
:id="pageId" :id="pageId"
:pageUri="pageUri"
:name="pageName" :name="pageName"
@onSubmitFilter="onSubmitFilter" @onSubmitFilter="onSubmitFilter"
@onRemoveFilter="onRemoveFilter" @onRemoveFilter="onRemoveFilter"
@@ -46,6 +47,7 @@ import CaseDetail from "./CaseDetail";
import XCase from "./XCase"; import XCase from "./XCase";
import TaskReassignments from "./TaskReassignments"; import TaskReassignments from "./TaskReassignments";
import AdvancedSearch from "./AdvancedSearch"; import AdvancedSearch from "./AdvancedSearch";
import LegacyFrame from "./LegacyFrame";
import api from "./../api/index"; import api from "./../api/index";
@@ -64,6 +66,7 @@ export default {
Paused, Paused,
Unassigned, Unassigned,
CaseDetail, CaseDetail,
LegacyFrame
}, },
data() { data() {
return { return {
@@ -78,7 +81,19 @@ export default {
sidebarWidth: "310px", sidebarWidth: "310px",
pageId: null, pageId: null,
pageName: null, pageName: null,
filters: null, pageUri: null,
filters: null,
menuMap: {
CASES_MY_CASES: "MyCases",
CASES_SEARCH: "advanced-search",
CASES_INBOX: "todo",
CASES_DRAFT: "draft",
CASES_PAUSED: "paused",
CASES_SELFSERVICE: "unassigned",
CONSOLIDATED_CASES: "batch-routing",
CASES_TO_REASSIGN: "task-reassignments",
CASES_FOLDERS: "my-documents"
}
}; };
}, },
mounted() { mounted() {
@@ -86,20 +101,29 @@ export default {
window.addEventListener("resize", this.onResize); window.addEventListener("resize", this.onResize);
this.getMenu(); this.getMenu();
this.listenerIframe(); this.listenerIframe();
window.setInterval(this.setCounter, parseInt(window.config.FORMATS.casesListRefreshTime) * 1000); window.setInterval(
this.setCounter,
parseInt(window.config.FORMATS.casesListRefreshTime) * 1000
);
}, },
methods: { methods: {
/** /**
* Listener for iframes childs * Listener for iframes childs
*/ */
listenerIframe(){ listenerIframe() {
let that = this, let that = this,
eventMethod = window.addEventListener? "addEventListener": "attachEvent", eventMethod = window.addEventListener
eventer = window[eventMethod], ? "addEventListener"
messageEvent = eventMethod === "attachEvent"? "onmessage": "message"; : "attachEvent",
eventer = window[eventMethod],
messageEvent =
eventMethod === "attachEvent" ? "onmessage" : "message";
eventer(messageEvent, function (e) { eventer(messageEvent, function(e) {
if (e.data === "redirect=todo" || e.message === "redirect=todo"){ if (
e.data === "redirect=todo" ||
e.message === "redirect=todo"
) {
that.page = "todo"; that.page = "todo";
} }
}); });
@@ -111,6 +135,7 @@ export default {
api.menu api.menu
.get() .get()
.then((response) => { .then((response) => {
this.setDefaultCasesMenu(response.data);
this.menu = this.mappingMenu(response.data); this.menu = this.mappingMenu(response.data);
this.setCounter(); this.setCounter();
}) })
@@ -118,6 +143,18 @@ export default {
console.error(e); console.error(e);
}); });
}, },
/**
* Set default cases menu option
*/
setDefaultCasesMenu(data) {
let menuItem = _.find(data, function(o) {
return o.id === window.config._nodeId;
});
if (menuItem && menuItem.href) {
this.page = this.menuMap[window.config._nodeId] || "MyCases";
this.$router.push(menuItem.href);
}
},
/** /**
* Do a mapping of vue view for menus * Do a mapping of vue view for menus
* @returns array * @returns array
@@ -126,22 +163,13 @@ export default {
var i, var i,
j, j,
newData = data, newData = data,
auxId, auxId;
viewVue = {
CASES_MY_CASES: "MyCases",
CASES_SEARCH: "advanced-search",
CASES_INBOX: "todo",
CASES_DRAFT: "draft",
CASES_PAUSED: "paused",
CASES_SELFSERVICE: "unassigned",
CONSOLIDATED_CASES: "batch-routing",
CASES_TO_REASSIGN: "task-reassignments",
CASES_FOLDERS: "my-documents",
};
for (i = 0; i < data.length; i += 1) { for (i = 0; i < data.length; i += 1) {
auxId = data[i].id || ""; auxId = data[i].id || "";
if (auxId !== "" && viewVue[auxId]) { if (auxId !== "" && this.menuMap[auxId]) {
newData[i].id = viewVue[auxId]; newData[i].id = this.menuMap[auxId];
} else if (newData[i].href) {
newData[i].id = "LegacyFrame";
} }
} }
return newData; return newData;
@@ -151,10 +179,12 @@ export default {
this.page = "advanced-search"; this.page = "advanced-search";
this.filters = item.item.filters; this.filters = item.item.filters;
this.pageId = item.item.id; this.pageId = item.item.id;
this.pageUri = item.item.href;
this.pageName = item.item.title; this.pageName = item.item.title;
} else { } else {
this.filters = []; this.filters = [];
this.pageId = null; this.pageId = null;
this.pageUri = item.item.href;
this.page = item.item.id || "MyCases"; this.page = item.item.id || "MyCases";
if (this.$refs["component"] && this.$refs["component"].updateView) { if (this.$refs["component"] && this.$refs["component"].updateView) {
this.$refs["component"].updateView(); this.$refs["component"].updateView();
@@ -171,7 +201,7 @@ export default {
var i, var i,
j, j,
data = response.data; data = response.data;
that.counters = data; that.counters = data;
for (i = 0; i < that.menu.length; i += 1) { for (i = 0; i < that.menu.length; i += 1) {
if (that.menu[i].id && data[that.menu[i].id]) { if (that.menu[i].id && data[that.menu[i].id]) {
that.menu[i].badge.text = data[that.menu[i].id]; that.menu[i].badge.text = data[that.menu[i].id];
@@ -276,7 +306,7 @@ export default {
onUpdateFilters(filters) { onUpdateFilters(filters) {
this.filters = filters; this.filters = filters;
} }
}, }
}; };
</script> </script>

View File

@@ -0,0 +1,40 @@
<template>
<div>
<iframe
:width="width"
ref="xIFrame"
frameborder="0"
:src="pageUri"
:height="height"
allowfullscreen
></iframe>
</div>
</template>
<script>
export default {
name: "LegacyFrame",
components: {},
props: {
pageUri: String,
},
mounted() {
this.height = window.innerHeight - this.diffHeight;
},
data() {
return {
height: "100%",
width: "100%",
diffHeight: 10
};
},
methods: {
classBtn(cls) {
return "btn v-btn-request " + cls;
},
},
};
</script>
<style>
</style>

View File

@@ -126,6 +126,11 @@ export default {
}, },
mounted() { mounted() {
this.getHeaders(); this.getHeaders();
// force to open start cases modal
// if the user has start case as a default case menu option
if (window.config._nodeId === "CASES_START_CASE") {
this.$refs["newRequest"].show();
}
}, },
watch: {}, watch: {},
computed: { computed: {

View File

@@ -65,7 +65,7 @@ $G_TMP_MENU->AddIdRawOption(
$G_TMP_MENU->AddIdRawOption( $G_TMP_MENU->AddIdRawOption(
'CASES_SENT', 'CASES_SENT',
'casesListExtJs?action=sent', 'casesListExtJs?action=sent',
G::LoadTranslation('ID_SENT'), G::LoadTranslation('ID_MY_CASES'),
'icon-cases-outbox.png' 'icon-cases-outbox.png'
); );
$G_TMP_MENU->AddIdRawOption( $G_TMP_MENU->AddIdRawOption(

View File

@@ -131,6 +131,8 @@ $userCanAccess = 1;
global $translation; global $translation;
$pmDynaform = new PmDynaform(); $pmDynaform = new PmDynaform();
ScriptVariables::add('defaultOption', $defaultOption);
ScriptVariables::add('_nodeId', isset($confDefaultOption) ? $confDefaultOption : "PM_USERS");
ScriptVariables::add('SYS_CREDENTIALS', $pmDynaform->getCredentials()); ScriptVariables::add('SYS_CREDENTIALS', $pmDynaform->getCredentials());
ScriptVariables::add('SYS_SERVER', System::getHttpServerHostnameRequestsFrontEnd()); ScriptVariables::add('SYS_SERVER', System::getHttpServerHostnameRequestsFrontEnd());
ScriptVariables::add('SYS_WORKSPACE', config("system.workspace")); ScriptVariables::add('SYS_WORKSPACE', config("system.workspace"));