From 9cb106227521587a2950a29a0c364a7beefb7d9b Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 11 Jul 2019 12:59:30 +0200 Subject: [PATCH] Added new option hideMenu to FilterWidget --- application/libraries/FilterWidgetLib.php | 1 + application/views/widgets/filter/filter.php | 4 +- .../views/widgets/filter/filterOptions.php | 2 + application/widgets/FilterWidget.php | 18 ++++- public/js/FilterWidget.js | 69 ++++++++++++------- 5 files changed, 63 insertions(+), 31 deletions(-) diff --git a/application/libraries/FilterWidgetLib.php b/application/libraries/FilterWidgetLib.php index c8a0134bd..f60a28e23 100644 --- a/application/libraries/FilterWidgetLib.php +++ b/application/libraries/FilterWidgetLib.php @@ -60,6 +60,7 @@ class FilterWidgetLib const HIDE_SAVE = 'hideSave'; const CUSTOM_MENU = 'customMenu'; // ...to specify if the menu for this filter is custom (true) or not (false) + const HIDE_MENU = 'hideMenu'; // ...to specify if the menu should be shown or not // ...to specify how to represent the dataset (ex: tablesorter, pivotUI, ...) const DATASET_REPRESENTATION = 'datasetRepresentation'; diff --git a/application/views/widgets/filter/filter.php b/application/views/widgets/filter/filter.php index 34469747a..9c05581ff 100644 --- a/application/views/widgets/filter/filter.php +++ b/application/views/widgets/filter/filter.php @@ -8,13 +8,11 @@ -
-
-
+
diff --git a/application/views/widgets/filter/filterOptions.php b/application/views/widgets/filter/filterOptions.php index 4d8fbde65..6f1dd3885 100644 --- a/application/views/widgets/filter/filterOptions.php +++ b/application/views/widgets/filter/filterOptions.php @@ -31,3 +31,5 @@
+ +
diff --git a/application/widgets/FilterWidget.php b/application/widgets/FilterWidget.php index cb42995d5..828cd194d 100644 --- a/application/widgets/FilterWidget.php +++ b/application/widgets/FilterWidget.php @@ -48,6 +48,7 @@ class FilterWidget extends Widget private $_hideSelectFilters; // if true hides the filters selections private $_hideSave; // if true hides the GUI to save a custom filter + private $_hideMenu; // if true then the menu is not shown private $_customMenu; // if true then method _setFilterMenu is NOT called private $_datasetRepresentation; // dataset representation (ex: tablesorter, pivotUI, ...) @@ -78,7 +79,7 @@ class FilterWidget extends Widget $this->_startFilterWidget(); // If a custom menu is not used, then default menu is used - if ($this->_customMenu != true) $this->_setFilterMenu(); + if ($this->_hideMenu != true && $this->_customMenu != true) $this->_setFilterMenu(); } } @@ -90,7 +91,11 @@ class FilterWidget extends Widget */ public function display($widgetData) { - $this->view(self::WIDGET_URL_FILTER); // GUI starts here + $this->view(self::WIDGET_URL_FILTER, array( + 'app' => $this->_app, + 'dataset' => $this->_datasetName, + 'filterid' => $this->_filterId + )); // GUI starts here } //------------------------------------------------------------------------------------------------------------------ @@ -190,6 +195,7 @@ class FilterWidget extends Widget $this->_hideSelectFields = null; $this->_hideSelectFilters = null; $this->_hideSave = null; + $this->_hideMenu = null; $this->_customMenu = null; $this->_datasetRepresentation = null; $this->_datasetRepresentationOptions = null; @@ -292,6 +298,12 @@ class FilterWidget extends Widget $this->_hideSave = $args[FilterWidgetLib::HIDE_SAVE]; } + // If the menu should be shown or not + if (isset($args[FilterWidgetLib::HIDE_MENU]) && is_bool($args[FilterWidgetLib::HIDE_MENU])) + { + $this->_hideMenu = $args[FilterWidgetLib::HIDE_MENU]; + } + // If a custom menu is set if (isset($args[FilterWidgetLib::CUSTOM_MENU]) && is_bool($args[FilterWidgetLib::CUSTOM_MENU])) { @@ -335,7 +347,7 @@ class FilterWidget extends Widget && !isset($args[FilterWidgetLib::FILTER_ID])) { show_error( - 'The parameters ("'.FilterWidgetLib::APP_PARAMETER.'" and "'.FilterWidgetLib::DATASET_NAME_PARAMETER.') OR "'. + 'The parameters ("'.FilterWidgetLib::APP_PARAMETER.'" AND "'.FilterWidgetLib::DATASET_NAME_PARAMETER.') OR "'. FilterWidgetLib::FILTER_ID.'" must be specified' ); } diff --git a/public/js/FilterWidget.js b/public/js/FilterWidget.js index 48e009047..747843b0d 100644 --- a/public/js/FilterWidget.js +++ b/public/js/FilterWidget.js @@ -33,34 +33,38 @@ function refreshSideMenuHook() */ function sideMenuHook() { - $(".remove-custom-filter").click(function() { + // If menu is present + if (FHC_FilterWidget._hideMenu != true) + { + $(".remove-custom-filter").click(function() { - // Ajax call to remove a custom filter - FHC_AjaxClient.ajaxCallPost( - "widgets/Filters/removeCustomFilter", - { - filter_id: $(this).attr("value"), // filter_id of the filter to be removed - filter_page: FHC_FilterWidget.getFilterPage() - }, - { - successCallback: function(data, textStatus, jqXHR) { + // Ajax call to remove a custom filter + FHC_AjaxClient.ajaxCallPost( + "widgets/Filters/removeCustomFilter", + { + filter_id: $(this).attr("value"), // filter_id of the filter to be removed + filter_page: FHC_FilterWidget.getFilterPage() + }, + { + successCallback: function(data, textStatus, jqXHR) { - if (FHC_AjaxClient.isError(data)) - { - console.log(FHC_AjaxClient.getError(data)); - } - else - { - // If a success and refreshSideMenuHook is a valid function then call it to refresh the side menu - if (typeof refreshSideMenuHook == "function") + if (FHC_AjaxClient.isError(data)) { - refreshSideMenuHook(); + console.log(FHC_AjaxClient.getError(data)); + } + else + { + // If a success and refreshSideMenuHook is a valid function then call it to refresh the side menu + if (typeof refreshSideMenuHook == "function") + { + refreshSideMenuHook(); + } } } } - } - ); - }); + ); + }); + } } //-------------------------------------------------------------------------------------------------------------------- @@ -215,6 +219,7 @@ var FHC_FilterWidget = { FHC_FilterWidget._initSessionStorage(); // initialize the session storage FHC_FilterWidget._setDatasetRepresentation(data); // set what type of dataset representation was choosen + FHC_FilterWidget._setHideMenu(data); // sets the _hideMenu property FHC_FilterWidget._turnOffEvents(); // turns all the events off FHC_FilterWidget._resetGUI(); // Reset the entire GUI @@ -559,10 +564,13 @@ var FHC_FilterWidget = { }, { successCallback: function(data, textStatus, jqXHR) { - // If a success and refreshSideMenuHook is a valid function then call it to refresh the side menu - if (typeof refreshSideMenuHook == "function") + if (FHC_FilterWidget._hideMenu != true) { - refreshSideMenuHook(); + // If a success and refreshSideMenuHook is a valid function then call it to refresh the side menu + if (typeof refreshSideMenuHook == "function") + { + refreshSideMenuHook(); + } } } } @@ -1197,6 +1205,17 @@ var FHC_FilterWidget = { { FHC_FilterWidget._datasetRepresentation = data.datasetRepresentation; } + }, + + /** + * Set what type of dataset representation was choosen + */ + _setHideMenu: function(data) { + + if (data.hasOwnProperty("hideMenu")) + { + FHC_FilterWidget._hideMenu = data.hideMenu; + } } };