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('