Ver código fonte

added load more record functions

Piotr Labudda 7 anos atrás
pai
commit
d2af81ed43
1 arquivos alterados com 125 adições e 4 exclusões
  1. 125 4
      tools/Bocian.php.view.js

+ 125 - 4
tools/Bocian.php.view.js

@@ -2,6 +2,8 @@
 if (!URL_TABLE_POWIAZANIA) throw "Brak URL_TABLE_POWIAZANIA";
 if (!BASE_URLS) throw "Brak BASE_URLS"
 
+var RECORD_MORE_FUNCTIONS_OPENED_NODE = null;
+
 var FIELD_LIST_PRACOWNICY = [
 	'f_ID',
 	'f_imiona',
@@ -51,6 +53,7 @@ $(window).on('hashchange', function() {
 	initLocalStorage();
 	rootChangeForm();
 	updateTopCounters();
+	hideMoreRecordFunctionsPopover()
 });
 
 
@@ -730,6 +733,7 @@ function getNameGroupById(store, filterIdGroup) {
 
 
 function urlFetchKontrahenci(page) {
+	hideMoreRecordFunctionsPopover()
 			var page = page || getItemLocalStorage('Bocian.biAuditForm.kontrahenci.pagination.page');
 
 			selectPage('KONTRAHENCI', page);
@@ -764,7 +768,10 @@ function urlFetchKontrahenci(page) {
 
 						var listItemsKontrahenci = null;
 						data.body.items.forEach (function(row) {
-							listItemsKontrahenci += '<tr><td><input type="checkbox" name="kontrID[]" value="'+row['ID']+'" /></td>'+
+							listItemsKontrahenci += '<tr><td style="white-space:nowrap">' +
+									'<input style="vertical-align:top" type="checkbox" name="kontrID[]" value="'+row['ID']+'" />' +
+									'<i onClick="kontrahenciLoadMoreRecordFunctions(event, this, '+row['ID']+')" style="margin-left:6px; cursor:pointer; color:#333" class="glyphicon glyphicon-menu-hamburger" title="Więcej funkcji dla rekordu nr ' + row['ID'] + '"></i>' +
+								'</td>' +
 								'<td align="right">'+row["ID"]+'</td>'+
 								'<td align="right">' + ( row["Nazwa_grupy_kapitalowej"] || '' ) + '</td>' +
 								'<td align="right">' + ( row["Pelna_nazwa_kontrahenta"] || '' ) + '</td>' +
@@ -882,6 +889,7 @@ function urlFetchKontrahenci(page) {
 }
 
 function urlFetchPracownicy(page) {
+	hideMoreRecordFunctionsPopover()
 
 		var page = page || getItemLocalStorage('Bocian.biAuditForm.pracownicy.pagination.page');
 
@@ -922,9 +930,11 @@ function urlFetchPracownicy(page) {
 							addresPerson = getAddressData(row["default_db__x3A__BI_audit_ENERGA_PRACOWNICY_adresy:BI_audit_ENERGA_PRACOWNICY_adresy"]);
 						}
 
-
-						listItemsPracownik += '<tr><td><input type="checkbox" name="prID[]" value="'+row['ID']+'" /></td>'+
-							'<td align="right">'+row["ID"]+'</td>'+
+						listItemsPracownik += '<tr><td style="white-space:nowrap">' +
+								'<input style="vertical-align:top" type="checkbox" name="prID[]" value="'+row['ID']+'" />' +
+								'<i onClick="pracownicyLoadMoreRecordFunctions(event, this, '+row['ID']+')" style="margin-left:6px; cursor:pointer; color:#333" class="glyphicon glyphicon-menu-hamburger" title="Więcej funkcji dla rekordu nr ' + row['ID'] + '"></i>' +
+							'</td>' +
+							'<td align="right">'+row["ID"]+'</td>' +
 							'<td align="right">' + ( row["imiona"] || '' ) + '</td>' +
 							'<td align="right">' + ( row["nazwisko"] || '' ) + '</td>' +
 							'<td align="right">' + ( row["nip"] || '' ) + '</td>' +
@@ -1698,6 +1708,108 @@ function onChangeFiltersKontrahenci(inputNode) {
 	urlFetchKontrahenci(1)
 }
 
+function loadMoreRecordFunctions(event, node, rowPK, namespace) {
+	var _node = node
+	var _rowPK = rowPK
+	var toShow = true
+	if (RECORD_MORE_FUNCTIONS_OPENED_NODE) {
+		if (RECORD_MORE_FUNCTIONS_OPENED_NODE === node) toShow = false
+		if (RECORD_MORE_FUNCTIONS_OPENED_NODE !== node) {
+			jQuery(RECORD_MORE_FUNCTIONS_OPENED_NODE).popover('destroy')
+		}
+	}
+	RECORD_MORE_FUNCTIONS_OPENED_NODE = node
+
+	// jQuery(node).popover({
+	// 	container: 'body',
+	// 	placement: 'right',
+	// 	trigger: 'click',
+	// 	template: '<div class="popover" role="tooltip" style="max-width:600px;width:440px;">' +
+	// 		'<div class="arrow"></div>' +
+	// 		'<div style="display:block;position:relative;">' +
+	// 			'<div class="popover-title">' +
+	// 			'</div>' +
+	// 			'<button type="button" class="close" onclick="return hideMoreRecordFunctionsPopover();" style="position:absolute;right:8px;top:6px;">&times;</button>' +
+	// 		'</div>' +
+	// 		'<div class="popover-content"></div>' +
+	// 		'</div>' +
+	// 	'',
+	// 	html: true,
+	// })
+	// jQuery(node).popover('show')
+
+	global.fetch(BASE_URLS + 'index.php?_route=ViewTableAjax&namespace=' + namespace + '&_task=moreFunctionsCellAjax&ID=' + rowPK, {
+		credentials: 'same-origin'
+	}).then(function (response) {
+		return response.json()
+	}).then(function (json) {
+		var funcListWrap = $('<div></div>')
+		var funcListNode = $('<ul class="list-unstyled popoverRowFunctions"></ul>').appendTo(funcListWrap)
+
+		if (_node === RECORD_MORE_FUNCTIONS_OPENED_NODE) {
+			if (json && 'success' === json.type && json.rowFunctions && json.rowFunctions.length > 0) {
+				json.rowFunctions.forEach(function(funObj) {
+					var funcNode = p5UI_TableAjax_generateFunctionNode(funObj, _rowPK, {ico: true, label: true});
+					var funcItemNode = jQuery('<li></li>')
+					funcItemNode.append(funcNode)
+					funcListNode.append(funcItemNode)
+				});
+			}
+		}
+
+		// jQuery(RECORD_MORE_FUNCTIONS_OPENED_NODE).popover('destroy')
+		jQuery(RECORD_MORE_FUNCTIONS_OPENED_NODE).popover({
+			container: 'body',
+			placement: 'right',
+			trigger: 'click',
+			template: '<div class="popover" role="tooltip" style="max-width:600px;width:440px;">' +
+				'<div class="arrow"></div>' +
+				'<div style="display:block;position:relative;">' +
+					'<div class="popover-title">' +
+					'</div>' +
+					'<button type="button" class="close" onclick="return hideMoreRecordFunctionsPopover();" style="position:absolute;right:8px;top:6px;">&times;</button>' +
+				'</div>' +
+				'<div class="popover-content"></div>' +
+				'</div>' +
+			'',
+			html: true,
+			content: funcListWrap.html(),
+		})
+		jQuery(RECORD_MORE_FUNCTIONS_OPENED_NODE).popover('show')
+
+	}).catch(function (err) {
+		// console.log('err', err)
+	})
+}
+
+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
+
 
 $(document).ready(function(){
 	rootChangeForm();
@@ -1705,6 +1817,15 @@ $(document).ready(function(){
 	updateTopCounters();
 });
 
+global.hideMoreRecordFunctionsPopover = function() {
+	if (RECORD_MORE_FUNCTIONS_OPENED_NODE) jQuery(RECORD_MORE_FUNCTIONS_OPENED_NODE).popover('destroy')
+}
+global.pracownicyLoadMoreRecordFunctions = function(event, node, rowPK) {
+	return loadMoreRecordFunctions(event, node, rowPK, "default_db/BI_audit_ENERGA_PRACOWNICY/BI_audit_ENERGA_PRACOWNICY")
+}
+global.kontrahenciLoadMoreRecordFunctions = function(event, node, rowPK) {
+	return loadMoreRecordFunctions(event, node, rowPK, "default_db/BI_audit_ENERGA_RUM_KONTRAHENCI/BI_audit_ENERGA_RUM_KONTRAHENCI")
+}
 global.removeFiltersPracownicy = removeFiltersPracownicy;
 global.removeFiltersKontrahenci = removeFiltersKontrahenci;
 global.onChangeFiltersPracownicy = onChangeFiltersPracownicy;