ソースを参照

U more feature functions ref list view

Piotr Labudda 7 年 前
コミット
cf30ebcd00
1 ファイル変更26 行追加18 行削除
  1. 26 18
      SE/se-lib/TableAjax.php.TableAjax.js

+ 26 - 18
SE/se-lib/TableAjax.php.TableAjax.js

@@ -1696,19 +1696,6 @@ var TableAjax = function() {
 			funcNode.addClass('func_name-' + funcName);
 			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>');
 
@@ -1784,10 +1771,15 @@ var TableAjax = function() {
 				} 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 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);
+						if (
+							'Powiązania od ' === funObj.label.substr(0, 'Powiązania od '.length)
+							|| 'Powiązania do ' === funObj.label.substr(0, 'Powiązania do '.length)
+						) {
+							if (funObj.total > 0) {
+								ret.refConnections.push(funObj);
+							} else {
+								ret.refEmptyConnections.push(funObj);
+							}
 						} else {
 							ret.others.push(funObj);
 						}
@@ -1796,7 +1788,7 @@ var TableAjax = function() {
 						// ico: "glyphicon glyphicon-random"
 						// label: "Powiązania od 'KRS' <span class="badge">0</span>"
 						// title: "Powiązania od 'Audyt / KRS' (0)"
-					}, { refConnections: [], others: [] });
+					}, { refConnections: [], refEmptyConnections: [], others: [] });
 
 					rowFunctionsByType.others.forEach(function(funObj) {
 						var funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, {ico: true, label: true});
@@ -1837,6 +1829,22 @@ var TableAjax = function() {
 							funcItemNode.append(funcNode);
 						})
 					}
+					if (rowFunctionsByType.refEmptyConnections.length) {
+						var refConnItemNode = $('<li style="margin-top:10px; opacity:0.7"></li>').appendTo(popoverCellContent);
+						var emptyRefsDetailsNode = $('<details></details>').appendTo(refConnItemNode);
+						// $('<summary><i class="glyphicon glyphicon-random"></i> Pozostałe powiązania</summary>').appendTo(emptyRefsDetailsNode);
+						$('<summary style="cursor:pointer">Pozostałe powiązania ...</summary>').appendTo(emptyRefsDetailsNode);
+						var refConnFuncList = $('<ul class="list-unstyled" style="margin-left:20px"></ul>').appendTo(emptyRefsDetailsNode);
+						rowFunctionsByType.refEmptyConnections.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 {
 					var popoverCellContent = $('<ul class="list-unstyled"></ul>');
 					rowFunctions.forEach(function(funObj) {