Parcourir la source

added open ref js function to override

Piotr Labudda il y a 8 ans
Parent
commit
d17126a0e1
2 fichiers modifiés avec 45 ajouts et 6 suppressions
  1. 21 6
      SE/se-lib/TableAjax.php
  2. 24 0
      SE/se-lib/TableAjax.php.openRef.js

+ 21 - 6
SE/se-lib/TableAjax.php

@@ -1177,12 +1177,26 @@ class TableAjax extends ViewAjax {
 				if ('ref' === columnProps.type) showTooltip = false;
 				if ('ref' === columnProps.type) cellNode.css('padding', "3px")
 				if ('ref' === columnProps.type && priv.options.debug) console.log('renderRow rowPK('+rowPK+') columnProps', columnProps)
-				if ('ref' === columnProps.type) cellNode.html('<a href="index.php?_route=ViewTableAjax' +
-					'&namespace=' + columnProps.xsdRefNsPrefix.replace('__x3A__', '/') + '/' + columnProps.xsdRefType +
-					'&backRefNS=' + priv.options.namespace +
-					'&backRefPK=' + rowPK +
-					'&backRefField=' + columnProps.column +
-					'">przeglądaj</a>')
+				// if ('ref' === columnProps.type) cellNode.html('<a href="index.php?_route=ViewTableAjax' +
+				// 	'&namespace=' + columnProps.xsdRefNsPrefix.replace('__x3A__', '/') + '/' + columnProps.xsdRefType +
+				// 	'&backRefNS=' + priv.options.namespace +
+				// 	'&backRefPK=' + rowPK +
+				// 	'&backRefField=' + columnProps.column +
+				// 	'">przeglądaj</a>')
+				if ('ref' === columnProps.type) {
+					cellNode.html('<a onClick="return p5UI__tableAjaxOpenRefCell(' +
+						'\'' + columnProps.xsdRefNsPrefix.replace('__x3A__', '/') + '/' + columnProps.xsdRefType + '\', ' + // namespace
+						'\'' + priv.options.namespace + '\', ' + // backRefNS
+						'\'' + rowPK + '\', ' + // backRefPK
+						'\'' + columnProps.column + '\')' + // backRefField
+						'" ' +
+						'href="index.php?_route=ViewTableAjax' +
+						'&namespace=' + columnProps.xsdRefNsPrefix.replace('__x3A__', '/') + '/' + columnProps.xsdRefType +
+						'&backRefNS=' + priv.options.namespace +
+						'&backRefPK=' + rowPK +
+						'&backRefField=' + columnProps.column +
+						'">przeglądaj</a>')
+				}
 
 				if (columnProps.xsdType && 'xsd:base64Binary' === columnProps.xsdType) {
 					cellCnt.empty();
@@ -3501,6 +3515,7 @@ class TableAjax extends ViewAjax {
 		'FUNCTION_EDIT_ROUTE' => "TableAjax__EDIT_Route",
 		'URL_EDIT_FORM_AJAX' => "{$this->syncUrl}&_hash={$this->_htmlID}&_task=editFormJson&_primaryKey=",
 	]);
+	UI::inlineJS(__FILE__ . '.openRef.js', []); // p5UI__tableAjaxOpenRefCell
 
 	$fltrs = (method_exists($acl, 'getSpecialFilters')) ? $acl->getSpecialFilters() : null;
 	$jsonSpecialFilters = (!empty($fltrs)) ? json_encode($fltrs) : 'false';

+ 24 - 0
SE/se-lib/TableAjax.php.openRef.js

@@ -0,0 +1,24 @@
+// @require variables:
+// if ('undefined' === typeof TABLE_AJAX_NODE_ID) throw "Missing TABLE_AJAX_NODE_ID"; // $this->_htmlID,
+
+function p5UI__tableAjaxOpenRefCell(namespace, backRefNS, backRefPK, backRefField) {
+	// console.log('p5UI__tableAjaxOpenRefCell', {namespace: namespace, backRefNS: backRefNS, backRefPK: backRefPK, backRefField: backRefField})
+	// return false;
+
+	// <a onClick="return p5UI__tableAjaxOpenRefCell(' +
+	// 	'\'' + columnProps.xsdRefNsPrefix.replace('__x3A__', '/') + '/' + columnProps.xsdRefType + '\', ' + // namespace
+	// 	'\'' + priv.options.namespace + '\', ' + // backRefNS
+	// 	'\'' + rowPK + '\', ' + // backRefPK
+	// 	'\'' + columnProps.column + '\')' + // backRefField
+	// 	'" ' +
+	// 	'href="index.php?_route=ViewTableAjax' +
+	// 	'&namespace=' + columnProps.xsdRefNsPrefix.replace('__x3A__', '/') + '/' + columnProps.xsdRefType +
+	// 	'&backRefNS=' + priv.options.namespace +
+	// 	'&backRefPK=' + rowPK +
+	// 	'&backRefField=' + columnProps.column +
+	// 	'">przeglądaj</a>')
+
+	return true;
+}
+
+global.p5UI__tableAjaxOpenRefCell = p5UI__tableAjaxOpenRefCell