diff --git a/application/controllers/system/Filters.php b/application/controllers/system/Filters.php index 3bdb6dde2..b29bd2bb0 100644 --- a/application/controllers/system/Filters.php +++ b/application/controllers/system/Filters.php @@ -216,6 +216,16 @@ class Filters extends FHC_Controller $this->outputJsonSuccess('Success'); } + /** + * Reloads the dataset + */ + public function reloadDataset() + { + $this->filterslib->reloadDataset(); + + $this->outputJsonSuccess('Success'); + } + //------------------------------------------------------------------------------------------------------------------ // Private methods diff --git a/application/libraries/FiltersLib.php b/application/libraries/FiltersLib.php index 6346150d8..6875d16ec 100644 --- a/application/libraries/FiltersLib.php +++ b/application/libraries/FiltersLib.php @@ -528,6 +528,14 @@ class FiltersLib return $applyFilters; } + /** + * Reloads dataset by setting session variable to true + */ + public function reloadDataset() + { + $this->setSessionElement(self::SESSION_RELOAD_DATASET, true); + } + /** * Add a filter (SQL where clause) to be applied to the current filter */ diff --git a/public/js/FilterWidget.js b/public/js/FilterWidget.js index 767cd228a..6aad74562 100644 --- a/public/js/FilterWidget.js +++ b/public/js/FilterWidget.js @@ -92,7 +92,7 @@ var FHC_FilterWidget = { }, /** - * Alias call to method display only to inprove the readability of the code + * Alias call to method display only to improve the readability of the code */ refresh: function() { @@ -100,13 +100,30 @@ var FHC_FilterWidget = { }, /** - * To retrive the page where the FilterWidget is used, using the FHC_JS_DATA_STORAGE_OBJECT + * To retrieve the page where the FilterWidget is used, using the FHC_JS_DATA_STORAGE_OBJECT */ getFilterPage: function() { return FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method; }, + /** + * Reload of dataset, also reloads page to show changes + */ + reloadDataset: function() { + FHC_AjaxClient.ajaxCallPost( + "system/Filters/reloadDataset", + { + filter_page: FHC_FilterWidget.getFilterPage() + }, + { + successCallback: function(data, textStatus, jqXHR) { + FHC_FilterWidget._failOrReload(data); + } + } + ); + }, + //------------------------------------------------------------------------------------------------------------------ // Private methods @@ -197,7 +214,7 @@ var FHC_FilterWidget = { }, /** - * This method calls all the other methods needed to rendere the GUI for a FilterWidget + * This method calls all the other methods needed to render the GUI for a FilterWidget * The parameter data contains all the data about the FilterWidget and it is given as parameter * to all the methods that here are called * NOTE: think very carefully before changing the order of the calls