- Moved controller system/Filters to widgets/Filters

- Renamed FiltersLib to FilterWidgetLib
- Adapted code in widgets/FilterWidget, public/js/FilterWidget.js and public/js/infocenter/infocenterPersonDataset.js
This commit is contained in:
Paolo
2019-07-10 14:39:59 +02:00
parent 7050def0bb
commit 2daf745ad5
5 changed files with 134 additions and 138 deletions
@@ -3,7 +3,7 @@
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* This controller operates between (interface) the JS (GUI) and the FiltersLib (back-end)
* This controller operates between (interface) the JS (GUI) and the FilterWidgetLib (back-end)
* Provides data to the ajax get calls about the filter
* Accepts ajax post calls to change the filter data
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
@@ -15,7 +15,7 @@ class Filters extends FHC_Controller
const FILTER_PAGE_PARAM = 'filter_page';
/**
* Calls the parent's constructor and loads the FiltersLib
* Calls the parent's constructor and loads the FilterWidgetLib
*/
public function __construct()
{
@@ -24,8 +24,8 @@ class Filters extends FHC_Controller
// Loads authentication library and starts authentication
$this->load->library('AuthLib');
// Loads the FiltersLib with HTTP GET/POST parameters
$this->_loadFiltersLib();
// Loads the FilterWidgetLib with HTTP GET/POST parameters
$this->_loadFilterWidgetLib();
// Checks if the caller is allow to read this data
$this->_isAllowed();
@@ -39,7 +39,7 @@ class Filters extends FHC_Controller
*/
public function getFilter()
{
$this->outputJsonSuccess($this->filterslib->getSession());
$this->outputJsonSuccess($this->filterwidgetlib->getSession());
}
/**
@@ -48,7 +48,7 @@ class Filters extends FHC_Controller
public function rowNumber()
{
$rowNumber = 0;
$dataset = $this->filterslib->getSessionElement(FiltersLib::SESSION_DATASET);
$dataset = $this->filterwidgetlib->getSessionElement(FilterWidgetLib::SESSION_DATASET);
if (isset($dataset) && is_array($dataset))
{
@@ -66,7 +66,7 @@ class Filters extends FHC_Controller
{
$selectedFields = $this->input->post('selectedFields');
if ($this->filterslib->sortSelectedFields($selectedFields) == true)
if ($this->filterwidgetlib->sortSelectedFields($selectedFields) == true)
{
$this->getFilter();
}
@@ -84,7 +84,7 @@ class Filters extends FHC_Controller
{
$selectedField = $this->input->post('selectedField');
if ($this->filterslib->removeSelectedField($selectedField) == true)
if ($this->filterwidgetlib->removeSelectedField($selectedField) == true)
{
$this->getFilter();
}
@@ -101,7 +101,7 @@ class Filters extends FHC_Controller
{
$selectedField = $this->input->post('selectedField');
if ($this->filterslib->addSelectedField($selectedField) == true)
if ($this->filterwidgetlib->addSelectedField($selectedField) == true)
{
$this->getFilter();
}
@@ -118,7 +118,7 @@ class Filters extends FHC_Controller
{
$appliedFilter = $this->input->post('appliedFilter');
if ($this->filterslib->removeAppliedFilter($appliedFilter) == true)
if ($this->filterwidgetlib->removeAppliedFilter($appliedFilter) == true)
{
$this->outputJsonSuccess('Removed');
}
@@ -138,7 +138,7 @@ class Filters extends FHC_Controller
$appliedFiltersConditions = $this->input->post('appliedFiltersConditions');
$appliedFiltersOptions = $this->input->post('appliedFiltersOptions');
if ($this->filterslib->applyFilters(
if ($this->filterwidgetlib->applyFilters(
$appliedFilters,
$appliedFiltersOperations,
$appliedFiltersConditions,
@@ -160,7 +160,7 @@ class Filters extends FHC_Controller
{
$filter = $this->input->post('filter');
if ($this->filterslib->addFilter($filter) == true)
if ($this->filterwidgetlib->addFilter($filter) == true)
{
$this->getFilter();
}
@@ -177,7 +177,7 @@ class Filters extends FHC_Controller
{
$customFilterDescription = $this->input->post('customFilterDescription');
if ($this->filterslib->saveCustomFilter($customFilterDescription) == true)
if ($this->filterwidgetlib->saveCustomFilter($customFilterDescription) == true)
{
$this->outputJsonSuccess('Saved');
}
@@ -194,7 +194,7 @@ class Filters extends FHC_Controller
{
$filter_id = $this->input->post('filter_id');
if ($this->filterslib->removeCustomFilter($filter_id) == true)
if ($this->filterwidgetlib->removeCustomFilter($filter_id) == true)
{
$this->outputJsonSuccess('Removed');
}
@@ -211,7 +211,7 @@ class Filters extends FHC_Controller
public function setNavigationMenu()
{
// Generates the filters structure array
$filterMenu = $this->filterslib->generateFilterMenu($this->input->get(FiltersLib::NAVIGATION_PAGE));
$filterMenu = $this->filterwidgetlib->generateFilterMenu($this->input->get(FilterWidgetLib::NAVIGATION_PAGE));
$this->outputJsonSuccess('Success');
}
@@ -224,18 +224,18 @@ class Filters extends FHC_Controller
*/
private function _isAllowed()
{
if (!$this->filterslib->isAllowed())
if (!$this->filterwidgetlib->isAllowed())
{
$this->terminateWithJsonError('You are not allowed to access to this content');
}
}
/**
* Loads the FiltersLib with the FILTER_PAGE_PARAM parameter
* Loads the FilterWidgetLib with the FILTER_PAGE_PARAM parameter
* If the parameter FILTER_PAGE_PARAM is not given then the execution of the controller is terminated and
* an error message is printed
*/
private function _loadFiltersLib()
private function _loadFilterWidgetLib()
{
// If the parameter FILTER_PAGE_PARAM is present in the HTTP GET or POST
if (isset($_GET[self::FILTER_PAGE_PARAM]) || isset($_POST[self::FILTER_PAGE_PARAM]))
@@ -250,8 +250,8 @@ class Filters extends FHC_Controller
$filterPage = $this->input->post(self::FILTER_PAGE_PARAM); // is retrieved from the HTTP POST
}
// Loads the FiltersLib that contains all the used logic
$this->load->library('FiltersLib', array(self::FILTER_PAGE_PARAM => $filterPage));
// Loads the FilterWidgetLib that contains all the used logic
$this->load->library('FilterWidgetLib', array(self::FILTER_PAGE_PARAM => $filterPage));
}
else // Otherwise an error will be written in the output
{
@@ -5,7 +5,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* FilterWidget logic
*/
class FiltersLib
class FilterWidgetLib
{
// Session parameters names
const SESSION_NAME = 'FHC_FILTER_WIDGET'; // Filter session name
@@ -684,7 +684,7 @@ class FiltersLib
public function generateFilterMenu($navigationPage)
{
// Loads the NavigationLib for the current page (given as parameter)
$this->_ci->load->library('NavigationLib', array(FiltersLib::NAVIGATION_PAGE => $navigationPage));
$this->_ci->load->library('NavigationLib', array(FilterWidgetLib::NAVIGATION_PAGE => $navigationPage));
$filterMenu = null;
$currentMenu = $this->_ci->navigationlib->getSessionMenu(); // The navigation menu currently stored in session
@@ -766,7 +766,7 @@ class FiltersLib
);
// Sets in the session only the element related to the filters menu
$this->_ci->navigationlib->setSessionElementMenu(FiltersLib::NAV_MENU_FILTER_KEY, $filterMenu);
$this->_ci->navigationlib->setSessionElementMenu(FilterWidgetLib::NAV_MENU_FILTER_KEY, $filterMenu);
}
}
}
+100 -104
View File
@@ -64,13 +64,13 @@ class FilterWidget extends Widget
self::$_FilterWidgetInstance = $this; // set static property $_FilterWidgetInstance with this instance
$this->load->library('FiltersLib'); // Loads the FiltersLib that contains all the used logic
$this->load->library('FilterWidgetLib'); // Loads the FilterWidgetLib that contains all the used logic
$this->_initFilterWidget($args); // checks parameters and initialize properties
// Let's start if it's allowed
// NOTE: If it is NOT allowed then no data are loaded
if ($this->filterslib->isAllowed($this->_requiredPermissions))
if ($this->filterwidgetlib->isAllowed($this->_requiredPermissions))
{
$this->_startFilterWidget();
@@ -131,17 +131,17 @@ class FilterWidget extends Widget
*/
public static function loadViewDataset()
{
if (self::$_FilterWidgetInstance->_datasetRepresentation == FiltersLib::DATASET_REP_TABLESORTER)
if (self::$_FilterWidgetInstance->_datasetRepresentation == FilterWidgetLib::DATASET_REP_TABLESORTER)
{
self::_loadView(self::WIDGET_URL_DATASET_TABLESORTER);
}
if (self::$_FilterWidgetInstance->_datasetRepresentation == FiltersLib::DATASET_REP_PIVOTUI)
if (self::$_FilterWidgetInstance->_datasetRepresentation == FilterWidgetLib::DATASET_REP_PIVOTUI)
{
self::_loadView(self::WIDGET_URL_DATASET_PIVOTUI);
}
if (self::$_FilterWidgetInstance->_datasetRepresentation == FiltersLib::DATASET_REP_TABULATOR)
if (self::$_FilterWidgetInstance->_datasetRepresentation == FilterWidgetLib::DATASET_REP_TABULATOR)
{
self::_loadView(self::WIDGET_URL_DATASET_TABULATOR);
}
@@ -180,115 +180,115 @@ class FilterWidget extends Widget
$this->_datasetRepFieldsDefs = null;
// Retrieved the required permissions parameter if present
if (isset($args[FiltersLib::REQUIRED_PERMISSIONS_PARAMETER]))
if (isset($args[FilterWidgetLib::REQUIRED_PERMISSIONS_PARAMETER]))
{
$this->_requiredPermissions = $args[FiltersLib::REQUIRED_PERMISSIONS_PARAMETER];
$this->_requiredPermissions = $args[FilterWidgetLib::REQUIRED_PERMISSIONS_PARAMETER];
}
// Parameters needed to retrieve univocally a filter from DB
if (isset($args[FiltersLib::APP_PARAMETER]))
if (isset($args[FilterWidgetLib::APP_PARAMETER]))
{
$this->_app = $args[FiltersLib::APP_PARAMETER];
$this->_app = $args[FilterWidgetLib::APP_PARAMETER];
}
if (isset($args[FiltersLib::DATASET_NAME_PARAMETER]))
if (isset($args[FilterWidgetLib::DATASET_NAME_PARAMETER]))
{
$this->_datasetName = $args[FiltersLib::DATASET_NAME_PARAMETER];
$this->_datasetName = $args[FilterWidgetLib::DATASET_NAME_PARAMETER];
}
if (isset($args[FiltersLib::FILTER_KURZBZ_PARAMETER]))
if (isset($args[FilterWidgetLib::FILTER_KURZBZ_PARAMETER]))
{
$this->_filterKurzbz = $args[FiltersLib::FILTER_KURZBZ_PARAMETER];
$this->_filterKurzbz = $args[FilterWidgetLib::FILTER_KURZBZ_PARAMETER];
}
if (isset($args[FiltersLib::FILTER_ID]))
if (isset($args[FilterWidgetLib::FILTER_ID]))
{
$this->_filterId = $args[FiltersLib::FILTER_ID];
$this->_filterId = $args[FilterWidgetLib::FILTER_ID];
}
// How to retrieve data for the filter: SQL statement or a result from DB
if (isset($args[FiltersLib::QUERY_PARAMETER]))
if (isset($args[FilterWidgetLib::QUERY_PARAMETER]))
{
$this->_query = $args[FiltersLib::QUERY_PARAMETER];
$this->_query = $args[FilterWidgetLib::QUERY_PARAMETER];
}
if (isset($args[FiltersLib::DATASET_RELOAD_PARAMETER]))
if (isset($args[FilterWidgetLib::DATASET_RELOAD_PARAMETER]))
{
$this->_reloadDataset = $args[FiltersLib::DATASET_RELOAD_PARAMETER];
$this->_reloadDataset = $args[FilterWidgetLib::DATASET_RELOAD_PARAMETER];
}
// Parameter is used to add extra columns to the dataset
if (isset($args[FiltersLib::ADDITIONAL_COLUMNS])
&& is_array($args[FiltersLib::ADDITIONAL_COLUMNS])
&& count($args[FiltersLib::ADDITIONAL_COLUMNS]) > 0)
if (isset($args[FilterWidgetLib::ADDITIONAL_COLUMNS])
&& is_array($args[FilterWidgetLib::ADDITIONAL_COLUMNS])
&& count($args[FilterWidgetLib::ADDITIONAL_COLUMNS]) > 0)
{
$this->_additionalColumns = $args[FiltersLib::ADDITIONAL_COLUMNS];
$this->_additionalColumns = $args[FilterWidgetLib::ADDITIONAL_COLUMNS];
}
// Parameter is used to add use aliases for the columns fo the dataset
if (isset($args[FiltersLib::COLUMNS_ALIASES])
&& is_array($args[FiltersLib::COLUMNS_ALIASES])
&& count($args[FiltersLib::COLUMNS_ALIASES]) > 0)
if (isset($args[FilterWidgetLib::COLUMNS_ALIASES])
&& is_array($args[FilterWidgetLib::COLUMNS_ALIASES])
&& count($args[FilterWidgetLib::COLUMNS_ALIASES]) > 0)
{
$this->_columnsAliases = $args[FiltersLib::COLUMNS_ALIASES];
$this->_columnsAliases = $args[FilterWidgetLib::COLUMNS_ALIASES];
}
// Parameter that contains a function to format the rows of the dataset
if (isset($args[FiltersLib::FORMAT_ROW]) && is_callable($args[FiltersLib::FORMAT_ROW]))
if (isset($args[FilterWidgetLib::FORMAT_ROW]) && is_callable($args[FilterWidgetLib::FORMAT_ROW]))
{
$this->_formatRow = $args[FiltersLib::FORMAT_ROW];
$this->_formatRow = $args[FilterWidgetLib::FORMAT_ROW];
}
// Parameter that contains a function to mark in the GUI the rows of the dataset
if (isset($args[FiltersLib::MARK_ROW]) && is_callable($args[FiltersLib::MARK_ROW]))
if (isset($args[FilterWidgetLib::MARK_ROW]) && is_callable($args[FilterWidgetLib::MARK_ROW]))
{
$this->_markRow = $args[FiltersLib::MARK_ROW];
$this->_markRow = $args[FilterWidgetLib::MARK_ROW];
}
// Parameter used to specify the column of the dataset that will be used
// as id of the checkboxes column in the GUI
if (isset($args[FiltersLib::CHECKBOXES]))
if (isset($args[FilterWidgetLib::CHECKBOXES]))
{
$this->_checkboxes = $args[FiltersLib::CHECKBOXES];
$this->_checkboxes = $args[FilterWidgetLib::CHECKBOXES];
}
// To specify if the header to operate with the FilterWidget is shown or not
if (isset($args[FiltersLib::HIDE_HEADER]) && is_bool($args[FiltersLib::HIDE_HEADER]))
if (isset($args[FilterWidgetLib::HIDE_HEADER]) && is_bool($args[FilterWidgetLib::HIDE_HEADER]))
{
$this->_hideHeader = $args[FiltersLib::HIDE_HEADER];
$this->_hideHeader = $args[FilterWidgetLib::HIDE_HEADER];
}
// To specify if the form to save a custom FilterWidget is shown or not
if (isset($args[FiltersLib::HIDE_SAVE]) && is_bool($args[FiltersLib::HIDE_SAVE]))
if (isset($args[FilterWidgetLib::HIDE_SAVE]) && is_bool($args[FilterWidgetLib::HIDE_SAVE]))
{
$this->_hideSave = $args[FiltersLib::HIDE_SAVE];
$this->_hideSave = $args[FilterWidgetLib::HIDE_SAVE];
}
// If a custom menu is set
if (isset($args[FiltersLib::CUSTOM_MENU]) && is_bool($args[FiltersLib::CUSTOM_MENU]))
if (isset($args[FilterWidgetLib::CUSTOM_MENU]) && is_bool($args[FilterWidgetLib::CUSTOM_MENU]))
{
$this->_customMenu = $args[FiltersLib::CUSTOM_MENU];
$this->_customMenu = $args[FilterWidgetLib::CUSTOM_MENU];
}
// To specify how to represent the dataset (ex: tablesorter, pivotUI, ...)
if (isset($args[FiltersLib::DATASET_REPRESENTATION])
&& ($args[FiltersLib::DATASET_REPRESENTATION] == FiltersLib::DATASET_REP_TABLESORTER
|| $args[FiltersLib::DATASET_REPRESENTATION] == FiltersLib::DATASET_REP_PIVOTUI
|| $args[FiltersLib::DATASET_REPRESENTATION] == FiltersLib::DATASET_REP_TABULATOR))
if (isset($args[FilterWidgetLib::DATASET_REPRESENTATION])
&& ($args[FilterWidgetLib::DATASET_REPRESENTATION] == FilterWidgetLib::DATASET_REP_TABLESORTER
|| $args[FilterWidgetLib::DATASET_REPRESENTATION] == FilterWidgetLib::DATASET_REP_PIVOTUI
|| $args[FilterWidgetLib::DATASET_REPRESENTATION] == FilterWidgetLib::DATASET_REP_TABULATOR))
{
$this->_datasetRepresentation = $args[FiltersLib::DATASET_REPRESENTATION];
$this->_datasetRepresentation = $args[FilterWidgetLib::DATASET_REPRESENTATION];
}
// To specify options for the dataset representation (ex: tablesorter, pivotUI, ...)
if (isset($args[FiltersLib::DATASET_REP_OPTIONS]) && !isEmptyString($args[FiltersLib::DATASET_REP_OPTIONS]))
if (isset($args[FilterWidgetLib::DATASET_REP_OPTIONS]) && !isEmptyString($args[FilterWidgetLib::DATASET_REP_OPTIONS]))
{
$this->_datasetRepresentationOptions = $args[FiltersLib::DATASET_REP_OPTIONS];
$this->_datasetRepresentationOptions = $args[FilterWidgetLib::DATASET_REP_OPTIONS];
}
// To specify how to represent each record field
if (isset($args[FiltersLib::DATASET_REP_FIELDS_DEFS]) && !isEmptyString($args[FiltersLib::DATASET_REP_FIELDS_DEFS]))
if (isset($args[FilterWidgetLib::DATASET_REP_FIELDS_DEFS]) && !isEmptyString($args[FilterWidgetLib::DATASET_REP_FIELDS_DEFS]))
{
$this->_datasetRepFieldsDefs = $args[FiltersLib::DATASET_REP_FIELDS_DEFS];
$this->_datasetRepFieldsDefs = $args[FilterWidgetLib::DATASET_REP_FIELDS_DEFS];
}
}
@@ -303,36 +303,36 @@ class FilterWidget extends Widget
}
else
{
if ((!isset($args[FiltersLib::APP_PARAMETER]) && !isset($args[FiltersLib::DATASET_NAME_PARAMETER]))
&& !isset($args[FiltersLib::FILTER_ID]))
if ((!isset($args[FilterWidgetLib::APP_PARAMETER]) && !isset($args[FilterWidgetLib::DATASET_NAME_PARAMETER]))
&& !isset($args[FilterWidgetLib::FILTER_ID]))
{
show_error(
'The parameters ("'.FiltersLib::APP_PARAMETER.'" and "'.FiltersLib::DATASET_NAME_PARAMETER.') OR "'.
FiltersLib::FILTER_ID.'" must be specified'
'The parameters ("'.FilterWidgetLib::APP_PARAMETER.'" and "'.FilterWidgetLib::DATASET_NAME_PARAMETER.') OR "'.
FilterWidgetLib::FILTER_ID.'" must be specified'
);
}
if (!isset($args[FiltersLib::QUERY_PARAMETER]))
if (!isset($args[FilterWidgetLib::QUERY_PARAMETER]))
{
show_error('The parameters "'.FiltersLib::QUERY_PARAMETER.'" must be specified');
show_error('The parameters "'.FilterWidgetLib::QUERY_PARAMETER.'" must be specified');
}
if (!isset($args[FiltersLib::DATASET_REPRESENTATION]))
if (!isset($args[FilterWidgetLib::DATASET_REPRESENTATION]))
{
show_error('The parameter "'.FiltersLib::DATASET_REPRESENTATION.'" must be specified');
show_error('The parameter "'.FilterWidgetLib::DATASET_REPRESENTATION.'" must be specified');
}
if (isset($args[FiltersLib::DATASET_REPRESENTATION])
&& $args[FiltersLib::DATASET_REPRESENTATION] != FiltersLib::DATASET_REP_TABLESORTER
&& $args[FiltersLib::DATASET_REPRESENTATION] != FiltersLib::DATASET_REP_PIVOTUI
&& $args[FiltersLib::DATASET_REPRESENTATION] != FiltersLib::DATASET_REP_TABULATOR)
if (isset($args[FilterWidgetLib::DATASET_REPRESENTATION])
&& $args[FilterWidgetLib::DATASET_REPRESENTATION] != FilterWidgetLib::DATASET_REP_TABLESORTER
&& $args[FilterWidgetLib::DATASET_REPRESENTATION] != FilterWidgetLib::DATASET_REP_PIVOTUI
&& $args[FilterWidgetLib::DATASET_REPRESENTATION] != FilterWidgetLib::DATASET_REP_TABULATOR)
{
show_error(
'The parameter "'.FiltersLib::DATASET_REPRESENTATION.
'The parameter "'.FilterWidgetLib::DATASET_REPRESENTATION.
'" must be IN ("'
.FiltersLib::DATASET_REP_TABLESORTER.'", "'
.FiltersLib::DATASET_REP_PIVOTUI.'", "'
.FiltersLib::DATASET_REP_TABULATOR.'")'
.FilterWidgetLib::DATASET_REP_TABLESORTER.'", "'
.FilterWidgetLib::DATASET_REP_PIVOTUI.'", "'
.FilterWidgetLib::DATASET_REP_TABULATOR.'")'
);
}
}
@@ -344,51 +344,49 @@ class FilterWidget extends Widget
private function _startFilterWidget()
{
// Read the all session for this filter widget
$session = $this->filterslib->getSession();
$session = $this->filterwidgetlib->getSession();
// If session is NOT empty -> a filter was already loaded
if ($session != null)
{
// Retrieve the filterId stored in the session
$sessionFilterId = $this->filterslib->getSessionElement(FiltersLib::FILTER_ID);
$sessionFilterId = $this->filterwidgetlib->getSessionElement(FilterWidgetLib::FILTER_ID);
// If the filter loaded in session is NOT the same that is being requested then empty the session
if ($this->_filterId != $sessionFilterId)
{
$this->filterslib->setSession(null);
$this->filterwidgetlib->setSession(null);
$session = null;
}
else // else if the filter loaded in session is the same that is being requested
{
// Get SESSION_RELOAD_DATASET from the session
$sessionReloadDataset = $this->filterslib->getSessionElement(FiltersLib::SESSION_RELOAD_DATASET);
$sessionReloadDataset = $this->filterwidgetlib->getSessionElement(FilterWidgetLib::SESSION_RELOAD_DATASET);
// if Filter changed or reload is forced by parameter then reload the Dataset
if ($this->_reloadDataset === true || $sessionReloadDataset === true)
{
// Set as false to stop changing the dataset
$this->filterslib->setSessionElement(FiltersLib::SESSION_RELOAD_DATASET, false);
$this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_RELOAD_DATASET, false);
// Generate dataset query using filters from the session
$datasetQuery = $this->filterslib->generateDatasetQuery(
$datasetQuery = $this->filterwidgetlib->generateDatasetQuery(
$this->_query,
$this->filterslib->getSessionElement(FiltersLib::SESSION_FILTERS)
$this->filterwidgetlib->getSessionElement(FilterWidgetLib::SESSION_FILTERS)
);
// Then retrieve dataset from DB
$dataset = $this->filterslib->getDataset($datasetQuery);
$dataset = $this->filterwidgetlib->getDataset($datasetQuery);
// Save changes into session if data are valid
if (!isError($dataset))
{
$this->_formatDataset($dataset); // marks rows using markRow and format rowns using formatRow
$this->load->model('system/Filters_model', 'FiltersModel');
// Set the new dataset and its attributes in the session
$this->filterslib->setSessionElement(FiltersLib::SESSION_METADATA, $this->FiltersModel->getExecutedQueryMetaData());
$this->filterslib->setSessionElement(FiltersLib::SESSION_ROW_NUMBER, count($dataset->retval));
$this->filterslib->setSessionElement(FiltersLib::SESSION_DATASET, $dataset->retval);
$this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_METADATA, $this->FiltersModel->getExecutedQueryMetaData());
$this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_ROW_NUMBER, count($dataset->retval));
$this->filterwidgetlib->setSessionElement(FilterWidgetLib::SESSION_DATASET, $dataset->retval);
}
}
}
@@ -398,7 +396,7 @@ class FilterWidget extends Widget
if ($session == null)
{
// Load filter definition data from DB
$definition = $this->filterslib->loadDefinition(
$definition = $this->filterwidgetlib->loadDefinition(
$this->_filterId,
$this->_app,
$this->_datasetName,
@@ -406,45 +404,43 @@ class FilterWidget extends Widget
);
// Checks and parse json present into the definition
$parsedFilterJson = $this->filterslib->parseFilterJson($definition);
$parsedFilterJson = $this->filterwidgetlib->parseFilterJson($definition);
if ($parsedFilterJson != null) // if the json is valid
{
// Generate dataset query
$datasetQuery = $this->filterslib->generateDatasetQuery($this->_query, $parsedFilterJson->filters);
$datasetQuery = $this->filterwidgetlib->generateDatasetQuery($this->_query, $parsedFilterJson->filters);
// Then retrieve dataset from DB
$dataset = $this->filterslib->getDataset($datasetQuery);
$dataset = $this->filterwidgetlib->getDataset($datasetQuery);
// Try to load the name of the filter using the PhrasesLib
$filterName = $this->filterslib->getFilterName($parsedFilterJson);
$filterName = $this->filterwidgetlib->getFilterName($parsedFilterJson);
// Save changes into session if data are valid
if (!isError($dataset))
{
$this->_formatDataset($dataset); // marks rows using markRow and format rowns using formatRow
$this->load->model('system/Filters_model', 'FiltersModel');
// Stores an array that contains all the data useful for
$this->filterslib->setSession(
$this->filterwidgetlib->setSession(
array(
FiltersLib::FILTER_ID => $this->_filterId, // the current filter id
FiltersLib::APP_PARAMETER => $this->_app, // the current app parameter
FiltersLib::DATASET_NAME_PARAMETER => $this->_datasetName, // the carrent dataset name
FiltersLib::SESSION_FILTER_NAME => $filterName, // the current filter name
FiltersLib::SESSION_FIELDS => $this->FiltersModel->getExecutedQueryListFields(), // all the fields of the dataset
FiltersLib::SESSION_SELECTED_FIELDS => $this->_getColumnsNames($parsedFilterJson->columns), // all the selected fields
FiltersLib::SESSION_COLUMNS_ALIASES => $this->_columnsAliases, // all the fields aliases
FiltersLib::SESSION_ADDITIONAL_COLUMNS => $this->_additionalColumns, // additional columns
FiltersLib::SESSION_CHECKBOXES => $this->_checkboxes, // the name of the field used to build the checkboxes column
FiltersLib::SESSION_FILTERS => $parsedFilterJson->filters, // all the filters used to filter the dataset
FiltersLib::SESSION_METADATA => $this->FiltersModel->getExecutedQueryMetaData(), // the metadata of the dataset
FiltersLib::SESSION_ROW_NUMBER => count($dataset->retval), // the number of loaded rows by this filter
FiltersLib::SESSION_DATASET => $dataset->retval, // the entire dataset
FiltersLib::SESSION_RELOAD_DATASET => false, // if the dataset must be reloaded, not needed the first time
FiltersLib::SESSION_DATASET_REPRESENTATION => $this->_datasetRepresentation, // the choosen dataset representation
FiltersLib::SESSION_DATASET_REP_OPTIONS => $this->_datasetRepresentationOptions, // the choosen dataset representation options
FiltersLib::SESSION_DATASET_REP_FIELDS_DEFS => $this->_datasetRepFieldsDefs // the choosen dataset representation record fields definition
FilterWidgetLib::FILTER_ID => $this->_filterId, // the current filter id
FilterWidgetLib::APP_PARAMETER => $this->_app, // the current app parameter
FilterWidgetLib::DATASET_NAME_PARAMETER => $this->_datasetName, // the carrent dataset name
FilterWidgetLib::SESSION_FILTER_NAME => $filterName, // the current filter name
FilterWidgetLib::SESSION_FIELDS => $this->FiltersModel->getExecutedQueryListFields(), // all the fields of the dataset
FilterWidgetLib::SESSION_SELECTED_FIELDS => $this->_getColumnsNames($parsedFilterJson->columns), // all the selected fields
FilterWidgetLib::SESSION_COLUMNS_ALIASES => $this->_columnsAliases, // all the fields aliases
FilterWidgetLib::SESSION_ADDITIONAL_COLUMNS => $this->_additionalColumns, // additional columns
FilterWidgetLib::SESSION_CHECKBOXES => $this->_checkboxes, // the name of the field used to build the checkboxes column
FilterWidgetLib::SESSION_FILTERS => $parsedFilterJson->filters, // all the filters used to filter the dataset
FilterWidgetLib::SESSION_METADATA => $this->FiltersModel->getExecutedQueryMetaData(), // the metadata of the dataset
FilterWidgetLib::SESSION_ROW_NUMBER => count($dataset->retval), // the number of loaded rows by this filter
FilterWidgetLib::SESSION_DATASET => $dataset->retval, // the entire dataset
FilterWidgetLib::SESSION_RELOAD_DATASET => false, // if the dataset must be reloaded, not needed the first time
FilterWidgetLib::SESSION_DATASET_REPRESENTATION => $this->_datasetRepresentation, // the choosen dataset representation
FilterWidgetLib::SESSION_DATASET_REP_OPTIONS => $this->_datasetRepresentationOptions, // the choosen dataset representation options
FilterWidgetLib::SESSION_DATASET_REP_FIELDS_DEFS => $this->_datasetRepFieldsDefs // the choosen dataset representation record fields definition
)
);
}
@@ -453,7 +449,7 @@ class FilterWidget extends Widget
// To be always stored in the session, otherwise is not possible to load data from Filters controller
// NOTE: must the latest operation to be performed in the session to be shure that is always present
$this->filterslib->setSessionElement(FiltersLib::REQUIRED_PERMISSIONS_PARAMETER, $this->_requiredPermissions);
$this->filterwidgetlib->setSessionElement(FilterWidgetLib::REQUIRED_PERMISSIONS_PARAMETER, $this->_requiredPermissions);
}
/**
@@ -462,7 +458,7 @@ class FilterWidget extends Widget
private function _setFilterMenu()
{
// Generates the filters structure array
$filterMenu = $this->filterslib->generateFilterMenu(
$filterMenu = $this->filterwidgetlib->generateFilterMenu(
$this->router->directory.$this->router->class.'/'.$this->router->method
);
}
+10 -10
View File
@@ -18,7 +18,7 @@
function refreshSideMenuHook()
{
FHC_NavigationWidget.refreshSideMenuHook(
'system/Filters/setNavigationMenu',
'widgets/Filters/setNavigationMenu',
{
filter_page: FHC_FilterWidget.getFilterPage(),
navigation_page: FHC_NavigationWidget.getNavigationPage()
@@ -37,7 +37,7 @@ function sideMenuHook()
// Ajax call to remove a custom filter
FHC_AjaxClient.ajaxCallPost(
"system/Filters/removeCustomFilter",
"widgets/Filters/removeCustomFilter",
{
filter_id: $(this).attr("value"), // filter_id of the filter to be removed
filter_page: FHC_FilterWidget.getFilterPage()
@@ -181,7 +181,7 @@ var FHC_FilterWidget = {
_getFilter: function(renderFunction) {
FHC_AjaxClient.ajaxCallGet(
"system/Filters/getFilter",
"widgets/Filters/getFilter",
{
filter_page: FHC_FilterWidget.getFilterPage()
},
@@ -376,7 +376,7 @@ var FHC_FilterWidget = {
});
FHC_AjaxClient.ajaxCallPost(
"system/Filters/sortSelectedFields",
"widgets/Filters/sortSelectedFields",
{
selectedFields: arrayDndId,
filter_page: FHC_FilterWidget.getFilterPage()
@@ -397,7 +397,7 @@ var FHC_FilterWidget = {
_revomeSelectedFieldsEvent: function(event) {
FHC_AjaxClient.ajaxCallPost(
"system/Filters/removeSelectedField",
"widgets/Filters/removeSelectedField",
{
selectedField: $(this).attr("fieldToRemove"),
filter_page: FHC_FilterWidget.getFilterPage()
@@ -437,7 +437,7 @@ var FHC_FilterWidget = {
_addFieldEvent: function(event) {
FHC_AjaxClient.ajaxCallPost(
"system/Filters/addSelectedField",
"widgets/Filters/addSelectedField",
{
selectedField: $(this).val(),
filter_page: FHC_FilterWidget.getFilterPage()
@@ -469,7 +469,7 @@ var FHC_FilterWidget = {
});
FHC_AjaxClient.ajaxCallPost(
"system/Filters/applyFilters",
"widgets/Filters/applyFilters",
{
appliedFilters: appliedFilters,
appliedFiltersOperations: appliedFiltersOperations,
@@ -491,7 +491,7 @@ var FHC_FilterWidget = {
_removeAppliedFiltersEvent: function(event) {
FHC_AjaxClient.ajaxCallPost(
"system/Filters/removeAppliedFilter",
"widgets/Filters/removeAppliedFilter",
{
appliedFilter: $(this).attr("filterToRemove"),
filter_page: FHC_FilterWidget.getFilterPage()
@@ -510,7 +510,7 @@ var FHC_FilterWidget = {
_addFilterEvent: function(event) {
FHC_AjaxClient.ajaxCallPost(
"system/Filters/addFilter",
"widgets/Filters/addFilter",
{
filter: $(this).val(),
filter_page: FHC_FilterWidget.getFilterPage()
@@ -552,7 +552,7 @@ var FHC_FilterWidget = {
if ($("#customFilterDescription").val() != "")
{
FHC_AjaxClient.ajaxCallPost(
"system/Filters/saveCustomFilter",
"widgets/Filters/saveCustomFilter",
{
customFilterDescription: $("#customFilterDescription").val(),
filter_page: FHC_FilterWidget.getFilterPage()
@@ -47,7 +47,7 @@ var InfocenterPersonDataset = {
var personcount = 0;
FHC_AjaxClient.ajaxCallGet(
'system/Filters/rowNumber',
'widgets/Filters/rowNumber',
{
filter_page: FHC_FilterWidget.getFilterPage()
},