Ver Fonte

fixed render TableAjax special filters

Piotr Labudda há 8 anos atrás
pai
commit
c0be137db4
1 ficheiros alterados com 25 adições e 18 exclusões
  1. 25 18
      SE/se-lib/TableAjax.php

+ 25 - 18
SE/se-lib/TableAjax.php

@@ -1490,10 +1490,10 @@ class TableAjax extends ViewAjax {
 		};
 
 		priv.renderHeadSpecialFilters = function() {
+			// console.log("priv.renderHeadSpecialFilters state:", { 'priv.options.specialFilterFunctions': priv.options.specialFilterFunctions, '_state.specialFilters': _state.specialFilters });
 			var nodeClass = 'tblAjax__' + 'head__specialFilter',
-					currentNode = $(_uiNodeCont).prev('.' + nodeClass),
+					currentNode = $(_uiNodeCont).prevAll('.' + nodeClass),
 					node;
-			/// console.log('L.<?php echo __LINE__; ?> renderTable::renderHeadSpecialFilters...');//TODO:DBG:RMME
 			if (!priv.options.specialFilterFunctions) {
 				return;
 			}
@@ -1508,6 +1508,7 @@ class TableAjax extends ViewAjax {
 				if (groupName in _state.specialFilters) {
 					btnSelected = _state.specialFilters[groupName];
 				}
+				// console.log("priv.renderHeadSpecialFilters loop:", {groupName: groupName, btnSelected: btnSelected});
 				if (groupObj.icon) {
 					$('<button class="btn btn-xs btn-default" title="' + groupLabel + '"><i class="' + groupObj.icon + '"></i></button>').appendTo(groupHtml);
 				}
@@ -1520,6 +1521,8 @@ class TableAjax extends ViewAjax {
 				groupHtml.appendTo(node);
 			});
 
+			// console.log("priv.renderHeadSpecialFilters replace:", { 'priv.options.specialFilterFunctions': priv.options.specialFilterFunctions, '_state.specialFilters': _state.specialFilters });
+			// console.log("priv.renderHeadSpecialFilters replace node:", { 'currentNode': currentNode, 'node': node, '_uiNodeCont': _uiNodeCont });
 			currentNode.replaceWith(node);
 		};
 
@@ -3483,25 +3486,37 @@ class TableAjax extends ViewAjax {
 		'URL_HIST_BASE' => "index-ajax.php?_zasobID={$this->_zasobID}&_cls=" . __CLASS__ . "&_hash={$this->_htmlID}&_task=HIST", // &ID=...
 		'FUNCTION_HIST_ROUTE' => "TableAjax__HIST_Route",
 	]);
+
+
+	$fltrs = (method_exists($acl, 'getSpecialFilters')) ? $acl->getSpecialFilters() : null;
+	$jsonSpecialFilters = (!empty($fltrs)) ? json_encode($fltrs) : 'false';
 ?>
 		<script>
 var TABLE_AJAX_NODE_ID = '<?= $this->_htmlID; ?>';
+var NAMESPACE = '<?= $acl->getNamespace(); ?>';
 var FUNCTION_HIST_ROUTE = window['TableAjax__HIST_Route'];
+var URL_LOAD_AJAX_BASE = '<?= $this->syncUrl; ?>&_hash=<?= $this->_htmlID; ?>&_task=loadDataAjax';
+var URL_USER_TABLE_FILTER = '<?= ($this->useUserTableFilter) ? $this->useUserTableFilter : ''; ?>';
+var FILER_INIT = <?= json_encode($filterInit); ?>;
+var FIRCE_FILER_INIT = <?= json_encode($forceFilterInit); ?>;
+var PAGE_SIZE = '<?= $pageSize; ?>';
+var PAGE_SIZES = <?= json_encode($pageSizes); ?>;
+
 jQuery(document).ready(function(){
 	jQuery('#' + TABLE_AJAX_NODE_ID).TableAjax({
-		namespace: '<?= $acl->getNamespace(); ?>',
-		url: '<?= $this->syncUrl; ?>&_hash=<?= $this->_htmlID; ?>&_task=loadDataAjax',// priv.options.url
-		userTableFilterUrl: '<?= ($this->useUserTableFilter) ? $this->useUserTableFilter : ''; ?>',
+		namespace: NAMESPACE,
+		url: URL_LOAD_AJAX_BASE,
+		userTableFilterUrl: URL_USER_TABLE_FILTER,
 		columnPicker: true,
 		filter: true,
-		filterInit: <?php echo json_encode($filterInit); ?>,
-		forceFilterInit: <?php echo json_encode($forceFilterInit); ?>,
+		filterInit: FILER_INIT,
+		forceFilterInit: FIRCE_FILER_INIT,
 		debug: false,
 		height: 400,
 		sorting: true,
 		paging: true,
-		pageSize: <?php echo $pageSize; ?>,
-		pageSizes: <?php echo json_encode($pageSizes); ?>,
+		pageSize: PAGE_SIZE,
+		pageSizes: PAGE_SIZES,
 		tblFunctions: {
 			shortdesc: {
 				icon: 'align-left',
@@ -3528,15 +3543,7 @@ jQuery(document).ready(function(){
 		},
 		rowFunctions: <?php echo json_encode($rowFunctions); ?>,
 		exportFields: <?php echo json_encode($exportFields); ?>,
-		specialFilterFunctions: <?php
-			$fltrs = (method_exists($acl, 'getSpecialFilters')) ? $acl->getSpecialFilters() : null;
-			if (!empty($fltrs)) {
-				echo json_encode($fltrs);
-			} else {
-				echo 'false';
-			}
-			echo ',';
-		?>
+		specialFilterFunctions: <?= $jsonSpecialFilters; ?>,
 		router: function() {
 			var routes = {
 				EDIT: function(args) {