diff --git a/workflow/engine/methods/cases/casesListExtJsRedirector.php b/workflow/engine/methods/cases/casesListExtJsRedirector.php index f9bced812..0b4e7757f 100644 --- a/workflow/engine/methods/cases/casesListExtJsRedirector.php +++ b/workflow/engine/methods/cases/casesListExtJsRedirector.php @@ -42,7 +42,7 @@ if (isset($_GET['ux'])) { } /*----------------------------------********---------------------------------*/ } -echo "try {parent.parent.updateCasesTree();} catch(e) {}"; +echo "try {parent.parent.updateCasesTree();parent.parent.highlightCasesTree();} catch(e) {}"; ?> } \ No newline at end of file diff --git a/workflow/engine/methods/cases/casesMenuHighlight.php b/workflow/engine/methods/cases/casesMenuHighlight.php new file mode 100644 index 000000000..b58ab1a13 --- /dev/null +++ b/workflow/engine/methods/cases/casesMenuHighlight.php @@ -0,0 +1,28 @@ +limit(1); + $items = $query->get(); + $atLeastOne = $items->count() > 0; +} else { + $query .= " LIMIT 1"; + $items = DB::select($query); + $atLeastOne = !empty($items); +} + +// Initializing the response variable +$response = []; + +// The scope for the first version of this feature is only for unassigned list, so, this value is currently fixed +$response[] = ['item' => 'CASES_SELFSERVICE', 'highlight' => $atLeastOne]; + +// Print the response in JSON format +header('Content-Type: application/json'); +echo json_encode($response); diff --git a/workflow/engine/methods/cases/casesMenuLoader.php b/workflow/engine/methods/cases/casesMenuLoader.php index c956e957a..316e0ccf5 100644 --- a/workflow/engine/methods/cases/casesMenuLoader.php +++ b/workflow/engine/methods/cases/casesMenuLoader.php @@ -21,78 +21,78 @@ function getLoadTreeMenuData() { header("content-type: text/xml"); - global $G_TMP_MENU; - $oMenu = new Menu(); - $oMenu->load('cases'); + $menuInstance = new Menu(); + $menuInstance->load('cases'); - $oCases = new Cases(); - $aTypes = array('to_do','draft','cancelled','sent','paused','completed','selfservice'); - //'to_revise', - //'to_reassign' - $aTypesID = array('CASES_INBOX' => 'to_do','CASES_DRAFT' => 'draft','CASES_CANCELLED' => 'cancelled','CASES_SENT' => 'sent','CASES_PAUSED' => 'paused','CASES_COMPLETED' => 'completed','CASES_SELFSERVICE' => 'selfservice'); + $types = ['to_do', 'draft', 'cancelled', 'sent', 'paused', 'completed']; + $typesId = ['CASES_INBOX' => 'to_do', 'CASES_DRAFT' => 'draft', 'CASES_CANCELLED' => 'cancelled', + 'CASES_SENT' => 'sent', 'CASES_PAUSED' => 'paused', 'CASES_COMPLETED' => 'completed']; + + // If the feature for highlight the home folders is disabled, add unassigned list to tree options with counters + if (!HIGHLIGHT_HOME_FOLDER_ENABLE) { + $types[] = 'selfservice'; + $typesId['CASES_SELFSERVICE'] = 'selfservice'; + } /*----------------------------------********---------------------------------*/ $licensedFeatures = PMLicensedFeatures::getSingleton(); if ($licensedFeatures->verifyfeature('7TTeDBQeWRoZTZKYjh4eFpYUlRDUUEyVERPU3FxellWank=')) { - $aTypesID['CONSOLIDATED_CASES'] = 'batch_routing'; - $aTypes[] = 'batch_routing'; + $typesId['CONSOLIDATED_CASES'] = 'batch_routing'; + $types[] = 'batch_routing'; } /*----------------------------------********---------------------------------*/ - //'CASES_TO_REVISE'=>'to_revise', - //'CASES_TO_REASSIGN'=>'to_reassign' - $list = array(); + $list = []; $list['count'] = ' '; - $empty = array(); - foreach ($aTypes as $key => $val) { + $empty = []; + foreach ($types as $key => $val) { $empty[$val] = $list; } - $aCount = $empty; //$oCases->getAllConditionCasesCount($aTypes, true); - $processNameMaxSize = 20; + $count = $empty; - //now drawing the treeview using the menu options from menu/cases.php - $menuCases = array(); - for ($i = 0; $i < count($oMenu->Options); $i++) { - if ($oMenu->Types[$i] == 'blockHeader') { - $CurrentBlockID = $oMenu->Id[$i]; - $menuCases[$CurrentBlockID]['blockTitle'] = $oMenu->Labels[$i]; - if ($oMenu->Options[$i] != "") { - $menuCases[$CurrentBlockID]['link'] = $oMenu->Options[$i]; + // Now drawing the tree view using the menu options from menu/cases.php + $menuCases = []; + for ($i = 0; $i < count($menuInstance->Options); $i++) { + if ($menuInstance->Types[$i] == 'blockHeader') { + $currentBlockID = $menuInstance->Id[$i]; + $menuCases[$currentBlockID]['blockTitle'] = $menuInstance->Labels[$i]; + if ($menuInstance->Options[$i] != "") { + $menuCases[$currentBlockID]['link'] = $menuInstance->Options[$i]; } - } elseif ($oMenu->Types[$i] == 'blockNestedTree') { - $CurrentBlockID = $oMenu->Id[$i]; - $menuCases[$CurrentBlockID]['blockTitle'] = $oMenu->Labels[$i]; - $menuCases[$CurrentBlockID]['blockType'] = $oMenu->Types[$i]; - $menuCases[$CurrentBlockID]['loaderurl'] = $oMenu->Options[$i]; - } elseif ($oMenu->Types[$i] == 'blockHeaderNoChild') { - $CurrentBlockID = $oMenu->Id[$i]; - $menuCases[$CurrentBlockID]['blockTitle'] = $oMenu->Labels[$i]; - $menuCases[$CurrentBlockID]['blockType'] = $oMenu->Types[$i]; - $menuCases[$CurrentBlockID]['link'] = $oMenu->Options[$i]; - } elseif ($oMenu->Types[$i] == 'rootNode') { - $menuCases[$CurrentBlockID]['blockItems'][$oMenu->Id[$i]] = array( - 'label' => $oMenu->Labels[$i], - 'link' => $oMenu->Options[$i], - 'icon' => (isset($oMenu->Icons[$i]) && $oMenu->Icons[$i] != '') ? $oMenu->Icons[$i] : 'kcmdf.png' - ); + } elseif ($menuInstance->Types[$i] == 'blockNestedTree') { + $currentBlockID = $menuInstance->Id[$i]; + $menuCases[$currentBlockID]['blockTitle'] = $menuInstance->Labels[$i]; + $menuCases[$currentBlockID]['blockType'] = $menuInstance->Types[$i]; + $menuCases[$currentBlockID]['loaderurl'] = $menuInstance->Options[$i]; + } elseif ($menuInstance->Types[$i] == 'blockHeaderNoChild') { + $currentBlockID = $menuInstance->Id[$i]; + $menuCases[$currentBlockID]['blockTitle'] = $menuInstance->Labels[$i]; + $menuCases[$currentBlockID]['blockType'] = $menuInstance->Types[$i]; + $menuCases[$currentBlockID]['link'] = $menuInstance->Options[$i]; + } elseif ($menuInstance->Types[$i] == 'rootNode') { + $menuCases[$currentBlockID]['blockItems'][$menuInstance->Id[$i]] = [ + 'label' => $menuInstance->Labels[$i], + 'link' => $menuInstance->Options[$i], + 'icon' => (isset($menuInstance->Icons[$i]) && $menuInstance->Icons[$i] != '') ? $menuInstance->Icons[$i] : 'kcmdf.png' + ]; $index = $i; - list($childs, $index) = getChilds($oMenu, ++$index); + list($childs, $index) = getChilds($menuInstance, ++$index); - $menuCases[$CurrentBlockID]['blockItems'][$oMenu->Id[$i]]['childs'] = $childs; + $menuCases[$currentBlockID]['blockItems'][$menuInstance->Id[$i]]['childs'] = $childs; $i = $index; } else { - $menuCases[$CurrentBlockID]['blockItems'][$oMenu->Id[$i]] = array( - 'label' => $oMenu->Labels[$i], - 'link' => $oMenu->Options[$i], - 'icon' => (isset($oMenu->Icons[$i]) && $oMenu->Icons[$i] != '') ? $oMenu->Icons[$i] : 'kcmdf.png' - ); + $menuCases[$currentBlockID]['blockItems'][$menuInstance->Id[$i]] = [ + 'label' => $menuInstance->Labels[$i], + 'link' => $menuInstance->Options[$i], + 'icon' => (isset($menuInstance->Icons[$i]) && $menuInstance->Icons[$i] != '') ? $menuInstance->Icons[$i] : 'kcmdf.png' + ]; - if (isset($aTypesID[$oMenu->Id[$i]])) { - $menuCases[$CurrentBlockID]['blockItems'][$oMenu->Id[$i]]['cases_count'] = $aCount[$aTypesID[$oMenu->Id[$i]]]['count']; + if (isset($typesId[$menuInstance->Id[$i]])) { + $menuCases[$currentBlockID]['blockItems'][$menuInstance->Id[$i]]['cases_count'] = $count[$typesId[$menuInstance->Id[$i]]]['count']; } } } @@ -114,8 +114,8 @@ function getLoadTreeMenuData() } } - //This function generates an xml, so it prevents the output of a badly formed xml - //by cleaning any content prior to this function with ob_clean + // This function generates an xml, so it prevents the output of a badly formed xml + // by cleaning any content prior to this function with ob_clean ob_clean(); echo $xml->asXML(); die; @@ -134,7 +134,7 @@ function getLoadTreeMenuData() $menuBlockNode->addAttribute('url', $menuBlock['link']); } - // adding "menu_block" childs nodes + // Adding "menu_block" child nodes foreach ($menuBlock['blockItems'] as $id => $menu) { if (! empty($menu['childs'])) { $rootNode = $menuBlockNode->addChild('menu_block'); @@ -177,8 +177,8 @@ function getLoadTreeMenuData() } } - //This function generates an xml, so it prevents the output of a badly formed xml - //by cleaning any content prior to this function with ob_clean + // This function generates an xml, so it prevents the output of a badly formed xml + // by cleaning any content prior to this function with ob_clean ob_clean(); echo $xml->asXML(); die; diff --git a/workflow/engine/methods/cases/main_init.php b/workflow/engine/methods/cases/main_init.php index 42da23301..f4d4b47ab 100644 --- a/workflow/engine/methods/cases/main_init.php +++ b/workflow/engine/methods/cases/main_init.php @@ -126,6 +126,15 @@ $oHeadPublisher->assign('urlProxy', $urlProxy); //sending the urlProxy to make $oHeadPublisher->assign("_nodeId", isset($confDefaultOption) ? $confDefaultOption : "PM_USERS"); //User menu permissions $oHeadPublisher->assign("FORMATS", $conf->getFormats()); +/*----------------------------------********---------------------------------*/ +// If the feature for highlight the home folders is enabled, set some javascript variables +if (HIGHLIGHT_HOME_FOLDER_ENABLE) { + $oHeadPublisher->assign("highlightUrlProxy", "casesMenuHighlight?r="); + $oHeadPublisher->assign("highlightRefreshTime", HIGHLIGHT_HOME_FOLDER_REFRESH_TIME); + $oHeadPublisher->assign("highlightScope", HIGHLIGHT_HOME_FOLDER_SCOPE); +} +/*----------------------------------********---------------------------------*/ + $_SESSION["current_ux"] = "NORMAL"; G::RenderPage("publish", "extJs"); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Lists.php b/workflow/engine/src/ProcessMaker/BusinessModel/Lists.php index 3944c5243..60f2f4051 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Lists.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Lists.php @@ -56,7 +56,7 @@ class Lists */ public function __construct() { - $this->mapList = array( + $this->mapList = [ 'ListInbox' => 'CASES_INBOX', 'ListDraft' => 'CASES_DRAFT', 'ListCanceled' => 'CASES_CANCELLED', @@ -66,8 +66,7 @@ class Lists /*----------------------------------********---------------------------------*/ 'ListConsolidated' => 'CONSOLIDATED_CASES', /*----------------------------------********---------------------------------*/ - 'ListSelfService' => 'CASES_SELFSERVICE' - ); + ]; $this->ListInbox = new \ListInbox(); $this->ListDraft = new \ListInbox(); @@ -77,8 +76,12 @@ class Lists $this->ListCompleted = new \ListCompleted(); /*----------------------------------********---------------------------------*/ $this->ListConsolidated = new Consolidated(); + // If the feature for highlight the home folders is disabled, add/initialize properties related to self-service list + if (!HIGHLIGHT_HOME_FOLDER_ENABLE) { + $this->mapList['ListSelfService'] = 'CASES_SELFSERVICE'; + $this->ListSelfService = new \ListUnassigned(); + } /*----------------------------------********---------------------------------*/ - $this->ListSelfService = new \ListUnassigned(); } @@ -150,8 +153,11 @@ class Lists $listpeer = 'ListMyInboxPeer'; break; case 'unassigned': - $list = new \ListUnassigned(); - $listpeer = 'ListUnassignedPeer'; + // If the feature for highlight the home folders is disabled, initialize the variables for unassigned list + if (!HIGHLIGHT_HOME_FOLDER_ENABLE) { + $list = new \ListUnassigned(); + $listpeer = 'ListUnassignedPeer'; + } break; } diff --git a/workflow/engine/templates/cases/main.js b/workflow/engine/templates/cases/main.js index ec49cd577..6f2445d86 100644 --- a/workflow/engine/templates/cases/main.js +++ b/workflow/engine/templates/cases/main.js @@ -31,6 +31,7 @@ Ext.onReady(function(){ } e.stopEvent(); updateCasesTree(); + highlightCasesTree(); } else Ext.Msg.alert(_('ID_REFRESH_LABEL'),_('ID_REFRESH_MESSAGE')); @@ -132,6 +133,7 @@ Ext.onReady(function(){ if (defaultOption.indexOf('open') > -1) { //if it is, then update cases trees updateCasesTree(); + highlightCasesTree(); } if (_nodeId !== '') { treePanel1 = Ext.getCmp('tree-panel'); @@ -142,6 +144,7 @@ Ext.onReady(function(){ node.select(); if (_nodeId === 'CASES_START_CASE') { updateCasesTree(); + highlightCasesTree(); } } } @@ -177,7 +180,8 @@ Ext.onReady(function(){ treeMenuItems ] }); - mainMenu.setTitle("
"); + mainMenu.setTitle(""); propStore = new Ext.data.Store({ proxy: new Ext.data.HttpProxy({url: 'debug_vars'}), @@ -499,9 +503,15 @@ Ext.onReady(function(){ // Get the counters the first time updateCasesTree(); + highlightCasesTree(); // FORMATS.casesListRefreshTime is in seconds setInterval("timer()", parseInt(FORMATS.casesListRefreshTime) * 1000); + + // If the feature for highlight the home folders is enabled, add timer for highlight the tree options + if (typeof highlightUrlProxy !== "undefined") { + setInterval("highlightCasesTree()", (parseInt(highlightRefreshTime) * 60) * 1000); + } }); function updateCasesView(viewList) { @@ -530,8 +540,6 @@ function updateCasesView(viewList) { function updateCasesTree() { document.getElementById('refreshNotifiers').src = '/images/ext/default/grid/loading.gif'; - itemsTypes = Array('CASES_INBOX', 'CASES_DRAFT', 'CASES_CANCELLED', 'CASES_SENT', 'CASES_PAUSED', 'CASES_COMPLETED', 'CASES_SELFSERVICE'); - Ext.Ajax.request({ url: urlProxy + Math.random(), success: function (response) { @@ -561,6 +569,36 @@ function updateCasesTree() { }); } +/** + * Function to highlight the tree options + */ +function highlightCasesTree() { + if (typeof highlightUrlProxy !== "undefined") { + document.getElementById('refreshNotifiers').src = '/images/ext/default/grid/loading.gif'; + + Ext.Ajax.request({ + url: highlightUrlProxy + Math.random(), + success: function (response) { + var result = Ext.util.JSON.decode(response.responseText); + var treePanelObject = Ext.getCmp('tree-panel'); + for (var i = 0; i < result.length; i++) { + var nodeObject = treePanelObject.getNodeById(result[i].item); + // Set the style for the option + if (result[i].highlight) { + nodeObject.setCls('row_updated'); + } else { + nodeObject.setCls(''); + } + } + document.getElementById('refreshNotifiers').src = '/images/refresh.gif'; + }, + failure: function () { + // Nothing to do for now... + } + }); + } +} + function timer() { if (flagRefresh) { updateCasesTree(); diff --git a/workflow/engine/templates/cases/open.js b/workflow/engine/templates/cases/open.js index bdbddfe9b..0fa9372bd 100644 --- a/workflow/engine/templates/cases/open.js +++ b/workflow/engine/templates/cases/open.js @@ -509,7 +509,7 @@ Ext.onReady(function(){ iconCls: 'button_menu_ext ICON_RETURN', tooltip: { title:_('ID_RETURN_ADVANCED_SEARCH'), - text: _('ID_SHOW_RETURN_ADVANCED_SEARCH') + text: _('ID_SHOW_RETURN_ADVANCED_SEARCH') }, toggleHandler: function (btn, pressed) { //Force to redirect to advanced search list from any side @@ -1081,11 +1081,12 @@ Ext.onReady(function(){ if (data.status == true) { // The case was cancelled parent.notify('', _("ID_CASE_CANCELLED", stringReplace("\\: ", "", _APP_NUM))); + parent.updateCasesTree(); + parent.highlightCasesTree(); } else { // The case wasn't cancel parent.notify('', data.msg); } - parent.updateCasesTree(); } catch (e) { parent.notify('', _('ID_SOMETHING_WRONG')); } @@ -1353,6 +1354,7 @@ Ext.onReady(function(){ try { parent.notify('', data.msg); parent.updateCasesTree(); + parent.highlightCasesTree(); } catch (e) { } @@ -1553,6 +1555,7 @@ Ext.onReady(function(){ try { parent.notify('PAUSE CASE', req.result.msg); parent.updateCasesTree(); + parent.highlightCasesTree(); }catch (e) { } location.href = urlToRedirectAfterPause; @@ -1592,6 +1595,7 @@ Ext.onReady(function(){ try { parent.PMExt.notify(_('ID_UNPAUSE_ACTION'), data.msg); parent.updateCasesTree(); + parent.highlightCasesTree(); } catch (e) { } @@ -1646,6 +1650,7 @@ Ext.onReady(function(){ try { parent.PMExt.notify(_('ID_DELETE_ACTION'), data.msg); parent.updateCasesTree(); + parent.highlightCasesTree(); } catch (e) { } diff --git a/workflow/engine/templates/cases/showDebugFrameBreaker.php b/workflow/engine/templates/cases/showDebugFrameBreaker.php index b47831fec..d58f9c09d 100644 --- a/workflow/engine/templates/cases/showDebugFrameBreaker.php +++ b/workflow/engine/templates/cases/showDebugFrameBreaker.php @@ -3,7 +3,8 @@ $filter = new InputFilter(); if (isset($_POST['NextStep'])) { $nextStep = $filter->xssFilterHard($_POST['NextStep'], "url"); - $refresh = $nextStep == 'cases_Step?breakpoint=triggerdebug' ? 'try {parent.parent.updateCasesTree();} catch(e) {}' : ''; + $refresh = $nextStep == 'cases_Step?breakpoint=triggerdebug' ? 'try {parent.parent.updateCasesTree();' . + 'parent.parent.highlightCasesTree();} catch(e) {}' : ''; ?>