Sfoglia il codice sorgente

fixed TableAjax js files - proces init filtr

Piotr Labudda 8 anni fa
parent
commit
eee8b13456

+ 0 - 1
SE/se-lib/Route/Budget.php

@@ -821,7 +821,6 @@ END
 		$tbl->addRowFunction('hist');
 		$tbl->addRowFunction('files');
 		$tbl->addRowFunction('cp');
-		$tbl->showProcesInit(false);
 		echo $tbl->render();
 
 		UI::dol();

+ 0 - 2
SE/se-lib/Route/Users.php

@@ -453,7 +453,6 @@ class Route_Users extends RouteBase {
 			$tbl->addRowFunction('hist');
 			$tbl->addRowFunction('files');
 			$tbl->addRowFunction('cp');
-			$tbl->showProcesInit(false);// hide Proces filter field
 			echo $tbl->render();
 		}
 	}
@@ -651,7 +650,6 @@ class Route_Users extends RouteBase {
 			$tbl->addRowFunction('hist');
 			$tbl->addRowFunction('files');
 			$tbl->addRowFunction('cp');
-			$tbl->showProcesInit(false);// hide Proces filter field
 			echo $tbl->render();
 		}
 	}

+ 1 - 1
SE/se-lib/Route/ViewObject.php

@@ -20,7 +20,7 @@ class Route_ViewObject extends Route_ViewTableAjax {
 	public function getTableAjaxWidget($acl) {
 		$syncUrl = Request::getPathUri() . 'index.php?_route=ViewObject&namespace=' . $acl->getNamespace();
 		$tbl = new TableAjax($acl);
-		$tbl->showProcesInit(false); // TODO: activate when ready
+		// $tbl->showProcesInitFiltr = true; // TODO: activate when ready
 		$tblLabel = $acl->getNamespace();
 		if ('default_db' == $acl->getSourceName()) {
 			$tblLabel = array();

+ 5 - 4
SE/se-lib/Route/ViewTableAjax.php

@@ -16,19 +16,20 @@ Lib::loadClass('UserProfile');
 class Route_ViewTableAjax extends RouteBase {
 
 	public function getTableAjaxWidget($acl) {
-		$syncUrl = Request::getPathUri() . 'index.php?_route=ViewTableAjax&namespace=' . $acl->getNamespace();
+		$syncUrl = $this->getLink('', [ 'namespace' => $acl->getNamespace() ]);
 		$tbl = new TableAjax($acl);
 		$tblLabel = $acl->getNamespace();
 		if ('default_db' == $acl->getSourceName()) {
 			$tblLabel = array();
 			$zasobObj = ProcesHelper::getZasobTableInfo($acl->getID());
 			if (!$zasobObj) throw new Exception("Zasob TABELA ID=" . $acl->getID() . " nie istnieje");
-			if (!empty($zasobObj->DESC_PL)) $tblLabel []= $zasobObj->DESC_PL;
-			if (!empty($zasobObj->OPIS))    $tblLabel []= $zasobObj->OPIS;
+			if (!empty($zasobObj->DESC_PL)) $tblLabel[] = $zasobObj->DESC_PL;
+			if (!empty($zasobObj->OPIS))    $tblLabel[] = $zasobObj->OPIS;
 			$tblLabel = implode(" - ", $tblLabel);
 		}
 		$tbl->setSyncUrl($syncUrl);
-		$tbl->showUserTableFilter($this->getLink("getUserTableFilterAjax"));
+		$tbl->showProcesInitFiltr = true;
+		$tbl->useUserTableFilter = $this->getLink("getUserTableFilterAjax");
 		$tbl->setLabel($tblLabel);
 		$tbl->addRowFunction('edit');
 		$tbl->addRowFunction('hist');

+ 60 - 290
SE/se-lib/TableAjax.php

@@ -16,15 +16,15 @@ Lib::loadClass('Core_AclHelper');
 
 class TableAjax extends ViewAjax {
 
-	private $_cnf = '';// Column
-	private $_htmlID = '';
-	private $_rowFunctions = array();
-	private $_pageSize = 10;
-	private $_pageSizes = array();
-	private $_filterInit = null;
-	private $_forceFilterInit = null;
-	private $_showProcesInit = true;
-	private $_useUserTableFilter = false;
+	public $_cnf = '';// Column
+	public $_htmlID = '';
+	public $_rowFunctions = array();
+	public $_pageSize = 10;
+	public $_pageSizes = array();
+	public $_filterInit = null;
+	public $_forceFilterInit = null;
+	public $showProcesInitFiltr = false;
+	public $useUserTableFilter = false;
 	public $syncUrl = null;
 
 	public function __construct($tblAcl) {
@@ -55,14 +55,6 @@ class TableAjax extends ViewAjax {
 		$this->syncUrl = $syncUrl;
 	}
 
-	public function showProcesInit($bool = true) {
-		$this->_showProcesInit = $bool;
-	}
-
-	public function showUserTableFilter($url = null) {
-		$this->_useUserTableFilter = $url;
-	}
-
 	private function _hasStateFilterInit() {
 		return array_key_exists($this->_htmlID, $_SESSION['TableAjax_Cache']) && array_key_exists('_filterInit', $_SESSION['TableAjax_Cache'][$this->_htmlID]);
 	}
@@ -413,167 +405,56 @@ class TableAjax extends ViewAjax {
 		?>
 		<div class="AjaxTableCont">
 			<ul class="breadcrumb">
-				<li><a href="#" onclick="return tableAjaxBackToTable();"><?php echo $this->getLabelHtml(); ?></a></li>
-				<!-- TODO: if has perm 'C' then add btn to create new record -->
-				<?php if ($hasPermCreate) : ?>
-					<li><a title="Dodaj nowy rekord"
-								 class=""
-								 href="#CREATE"><span class="glyphicon glyphicon-plus"></span> Dodaj nowy rekord</a></li>
-				<?php endif; ?>
-				<?php if ($this->_showProcesInit) : ?>
-				<div class="btn-group pull-right">
-					<a class="btn btn-xs btn-info dropdown-toggle"
-						 data-toggle="dropdown"
-						 href="#"
-						 title="Uruchom filtr procesu powiązanego z tabelą <?php echo $this->getLabel(); ?>"
-						 onclick="return <?php echo $jsToogleFiltrProcesuFunctionName; ?>(this);">
-						Filtr procesu <span class="caret"></span>
-					</a>
-					<ul class="dropdown-menu pull-left" style="max-height:250px;overflow:auto;">
-						<li class="disabled"><a href="#" onclick="return false;"> loading ... </a></li>
-					</ul>
-				</div>
-				<?php endif; ?>
+				<?php
+				echo UI::h('li', [], [
+					UI::h('a', [ 'href' => "#", 'onclick' => "return tableAjaxBackToTable();" ], $this->getLabelHtml() ),
+				]);
+				if ($hasPermCreate) {
+					echo UI::h('li', [], [
+						UI::h('a', [ 'title' => "Dodaj nowy rekord", 'class' => "", 'href' => "#CREATE" ], [
+							UI::h('span', [ 'class' => "glyphicon glyphicon-plus" ]),
+							" Dodaj nowy rekord",
+						]),
+					]);
+				}
+				if ($this->showProcesInitFiltr) {
+					echo UI::h('div', [ 'class' => "btn-group pull-right" ], [
+						UI::h('a', [ 'class' => "btn btn-xs btn-info dropdown-toggle",
+							 'data-toggle' => "dropdown",
+							 'href' => "#",
+							 'title' => "Uruchom filtr procesu powiązanego z tabelą " . $this->getLabel(),
+							 'onclick' => "return {$jsToogleFiltrProcesuFunctionName}(this);",
+						 ], "Filtr procesu <span class=\"caret\"></span>"),
+						UI::h('ul', [ 'class' => "dropdown-menu pull-left", 'style' => "max-height:250px;overflow:auto;" ], [
+							UI::h('li', [ 'class' => "disabled" ], [
+								UI::h('a', [ 'href' => "#", 'onclick' => "return false;" ], " loading ... "),
+							]),
+						]),
+					]);
+				}
+				?>
 				<?php if ($this->_tbl == 'IN7_MK_BAZA_DYSTRYBUCJI') : ?>
-					<a class="pull-right" style="padding:0 20px 0 0;" href="<?php echo "index.php?MENU_INIT=TREEJS&ZASOB_ID={$this->_zasobID}"; ?>"><i class="glyphicon glyphicon-eye-open"></i> Drzewo</a>
+					<a class="pull-right" style="padding:0 20px 0 0;" href="<?= "index.php?MENU_INIT=TREEJS&ZASOB_ID={$this->_zasobID}"; ?>"><i class="glyphicon glyphicon-eye-open"></i> Drzewo</a>
 				<?php elseif ($this->allowTreeView()) : ?>
-					<a class="pull-right" style="padding:0 20px 0 0;" href="<?php echo "index.php?MENU_INIT=VIEWTREE_AJAX&ZASOB_ID={$this->_zasobID}"; ?>"><i class="glyphicon glyphicon-eye-open"></i> Drzewo</a>
+					<a class="pull-right" style="padding:0 20px 0 0;" href="<?= "index.php?MENU_INIT=VIEWTREE_AJAX&ZASOB_ID={$this->_zasobID}"; ?>"><i class="glyphicon glyphicon-eye-open"></i> Drzewo</a>
 				<?php endif; ?>
 				<?php if ($this->_tbl == 'WMS_MAP_GEOREFERENCES') : ?>
-					<a class="pull-right" style="padding:0 20px 0 0;" href="<?php echo "index.php?_route=GeoreferencesManager"; ?>"><i class="glyphicon glyphicon glyphicon-wrench"></i> Zarządzaj punktami</a>
+					<a class="pull-right" style="padding:0 20px 0 0;" href="<?= "index.php?_route=GeoreferencesManager"; ?>"><i class="glyphicon glyphicon glyphicon-wrench"></i> Zarządzaj punktami</a>
 				<?php endif; ?>
 			</ul>
-			<div id="<?php echo $this->_htmlID; ?>"></div>
+			<div id="<?= $this->_htmlID; ?>"></div>
 		</div>
+		<?php
+		UI::inlineJS(__FILE__ . '.generateFunctionNode.js');
+		UI::inlineJS(__FILE__ . '.GeomField.js');
+		$clsName = __CLASS__;
+		UI::inlineJS(__FILE__ . '.procesInitFiltr.js', [
+			'JS_FUNCTION_NAME' => $jsToogleFiltrProcesuFunctionName,
+			'URL_GET_PROCES_INIT_FILTR' => "index-ajax.php?_zasobID={$this->_zasobID}&_cls={$clsName}&_hash={$this->_htmlID}&_task=PROCES_INIT_FILTR",
+			'ID_ZASOB' => $this->_zasobID,
+		]);
+		?>
 		<script>
-
-var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
-	var defaultsProps = {
-				ico: true,
-				label: false
-			},
-			props = $.extend({}, defaultsProps, props);
-			funcNode = $('<a href="#" style="margin:0 2px;"></a>')
-	;
-	if ('href' in funObj) funcNode.attr('href', p5Utils__format(funObj.href, [rowPK]));
-	if (props.ico) {
-		if ('ico' in funObj) funcNode.append('<span class="' + funObj.ico + '"></span>');
-	}
-	if ('onclick' in funObj) funcNode.attr('onclick', p5Utils__format(funObj.onclick, [rowPK]));
-	if ('title' in funObj) funcNode.attr('title', funObj.title);
-	if ('target' in funObj) funcNode.attr('target', funObj.target);
-
-	if (props.label) {
-		if ('label' in funObj) {
-			funcNode.append(' ' + funObj.label);
-		} else if ('title' in funObj) {
-			funcNode.append(' ' + funObj.title);
-		}
-	}
-
-	return funcNode;
-};
-
-
-(function($) {
-	var TableAjaxGeomField = function() {
-		var priv = {}; //private api
-		var publ = {}; //public api
-
-		priv.options = {};
-		var defaults = {
-			recordID: '',
-			fieldValue: '',
-			hasValueClassName: 'TableAjaxGeomField-hasValue',
-			linkClassNamePrefix: 'TableAjaxGeomField',
-			linkSelectClassName: 'select',
-			linkSelectAddClassNames: '', // 'glyphicon glyphicon-map-marker'
-			linkRemoveClassName: 'remove',
-			linkRemoveAddClassNames: '', // 'glyphicon glyphicon-remove'
-			removeUrl: '',
-			onSelect: null,
-			onRemove: null,
-			debug: false
-		};
-
-		priv.init = function() {
-			priv.render();
-		};
-
-		priv.render = function() {
-			var state = priv.options;
-			var cellMapSelect = jQuery('<i title="Pokaż/utwórz obiekt na mapie"></i>');
-			cellMapSelect.addClass(state.linkClassNamePrefix + '-' + state.linkSelectClassName);
-			if (state.linkSelectAddClassNames) {
-				cellMapSelect.addClass(state.linkSelectAddClassNames);
-			}
-			cellMapSelect.on('click', {recordID: priv.options.recordID, fieldValue: priv.options.fieldValue}, function(e) {
-				if (typeof state.onSelect == "function") {
-					state.onSelect.call(this, e.data.recordID, e.data.fieldValue);
-				}
-			});
-
-			var cellMapRemove = jQuery('<i title="Usuń obiekt z mapy"></i>');
-			cellMapRemove.addClass(state.linkClassNamePrefix + '-' + state.linkRemoveClassName);
-			if (state.linkRemoveAddClassNames) {
-				cellMapRemove.addClass(state.linkRemoveAddClassNames);
-			}
-			cellMapRemove.on('click', {recordID: state.recordID, fieldValue: state.fieldValue}, function(e) {
-				if (typeof state.onRemove == "function") {
-					state.onRemove.call(this, publ, e.data.recordID, e.data.fieldValue);
-				}
-			});
-
-			var node = $(state.id);
-			node.empty();
-			node.addClass(state.linkClassNamePrefix);
-			node.removeClass(state.hasValueClassName);
-			if (state.fieldValue) {
-				node.addClass(state.hasValueClassName);
-			}
-
-			node.append(cellMapSelect);
-			node.append(cellMapRemove);
-		};
-
-		publ.setValue = function(value) {
-			if (priv.options.debug) console.log('TEST setValue: ', value, 'this', this);
-			priv.options.fieldValue = value;
-			priv.render();
-		};
-
-		publ.init = function(options) {
-			if (priv.options.debug) console.log('TableAjaxGeomField initialization...', options);
-			//merge supplied options with defaults
-			$.extend(priv.options, defaults, options);
-			priv.init();
-			return publ;
-		};
-		return publ;
-	};
-
-	$.fn.TableAjaxGeomFieldSetValue = function(value) {
-		return this.each(function() {
-			var tblAjaxMapGeomFld = $(this).data('TableAjaxGeomField');
-			if (tblAjaxMapGeomFld) {
-				tblAjaxMapGeomFld.setValue(value);
-			}
-		});
-		return this;
-	};
-
-	$.fn.TableAjaxGeomField = function(options) {
-		options = options || {};
-		return this.each(function() {
-			options.id = this;
-			if (!$(this).data('TableAjaxGeomField')) {
-				$(this).data('TableAjaxGeomField', new TableAjaxGeomField().init(options));
-			}
-		});
-		return this;
-	};
-}(jQuery));
-
 (function($, undefined) {
 	var TableAjax = function() {
 		var priv = {}; //private api
@@ -781,7 +662,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 			/// console.log('renderTable:: _uiNode$Table', _uiNode$Table);//TODO:DBG:RMME
 
 			//create the header which will later hold both sorting and filtering
-			/// console.log('L.<?php echo __LINE__; ?> renderTable:: _head', _head);//TODO:DBG:RMME
+			/// console.log('renderTable:: _head', _head);//TODO:DBG:RMME
 			if (!_head) {
 				_headSort = _headFilter = _headSpecialFilter = undefined;
 				//_head = $('<thead></thead>');
@@ -792,13 +673,13 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 
 			//create the header sorting row
 			if (!_headSort) {
-				/// console.log('L.<?php echo __LINE__; ?> renderTable::renderTableTheadSort...');//TODO:DBG:RMME
+				/// console.log('renderTable::renderTableTheadSort...');//TODO:DBG:RMME
 				priv.renderTableTheadSort();
 			}
 
 			//create the header filtering row
 			if (!_headFilter && priv.options.filter) {
-				/// console.log('L.<?php echo __LINE__; ?> renderTable::renderTableTheadFilter...');//TODO:DBG:RMME
+				/// console.log('renderTable::renderTableTheadFilter...');//TODO:DBG:RMME
 				priv.renderTableTheadFilter();
 				_headFilter = true;
 			}
@@ -883,7 +764,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 			if (_data.total == 0 && priv.options.hidePagerOnEmpty) {
 				$('.btn-toolbar', _foot).remove();
 			}
-			if (priv.options.debug) console.log('table created L.<?php echo __LINE__; ?>');
+			if (priv.options.debug) console.log('table created');
 			if (typeof priv.options.tableCreated == 'function') {
 				priv.options.tableCreated.call(_uiNode$Table.get(0), {table: _uiNode$Table.get(0)});
 			}
@@ -1076,7 +957,6 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 								recordID: fieldPK,
 								fieldValue: val,
 								hasValueClassName: 'cell-mapfld-hasValue',
-								//removeUrl: 'index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_cls=<?php echo __CLASS__; ?>&_hash=<?php echo $this->_htmlID; ?>&_task=THE_GEOM_REMOVE&ID=' + rowPK,
 								linkClassNamePrefix: 'cell-mapfld',
 								linkSelectClassName: 'select',
 								linkSelectAddClassNames: 'glyphicon glyphicon-map-marker',
@@ -2883,7 +2763,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 						},
 						credentials: 'same-origin',// add cookies
 						body: JSON.stringify({
-							namespace: '<?= $acl->getNamespace(); ?>',
+							namespace: priv.options.namespace,
 						})
 					}).then(function (response) {
 						return response.json()
@@ -3689,7 +3569,7 @@ jQuery(document).ready(function(){
 	jQuery('#<?php echo $this->_htmlID; ?>').TableAjax({
 		namespace: '<?= $acl->getNamespace(); ?>',
 		url: '<?= $this->syncUrl; ?>&_hash=<?= $this->_htmlID; ?>&_task=loadDataAjax',// priv.options.url
-		userTableFilterUrl: '<?= ($this->_useUserTableFilter) ? $this->_useUserTableFilter : ''; ?>',
+		userTableFilterUrl: '<?= ($this->useUserTableFilter) ? $this->useUserTableFilter : ''; ?>',
 		columnPicker: true,
 		filter: true,
 		filterInit: <?php echo json_encode($filterInit); ?>,
@@ -4011,112 +3891,6 @@ function hidePopover() {
 	}
 	return false;
 }
-
-function <?php echo $jsToogleFiltrProcesuFunctionName; ?>(n) {
-	var $n = jQuery(n);
-	var $ul = $n.next();
-	if ($n.data('fetched')) return false;
-
-	function parseProcesInitData(pInitData) {
-		var procesInitMapHtml = '';
-		if (!pInitData) {
-			return '<li><a href="#">' + "Brak danych" + '</a></li>';
-		} else {
-			function _viewProcesInitListItem(pInitId, gotoIds, pInitList) {
-				var label = pInitList[pInitId];
-				var jsInfo = "window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=" + pInitId + "&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;";
-				var out = '<a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=' + pInitId + '&MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $this->_zasobID; ?>" title="' + "{" + pInitId + "} " + label + '">';// TODO: change to _route=ViewTableAjax&typeName=p5_default_db:{tblName}
-					out += ' <i class="glyphicon glyphicon-info-sign"';
-						out += ' onclick="' + jsInfo + '"';
-						out += ' style="color:#aaa;"';
-						out += ' onmouseover="' + "this.style.color='#337AB7'" + '"';
-						out += ' onmouseout="' + "this.style.color='#aaa'" + '"></i>';
-					out += " {" + pInitId + "} " + label;
-				out += '</a>';
-				return out;
-			}
-			function _viewProcesGotoAndRetListItem(gotoId, pInitList) {
-				var label = pInitList[gotoId];
-				var jsInfo = "window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=" + gotoId + "&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;";
-				var out = '';
-				out += '<a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=' + gotoId + '&MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $this->_zasobID; ?>" title="' + "{" + gotoId + "} " + label + '">';// TODO: change to _route=ViewTableAjax&typeName=p5_default_db:{tblName}
-					out += ' <span style="padding:10px;"></span>';
-					out += ' <i class="glyphicon glyphicon-arrow-right" style="color:#aaa"></i>';
-					out += ' <i class="glyphicon glyphicon-info-sign"';
-						out += ' onclick="' + jsInfo + '"';
-						out += ' style="color:#aaa;"';
-						out += ' onmouseover="' + "this.style.color='#337AB7'" + '"';
-						out += ' onmouseout="' + "this.style.color='#aaa'" + '"></i>';
-					out += " {" + gotoId + "} " + label;
-				out += '</a>';
-				return out;
-			}
-			function _viewProcesGotoAndRetLvl2ListItem(gotoLvl2Id, pInitList) {
-				var label = pInitList[gotoLvl2Id];
-				var jsInfo = "window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=" + gotoLvl2Id + "&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;";
-				var out = '';
-				out += '<a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=' + gotoLvl2Id + '&MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $this->_zasobID; ?>" title="' + "{" + gotoLvl2Id + "} " + label + '">';// TODO: change to _route=ViewTableAjax&typeName=p5_default_db:{tblName}
-					out += ' <span style="padding:20px;"></span>';
-					out += ' <i class="glyphicon glyphicon-arrow-right" style="color:#aaa"></i>';
-					out += ' <i class="glyphicon glyphicon-info-sign"';
-						out += ' onclick="' + jsInfo + '"';
-						out += ' style="color:#aaa;"';
-						out += ' onmouseover="' + "this.style.color='#337AB7'" + '"';
-						out += ' onmouseout="' + "this.style.color='#aaa'" + '"></i>';
-					out += " {" + gotoLvl2Id + "} " + label;
-				out += '</a>';
-				return out;
-			}
-			var sel = '',
-					liStyle = "white-space:nowrap; overflow:hidden; max-width:500px; /* text-overflow:ellipsis; */";
-			$.map(pInitData.mapTree, function(gotoIds, vInitId) {
-				sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId)? ' class="disabled"' : '';
-				procesInitMapHtml += '<li' + sel + ' style="' + liStyle + '">';
-				procesInitMapHtml += _viewProcesInitListItem(vInitId, gotoIds, pInitData.pInitList);
-				procesInitMapHtml += '</li>' + "\n";
-				$.map(gotoIds, function(gotoLvl2Ids, gotoId) {
-					sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId)? ' class="disabled"' : '';
-					procesInitMapHtml += '<li' + sel + ' style="' + liStyle + '">';
-					procesInitMapHtml += _viewProcesGotoAndRetListItem(gotoId, pInitData.pInitList);
-					procesInitMapHtml += '</li>' + "\n";
-					$.map(gotoLvl2Ids, function(vBool, gotoLvl2Id) {
-						sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId)? ' class="disabled"' : '';
-						procesInitMapHtml += '<li' + sel + ' style="' + liStyle + '">';
-						procesInitMapHtml += _viewProcesGotoAndRetLvl2ListItem(gotoLvl2Id, pInitData.pInitList);
-						procesInitMapHtml += '</li>' + "\n";
-					});
-				});
-			});
-		}
-		return procesInitMapHtml;
-	}
-
-	jQuery.ajax({
-		data: null,
-		dataType: 'json',
-		type: "GET",
-		async: true,
-		url: 'index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_cls=<?php echo __CLASS__; ?>&_hash=<?php echo $this->_htmlID; ?>&_task=PROCES_INIT_FILTR',
-	})
-	.always(function(data, textStatus, jqXHR) {
-		var type = data.type || null,
-				msg = data.msg || "Error",
-				pInitData = data.pInitData || null;
-		if (type) {
-			if ('success' == type) {
-				$ul.html(parseProcesInitData(pInitData));
-			} else if ('error' == type) {
-				$ul.html('<li><a href="#">' + msg + '</a></li>');
-			} else {
-				$ul.html('<li><a href="#">Wystapił błąd podczas pobierania listy procesów</a></li>');
-			}
-		} else {
-			$ul.html('<li><a href="#">Wystapił błąd podczas pobierania listy procesów</a></li>');
-		}
-		$n.data('fetched', true);
-	});
-	return false;
-}
 		</script>
 		<?php
 		UI::inlineJS(__FILE__ . '.upload.js', [
@@ -5462,7 +5236,6 @@ jQuery(document).ready(function(){
 							UI::h('div', [
 								'id' => "FILES_MULTIPLE_UPLOAD_{$this->_htmlID}",
 								'style' => "width:86%; margin:10px auto; padding:40px 100px; background-color:#eee; border-radius:4px; text-align:center",
-								// 'ondrop' => "p5TA_onDrop(event, '{$id}', '{$namespace}')",
 								'ondrop' => "p5TAFiles_onDropMultiple(event, this, '{$id}', '{$namespace}')",
 								'ondragover' => "p5TAFiles_onDragOverMultiple(event, this)", // "event.preventDefault(); this.style.backgroundColor='#D9EDF7'",
 								'ondragleave' => "p5TAFiles_onDragLeaveMultiple(event, this)", // "event.preventDefault(); this.style.backgroundColor='#eee'",
@@ -6150,18 +5923,15 @@ jQuery(document).ready(function(){
 		$response = new stdClass();
 
 		$pInitList = array();// [proces_init_id] => label (DESC)
-		if (!$this->_showProcesInit) {
-			$response->type = 'error';
-			return $response;
-		}
 		$userAcl = User::getAcl();
 		$pInitList = $userAcl->getTableProcesInitList($this->_zasobID);
 
+		DBG::log($pInitList, 'array', "\$pInitList");
 		if (!empty($pInitList)) {
 			$procesIds = array_keys($pInitList);
 			$mapTree = ACL::getProcesInitMapTreeOnlyIds($procesIds);
-			DBG::_('DBG_MAP', '1', "mapTree", $mapTree, __CLASS__, __FUNCTION__, __LINE__);
-			DBG::_('DBG_MAP', '1', "pInitList", $pInitList, __CLASS__, __FUNCTION__, __LINE__);
+			DBG::log($mapTree, 'array', "\$mapTree");
+			DBG::log($pInitList, 'array', "\$pInitList");
 			$pInitListSelected = $this->getProcesInitSelected();
 			$response->pInitData = new stdClass();
 			$response->pInitData->pInitList = $pInitList;

+ 105 - 0
SE/se-lib/TableAjax.php.GeomField.js

@@ -0,0 +1,105 @@
+// @require jQuery
+
+// @require variables:
+// if ('undefined' === typeof UNIQ_HASH) throw "Missing UNIQ_HASH"; // $this->_htmlID
+
+(function($) {
+	var TableAjaxGeomField = function() {
+		var priv = {}; //private api
+		var publ = {}; //public api
+
+		priv.options = {};
+		var defaults = {
+			recordID: '',
+			fieldValue: '',
+			hasValueClassName: 'TableAjaxGeomField-hasValue',
+			linkClassNamePrefix: 'TableAjaxGeomField',
+			linkSelectClassName: 'select',
+			linkSelectAddClassNames: '', // 'glyphicon glyphicon-map-marker'
+			linkRemoveClassName: 'remove',
+			linkRemoveAddClassNames: '', // 'glyphicon glyphicon-remove'
+			removeUrl: '',
+			onSelect: null,
+			onRemove: null,
+			debug: false
+		};
+
+		priv.init = function() {
+			priv.render();
+		};
+
+		priv.render = function() {
+			var state = priv.options;
+			var cellMapSelect = jQuery('<i title="Pokaż/utwórz obiekt na mapie"></i>');
+			cellMapSelect.addClass(state.linkClassNamePrefix + '-' + state.linkSelectClassName);
+			if (state.linkSelectAddClassNames) {
+				cellMapSelect.addClass(state.linkSelectAddClassNames);
+			}
+			cellMapSelect.on('click', {recordID: priv.options.recordID, fieldValue: priv.options.fieldValue}, function(e) {
+				if (typeof state.onSelect == "function") {
+					state.onSelect.call(this, e.data.recordID, e.data.fieldValue);
+				}
+			});
+
+			var cellMapRemove = jQuery('<i title="Usuń obiekt z mapy"></i>');
+			cellMapRemove.addClass(state.linkClassNamePrefix + '-' + state.linkRemoveClassName);
+			if (state.linkRemoveAddClassNames) {
+				cellMapRemove.addClass(state.linkRemoveAddClassNames);
+			}
+			cellMapRemove.on('click', {recordID: state.recordID, fieldValue: state.fieldValue}, function(e) {
+				if (typeof state.onRemove == "function") {
+					state.onRemove.call(this, publ, e.data.recordID, e.data.fieldValue);
+				}
+			});
+
+			var node = $(state.id);
+			node.empty();
+			node.addClass(state.linkClassNamePrefix);
+			node.removeClass(state.hasValueClassName);
+			if (state.fieldValue) {
+				node.addClass(state.hasValueClassName);
+			}
+
+			node.append(cellMapSelect);
+			node.append(cellMapRemove);
+		};
+
+		publ.setValue = function(value) {
+			if (priv.options.debug) console.log('TEST setValue: ', value, 'this', this);
+			priv.options.fieldValue = value;
+			priv.render();
+		};
+
+		publ.init = function(options) {
+			if (priv.options.debug) console.log('TableAjaxGeomField initialization...', options);
+			//merge supplied options with defaults
+			$.extend(priv.options, defaults, options);
+			priv.init();
+			return publ;
+		};
+		return publ;
+	};
+
+	$.fn.TableAjaxGeomFieldSetValue = function(value) {
+		return this.each(function() {
+			var tblAjaxMapGeomFld = $(this).data('TableAjaxGeomField');
+			if (tblAjaxMapGeomFld) {
+				tblAjaxMapGeomFld.setValue(value);
+			}
+		});
+		return this;
+	};
+
+	$.fn.TableAjaxGeomField = function(options) {
+		options = options || {};
+		return this.each(function() {
+			options.id = this;
+			if (!$(this).data('TableAjaxGeomField')) {
+				$(this).data('TableAjaxGeomField', new TableAjaxGeomField().init(options));
+			}
+		});
+		return this;
+	};
+}(jQuery));
+
+// global['...'] = ...

+ 34 - 0
SE/se-lib/TableAjax.php.generateFunctionNode.js

@@ -0,0 +1,34 @@
+// @require p5Utils__format
+
+// @require variables:
+// if ('undefined' === typeof UNIQ_HASH) throw "Missing UNIQ_HASH"; // $this->_htmlID
+
+var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
+	var defaultsProps = {
+				ico: true,
+				label: false
+			},
+			props = jQuery.extend({}, defaultsProps, props);
+			funcNode = $('<a href="#" style="margin:0 2px;"></a>')
+	;
+	if ('href' in funObj) funcNode.attr('href', p5Utils__format(funObj.href, [rowPK]));
+	if (props.ico) {
+		if ('ico' in funObj) funcNode.append('<span class="' + funObj.ico + '"></span>');
+	}
+	if ('onclick' in funObj) funcNode.attr('onclick', p5Utils__format(funObj.onclick, [rowPK]));
+	if ('title' in funObj) funcNode.attr('title', funObj.title);
+	if ('target' in funObj) funcNode.attr('target', funObj.target);
+
+	if (props.label) {
+		if ('label' in funObj) {
+			funcNode.append(' ' + funObj.label);
+		} else if ('title' in funObj) {
+			funcNode.append(' ' + funObj.title);
+		}
+	}
+
+	return funcNode;
+};
+
+
+global['p5UI_TableAjax_generateFunctionNode'] = p5UI_TableAjax_generateFunctionNode

+ 113 - 0
SE/se-lib/TableAjax.php.procesInitFiltr.js

@@ -0,0 +1,113 @@
+// @require variables:
+if ('undefined' === typeof JS_FUNCTION_NAME) throw "Missing JS_FUNCTION_NAME";
+if ('undefined' === typeof URL_GET_PROCES_INIT_FILTR) throw "Missing URL_GET_PROCES_INIT_FILTR";
+if ('undefined' === typeof ID_ZASOB) throw "Missing ID_ZASOB";
+
+function toggleProcesInitFiltr(n) {
+	var $n = jQuery(n);
+	var $ul = $n.next();
+	if ($n.data('fetched')) return false;
+
+	function parseProcesInitData(pInitData) {
+		var procesInitMapHtml = '';
+		if (!pInitData) {
+			return '<li><a href="#">' + "Brak danych" + '</a></li>';
+		} else {
+			function _viewProcesInitListItem(pInitId, gotoIds, pInitList) {
+				var label = pInitList[pInitId];
+				var jsInfo = "window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=" + pInitId + "&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;";
+				var out = '<a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=' + pInitId + '&MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=' + ID_ZASOB + '" title="' + "{" + pInitId + "} " + label + '">';// TODO: change to _route=ViewTableAjax&typeName=p5_default_db:{tblName}
+					out += ' <i class="glyphicon glyphicon-info-sign"';
+						out += ' onclick="' + jsInfo + '"';
+						out += ' style="color:#aaa;"';
+						out += ' onmouseover="' + "this.style.color='#337AB7'" + '"';
+						out += ' onmouseout="' + "this.style.color='#aaa'" + '"></i>';
+					out += " {" + pInitId + "} " + label;
+				out += '</a>';
+				return out;
+			}
+			function _viewProcesGotoAndRetListItem(gotoId, pInitList) {
+				var label = pInitList[gotoId];
+				var jsInfo = "window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=" + gotoId + "&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;";
+				var out = '';
+				out += '<a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=' + gotoId + '&MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=' + ID_ZASOB + '" title="' + "{" + gotoId + "} " + label + '">';// TODO: change to _route=ViewTableAjax&typeName=p5_default_db:{tblName}
+					out += ' <span style="padding:10px;"></span>';
+					out += ' <i class="glyphicon glyphicon-arrow-right" style="color:#aaa"></i>';
+					out += ' <i class="glyphicon glyphicon-info-sign"';
+						out += ' onclick="' + jsInfo + '"';
+						out += ' style="color:#aaa;"';
+						out += ' onmouseover="' + "this.style.color='#337AB7'" + '"';
+						out += ' onmouseout="' + "this.style.color='#aaa'" + '"></i>';
+					out += " {" + gotoId + "} " + label;
+				out += '</a>';
+				return out;
+			}
+			function _viewProcesGotoAndRetLvl2ListItem(gotoLvl2Id, pInitList) {
+				var label = pInitList[gotoLvl2Id];
+				var jsInfo = "window.open('procesy5.php?task=PROCES_VIEW_LIST&id_proces=" + gotoLvl2Id + "&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1');return false;";
+				var out = '';
+				out += '<a href="index.php?FUNCTION_INIT=MENU_SELECT_PROCES&_action=setPermsByProces&id_proces=' + gotoLvl2Id + '&MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=' + ID_ZASOB + '" title="' + "{" + gotoLvl2Id + "} " + label + '">';// TODO: change to _route=ViewTableAjax&typeName=p5_default_db:{tblName}
+					out += ' <span style="padding:20px;"></span>';
+					out += ' <i class="glyphicon glyphicon-arrow-right" style="color:#aaa"></i>';
+					out += ' <i class="glyphicon glyphicon-info-sign"';
+						out += ' onclick="' + jsInfo + '"';
+						out += ' style="color:#aaa;"';
+						out += ' onmouseover="' + "this.style.color='#337AB7'" + '"';
+						out += ' onmouseout="' + "this.style.color='#aaa'" + '"></i>';
+					out += " {" + gotoLvl2Id + "} " + label;
+				out += '</a>';
+				return out;
+			}
+			var sel = '',
+					liStyle = "white-space:nowrap; overflow:hidden; max-width:500px; /* text-overflow:ellipsis; */";
+			$.map(pInitData.mapTree, function(gotoIds, vInitId) {
+				sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId)? ' class="disabled"' : '';
+				procesInitMapHtml += '<li' + sel + ' style="' + liStyle + '">';
+				procesInitMapHtml += _viewProcesInitListItem(vInitId, gotoIds, pInitData.pInitList);
+				procesInitMapHtml += '</li>' + "\n";
+				$.map(gotoIds, function(gotoLvl2Ids, gotoId) {
+					sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId)? ' class="disabled"' : '';
+					procesInitMapHtml += '<li' + sel + ' style="' + liStyle + '">';
+					procesInitMapHtml += _viewProcesGotoAndRetListItem(gotoId, pInitData.pInitList);
+					procesInitMapHtml += '</li>' + "\n";
+					$.map(gotoLvl2Ids, function(vBool, gotoLvl2Id) {
+						sel = (pInitData.pInitListSelected && pInitData.pInitListSelected == vInitId)? ' class="disabled"' : '';
+						procesInitMapHtml += '<li' + sel + ' style="' + liStyle + '">';
+						procesInitMapHtml += _viewProcesGotoAndRetLvl2ListItem(gotoLvl2Id, pInitData.pInitList);
+						procesInitMapHtml += '</li>' + "\n";
+					});
+				});
+			});
+		}
+		return procesInitMapHtml;
+	}
+
+	jQuery.ajax({
+		data: null,
+		dataType: 'json',
+		type: "GET",
+		async: true,
+		url: URL_GET_PROCES_INIT_FILTR
+	})
+	.always(function(data, textStatus, jqXHR) {
+		var type = data.type || null,
+				msg = data.msg || "Error",
+				pInitData = data.pInitData || null;
+		if (type) {
+			if ('success' == type) {
+				$ul.html(parseProcesInitData(pInitData));
+			} else if ('error' == type) {
+				$ul.html('<li><a href="#">' + msg + '</a></li>');
+			} else {
+				$ul.html('<li><a href="#">Wystapił błąd podczas pobierania listy procesów</a></li>');
+			}
+		} else {
+			$ul.html('<li><a href="#">Wystapił błąd podczas pobierania listy procesów</a></li>');
+		}
+		$n.data('fetched', true);
+	});
+	return false;
+}
+
+
+global[JS_FUNCTION_NAME] = toggleProcesInitFiltr