diff --git a/application/controllers/system/Filters.php b/application/controllers/system/Filters.php index b9b2b480d..ff1d47b0a 100644 --- a/application/controllers/system/Filters.php +++ b/application/controllers/system/Filters.php @@ -174,7 +174,7 @@ class Filters extends FHC_Controller } else { - $this->outputJsonError('Wrong parameter'); + $this->outputJsonError('An error occurred while saving a custom filter'); } } diff --git a/public/css/NavigationWidget.css b/public/css/NavigationWidget.css index 9d7753825..b6d6c800e 100644 --- a/public/css/NavigationWidget.css +++ b/public/css/NavigationWidget.css @@ -48,7 +48,7 @@ float: left; height: 50px; padding-top: 15px; - padding-right: 12px; padding-left: 7px; font-size: 16px; + margin-right: 3px; } diff --git a/public/js/FilterWidget.js b/public/js/FilterWidget.js index c96a06590..21352c622 100644 --- a/public/js/FilterWidget.js +++ b/public/js/FilterWidget.js @@ -11,6 +11,8 @@ /** * Global function used by NavigationWidget JS to bind events to side menu elements + * NOTE: it is called from the NavigationWidget JS therefore must be a global function + * Be carefull about recursive function calls!!! */ function sideMenuHook() { @@ -32,10 +34,10 @@ function sideMenuHook() } else { - // If a success and refreshSideMenu is a valid function then call it to refresh the side menu - if (typeof refreshSideMenu == "function") + // If a success and refreshSideMenuHook is a valid function then call it to refresh the side menu + if (typeof refreshSideMenuHook == "function") { - refreshSideMenu(); + refreshSideMenuHook(); } } } @@ -486,7 +488,7 @@ var FHC_FilterWidget = { filter_page: FHC_FilterWidget.getFilterPage() }, { - successCallback: refreshSideMenu // NOTE: to be checked + successCallback: refreshSideMenuHook // NOTE: to be checked } ); } diff --git a/public/js/NavigationWidget.js b/public/js/NavigationWidget.js index 4f7d05792..ee9adb83d 100644 --- a/public/js/NavigationWidget.js +++ b/public/js/NavigationWidget.js @@ -20,7 +20,8 @@ var FHC_NavigationWidget = { * Renders the header menu (top horizontal menu) */ renderHeaderMenu: function() { - // + + // Retrives the header menu array FHC_AjaxClient.ajaxCallGet( 'system/Navigation/header', { @@ -28,24 +29,16 @@ var FHC_NavigationWidget = { }, { successCallback: function(data, textStatus, jqXHR) { + if (FHC_AjaxClient.hasData(data)) { + var strHeaderMenu = ''; + jQuery.each(FHC_AjaxClient.getData(data), function(i, e) { - - var headerEntry = ''; - - if (e['icon'] != 'undefined' && e['icon'] != '') - { - headerEntry += ''; - } - - var target = ''; - if (e['target'] != null) target = e['target']; - - headerEntry += '' + e['description'] + ''; - - $(".menu-header-items").append(headerEntry); + if (e != null) strHeaderMenu += FHC_NavigationWidget._buildHeaderMenuStructure(e); }); + + $(".menu-header-items").html(strHeaderMenu); } } } @@ -56,7 +49,8 @@ var FHC_NavigationWidget = { * Renders the side left menu */ renderSideMenu: function() { - // + + // Retrives the left menu array FHC_AjaxClient.ajaxCallGet( 'system/Navigation/menu', { @@ -64,39 +58,67 @@ var FHC_NavigationWidget = { }, { successCallback: function(data, textStatus, jqXHR) { + if (FHC_AjaxClient.hasData(data)) { - var strMenu = ''; + FHC_NavigationWidget._printCollapseIcon(); // Applies bootstrap SB Admin 2 theme elements to the left menu - FHC_NavigationWidget._printCollapseIcon(); + var strLeftMenu = ''; + // Builds left menu jQuery.each(FHC_AjaxClient.getData(data), function(i, e) { - if (e != null) strMenu += FHC_NavigationWidget._printNavItem(e); + if (e != null) strLeftMenu += FHC_NavigationWidget._buildLeftMenuStructure(e); }); - $("#side-menu").html(strMenu); - $("#side-menu").metisMenu(); + $("#side-menu").html(strLeftMenu); // render left menu + $("#side-menu").metisMenu(); // call the Bootstrap SB Admin 2 theme renderer } + // If this global function is present... if (typeof sideMenuHook == 'function') { - sideMenuHook(); + sideMenuHook(); // ...then call it } } } ); }, + /** + * Calls URL to retrive a refreshed menu array + */ + refreshSideMenuHook: function(url) { + + FHC_AjaxClient.ajaxCallGet( + url, + { + navigation_page: FHC_NavigationWidget._getNavigationWidgetCalled() + }, + { + successCallback: function(data, textStatus, jqXHR) { + FHC_NavigationWidget.renderSideMenu(); + }, + errorCallback: function(jqXHR, textStatus, errorThrown) { + alert(textStatus); + } + } + ); + }, + //------------------------------------------------------------------------------------------------------------------ // Private methods /** - * + * Applies bootstrap SB Admin 2 theme elements to the left menu */ _printCollapseIcon: function() { // Hiding/showing navigation menu - works only with sb admin 2 template!! if(!$("#collapseicon").length) - $("#side-menu").parent().append('
'); + $("#side-menu").parent().append( + '
' + + ' ' + + '
' + ); $("#collapseicon").click(function() { $("#page-wrapper").css('margin-left', '0px'); @@ -114,48 +136,68 @@ var FHC_NavigationWidget = { }, /** - * + * Recursively builds the header menu structure */ - _printNavItem: function(item, depth = 1) { + _buildHeaderMenuStructure: function(item) { - strMenu = ""; - var expanded = typeof item['expand'] != 'undefined' && item['expand'] === true ? ' active' : ''; + var strHeaderMenu = ''; - strMenu += '
  • '; - - if (typeof item['subscriptLinkClass'] != 'undefined' && typeof item['subscriptDescription'] != 'undefined' - && item['subscriptLinkClass'] != null && item['subscriptDescription'] != null) + if (item['icon'] != 'undefined' && item['icon'] != '') { - strMenu += ''; + strHeaderMenu += ''; } var target = ''; if (item['target'] != null) target = item['target']; - strMenu += ''; + strHeaderMenu += '' + item['description'] + ''; + + return strHeaderMenu; + }, + + /** + * Recursively builds the left menu structure + */ + _buildLeftMenuStructure: function(item, depth = 1) { + + strLeftMenu = ""; + var expanded = item['expand'] != null && item['expand'] === true ? ' active' : ''; + + strLeftMenu += '
  • '; + + if (item['subscriptLinkClass'] != null && item['subscriptDescription'] != null) + { + strLeftMenu += ''; + } + + var target = ''; + if (item['target'] != null) target = item['target']; + + strLeftMenu += ''; if (item['icon'] != 'undefined') { - strMenu += ' '; + strLeftMenu += ' '; } - strMenu += item['description']; + strLeftMenu += item['description']; - if (typeof item['children'] != 'undefined' && Object.keys(item['children']).length > 0) + if (item['children'] != null && Object.keys(item['children']).length > 0) { - strMenu += ''; + strLeftMenu += ''; } - strMenu += ''; + strLeftMenu += ''; - if (typeof item['subscriptLinkClass'] != 'undefined' && typeof item['subscriptDescription'] != 'undefined' - && item['subscriptLinkClass'] != null && item['subscriptDescription'] != null) + if (item['subscriptLinkClass'] != null && item['subscriptDescription'] != null) { - strMenu += ' (' + item['subscriptDescription'] + ')'; - strMenu += ''; + strLeftMenu += '' + + ' (' + item['subscriptDescription'] + ')' + + ''; + strLeftMenu += ''; } - if (typeof item['children'] != 'undefined' && Object.keys(item['children']).length > 0) + if (item['children'] != null && Object.keys(item['children']).length > 0) { var level = ''; if (depth === 1) @@ -167,18 +209,18 @@ var FHC_NavigationWidget = { level = 'third'; } - strMenu += ''; } - strMenu += '
  • '; + strLeftMenu += ''; - return strMenu; + return strLeftMenu; }, /** diff --git a/public/js/infocenter/infocenterPersonDataset.js b/public/js/infocenter/infocenterPersonDataset.js index 1bad6590e..1b87d3333 100644 --- a/public/js/infocenter/infocenterPersonDataset.js +++ b/public/js/infocenter/infocenterPersonDataset.js @@ -3,26 +3,12 @@ */ /** -* Refreshes the side menu -* NOTE: it is called from the FilterWidget therefore must be a global function +* Global function used by FilterWidget JS to refresh the side menu +* NOTE: it is called from the FilterWidget JS therefore must be a global function */ -function refreshSideMenu() +function refreshSideMenuHook() { - // - FHC_AjaxClient.ajaxCallGet( - 'system/infocenter/InfoCenter/setNavigationMenuArrayJson', - { - navigation_page: FHC_NavigationWidget._getNavigationWidgetCalled() - }, - { - successCallback: function(data, textStatus, jqXHR) { - FHC_NavigationWidget.renderSideMenu(); - }, - errorCallback: function(jqXHR, textStatus, errorThrown) { - alert(textStatus); - } - } - ); + FHC_NavigationWidget.refreshSideMenuHook('system/infocenter/InfoCenter/setNavigationMenuArrayJson'); } /**