Explorar el Código

- fix selected filter button
- fix sending twice request when reload page and click filtr

dariusz.andryskowski hace 7 años
padre
commit
bb7493abaf
Se han modificado 1 ficheros con 13 adiciones y 14 borrados
  1. 13 14
      tools/Bocian.php.view.js

+ 13 - 14
tools/Bocian.php.view.js

@@ -260,9 +260,9 @@ function parseCsvFile( fileData, enumType ) {
 						 		},
 							 }).then(function (result) {
 
-	 							console.log('result', result)
+	 							if(DBG) console.log('result', result)
 	 						}).catch(function (e) {
-	 							console.log('catch: ', e)
+	 							if(DBG) console.log('catch: ', e)
 	 						});
 
  }).catch(function(ex) {
@@ -1147,7 +1147,6 @@ function urlFetchKontrahenci(page) {
 
 function urlFetchPracownicy(page) {
 	hideMoreRecordFunctionsPopover()
-
 		var page = page || getItemLocalStorage('Bocian.biAuditForm.pracownicy.pagination.page');
 
 		if ( page === 1) {
@@ -1532,7 +1531,6 @@ function deleteListIdBiAuditReaport(type, valueArray) {
 
 // filter group detect
 function fetchGroupPracownicy() {
-
 		fetch(URL_FETCH_GROUP_PRACOWNICY, {
 				credentials: 'same-origin'
 			})
@@ -1556,7 +1554,9 @@ function fetchGroupPracownicy() {
 					var activeButton = '';
 
 					data.body.itmesGroupPracownicy.forEach (function(row) {
-							if ( filterIdGroup === row['ID'] ) { activeButton = 'active'; $('#group-pracownicy button.active').removeClass('active'); }
+							activeButton = '';
+							if ( filterIdGroup === parseInt(row['ID']) ) {activeButton = 'active'; $('#group-pracownicy button.active').removeClass('active');
+							}
 							groupsPracownicy += '<button class="btn btn-default '+activeButton+'" title="' + row['NAZWA'] + '" data-group-filter="' + row['ID'] + '">' + row['NAZWA'] + '</button>';
 					});
 
@@ -1595,7 +1595,8 @@ function fetchGroupKontrahenci() {
 					var activeButton = '';
 
 					data.body.itemsGroupKontrahenci.forEach (function(row) {
-							if ( filterIdGroup === row['ID'] ) { activeButton = 'active'; $('#group-kontrahenci button.active').removeClass('active'); }
+							activeButton = '';
+							if ( filterIdGroup === parseInt(row['ID']) ) { activeButton = 'active'; $('#group-kontrahenci button.active').removeClass('active'); }
 							groupsKontrahenci += '<button class="btn btn-default '+activeButton+'" title="'+row['NAZWA']+'" data-group-filter="'+row['ID']+'">'+row['NAZWA']+'</button>';
 					});
 
@@ -1614,7 +1615,6 @@ function fetchGroupKontrahenci() {
 function detectChoiseFilter() {
 
 	$('#group-kontrahenci').on('click', 'button', function(evt) {
-
 		$('#group-kontrahenci button.active').removeClass('active');
 		$(this).addClass('active');
 
@@ -1639,8 +1639,8 @@ function detectChoiseFilter() {
 		urlFetchKontrahenci(1);
 
 	});
-	$('#group-pracownicy').on('click', 'button', function(evt) {
-
+	$('#group-pracownicy').on('click', 'button', function(e) {
+		e.preventDefault();
 		$('#group-pracownicy button.active').removeClass('active');
 		$(this).addClass('active');
 
@@ -2008,8 +2008,8 @@ var Pagination = {
     }
 };
 
-/*function todo__fetchRaport(id) {
-	p5WFS_GetFeature('default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', {
+function todo__fetchRaport(id) {
+/*	p5WFS_GetFeature('default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA', {
 		primaryKey: id,
 		resolve: 'all',
 		resolveDepth: 3,
@@ -2018,8 +2018,8 @@ var Pagination = {
 	}).catch(function (e) {
 		if(DBG) console.warn(e)
 		p5UI__notifyAjaxCallback({ type: 'error', msg: e })
-	})
-}*/
+	})*/
+}
 
 function removeFiltersPracownicy(event, btnNode) {
 	event.preventDefault()
@@ -2166,7 +2166,6 @@ global.p5UI_TableAjax_generateFunctionNode = p5UI_TableAjax_generateFunctionNode
 
 $(document).ready(function(){
 	rootChangeForm();
-	detectChoiseFilter();
 	updateTopCounters();
 });