Forráskód Böngészése

table ajax more func popover

Piotr Labudda 10 éve
szülő
commit
4f82729ac4
1 módosított fájl, 42 hozzáadás és 16 törlés
  1. 42 16
      SE/se-lib/TableAjax.php

+ 42 - 16
SE/se-lib/TableAjax.php

@@ -995,6 +995,7 @@ class TableAjax extends ViewAjax {
 					moreFunctions = [],
 					moreFunctions = [],
 					idx
 					idx
 			;
 			;
+			if (priv.options.debug) console.log('TableAjax::renderCellRowFunctions: rowFunctions', rowFunctions);
 			idx = keys.indexOf('hist');
 			idx = keys.indexOf('hist');
 			if (idx !== -1) {
 			if (idx !== -1) {
 				histFunc = keys.splice(idx, 1);
 				histFunc = keys.splice(idx, 1);
@@ -1002,24 +1003,49 @@ class TableAjax extends ViewAjax {
 			}
 			}
 			moreFunctions = keys.splice(3);
 			moreFunctions = keys.splice(3);
 			keys.forEach(function(key) {
 			keys.forEach(function(key) {
-				var funObj = rowFunctions[key];
-				$(funObj.f(rowPK)).appendTo(cellNode);
+				var funObj = rowFunctions[key],
+						funcNode = $('<a href="#" style="margin:0 2px;"></a>')
+				;
+				//funcNode = funObj.f(rowPK);
+				if ('href' in funObj) funcNode.attr('href', funObj.href.f(rowPK));
+				if ('ico' in funObj) funcNode.append('<span class="' + funObj.ico + '"></span>');
+				if ('onclick' in funObj) funcNode.attr('onclick', funObj.onclick.f(rowPK));
+				if ('title' in funObj) funcNode.attr('title', funObj.title);
+				funcNode.appendTo(cellNode);
 			});
 			});
-			moreFuncBtnNode = $('<a href="#" style="text-decoration:none" title="Więcej funkcji" class="glyphicon glyphicon-menu-hamburger"> </a>');
+			moreFuncBtnNode = $('<a href="#" style="margin:0 2px;text-decoration:none" title="Więcej funkcji ['+rowPK+']" class="glyphicon glyphicon-menu-hamburger"> </a>');
 			moreFuncBtnNode.on('click', {rowPK: rowPK, rowFunctions: rowFunctions, more: moreFunctions}, priv.popoverCellMoreFunctions);
 			moreFuncBtnNode.on('click', {rowPK: rowPK, rowFunctions: rowFunctions, more: moreFunctions}, priv.popoverCellMoreFunctions);
 			moreFuncBtnNode.appendTo(cellNode);
 			moreFuncBtnNode.appendTo(cellNode);
 			return cellNode;
 			return cellNode;
 		};
 		};
 
 
+		priv.generateMoreFunctionsNodeList = function (moreFunctions, rowFunctions, rowPK) {
+			var moreFuncNodeList = [];
+			moreFunctions.forEach(function(funcName) {
+				var funObj = rowFunctions[funcName],
+						funcNode = $('<a href="#" style="margin:0 2px;"></a>')
+				;
+				//moreFuncNodeList += link.f(rowPK);
+				if ('href' in funObj) funcNode.attr('href', funObj.href.f(rowPK));
+				if ('ico' in funObj) funcNode.append('<span class="' + funObj.ico + '"></span>');
+				if ('onclick' in funObj) funcNode.attr('onclick', funObj.onclick.f(rowPK));
+				if ('title' in funObj) funcNode.attr('title', funObj.title);
+				if ('title' in funObj) funcNode.append(' ' + funObj.title);
+				moreFuncNodeList.push(funcNode);
+			});
+			return moreFuncNodeList;
+		};
+
 		priv.popoverCellMoreFunctions = function (e) {
 		priv.popoverCellMoreFunctions = function (e) {
 			e.preventDefault();
 			e.preventDefault();
 			e.stopPropagation();
 			e.stopPropagation();
-console.log('priv.popoverCellMoreFunctions::rowPK', e.data.rowPK, 'moreFunctions', e.data.more, 'rowFunctions', e.data.rowFunctions);
+			if (priv.options.debug) console.log('TableAjax::popoverCellMoreFunctions: rowPK', e.data.rowPK, 'moreFunctions', e.data.more, 'rowFunctions', e.data.rowFunctions);
 			if ('rowPK' in e.data && e.data.rowPK > 0) {
 			if ('rowPK' in e.data && e.data.rowPK > 0) {
 				var lastId = _popoverCell.data('rowid'),
 				var lastId = _popoverCell.data('rowid'),
 						lastCol = _popoverCell.data('col'),
 						lastCol = _popoverCell.data('col'),
 						rowPK = e.data.rowPK,
 						rowPK = e.data.rowPK,
-						moreFuncHtml = 'TODO: moreFunctions=['+e.data.more.join(',')+']';
+						moreFuncNodeList = null
+				;
 
 
 				if (lastId == e.data.rowPK && lastCol == 'moreFunctions') {
 				if (lastId == e.data.rowPK && lastCol == 'moreFunctions') {
 					//_popoverCellCurrent.popover('toggle');
 					//_popoverCellCurrent.popover('toggle');
@@ -1029,9 +1055,12 @@ console.log('priv.popoverCellMoreFunctions::rowPK', e.data.rowPK, 'moreFunctions
 						_popoverCellCurrent.popover('destroy');
 						_popoverCellCurrent.popover('destroy');
 					}
 					}
 
 
+					moreFuncNodeList = priv.generateMoreFunctionsNodeList(e.data.more, e.data.rowFunctions, rowPK);
+
 					_popoverCell.data('rowid', rowPK);
 					_popoverCell.data('rowid', rowPK);
 					_popoverCell.data('col', 'rowFunctions');
 					_popoverCell.data('col', 'rowFunctions');
-					_popoverCell.html(moreFuncHtml + '<div class="popoverCellContent" style="white-space:normal"></div>');
+					_popoverCell.html(moreFuncNodeList);
+					_popoverCell.append('<div class="popoverCellContent" style="white-space:normal"></div>');
 
 
 					_popoverCellCurrent = jQuery(e.currentTarget);
 					_popoverCellCurrent = jQuery(e.currentTarget);
 					// title : '<span class="text-info"><strong>title</strong></span> <button type="button" id="close" class="close">&times;</button>'
 					// title : '<span class="text-info"><strong>title</strong></span> <button type="button" id="close" class="close">&times;</button>'
@@ -1042,15 +1071,15 @@ console.log('priv.popoverCellMoreFunctions::rowPK', e.data.rowPK, 'moreFunctions
 						html: true,
 						html: true,
 						content: _popoverCell.html()
 						content: _popoverCell.html()
 					}
 					}
-					opts.template += '<div class="popover" role="tooltip">';
+					opts.template += '<div class="popover" role="tooltip" style="max-width:400px;width:300px;">';
 					{
 					{
 						opts.template += '<div class="arrow"></div>';
 						opts.template += '<div class="arrow"></div>';
 						//opts.template += '<h3 class="popover-title"></h3>';
 						//opts.template += '<h3 class="popover-title"></h3>';
-						opts.template += '<div style="width:300px;display:block;position:relative;padding:0 20px 0 0;">';
+						opts.template += '<div style="display:block;position:relative;">';
 						{
 						{
 							opts.template += '<div class="popover-title">';
 							opts.template += '<div class="popover-title">';
 							opts.template += '</div>';
 							opts.template += '</div>';
-							opts.template += '<button type="button" class="close" onclick="return hidePopover();" style="position:absolute;right:0;top:0;">&times;</button>';
+							opts.template += '<button type="button" class="close" onclick="return hidePopover();" style="position:absolute;right:8px;top:6px;">&times;</button>';
 						}
 						}
 						opts.template += '</div>';
 						opts.template += '</div>';
 						opts.template += '<div class="popover-content"></div>';
 						opts.template += '<div class="popover-content"></div>';
@@ -1062,7 +1091,7 @@ console.log('priv.popoverCellMoreFunctions::rowPK', e.data.rowPK, 'moreFunctions
 						if (_popoverCellCurrent) {
 						if (_popoverCellCurrent) {
 							var popoverNodeId = _popoverCellCurrent.attr('aria-describedby');
 							var popoverNodeId = _popoverCellCurrent.attr('aria-describedby');
 							if (popoverNodeId) {
 							if (popoverNodeId) {
-								jQuery('#' + popoverNodeId).css({maxWidth:'400px', width:'300px'});
+								jQuery('#' + popoverNodeId).find('.popoverCellContent').html('<p class="text-muted">Pobieranie funkcji...<p>');
 							}
 							}
 						}
 						}
 						priv.ajaxLoadMoreFunctionsCell(rowPK);
 						priv.ajaxLoadMoreFunctionsCell(rowPK);
@@ -1080,9 +1109,6 @@ console.log('priv.popoverCellMoreFunctions::rowPK', e.data.rowPK, 'moreFunctions
 			if (_popoverCellAjaxXhr) {
 			if (_popoverCellAjaxXhr) {
 				_popoverCellAjaxXhr.abort();
 				_popoverCellAjaxXhr.abort();
 			}
 			}
-			var addHtml = '<p>TODO: more functions for ' + rowPK + '</p>';
-			_popoverCell.append(addHtml);
-			_popoverCell.find('.popoverCellContent').append(addHtml);
 
 
 			_popoverCellAjaxXhr = $.ajax({
 			_popoverCellAjaxXhr = $.ajax({
 				type: 'GET',
 				type: 'GET',
@@ -1098,7 +1124,7 @@ console.log('priv.popoverCellMoreFunctions::rowPK', e.data.rowPK, 'moreFunctions
 						if (_popoverCellCurrent) {
 						if (_popoverCellCurrent) {
 							var popoverNodeId = _popoverCellCurrent.attr('aria-describedby');
 							var popoverNodeId = _popoverCellCurrent.attr('aria-describedby');
 							if (popoverNodeId) {
 							if (popoverNodeId) {
-								jQuery('#' + popoverNodeId).find('.popoverCellContent').append(addHtml);
+								jQuery('#' + popoverNodeId).find('.popoverCellContent').html(addHtml);
 							}
 							}
 						}
 						}
 					}
 					}
@@ -2871,7 +2897,7 @@ console.log('priv.popoverCellMoreFunctions::rowPK', e.data.rowPK, 'moreFunctions
 	$forceFilterInit = $this->_forceFilterInit;
 	$forceFilterInit = $this->_forceFilterInit;
 	$pageSizes = $this->_pageSizes;
 	$pageSizes = $this->_pageSizes;
 	$pageSize = $this->_pageSize;
 	$pageSize = $this->_pageSize;
-	$rowFunctions = $this->_showRowFunctionsJson();
+	$rowFunctions = $this->_rowFunctions;//$this->_showRowFunctionsJson();
 	$exportFields = $this->_showExportFieldsJson();
 	$exportFields = $this->_showExportFieldsJson();
 ?>
 ?>
 		<script>
 		<script>
@@ -5119,7 +5145,7 @@ function fileListActions<?php echo $this->_htmlID; ?>() {
 	var filePermsReload = jQuery('#FILES_LIST_ACTIONS_<?php echo $this->_htmlID; ?>');
 	var filePermsReload = jQuery('#FILES_LIST_ACTIONS_<?php echo $this->_htmlID; ?>');
 	var btnReload = jQuery('<button class="btn-link btn-sm" title="odśwież uprawnienia do plików"><span class="glyphicon glyphicon-refresh"></span>Odśwież</button>');
 	var btnReload = jQuery('<button class="btn-link btn-sm" title="odśwież uprawnienia do plików"><span class="glyphicon glyphicon-refresh"></span>Odśwież</button>');
 	btnReload.on('click', function(e) {
 	btnReload.on('click', function(e) {
-		console.log('TODO: click reload perms...');
+		//console.log('TODO: click reload perms...');
 
 
 		function notifyAjaxCallback(data) {
 		function notifyAjaxCallback(data) {
 			var notify = {};
 			var notify = {};