Procházet zdrojové kódy

updated row functions view for ref list

Piotr Labudda před 7 roky
rodič
revize
0070a25ca6
1 změnil soubory, kde provedl 81 přidání a 16 odebrání
  1. 81 16
      SE/se-lib/TableAjax.php.TableAjax.js

+ 81 - 16
SE/se-lib/TableAjax.php.TableAjax.js

@@ -1641,6 +1641,13 @@ var TableAjax = function() {
 		}
 		}
 		moreFunctions = keys.splice(3);
 		moreFunctions = keys.splice(3);
 		keys.forEach(function(key) {
 		keys.forEach(function(key) {
+			// TODO: support for ui-function in rowFunctions
+			// var funObj = rowFunctions[key];
+			// var funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, {ico: true, label: false});
+			// DBG1 && console.log('TableAjax::renderCellRowFunctions: rowFunction[' + key + ']', { funObj: funObj, uiFunc: funObj['ui-function'], uiFuncExists: global[funObj['ui-function']] });
+			// if (funObj['ui-function'] && global[funObj['ui-function']]) {
+			// 	funcNode.on('click', function (event) { event.preventDefault(); global[funObj['ui-function']](rowPK); });
+			// }
 			var funObj = rowFunctions[key],
 			var funObj = rowFunctions[key],
 					funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, {ico: true, label: false})
 					funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, {ico: true, label: false})
 			;
 			;
@@ -1689,19 +1696,19 @@ var TableAjax = function() {
 			funcNode.addClass('func_name-' + funcName);
 			funcNode.addClass('func_name-' + funcName);
 			funcItemNode.append(funcNode);
 			funcItemNode.append(funcNode);
 		});
 		});
-		if (3 === priv.options.namespace.split('/').length) { // if namesapce is AntAcl [ and has ref fields or back ref ]
-			var funcItemNode = $('<li></li>').appendTo(funcListNode)
-			var funObj = {
-				ico: 'glyphicon glyphicon-random',
-				label: 'Przeglądaj powiązania',
-				href: 'index.php?_route=RefGraph&namespace=' + priv.options.namespace + '&primaryKey=' + rowPK,
-				// onclick: function (e) { // TODO: open in
-				// 	console.log('TODO: przeglądaj powiązania')
-				// }
-			}
-			var funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, { ico: true, label: true })
-			funcItemNode.append(funcNode);
-		}
+		// if (3 === priv.options.namespace.split('/').length) { // if namesapce is AntAcl [ and has ref fields or back ref ]
+		// 	var funcItemNode = $('<li></li>').appendTo(funcListNode)
+		// 	var funObj = {
+		// 		ico: 'glyphicon glyphicon-random',
+		// 		label: 'Przeglądaj powiązania',
+		// 		href: 'index.php?_route=RefGraph&namespace=' + priv.options.namespace + '&primaryKey=' + rowPK,
+		// 		// onclick: function (e) { // TODO: open in
+		// 		// 	console.log('TODO: przeglądaj powiązania')
+		// 		// }
+		// 	}
+		// 	var funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, { ico: true, label: true })
+		// 	funcItemNode.append(funcNode);
+		// }
 
 
 		_popoverCell.append('<div class="popoverCellContent" style="white-space:normal"></div>');
 		_popoverCell.append('<div class="popoverCellContent" style="white-space:normal"></div>');
 
 
@@ -1772,9 +1779,26 @@ var TableAjax = function() {
 				if (data.rowFunctions && data.rowFunctions.length > 0) {
 				if (data.rowFunctions && data.rowFunctions.length > 0) {
 					rowFunctions = data.rowFunctions;
 					rowFunctions = data.rowFunctions;
 				}
 				}
-				if (rowFunctions.length > 0) {
+				if (!rowFunctions.length) {
+					popoverCellContent = '<p class="text-muted">Brak dodatkowych funkcji</p>';
+				} else if (3 === priv.options.namespace.split('/').length) { // if namesapce is AntAcl [ and has ref fields or back ref ]
 					var popoverCellContent = $('<ul class="list-unstyled"></ul>');
 					var popoverCellContent = $('<ul class="list-unstyled"></ul>');
-					rowFunctions.forEach(function(funObj) {
+					var rowFunctionsByType = rowFunctions.reduce(function (ret, funObj) {
+						if ('Powiązania od' === funObj.label.substr(0, 'Powiązania od'.length)) {
+							ret.refConnections.push(funObj);
+						} else if ('Powiązania do' === funObj.label.substr(0, 'Powiązania do'.length)) {
+							ret.refConnections.push(funObj);
+						} else {
+							ret.others.push(funObj);
+						}
+						return ret;
+						// href: "https://biuro.biall-net.pl/dev-pl/se-master/index.php?_route=ViewTableAjax&namespace=default_db/BI_audit_KRS/BI_audit_KRS&childRefNS=default_db/BI_audit_KRS/BI_audit_KRS&childRefPK=2068689"
+						// ico: "glyphicon glyphicon-random"
+						// label: "Powiązania od 'KRS' <span class="badge">0</span>"
+						// title: "Powiązania od 'Audyt / KRS' (0)"
+					}, { refConnections: [], others: [] });
+
+					rowFunctionsByType.others.forEach(function(funObj) {
 						var funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, {ico: true, label: true});
 						var funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, {ico: true, label: true});
 						if (funObj.id) {
 						if (funObj.id) {
 							funcNodesToUpdate.push({id: funObj.id, node: funcNode});
 							funcNodesToUpdate.push({id: funObj.id, node: funcNode});
@@ -1783,9 +1807,50 @@ var TableAjax = function() {
 							funcItemNode.append(funcNode);
 							funcItemNode.append(funcNode);
 						}
 						}
 					});
 					});
+
+					if (!rowFunctionsByType.refConnections.length) {
+						$('<li>Brak powiązań</li>').appendTo(popoverCellContent);
+					} else {
+						var refConnItemNode = $('<li style="margin-top:10px"><i class="glyphicon glyphicon-random"></i> <b>Powiązania</b></li>').appendTo(popoverCellContent);
+						{
+							var funObj = {
+								// ico: 'glyphicon glyphicon-random',
+								label: 'przeglądaj',
+								title: "Przeglądaj powiązania",
+								href: 'index.php?_route=RefGraph&namespace=' + priv.options.namespace + '&primaryKey=' + rowPK,
+								// onclick: function (e) { // TODO: open in
+								// 	console.log('TODO: przeglądaj powiązania')
+								// }
+							}
+							var funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, { ico: true, label: true })
+							refConnItemNode.append(" - ");
+							refConnItemNode.append(funcNode);
+						}
+						var refConnFuncList = $('<ul class="list-unstyled" style="margin-left:20px"></ul>').appendTo(refConnItemNode);
+						rowFunctionsByType.refConnections.forEach(function(funObj) {
+							var refFunObj = Object.assign({}, funObj, {
+								// ico: null,
+								label: funObj.label.substr('Powiązania '.length),
+							});
+							var funcNode = p5UI_TableAjax_generateFunctionNode(refFunObj, rowPK, {ico: true, label: true});
+							var funcItemNode = $('<li></li>').appendTo(refConnFuncList);
+							funcItemNode.append(funcNode);
+						})
+					}
 				} else {
 				} else {
-					popoverCellContent = '<p class="text-muted">Brak dodatkowych funkcji</p>';
+					var popoverCellContent = $('<ul class="list-unstyled"></ul>');
+					rowFunctions.forEach(function(funObj) {
+						var funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, {ico: true, label: true});
+						if (funObj.id) {
+							funcNodesToUpdate.push({id: funObj.id, node: funcNode});
+						} else {
+							var funcItemNode = $('<li></li>').appendTo(popoverCellContent);
+							funcItemNode.append(funcNode);
+						}
+					});
 				}
 				}
+
+
 				//_popoverCell.append(popoverCellContent);// cache
 				//_popoverCell.append(popoverCellContent);// cache
 				if (_popoverCellCurrent) {
 				if (_popoverCellCurrent) {
 					var popoverNodeId = _popoverCellCurrent.attr('aria-describedby');
 					var popoverNodeId = _popoverCellCurrent.attr('aria-describedby');