Added new option hideMenu to FilterWidget

This commit is contained in:
Paolo
2019-07-11 12:59:30 +02:00
parent 31caf460ec
commit 9cb1062275
5 changed files with 63 additions and 31 deletions
@@ -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';
+1 -3
View File
@@ -8,13 +8,11 @@
<?php FilterWidget::loadViewFilterOptions(); ?>
<br>
<!-- Filter info top -->
<div id="datasetActionsTop"></div>
<!-- Filter table -->
<div>
<div id="divFilterWidgetDataset" app="<?php echo $app; ?>" dataset="<?php echo $dataset; ?>" filterid="<?php echo $filterid; ?>">
<?php FilterWidget::loadViewDataset(); ?>
</div>
@@ -31,3 +31,5 @@
</div>
</div>
</div>
<br>
+15 -3
View File
@@ -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'
);
}
+44 -25
View File
@@ -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;
}
}
};