diff --git a/public/css/AjaxLib.css b/public/css/AjaxLib.css
index d80ab95a6..61c9f9234 100644
--- a/public/css/AjaxLib.css
+++ b/public/css/AjaxLib.css
@@ -1,14 +1,13 @@
.veil {
position: absolute;
+ z-index: 9999;
top: 0;
left: 0;
- height: 98%;
- width: 99%;
+ height: 100%;
+ width: 100%;
background-color: white;
- border-width: 1px;
- border-style: solid;
- border-color: black;
- background-image: url("/public/imgages/loader.gif");
+ border-width: 0px;
+ background-image: url("../images/loader.gif");
background-repeat: no-repeat;
background-position: center;
}
diff --git a/public/js/AjaxLib.js b/public/js/AjaxLib.js
index 3597af7ac..abd079635 100644
--- a/public/js/AjaxLib.js
+++ b/public/js/AjaxLib.js
@@ -37,9 +37,9 @@ const REMOTE_CONTROLLER = "remoteController";
const FHC_CONTROLLER_ID = "fhc_controller_id";
/**
- * Definition and initialization of object FHC_Ajax_Client
+ * Definition and initialization of object FHC_AjaxClient
*/
-var FHC_Ajax_Client = {
+var FHC_AjaxClient = {
//------------------------------------------------------------------------------------------------------------------
// Properties
@@ -54,7 +54,7 @@ var FHC_Ajax_Client = {
* ajaxCallParameters is an object
*/
ajaxCallGet: function(remoteController, controllerParameters, ajaxCallParameters) {
- FHC_Ajax_Client._ajaxCall(remoteController, controllerParameters, HTTP_GET_METHOD, ajaxCallParameters);
+ FHC_AjaxClient._ajaxCall(remoteController, controllerParameters, HTTP_GET_METHOD, ajaxCallParameters);
},
/**
@@ -63,7 +63,7 @@ var FHC_Ajax_Client = {
* ajaxCallParameters is an object
*/
ajaxCallPost: function(remoteController, controllerParameters, ajaxCallParameters) {
- FHC_Ajax_Client._ajaxCall(remoteController, controllerParameters, HTTP_POST_METHOD, ajaxCallParameters);
+ FHC_AjaxClient._ajaxCall(remoteController, controllerParameters, HTTP_POST_METHOD, ajaxCallParameters);
},
/**
@@ -87,7 +87,7 @@ var FHC_Ajax_Client = {
* Checks if the response is an error
*/
isError: function(response) {
- return !FHC_Ajax_Client.isSuccess(response);
+ return !FHC_AjaxClient.isSuccess(response);
},
/**
@@ -96,7 +96,7 @@ var FHC_Ajax_Client = {
hasData: function(response) {
var hasData = false;
- if (FHC_Ajax_Client.isSuccess(response))
+ if (FHC_AjaxClient.isSuccess(response))
{
if ((jQuery.type(response.retval) == "object" && !jQuery.isEmptyObject(response.retval))
|| (jQuery.isArray(response.retval) && response.retval.length > 0)
@@ -116,7 +116,7 @@ var FHC_Ajax_Client = {
getData: function(response) {
var data = null;
- if (FHC_Ajax_Client.hasData(response))
+ if (FHC_AjaxClient.hasData(response))
{
data = response.retval;
}
@@ -147,20 +147,20 @@ var FHC_Ajax_Client = {
showVeil: function(veilTimeout) {
if (typeof veilTimeout == "number")
{
- FHC_Ajax_Client._veilTimeout = veilTimeout;
+ FHC_AjaxClient._veilTimeout = veilTimeout;
}
else
{
- FHC_Ajax_Client._veilTimeout = VEIL_TIMEOUT;
+ FHC_AjaxClient._veilTimeout = VEIL_TIMEOUT;
}
- FHC_Ajax_Client._showVeil();
+ FHC_AjaxClient._showVeil();
},
/**
* Hide a veil that was shown before
*/
hideVeil: function() {
- FHC_Ajax_Client._hideVeil();
+ FHC_AjaxClient._hideVeil();
},
//------------------------------------------------------------------------------------------------------------------
@@ -212,10 +212,10 @@ var FHC_Ajax_Client = {
*/
_onSuccess: function(response, textStatus, jqXHR) {
- FHC_Ajax_Client._printDebug(this._data, response); // debug time!
+ FHC_AjaxClient._printDebug(this._data, response); // debug time!
// Call the success callback saved in _successCallback property
- // NOTE: this is not referred to FHC_Ajax_Client but to the ajax object
+ // NOTE: this is not referred to FHC_AjaxClient but to the ajax object
this._successCallback(response);
},
@@ -224,10 +224,10 @@ var FHC_Ajax_Client = {
*/
_onError: function(jqXHR, textStatus, errorThrown) {
- FHC_Ajax_Client._printDebug(this._data, null, errorThrown); // debug time!
+ FHC_AjaxClient._printDebug(this._data, null, errorThrown); // debug time!
// Call the error callback saved in _errorCallback property
- // NOTE: this is not referred to FHC_Ajax_Client but to the ajax object
+ // NOTE: this is not referred to FHC_AjaxClient but to the ajax object
this._errorCallback(jqXHR, textStatus, errorThrown);
},
@@ -249,12 +249,12 @@ var FHC_Ajax_Client = {
* Method to show the veil
*/
_showVeil: function() {
- if (FHC_Ajax_Client._veilCallersCounter == 0)
+ if (FHC_AjaxClient._veilCallersCounter == 0)
{
$("
").appendTo('body');
}
- FHC_Ajax_Client._veilCallersCounter++;
+ FHC_AjaxClient._veilCallersCounter++;
},
/**
@@ -262,14 +262,14 @@ var FHC_Ajax_Client = {
*/
_hideVeil: function() {
window.setTimeout(function() {
- if (FHC_Ajax_Client._veilCallersCounter >= 0)
+ if (FHC_AjaxClient._veilCallersCounter >= 0)
{
- if (FHC_Ajax_Client._veilCallersCounter > 0)
+ if (FHC_AjaxClient._veilCallersCounter > 0)
{
- FHC_Ajax_Client._veilCallersCounter--;
+ FHC_AjaxClient._veilCallersCounter--;
}
- if (FHC_Ajax_Client._veilCallersCounter == 0)
+ if (FHC_AjaxClient._veilCallersCounter == 0)
{
$(".veil").remove();
}
@@ -319,7 +319,7 @@ var FHC_Ajax_Client = {
if (typeof remoteController == "string" && remoteController.trim() != "")
{
// Is it possible to generate the URL
- if ((url = FHC_Ajax_Client._generateRouterURI(remoteController)) != null)
+ if ((url = FHC_AjaxClient._generateRouterURI(remoteController)) != null)
{
ajaxParameters.url = url;
}
@@ -339,11 +339,10 @@ var FHC_Ajax_Client = {
if (typeof controllerParameters == "object")
{
// Copy the properties of controllerParameters into a new object
- var data = FHC_Ajax_Client._cpObjProps(controllerParameters);
- // Remote controller
- data[REMOTE_CONTROLLER] = remoteController;
+ var data = FHC_AjaxClient._cpObjProps(controllerParameters);
+
// fhc_controller_id is given if present
- data[FHC_CONTROLLER_ID] = FHC_Ajax_Client.getUrlParameter(FHC_CONTROLLER_ID);
+ data[FHC_CONTROLLER_ID] = FHC_AjaxClient.getUrlParameter(FHC_CONTROLLER_ID);
// Stores them into ajaxParameters
// NOTE: property data is not possible to get later,
@@ -367,7 +366,7 @@ var FHC_Ajax_Client = {
if (typeof ajaxCallParameters.errorCallback == "function")
{
ajaxParameters._errorCallback = ajaxCallParameters.errorCallback; // save as property the callback error
- ajaxParameters.error = FHC_Ajax_Client._onError; // function to call if an error occurred
+ ajaxParameters.error = FHC_AjaxClient._onError; // function to call if an error occurred
}
else
{
@@ -382,7 +381,7 @@ var FHC_Ajax_Client = {
if (typeof ajaxCallParameters.successCallback == "function")
{
ajaxParameters._successCallback = ajaxCallParameters.successCallback; // save as property the callback success
- ajaxParameters.success = FHC_Ajax_Client._onSuccess; // function to call if succeeded
+ ajaxParameters.success = FHC_AjaxClient._onSuccess; // function to call if succeeded
}
else
{
@@ -397,8 +396,8 @@ var FHC_Ajax_Client = {
if (ajaxCallParameters.veilTimeout > 0 && ajaxCallParameters.veilTimeout < 60000)
{
ajaxParameters._veilTimeout = ajaxCallParameters.veilTimeout;
- ajaxParameters.beforeSend = FHC_Ajax_Client._showVeil;
- ajaxParameters.complete = FHC_Ajax_Client._hideVeil;
+ ajaxParameters.beforeSend = FHC_AjaxClient._showVeil;
+ ajaxParameters.complete = FHC_AjaxClient._hideVeil;
}
else if(ajaxCallParameters.veilTimeout == 0)
{
@@ -413,8 +412,8 @@ var FHC_Ajax_Client = {
else // is not present or the value is invalid
{
ajaxParameters._veilTimeout = VEIL_TIMEOUT;
- ajaxParameters.beforeSend = FHC_Ajax_Client._showVeil;
- ajaxParameters.complete = FHC_Ajax_Client._hideVeil;
+ ajaxParameters.beforeSend = FHC_AjaxClient._showVeil;
+ ajaxParameters.complete = FHC_AjaxClient._hideVeil;
}
}
@@ -438,7 +437,7 @@ var FHC_Ajax_Client = {
*/
_ajaxCall: function(remoteController, controllerParameters, type, ajaxCallParameters) {
// Retrives the parameters for the ajax call
- var ajaxParameters = FHC_Ajax_Client._checkAndGenerateAjaxParams(remoteController, controllerParameters, type, ajaxCallParameters);
+ var ajaxParameters = FHC_AjaxClient._checkAndGenerateAjaxParams(remoteController, controllerParameters, type, ajaxCallParameters);
// Checks the given parameters if they are present and are valid
if (ajaxParameters != null)
diff --git a/public/js/FilterWidget.js b/public/js/FilterWidget.js
index 2cf63d9ef..190eb30ea 100644
--- a/public/js/FilterWidget.js
+++ b/public/js/FilterWidget.js
@@ -1,677 +1,695 @@
-var fhc_controller_id = FHC_Ajax_Client.getUrlParameter('fhc_controller_id');
+/**
+ * FH-Complete
+ *
+ * @package
+ * @author
+ * @copyright Copyright (c) 2016 fhcomplete.org
+ * @license GPLv3
+ * @link https://fhcomplete.org
+ * @since Version 1.0.0
+ */
+/**
+ * Global function used by MavigationWidget JS
+ */
function sideMenuHook()
{
$(".remove-filter").click(function() {
-
- $.ajax({
- url: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/" + 'system/Filters/deleteCustomFilter',
- method: "POST",
- data: {
+ //
+ FHC_AjaxClient.ajaxCallPost(
+ 'system/Filters/deleteCustomFilter',
+ {
filter_id: $(this).attr('value')
+ },
+ {
+ successCallback: refreshSideMenu // NOTE: to be checked
}
- })
- .done(function(data, textStatus, jqXHR) {
-
- refreshSideMenu();
-
- }).fail(function(jqXHR, textStatus, errorThrown) {
- // alert(textStatus);
- });
-
+ );
});
}
-function dndSF()
-{
- $(".filter-select-field-dnd-span").draggable({
- containment: "parent",
- cursor: "move",
- opacity: 0.4,
- revert: "invalid",
- revertDuration: 200,
- drag: function(event, ui) {
+/**
+ * FHC_FilterWidget
+ */
+var FHC_FilterWidget = {
+ //------------------------------------------------------------------------------------------------------------------
+ // Public methods
- var padding = 20;
- var draggedElement = $(this);
+ /**
+ *
+ */
+ renderSelectedFields: function() {
+ //
+ FHC_AjaxClient.ajaxCallGet(
+ 'system/Filters/selectFields',
+ {
+ filter_page: FHC_FilterWidget._getFilterPage()
+ },
+ {
+ successCallback: function(data, textStatus, jqXHR) {
- $(".filter-select-field-dnd-span").each(function(i, e) {
+ FHC_FilterWidget._resetEventsSF();
- if ($(this).attr('id') != draggedElement.attr('id'))
- {
- $(this).removeClass("selection-after");
- $(this).removeClass("selection-before");
-
- var elementCenter = $(this).offset().left + ((padding + $(this).width()) / 2);
-
- if (event.pageX > ($(this).offset().left - (padding / 2))
- && event.pageX < ($(this).offset().left + $(this).width() + (padding / 2)))
+ if (data != null)
{
- if (event.pageX > elementCenter)
+ var arrayFieldsToDisplay = [];
+
+ if (data.columnsAliases != null && $.isArray(data.columnsAliases))
{
- $(this).addClass("selection-after");
- $(this).removeClass("selection-before");
+ arrayFieldsToDisplay = data.columnsAliases;
}
- else if (event.pageX < elementCenter)
+ else if (data.selectedFields != null && $.isArray(data.selectedFields))
{
- $(this).addClass("selection-before");
- $(this).removeClass("selection-after");
+ arrayFieldsToDisplay = data.selectedFields;
+ }
+
+ for (var i = 0; i < arrayFieldsToDisplay.length; i++)
+ {
+ var fieldToDisplay = arrayFieldsToDisplay[i];
+ var fieldName = data.selectedFields[i];
+
+ var strHtml = '';
+
+ strHtml += '';
+ strHtml += fieldToDisplay;
+ strHtml += ' ';
+ strHtml += ' X ';
+ strHtml += ' ';
+ $("#filterSelectFieldsDnd").append(strHtml);
+ }
+
+ var strDropDown = 'Select a field to add... ';
+ $("#addField").append(strDropDown);
+
+ for (var i = 0; i < data.allSelectedFields.length; i++)
+ {
+ var fieldName = data.allSelectedFields[i];
+ var fieldToDisplay = data.allSelectedFields[i];
+
+ if (data.selectedFields.indexOf(fieldName) < 0)
+ {
+ if (data.allColumnsAliases != null && $.isArray(data.allColumnsAliases))
+ {
+ fieldToDisplay = data.allColumnsAliases[i];
+ }
+
+ strDropDown = '' + fieldToDisplay + ' ';
+ $("#addField").append(strDropDown);
+ }
}
}
+
+ FHC_FilterWidget._dndSF();
+ FHC_FilterWidget._addEventsSF();
}
+ }
+ );
+ },
- });
-
- }
- });
-
- $(".filter-select-field-dnd-span").droppable({
- accept: ".filter-select-field-dnd-span",
- drop: function(event, ui) {
-
- var padding = 20;
- var elementCenter = $(this).offset().left + ((padding + $(this).width()) / 2);
- var draggedElement = ui.helper;
-
- if (event.pageX > elementCenter)
+ /**
+ *
+ */
+ renderSelectedFilters: function() {
+ //
+ FHC_AjaxClient.ajaxCallGet(
+ 'system/Filters/selectFilters',
{
- draggedElement.insertAfter($(this));
- }
- else if (event.pageX < elementCenter)
+ filter_page: FHC_FilterWidget._getFilterPage()
+ },
{
- draggedElement.insertBefore($(this));
- }
+ successCallback: function(data, textStatus, jqXHR) {
- $(this).removeClass("selection-before");
- $(this).removeClass("selection-after");
+ FHC_FilterWidget._resetEventsSFilters();
- draggedElement.css({left: '0px', top: '10px'});
-
- var arrayDndId = [];
-
- $(".filter-select-field-dnd-span").each(function(i, e) {
-
- arrayDndId[i] = $(this).attr('id').replace('dnd', '');
-
- });
-
- $.ajax({
- url: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/" + 'system/Filters/sortSelectedFields',
- method: "POST",
- data: {
- selectedFieldsLst: arrayDndId,
- fhc_controller_id: fhc_controller_id,
- filter_page: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method
- }
- })
- .done(function(data, textStatus, jqXHR) {
-
- resetSelectedFields();
- renderSelectedFields();
-
- renderTableDataset();
-
- }).fail(function(jqXHR, textStatus, errorThrown) {
- // alert(textStatus);
- });
-
- }
- });
-}
-
-function resetEventsSF()
-{
- $("#addField").off('change');
- $(".remove-field").off('click');
-}
-
-function addEventsSF()
-{
- $("#addField").change(function(event) {
-
- $.ajax({
- url: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/" + 'system/Filters/addSelectedFields',
- method: "POST",
- data: {
- fieldName: $(this).val(),
- fhc_controller_id: fhc_controller_id,
- filter_page: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method
- }
- })
- .done(function(data, textStatus, jqXHR) {
-
- resetSelectedFields();
- renderSelectedFields();
-
- renderTableDataset();
-
- }).fail(function(jqXHR, textStatus, errorThrown) {
- // alert(textStatus);
- });
-
- });
-
- $(".remove-field").click(function(event) {
-
- $.ajax({
- url: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/" + 'system/Filters/removeSelectedFields',
- method: "POST",
- data: {
- fieldName: $(this).attr('fieldToRemove'),
- fhc_controller_id: fhc_controller_id,
- filter_page: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method
- }
- })
- .done(function(data, textStatus, jqXHR) {
-
- resetSelectedFields();
- renderSelectedFields();
-
- renderTableDataset();
-
- }).fail(function(jqXHR, textStatus, errorThrown) {
- // alert(textStatus);
- });
-
- });
-}
-
-function renderSelectedFields()
-{
- $.ajax({
- url: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/" + 'system/Filters/selectFields',
- method: "GET",
- data: {
- fhc_controller_id: fhc_controller_id,
- filter_page: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method
- },
- dataType: "json"
- })
- .done(function(data, textStatus, jqXHR) {
-
- resetEventsSF();
-
- if (data != null)
- {
- var arrayFieldsToDisplay = [];
-
- if (data.columnsAliases != null && $.isArray(data.columnsAliases))
- {
- arrayFieldsToDisplay = data.columnsAliases;
- }
- else if (data.selectedFields != null && $.isArray(data.selectedFields))
- {
- arrayFieldsToDisplay = data.selectedFields;
- }
-
- for (var i = 0; i < arrayFieldsToDisplay.length; i++)
- {
- var fieldToDisplay = arrayFieldsToDisplay[i];
- var fieldName = data.selectedFields[i];
-
- var strHtml = '';
-
- strHtml += '';
- strHtml += fieldToDisplay;
- strHtml += ' ';
- strHtml += ' X ';
- strHtml += ' ';
- $("#filterSelectFieldsDnd").append(strHtml);
- }
-
- var strDropDown = 'Select a field to add... ';
- $("#addField").append(strDropDown);
-
- for (var i = 0; i < data.allSelectedFields.length; i++)
- {
- var fieldName = data.allSelectedFields[i];
- var fieldToDisplay = data.allSelectedFields[i];
-
- if (data.selectedFields.indexOf(fieldName) < 0)
- {
- if (data.allColumnsAliases != null && $.isArray(data.allColumnsAliases))
+ if (data != null)
{
- fieldToDisplay = data.allColumnsAliases[i];
+ var strDropDown = 'Select a filter to add... ';
+ $("#addFilter").append(strDropDown);
+
+ for (var i = 0; i < data.selectedFilters.length; i++)
+ {
+ var selectedFilters = '';
+
+ selectedFilters += '';
+ selectedFilters += data.selectedFiltersAliases[i];
+ selectedFilters += ' ';
+
+ selectedFilters += FHC_FilterWidget._getSelectedFilterFields(
+ data.selectedFiltersMetaData[i],
+ data.selectedFiltersActiveFilters[i],
+ data.selectedFiltersActiveFiltersOperation[i],
+ data.selectedFiltersActiveFiltersOption[i]
+ );
+
+ selectedFilters += '';
+ selectedFilters += ' ';
+ selectedFilters += ' ';
+
+ selectedFilters += '
';
+
+ $("#selectedFilters").append(selectedFilters);
+ }
+
+ for (var i = 0; i < data.allSelectedFields.length; i++)
+ {
+ var fieldName = data.allSelectedFields[i];
+ var fieldToDisplay = data.allSelectedFields[i];
+
+ if (data.selectedFilters.indexOf(fieldName) < 0)
+ {
+ if (data.allColumnsAliases != null && $.isArray(data.allColumnsAliases))
+ {
+ fieldToDisplay = data.allColumnsAliases[i];
+ }
+
+ strDropDown = '' + fieldToDisplay + ' ';
+ $("#addFilter").append(strDropDown);
+ }
+ }
}
- strDropDown = '' + fieldToDisplay + ' ';
- $("#addField").append(strDropDown);
+ FHC_FilterWidget._addEventsSFilters();
}
}
- }
+ );
+ },
- dndSF();
- addEventsSF();
- })
- .fail(function(jqXHR, textStatus, errorThrown) {
- // alert(textStatus);
- });
-}
-
-function resetSelectedFields()
-{
- $("#filterSelectFieldsDnd").html("");
- $("#addField").html("");
-}
-
-function resetEventsSFilters()
-{
- $("#addFilter").off('change');
-}
-
-function addEventsSFilters()
-{
- $("#addFilter").change(function(event) {
-
- $.ajax({
- url: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/" + 'system/Filters/addSelectedFilters',
- method: "POST",
- data: {
- fieldName: $(this).val(),
- fhc_controller_id: fhc_controller_id,
- filter_page: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method
- }
- })
- .done(function(data, textStatus, jqXHR) {
-
- resetSelectedFilters();
- renderSelectedFilters();
-
- renderTableDataset();
-
- }).fail(function(jqXHR, textStatus, errorThrown) {
- // alert(textStatus);
- });
-
- });
-
- $(".select-filter-operation").change(function() {
-
- if ($(this).val() == "set" || $(this).val() == "nset")
- {
- $(this).parent().parent().find(".select-filter-operation-value").addClass("hidden-control");
- $(this).parent().parent().find(".select-filter-option").addClass("hidden-control");
-
- $(this).parent().parent().find(".select-filter-operation-value").prop('disabled', true);
- $(this).parent().parent().find(".select-filter-option").prop('disabled', true);
- }
- else
- {
- $(this).parent().parent().find(".select-filter-operation-value").removeClass("hidden-control");
- $(this).parent().parent().find(".select-filter-option").removeClass("hidden-control");
-
- $(this).parent().parent().find(".select-filter-operation-value").prop('disabled', false);
- $(this).parent().parent().find(".select-filter-option").prop('disabled', false);
- }
-
- });
-
- $("#applyFilter").click(function() {
-
- var selectFilterName = [];
- var selectFilterOperation = [];
- var selectFilterOperationValue = [];
- var selectFilterOption = [];
-
- $("#selectedFilters > div").each(function(i, e) {
- var tmpSelectFilterName = $(this).find('.hidden-field-name').val();
- var tmpSelectFilterOperation = $(this).find('.select-filter-operation').val();
- var tmpSelectFilterOperationValue = $(this).find('.select-filter-operation-value:enabled').val();
- var tmpSelectFilterOption = $(this).find('.select-filter-option:enabled').val();
-
- selectFilterName.push(tmpSelectFilterName);
- selectFilterOperation.push(tmpSelectFilterOperation);
- selectFilterOperationValue.push(tmpSelectFilterOperationValue != null ? tmpSelectFilterOperationValue : "");
- selectFilterOption.push(tmpSelectFilterOption != null ? tmpSelectFilterOption : "");
- });
-
- $.ajax({
- url: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/" + 'system/Filters/applyFilter',
- method: "POST",
- data: {
- filterNames: selectFilterName,
- filterOperations: selectFilterOperation,
- filterOperationValues: selectFilterOperationValue,
- filterOptions: selectFilterOption,
- fhc_controller_id: fhc_controller_id,
- filter_page: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method
- }
- })
- .done(function(data, textStatus, jqXHR) {
-
- // Success
-
- }).fail(function(jqXHR, textStatus, errorThrown) {
-
- // Error
-
- }).always(function() {
-
- location.reload();
-
- });
-
- });
-
- $(".remove-selected-filter").click(function(event) {
- $.ajax({
- url: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/" + 'system/Filters/removeSelectedFilters',
- method: "POST",
- data: {
- fieldName: $(this).attr('filterToRemove'),
- fhc_controller_id: fhc_controller_id,
- filter_page: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method
- }
- })
- .done(function(data, textStatus, jqXHR) {
- resetSelectedFilters();
- renderSelectedFilters();
- }).fail(function(jqXHR, textStatus, errorThrown) {
- // alert(textStatus);
- });
- });
-
-}
-
-function renderSelectedFilterFields(metaData, activeFilters, activeFiltersOperation, activeFiltersOption)
-{
- var html = '';
-
- if (metaData.type.toLowerCase().indexOf("int") >= 0)
- {
- html = '';
- html += ' ';
- html += ' equal ';
- html += ' not equal ';
- html += ' greater than ';
- html += ' less than ';
- html += ' ';
- html += ' ';
- html += '';
- html += ' ';
- html += ' ';
- }
- if (metaData.type.toLowerCase().indexOf('varchar') >= 0 || metaData.type.toLowerCase() == 'text')
- {
- html = '';
- html += ' ';
- html += ' contains ';
- html += ' does not contain ';
- html += ' ';
- html += ' ';
- html += '';
- html += ' ';
- html += ' ';
- }
- if (metaData.type.toLowerCase().indexOf('bool') >= 0)
- {
- html = '';
- html += ' ';
- html += ' is true ';
- html += ' is false ';
- html += ' ';
- html += ' ';
- html += '';
- html += ' ';
- html += ' ';
- }
- if (metaData.type.toLowerCase().indexOf('timestamp') >= 0 || metaData.type.toLowerCase().indexOf('date') >= 0)
- {
- var classOperation = 'form-control select-filter-operation-value';
- var classOption = 'form-control select-filter-option';
- var disabled = "";
-
- if (activeFiltersOperation == "set" || activeFiltersOperation == "nset")
- {
- classOperation += ' hidden-control';
- classOption += ' hidden-control';
- disabled = "disabled";
- }
-
- html = '';
- html += ' ';
- html += ' less than ';
- html += ' greater than ';
- html += ' is set ';
- html += ' is not set ';
- html += ' ';
- html += ' ';
- html += '';
- html += ' ';
- html += ' ';
- html += '';
- html += ' ';
- html += ' Days ';
- html += ' Months ';
- html += ' ';
- html += ' ';
- }
-
- html += '';
- html += ' ';
- html += ' ';
-
- return html;
-}
-
-function renderSelectedFilters()
-{
- $.ajax({
- url: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/" + 'system/Filters/selectFilters',
- method: "GET",
- data: {
- fhc_controller_id: fhc_controller_id,
- filter_page: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method
- },
- dataType: "json"
- })
- .done(function(data, textStatus, jqXHR) {
-
- resetEventsSFilters();
-
- if (data != null)
- {
- var strDropDown = 'Select a filter to add... ';
- $("#addFilter").append(strDropDown);
-
- for (var i = 0; i < data.selectedFilters.length; i++)
+ /**
+ *
+ */
+ renderTableDataset: function() {
+ //
+ FHC_AjaxClient.ajaxCallGet(
+ 'system/Filters/tableDataset',
{
- var selectedFilters = '';
-
- selectedFilters += '';
- selectedFilters += data.selectedFiltersAliases[i];
- selectedFilters += ' ';
-
- selectedFilters += renderSelectedFilterFields(
- data.selectedFiltersMetaData[i],
- data.selectedFiltersActiveFilters[i],
- data.selectedFiltersActiveFiltersOperation[i],
- data.selectedFiltersActiveFiltersOption[i]
- );
-
- selectedFilters += '';
- selectedFilters += ' ';
- selectedFilters += ' ';
-
- selectedFilters += '
';
-
- $("#selectedFilters").append(selectedFilters);
- }
-
- for (var i = 0; i < data.allSelectedFields.length; i++)
+ filter_page: FHC_FilterWidget._getFilterPage()
+ },
{
- var fieldName = data.allSelectedFields[i];
- var fieldToDisplay = data.allSelectedFields[i];
+ successCallback: function(data, textStatus, jqXHR) {
- if (data.selectedFilters.indexOf(fieldName) < 0)
- {
- if (data.allColumnsAliases != null && $.isArray(data.allColumnsAliases))
+ FHC_FilterWidget._resetTableDataset();
+
+ if (data != null)
{
- fieldToDisplay = data.allColumnsAliases[i];
- }
+ if (data.checkboxes != null)
+ {
+ $("#filterTableDataset > thead > tr").append("Select ");
+ }
- strDropDown = '' + fieldToDisplay + ' ';
- $("#addFilter").append(strDropDown);
- }
- }
- }
+ var arrayFieldsToDisplay = [];
- addEventsSFilters();
- })
- .fail(function(jqXHR, textStatus, errorThrown) {
- // alert(textStatus);
- });
-}
-
-function resetSelectedFilters()
-{
- $("#addFilter").html("");
- $("#selectedFilters").html("");
-}
-
-function callTableSorter()
-{
- // Checks if the table contains data (rows)
- if ($('#filterTableDataset').find('tbody:empty').length == 0
- && $('#filterTableDataset').find('tr:empty').length == 0
- && $('#filterTableDataset').hasClass('table-condensed'))
- {
- $("#filterTableDataset").tablesorter({
- widgets: ["zebra", "filter"]
- });
-
- var config = $('#filterTableDataset')[0].config;
- $.tablesorter.updateAll(config, true, null);
- }
-}
-
-function renderTableDataset()
-{
- $.ajax({
- url: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/" + 'system/Filters/tableDataset',
- method: "GET",
- data: {
- fhc_controller_id: fhc_controller_id,
- filter_page: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method
- },
- dataType: "json"
- })
- .done(function(data, textStatus, jqXHR) {
-
- resetTableDataset();
-
- if (data != null)
- {
- if (data.checkboxes != null)
- {
- $("#filterTableDataset > thead > tr").append("Select ");
- }
-
- var arrayFieldsToDisplay = [];
-
- if (data.columnsAliases != null && $.isArray(data.columnsAliases) && data.columnsAliases.length > 0)
- {
- arrayFieldsToDisplay = data.columnsAliases;
- }
- else if (data.selectedFields != null && $.isArray(data.selectedFields))
- {
- arrayFieldsToDisplay = data.selectedFields;
- }
-
- /* ------------------------------------------------------------------------------------------------ */
- if (data.checkboxes != null && data.checkboxes != "")
- {
- $("#filterTableDataset > thead > tr").html("Select ");
- }
-
- for (var i = 0; i < arrayFieldsToDisplay.length; i++)
- {
- var th = arrayFieldsToDisplay[i];
-
- $("#filterTableDataset > thead > tr").append("" + th + " ");
- }
-
- if (data.additionalColumns != null && $.isArray(data.additionalColumns))
- {
- for (var i = 0; i < data.additionalColumns.length; i++)
- {
- var th = data.additionalColumns[i];
-
- $("#filterTableDataset > thead > tr").append("" + th + " ");
- }
- }
- /* ------------------------------------------------------------------------------------------------ */
-
- if (arrayFieldsToDisplay.length > 0)
- {
- if (data.dataset != null && $.isArray(data.dataset))
- {
- for (var i = 0; i < data.dataset.length; i++)
- {
- var record = data.dataset[i];
- var strHtml = '';
+ if (data.columnsAliases != null && $.isArray(data.columnsAliases) && data.columnsAliases.length > 0)
+ {
+ arrayFieldsToDisplay = data.columnsAliases;
+ }
+ else if (data.selectedFields != null && $.isArray(data.selectedFields))
+ {
+ arrayFieldsToDisplay = data.selectedFields;
+ }
+ /* ------------------------------------------------------------------------------------------------ */
if (data.checkboxes != null && data.checkboxes != "")
{
- strHtml += '';
- strHtml += ' ';
- strHtml += ' ';
+ $("#filterTableDataset > thead > tr").html("Select ");
}
- $.each(arrayFieldsToDisplay, function(i, fieldToDisplay) {
+ for (var i = 0; i < arrayFieldsToDisplay.length; i++)
+ {
+ var th = arrayFieldsToDisplay[i];
- if (record.hasOwnProperty(data.selectedFields[i]))
- {
- strHtml += '' + record[data.selectedFields[i]] + ' ';
- }
- });
+ $("#filterTableDataset > thead > tr").append("" + th + " ");
+ }
if (data.additionalColumns != null && $.isArray(data.additionalColumns))
{
- $.each(data.additionalColumns, function(i, additionalColumn) {
+ for (var i = 0; i < data.additionalColumns.length; i++)
+ {
+ var th = data.additionalColumns[i];
- if (record.hasOwnProperty(additionalColumn))
- {
- strHtml += '' + record[additionalColumn] + ' ';
- }
-
- });
+ $("#filterTableDataset > thead > tr").append("" + th + " ");
+ }
}
+ /* ------------------------------------------------------------------------------------------------ */
- strHtml += ' ';
+ if (arrayFieldsToDisplay.length > 0)
+ {
+ if (data.dataset != null && $.isArray(data.dataset))
+ {
+ for (var i = 0; i < data.dataset.length; i++)
+ {
+ var record = data.dataset[i];
+ var strHtml = '';
- $("#filterTableDataset > tbody").append(strHtml);
+ if (data.checkboxes != null && data.checkboxes != "")
+ {
+ strHtml += '';
+ strHtml += ' ';
+ strHtml += ' ';
+ }
+
+ $.each(arrayFieldsToDisplay, function(i, fieldToDisplay) {
+
+ if (record.hasOwnProperty(data.selectedFields[i]))
+ {
+ strHtml += '' + record[data.selectedFields[i]] + ' ';
+ }
+ });
+
+ if (data.additionalColumns != null && $.isArray(data.additionalColumns))
+ {
+ $.each(data.additionalColumns, function(i, additionalColumn) {
+
+ if (record.hasOwnProperty(additionalColumn))
+ {
+ strHtml += '' + record[additionalColumn] + ' ';
+ }
+
+ });
+ }
+
+ strHtml += ' ';
+
+ $("#filterTableDataset > tbody").append(strHtml);
+ }
+ }
+ else
+ {
+ // console.log("No dataset!!!");
+ }
+ }
+ else
+ {
+ console.log("No fields to display!!!");
+ }
+ }
+ else
+ {
+ console.log("No data!!!");
+ }
+
+ FHC_FilterWidget._callTableSorter();
+
+ }
+ }
+ );
+ },
+
+ //------------------------------------------------------------------------------------------------------------------
+ // Private methods
+
+ /**
+ *
+ */
+ _dndSF: function() {
+ $(".filter-select-field-dnd-span").draggable({
+ containment: "parent",
+ cursor: "move",
+ opacity: 0.4,
+ revert: "invalid",
+ revertDuration: 200,
+ drag: function(event, ui) {
+
+ var padding = 20;
+ var draggedElement = $(this);
+
+ $(".filter-select-field-dnd-span").each(function(i, e) {
+
+ if ($(this).attr('id') != draggedElement.attr('id'))
+ {
+ $(this).removeClass("selection-after");
+ $(this).removeClass("selection-before");
+
+ var elementCenter = $(this).offset().left + ((padding + $(this).width()) / 2);
+
+ if (event.pageX > ($(this).offset().left - (padding / 2))
+ && event.pageX < ($(this).offset().left + $(this).width() + (padding / 2)))
+ {
+ if (event.pageX > elementCenter)
+ {
+ $(this).addClass("selection-after");
+ $(this).removeClass("selection-before");
+ }
+ else if (event.pageX < elementCenter)
+ {
+ $(this).addClass("selection-before");
+ $(this).removeClass("selection-after");
+ }
+ }
+ }
+
+ });
+
+ }
+ });
+
+ $(".filter-select-field-dnd-span").droppable({
+ accept: ".filter-select-field-dnd-span",
+ drop: function(event, ui) {
+
+ var padding = 20;
+ var elementCenter = $(this).offset().left + ((padding + $(this).width()) / 2);
+ var draggedElement = ui.helper;
+
+ if (event.pageX > elementCenter)
+ {
+ draggedElement.insertAfter($(this));
+ }
+ else if (event.pageX < elementCenter)
+ {
+ draggedElement.insertBefore($(this));
+ }
+
+ $(this).removeClass("selection-before");
+ $(this).removeClass("selection-after");
+
+ draggedElement.css({left: '0px', top: '10px'});
+
+ var arrayDndId = [];
+
+ $(".filter-select-field-dnd-span").each(function(i, e) {
+
+ arrayDndId[i] = $(this).attr('id').replace('dnd', '');
+
+ });
+
+ //
+ FHC_AjaxClient.ajaxCallPost(
+ 'system/Filters/sortSelectedFields',
+ {
+ selectedFieldsLst: arrayDndId,
+ filter_page: FHC_FilterWidget._getFilterPage()
+ },
+ {
+ successCallback: function(data, textStatus, jqXHR) {
+ FHC_FilterWidget._resetSelectedFields();
+
+ FHC_FilterWidget.renderSelectedFields();
+ FHC_FilterWidget.renderTableDataset();
+ }
+ }
+ );
+ }
+ });
+ },
+
+ /**
+ *
+ */
+ _resetEventsSF: function() {
+ $("#addField").off('change');
+ $(".remove-field").off('click');
+ },
+
+ /**
+ *
+ */
+ _addEventsSF: function() {
+ $("#addField").change(function(event) {
+ //
+ FHC_AjaxClient.ajaxCallPost(
+ 'system/Filters/addSelectedFields',
+ {
+ fieldName: $(this).val(),
+ filter_page: FHC_FilterWidget._getFilterPage()
+ },
+ {
+ successCallback: function(data, textStatus, jqXHR) {
+ FHC_FilterWidget._resetSelectedFields();
+
+ FHC_FilterWidget.renderSelectedFields();
+ FHC_FilterWidget.renderTableDataset();
}
}
- else
+ );
+ });
+
+ $(".remove-field").click(function(event) {
+ //
+ FHC_AjaxClient.ajaxCallPost(
+ 'system/Filters/removeSelectedFields',
{
- // console.log("No dataset!!!");
+ fieldName: $(this).attr('fieldToRemove'),
+ filter_page: FHC_FilterWidget._getFilterPage()
+ },
+ {
+ successCallback: function(data, textStatus, jqXHR) {
+ FHC_FilterWidget._resetSelectedFields();
+
+ FHC_FilterWidget.renderSelectedFields();
+ FHC_FilterWidget.renderTableDataset();
+ }
}
+ );
+ });
+ },
+
+ /**
+ *
+ */
+ _resetSelectedFields: function() {
+ $("#filterSelectFieldsDnd").html("");
+ $("#addField").html("");
+ },
+
+ /**
+ *
+ */
+ _resetEventsSFilters: function() {
+ $("#addFilter").off('change');
+ },
+
+ /**
+ *
+ */
+ _addEventsSFilters: function() {
+ $("#addFilter").change(function(event) {
+ //
+ FHC_AjaxClient.ajaxCallPost(
+ 'system/Filters/addSelectedFilters',
+ {
+ fieldName: $(this).val(),
+ filter_page: FHC_FilterWidget._getFilterPage()
+ },
+ {
+ successCallback: function(data, textStatus, jqXHR) {
+ FHC_FilterWidget._resetSelectedFilters();
+
+ FHC_FilterWidget.renderSelectedFilters();
+ FHC_FilterWidget.renderTableDataset();
+ }
+ }
+ );
+ });
+
+ $(".select-filter-operation").change(function() {
+
+ if ($(this).val() == "set" || $(this).val() == "nset")
+ {
+ $(this).parent().parent().find(".select-filter-operation-value").addClass("hidden-control");
+ $(this).parent().parent().find(".select-filter-option").addClass("hidden-control");
+
+ $(this).parent().parent().find(".select-filter-operation-value").prop('disabled', true);
+ $(this).parent().parent().find(".select-filter-option").prop('disabled', true);
}
else
{
- console.log("No fields to display!!!");
+ $(this).parent().parent().find(".select-filter-operation-value").removeClass("hidden-control");
+ $(this).parent().parent().find(".select-filter-option").removeClass("hidden-control");
+
+ $(this).parent().parent().find(".select-filter-operation-value").prop('disabled', false);
+ $(this).parent().parent().find(".select-filter-option").prop('disabled', false);
}
- }
- else
+
+ });
+
+ $("#applyFilter").click(function() {
+
+ var selectFilterName = [];
+ var selectFilterOperation = [];
+ var selectFilterOperationValue = [];
+ var selectFilterOption = [];
+
+ $("#selectedFilters > div").each(function(i, e) {
+ var tmpSelectFilterName = $(this).find('.hidden-field-name').val();
+ var tmpSelectFilterOperation = $(this).find('.select-filter-operation').val();
+ var tmpSelectFilterOperationValue = $(this).find('.select-filter-operation-value:enabled').val();
+ var tmpSelectFilterOption = $(this).find('.select-filter-option:enabled').val();
+
+ selectFilterName.push(tmpSelectFilterName);
+ selectFilterOperation.push(tmpSelectFilterOperation);
+ selectFilterOperationValue.push(tmpSelectFilterOperationValue != null ? tmpSelectFilterOperationValue : "");
+ selectFilterOption.push(tmpSelectFilterOption != null ? tmpSelectFilterOption : "");
+ });
+
+ //
+ FHC_AjaxClient.ajaxCallPost(
+ 'system/Filters/applyFilter',
+ {
+ filterNames: selectFilterName,
+ filterOperations: selectFilterOperation,
+ filterOperationValues: selectFilterOperationValue,
+ filterOptions: selectFilterOption,
+ filter_page: FHC_FilterWidget._getFilterPage()
+ },
+ {
+ successCallback: function(data, textStatus, jqXHR) {
+ FHC_FilterWidget._resetSelectedFilters();
+
+ location.reload();
+ }
+ }
+ );
+ });
+
+ $(".remove-selected-filter").click(function(event) {
+ //
+ FHC_AjaxClient.ajaxCallPost(
+ 'system/Filters/removeSelectedFilters',
+ {
+ fieldName: $(this).attr('filterToRemove'),
+ filter_page: FHC_FilterWidget._getFilterPage()
+ },
+ {
+ successCallback: function(data, textStatus, jqXHR) {
+ FHC_FilterWidget._resetSelectedFilters();
+
+ location.reload();
+ }
+ }
+ );
+ });
+
+ },
+
+ /**
+ *
+ */
+ _getSelectedFilterFields: function(metaData, activeFilters, activeFiltersOperation, activeFiltersOption) {
+ var html = '';
+
+ if (metaData.type.toLowerCase().indexOf("int") >= 0)
{
- console.log("No data!!!");
+ html = '';
+ html += ' ';
+ html += ' equal ';
+ html += ' not equal ';
+ html += ' greater than ';
+ html += ' less than ';
+ html += ' ';
+ html += ' ';
+ html += '';
+ html += ' ';
+ html += ' ';
+ }
+ if (metaData.type.toLowerCase().indexOf('varchar') >= 0 || metaData.type.toLowerCase() == 'text')
+ {
+ html = '';
+ html += ' ';
+ html += ' contains ';
+ html += ' does not contain ';
+ html += ' ';
+ html += ' ';
+ html += '';
+ html += ' ';
+ html += ' ';
+ }
+ if (metaData.type.toLowerCase().indexOf('bool') >= 0)
+ {
+ html = '';
+ html += ' ';
+ html += ' is true ';
+ html += ' is false ';
+ html += ' ';
+ html += ' ';
+ html += '';
+ html += ' ';
+ html += ' ';
+ }
+ if (metaData.type.toLowerCase().indexOf('timestamp') >= 0 || metaData.type.toLowerCase().indexOf('date') >= 0)
+ {
+ var classOperation = 'form-control select-filter-operation-value';
+ var classOption = 'form-control select-filter-option';
+ var disabled = "";
+
+ if (activeFiltersOperation == "set" || activeFiltersOperation == "nset")
+ {
+ classOperation += ' hidden-control';
+ classOption += ' hidden-control';
+ disabled = "disabled";
+ }
+
+ html = '';
+ html += ' ';
+ html += ' less than ';
+ html += ' greater than ';
+ html += ' is set ';
+ html += ' is not set ';
+ html += ' ';
+ html += ' ';
+ html += '';
+ html += ' ';
+ html += ' ';
+ html += '';
+ html += ' ';
+ html += ' Days ';
+ html += ' Months ';
+ html += ' ';
+ html += ' ';
}
- callTableSorter();
+ html += '';
+ html += ' ';
+ html += ' ';
- })
- .fail(function(jqXHR, textStatus, errorThrown) {
- // alert(textStatus);
- });
-}
+ return html;
+ },
-function resetTableDataset()
-{
- $("#filterTableDataset > thead > tr").html("");
- $("#filterTableDataset > tbody").html("");
-}
+ /**
+ *
+ */
+ _resetSelectedFilters: function() {
+ $("#addFilter").html("");
+ $("#selectedFilters").html("");
+ },
+ /**
+ *
+ */
+ _callTableSorter: function() {
+ // Checks if the table contains data (rows)
+ if ($('#filterTableDataset').find('tbody:empty').length == 0
+ && $('#filterTableDataset').find('tr:empty').length == 0
+ && $('#filterTableDataset').hasClass('table-condensed'))
+ {
+ $("#filterTableDataset").tablesorter({
+ widgets: ["zebra", "filter"]
+ });
+
+ var config = $('#filterTableDataset')[0].config;
+ $.tablesorter.updateAll(config, true, null);
+ }
+ },
+
+ /**
+ *
+ */
+ _resetTableDataset: function() {
+ $("#filterTableDataset > thead > tr").html("");
+ $("#filterTableDataset > tbody").html("");
+ },
+
+ /**
+ *
+ */
+ _getFilterPage: function() {
+ return FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method;
+ }
+};
+
+
+/**
+ * When JQuery is up
+ */
$(document).ready(function() {
$("[data-toggle='collapse']").click(function() {
@@ -698,22 +716,17 @@ $(document).ready(function() {
$("#saveCustomFilterButton").click(function() {
if ($("#customFilterDescription").val() != '')
{
- $.ajax({
- url: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/" + 'system/Filters/saveFilter',
- method: "POST",
- data: {
+ //
+ FHC_AjaxClient.ajaxCallPost(
+ 'system/Filters/saveFilter',
+ {
customFilterDescription: $("#customFilterDescription").val(),
- fhc_controller_id: fhc_controller_id,
- filter_page: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method
+ filter_page: FHC_FilterWidget._getFilterPage()
+ },
+ {
+ successCallback: refreshSideMenu // NOTE: to be checked
}
- })
- .done(function(data, textStatus, jqXHR) {
-
- refreshSideMenu()
-
- }).fail(function(jqXHR, textStatus, errorThrown) {
- // alert(textStatus);
- });
+ );
}
else
{
@@ -721,10 +734,8 @@ $(document).ready(function() {
}
});
- renderSelectedFields();
-
- renderSelectedFilters();
-
- renderTableDataset();
+ FHC_FilterWidget.renderSelectedFields();
+ FHC_FilterWidget.renderSelectedFilters();
+ FHC_FilterWidget.renderTableDataset();
});
diff --git a/public/js/NavigationWidget.js b/public/js/NavigationWidget.js
index 4c1bc8aa1..8b3405c26 100644
--- a/public/js/NavigationWidget.js
+++ b/public/js/NavigationWidget.js
@@ -1,171 +1,198 @@
/**
- * Used by the NavigationWidget
- */
-
-var fhc_controller_id = FHC_Ajax_Client.getUrlParameter('fhc_controller_id');
-
-/**
+ * FH-Complete
*
+ * @package
+ * @author
+ * @copyright Copyright (c) 2016 fhcomplete.org
+ * @license GPLv3
+ * @link https://fhcomplete.org
+ * @since Version 1.0.0
*/
-function printNavItem(item, depth = 1)
-{
- strMenu = "";
- var expanded = typeof item['expand'] != 'undefined' && item['expand'] === true ? ' active' : '';
- strMenu += '';
+/**
+ * FHC_NavigationWidget
+ */
+var FHC_NavigationWidget = {
+ //------------------------------------------------------------------------------------------------------------------
+ // Public methods
- if (typeof item['subscriptLinkClass'] != 'undefined' && typeof item['subscriptDescription'] != 'undefined')
- {
- strMenu += '';
- }
+ /**
+ * Renders the header menu (top horizontal menu)
+ */
+ renderHeaderMenu: function() {
+ //
+ FHC_AjaxClient.ajaxCallGet(
+ 'system/Navigation/header',
+ {
+ navigation_widget_called: FHC_NavigationWidget._getNavigationWidgetCalled()
+ },
+ {
+ successCallback: function(data, textStatus, jqXHR) {
+ if (data != null)
+ {
+ jQuery.each(data, function(i, e) {
+ $(".menu-header-items").append('' + i + ' ');
+ });
+ }
+ }
+ }
+ );
+ },
- // Handle fhc_controller_id
- if (fhc_controller_id != null && fhc_controller_id != '' && item['link'] != '#')
- {
- if (item['link'].indexOf('?') != -1)
- {
- item['link'] += '&';
- }
- else
- {
- item['link'] += '?';
- }
+ /**
+ * Renders the side left menu
+ */
+ renderSideMenu: function() {
+ //
+ FHC_AjaxClient.ajaxCallGet(
+ 'system/Navigation/menu',
+ {
+ navigation_widget_called: FHC_NavigationWidget._getNavigationWidgetCalled()
+ },
+ {
+ successCallback: function(data, textStatus, jqXHR) {
+ if (data != null)
+ {
+ var strMenu = '';
- item['link'] += 'fhc_controller_id=' + fhc_controller_id;
- }
+ FHC_NavigationWidget._printCollapseIcon();
- strMenu += '';
+ jQuery.each(data, function(i, e) {
+ strMenu += FHC_NavigationWidget._printNavItem(e);
+ });
- if (item['icon'] != 'undefined')
- {
- strMenu += ' ';
- }
+ $("#side-menu").html(strMenu);
+ $("#side-menu").metisMenu();
+ }
- strMenu += item['description'];
+ if (typeof sideMenuHook == 'function')
+ {
+ sideMenuHook();
+ }
+ }
+ }
+ );
+ },
- if (typeof item['children'] != 'undefined' && Object.keys(item['children']).length > 0)
- {
- strMenu += ' ';
- }
+ //------------------------------------------------------------------------------------------------------------------
+ // Private methods
- strMenu += ' ';
+ /**
+ *
+ */
+ _printCollapseIcon: function() {
+ // Hiding/showing navigation menu - works only with sb admin 2 template!!
+ if(!$("#collapseicon").length)
+ $("#side-menu").parent().append('
');
- if (typeof item['subscriptLinkClass'] != 'undefined' && typeof item['subscriptDescription'] != 'undefined')
- {
- strMenu += '';
- strMenu += ' ';
- }
-
- if (typeof item['children'] != 'undefined' && Object.keys(item['children']).length > 0)
- {
- var level = '';
- if (depth === 1)
- {
- level = 'second';
- }
- else if (depth > 1)
- {
- level = 'third';
- }
-
- strMenu += '';
-
- jQuery.each(item['children'], function(i, e) {
- strMenu += printNavItem(e, ++depth);
+ $("#collapseicon").click(function() {
+ $("#page-wrapper").css('margin-left', '0px');
+ $("#side-menu").hide();
+ $("#collapseicon").hide();
+ $("#collapseinicon").show();
});
- strMenu += ' ';
+ $("#collapseinicon").click(function() {
+ $("#page-wrapper").css('margin-left', '250px');
+ $("#side-menu").show();
+ $("#collapseicon").show();
+ $("#collapseinicon").hide();
+ });
+ },
+
+ /**
+ *
+ */
+ _printNavItem: function(item, depth = 1) {
+ strMenu = "";
+ var expanded = typeof item['expand'] != 'undefined' && item['expand'] === true ? ' active' : '';
+
+ strMenu += ' ';
+
+ if (typeof item['subscriptLinkClass'] != 'undefined' && typeof item['subscriptDescription'] != 'undefined')
+ {
+ strMenu += '';
+ }
+
+ // Handle fhc_controller_id
+ var fhc_controller_id = FHC_AjaxClient.getUrlParameter('fhc_controller_id');
+ if (fhc_controller_id != null && fhc_controller_id != '' && item['link'] != '#')
+ {
+ if (item['link'].indexOf('?') != -1)
+ {
+ item['link'] += '&';
+ }
+ else
+ {
+ item['link'] += '?';
+ }
+
+ item['link'] += 'fhc_controller_id=' + fhc_controller_id;
+ }
+
+ strMenu += '';
+
+ if (item['icon'] != 'undefined')
+ {
+ strMenu += ' ';
+ }
+
+ strMenu += item['description'];
+
+ if (typeof item['children'] != 'undefined' && Object.keys(item['children']).length > 0)
+ {
+ strMenu += ' ';
+ }
+
+ strMenu += ' ';
+
+ if (typeof item['subscriptLinkClass'] != 'undefined' && typeof item['subscriptDescription'] != 'undefined')
+ {
+ strMenu += '';
+ strMenu += ' ';
+ }
+
+ if (typeof item['children'] != 'undefined' && Object.keys(item['children']).length > 0)
+ {
+ var level = '';
+ if (depth === 1)
+ {
+ level = 'second';
+ }
+ else if (depth > 1)
+ {
+ level = 'third';
+ }
+
+ strMenu += '';
+
+ jQuery.each(item['children'], function(i, e) {
+ strMenu += FHC_NavigationWidget._printNavItem(e, ++depth);
+ });
+
+ strMenu += ' ';
+ }
+
+ strMenu += ' ';
+
+ return strMenu;
+ },
+
+ /**
+ * Returns the URI of the caller
+ */
+ _getNavigationWidgetCalled: function() {
+ return FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method;
}
+};
- strMenu += '';
-
- return strMenu;
-}
-
-function renderSideMenu()
-{
- $.ajax({
- url: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/" + 'system/Navigation/menu',
- method: "GET",
- data: {
- navigation_widget_called: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method
- }
- })
- .done(function(data, textStatus, jqXHR) {
-
- if (data != null)
- {
- var strMenu = '';
-
- printCollapseIcon();
-
- jQuery.each(data, function(i, e) {
- strMenu += printNavItem(e);
- });
-
- $("#side-menu").html(strMenu);
- $("#side-menu").metisMenu();
- }
-
- if (typeof sideMenuHook == 'function')
- {
- sideMenuHook();
- }
-
- }).fail(function(jqXHR, textStatus, errorThrown) {
- // alert(textStatus);
- });
-}
-
-
-function printCollapseIcon()
-{
- // Hiding/showing navigation menu - works only with sb admin 2 template!!
- if(!$("#collapseicon").length)
- $("#side-menu").parent().append('
');
-
- $("#collapseicon").click(function() {
- $("#page-wrapper").css('margin-left', '0px');
- $("#side-menu").hide();
- $("#collapseicon").hide();
- $("#collapseinicon").show();
- });
-
- $("#collapseinicon").click(function() {
- $("#page-wrapper").css('margin-left', '250px');
- $("#side-menu").show();
- $("#collapseicon").show();
- $("#collapseinicon").hide();
- });
-}
-
-function renderHeaderMenu()
-{
- $.ajax({
- url: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/" + 'system/Navigation/header',
- method: "GET",
- data: {
- navigation_widget_called: FHC_JS_DATA_STORAGE_OBJECT.called_path + "/" + FHC_JS_DATA_STORAGE_OBJECT.called_method
- }
- })
- .done(function(data, textStatus, jqXHR) {
-
- if (data != null)
- {
- jQuery.each(data, function(i, e) {
- $(".menu-header-items").append('' + i + ' ');
- });
- }
-
- }).fail(function(jqXHR, textStatus, errorThrown) {
- // alert(textStatus);
- });
-}
-
+/**
+ * When JQuery is up
+ */
$(document).ready(function() {
- renderHeaderMenu();
+ FHC_NavigationWidget.renderHeaderMenu();
- renderSideMenu();
+ FHC_NavigationWidget.renderSideMenu();
});
diff --git a/public/js/infocenter/infocenterDetails.js b/public/js/infocenter/infocenterDetails.js
index 58738fa18..445e667cd 100644
--- a/public/js/infocenter/infocenterDetails.js
+++ b/public/js/infocenter/infocenterDetails.js
@@ -1,5 +1,5 @@
-var fhc_controller_id = FHC_Ajax_Client.getUrlParameter('fhc_controller_id');
+var fhc_controller_id = FHC_AjaxClient.getUrlParameter('fhc_controller_id');
const CONTROLLER_URL = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/"+FHC_JS_DATA_STORAGE_OBJECT.called_path;
/**
diff --git a/public/js/infocenter/infocenterPersonDataset.js b/public/js/infocenter/infocenterPersonDataset.js
index 5e96edd66..2c063ac4d 100644
--- a/public/js/infocenter/infocenterPersonDataset.js
+++ b/public/js/infocenter/infocenterPersonDataset.js
@@ -145,7 +145,7 @@ function refreshSideMenu()
})
.done(function(data, textStatus, jqXHR) {
- renderSideMenu();
+ FHC_NavigationWidget.renderSideMenu();
}).fail(function(jqXHR, textStatus, errorThrown) {
alert(textStatus);