Jelajahi Sumber

- dodanie informacji o liczbie wybranych pracowników/kontrahentów
- dodanie opcji wyczyszczenia wybranej listy pracowników/kontrahentów
- fix problemu czyszczenia listy id

dariusz.andryskowski 7 tahun lalu
induk
melakukan
08bd870499
4 mengubah file dengan 94 tambahan dan 21 penghapusan
  1. 0 0
      theme/assets/css/styles.css
  2. 17 0
      theme/assets/less/styles.less
  3. 5 0
      tools/Bocian.php
  4. 72 21
      tools/Bocian.php.view.js

File diff ditekan karena terlalu besar
+ 0 - 0
theme/assets/css/styles.css


+ 17 - 0
theme/assets/less/styles.less

@@ -35,6 +35,10 @@ strong {
   color: @brand-primary;
 }
 
+.link-primary {
+  color: @brand-primary!important;
+  cursor: pointer;
+}
 .font-weight-700 {
   font-weight: 700;
 }
@@ -455,6 +459,13 @@ footer {
 
     .step-item {
 
+      a {
+        color: @brand-primary;
+        &:focus, &:hover {
+          color: @brand-primary;
+        }
+      }
+
       .step-title {
         color: @brand-text-light;
       }
@@ -464,6 +475,12 @@ footer {
   .smad-wizard-step.complete {
     .step-item {
       color: @brand-primary;
+      a {
+        color: @brand-primary;
+        &:focus, &:hover {
+          color: @brand-primary;
+        }
+      }
     }
 
     .step-title {

+ 5 - 0
tools/Bocian.php

@@ -1077,6 +1077,7 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
 
 					$formFilterHeadTitle = '<h2 class="title" id="smad-filter-head-title-kontrahenci">Wszyscy</h2>';
 					$formFilterHeadDesc = '<p>Liczba pozycji na liście: <span id="smad-filter-desc-kontrahenci">0</span></p>';
+					$countSelectedItem = '<div>Wybrano: <span id="count-selected-item-kontrahenci">0</span> <span><a title="wyczyść zapamietanych kontrahentów"  class="link-primary" onClick="clearListLocalStorageByType(\'kontrahenci\')"><small>(wyczyść)</small></a></span></div>';
 
 					$formAddNewData ='
 					<li><a  title="IMPORT KONTRAHENCI" onClick="showViewUploadFile(event, \'Import kontrahentów\', \'kontrahenci\', \'no\', \'/projects/bocian/theme/assets/file_example/kontrahenci_example.zip\' )" class="btn btn-info">IMPORT KONTRAHENCI</a></li>
@@ -1105,6 +1106,7 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
 
 					$formFilterHeadTitle = '<h2 class="title" id="smad-filter-head-title-pracownicy">Wszyscy</h2>';
 					$formFilterHeadDesc = '<p>Liczba pozycji na liście: <span id="smad-filter-desc-pracownicy">0</span></p>';
+					$countSelectedItem = '<div>Wybrano: <span id="count-selected-item-pracownicy">0</span> <span><a title="wyczyść zapamietanych pracowników" class="link-primary" onClick="clearListLocalStorageByType(\'pracownicy\')"><small>(wyczyść)</spall></a></span></div>';
 
 					$formAddNewData ='
 					<li><a  title="IMPORT PRACOWNIKÓW" onClick="showViewUploadFile(event, \'Import pracowników\', \'pracownicy\', \'yes\', \'/projects/bocian/theme/assets/file_example/pracownicy_example.zip\' )" class="btn btn-info">IMPORT PRACOWNIKÓW</a></li>
@@ -1214,6 +1216,9 @@ public function showPowiazaniaEnergaRumKontrahenciPowiazania($items) {
 											<div class="desc">
 													'.$formFilterHeadDesc.'
 											</div>
+											<div class="countSelectedItem">
+													'.$countSelectedItem.'
+											</div>
 									</div>
 									<div class="col-md-6">
 											<div class="menu-items">

+ 72 - 21
tools/Bocian.php.view.js

@@ -1,10 +1,3 @@
-console.log('test1... DBG:', DBG)
-
-// localStorage.setItem('Bocian.pracownicyIds', JSON.stringify(ids))
-// var ids = localStorage.getItem('Bocian.pracownicyIds')
-// localStorage.removeItem('Bocian.pracownicyIds')
-// localStorage.removeItem('Bocian.kontrahenciIds')
-// localStorage.removeItem('Bocian.depth') // TODO: zapis na stronie głównej i BiAuditRaport
 
 if (!BASE_URLS) {
 	throw "Brak BASE_URLS"
@@ -17,7 +10,6 @@ $(window).on('hashchange', function() {
 });
 
 
-
 /* DATA FOR READ REAPORT */
 
 function urlFetchKontrahenciPowiazania() {
@@ -38,7 +30,6 @@ function urlFetchKontrahenciPowiazania() {
 
 		$( "#body-reaport-kontrahenci-powiazani-tree" ).html(reaportItemsKontrahenciPowiazani);
 
-		console.log('request succeeded with JSON response URL_FETCH_KONTRAHENCI_POWIAZANIA', data)
 	}).catch(function(error) {
 		console.log('request failed', error)
 	});
@@ -300,7 +291,7 @@ function generateBiAuditRaport(event) {
 
 						p5UI__notifyAjaxCallback(result);
 						defaultBIAuditLocalStorage();
-						window.setTimeout(window.location.href = "/SE/index.php?_route=ViewTableAjax&namespace=default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA", 4000);
+						window.setTimeout(window.location.href = "/SE/index.php?_route=ViewTableAjax&namespace=default_db/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA/BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA", 6000);
 						resolve(result.msg);
 
 					} else {
@@ -911,6 +902,9 @@ function checkAll(type) {
 
 				deleteListIdBiAuditReaport(type, allValsUnChecked);
 			}
+
+			// update count selected IDs
+			updateCountItemCheckedByType(type.toLowerCase());
 	});
 }
 
@@ -919,6 +913,8 @@ function checkAll(type) {
  */
 function checkedChoiseItems(type, store) {
 
+	updateCountItemCheckedByType(type.toLowerCase());
+
 	var idElement = 'smad-table-' + type;
 
 	// if id element exist
@@ -940,7 +936,6 @@ function checkedChoiseItems(type, store) {
 
 	}
 
-	//$('#checkAll-' + type).on('bind', function() {
 	$('#smad-table-' + type + ' input[type=checkbox]').on( 'load', function() {
 		var itemsCHecked = getItemLocalStorage('Bocian.biAuditForm.pracownicyIds');
 
@@ -976,12 +971,10 @@ function checkedChoiseItems(type, store) {
 
 				deleteListIdBiAuditReaport(type, allValsUnChecked);
 			}
+
 	});
 }
 
-
-
-
 function catchEventCheckbox(type) {
 
 		$('#smad-table-' + type + ' input[type="checkbox"]').on('change', function() {
@@ -1001,6 +994,9 @@ function catchEventCheckbox(type) {
 
 						deleteListIdBiAuditReaport(type, allValsUnChecke);
 		    }
+
+				// update count selected IDs
+				updateCountItemCheckedByType(type.toLowerCase());
 		});
 
 }
@@ -1077,8 +1073,7 @@ function fetchGroupPracownicy() {
 					var filterIdGroup = getItemLocalStorage('Bocian.biAuditForm.pracownicy.filterIdGroup');
 					var currentDepthValue = getItemLocalStorage('Bocian.biAuditForm.depth');
 					setItemLocalStorage('Bocian.biAuditForm.pracownicy.filterIdGroup', filterIdGroup);
-					//reset LocalStorage
-					defaultBIAuditLocalStorage();
+
 					setItemLocalStorage('Bocian.biAuditForm.depth', currentDepthValue);
 
 					var groupsPracownicy = '';
@@ -1090,10 +1085,10 @@ function fetchGroupPracownicy() {
 					});
 
 					$("#group-pracownicy").append(groupsPracownicy);
+					updateCountItemCheckedByType('pracownicy');
 
-
-
-				console.log('request succeeded with JSON fetchGroupPracownicy', data.body.itmesGroupPracownicy)
+					// detect filter group
+					detectChoiseFilter();
 			}).catch(function(error) {
 				console.log('request failed', error)
 			});
@@ -1117,8 +1112,7 @@ function fetchGroupKontrahenci() {
 					var filterIdGroup = getItemLocalStorage('Bocian.biAuditForm.kontrahenci.filterIdGroup');
 					var currentDepthValue = getItemLocalStorage('Bocian.biAuditForm.depth');
 					setItemLocalStorage('Bocian.biAuditForm.kontrahenci.filterIdGroup', filterIdGroup);
-					//reset LocalStorage
-					defaultBIAuditLocalStorage();
+
 					setItemLocalStorage('Bocian.biAuditForm.depth', currentDepthValue);
 
 					var groupsKontrahenci = '';
@@ -1130,7 +1124,10 @@ function fetchGroupKontrahenci() {
 					});
 
 					$("#group-kontrahenci").append(groupsKontrahenci);
+					updateCountItemCheckedByType('kontrahenci');
 
+					// detect filter group
+					detectChoiseFilter();
 				console.log('request succeeded with JSON fetchGroupKontrahenci', data.body.itemsGroupKontrahenci);
 			}).catch(function(error) {
 				console.log('request failed', error)
@@ -1224,6 +1221,7 @@ function removeItemInArray(arr, item) {
  * item - array list items
  */
 function removeItemArrayInArray(arr, itemsArray) {
+
       for(var i = arr.length; i--;) {
 	      for(var j = itemsArray.length; j--;) {
 	          if(arr[i] === itemsArray[j]) {
@@ -1235,6 +1233,58 @@ function removeItemArrayInArray(arr, itemsArray) {
 			return arr;
   }
 
+/**
+ * Cleart list local storage by type
+ * typeNameLocalStorage - name (praconwicy/kontrahenci)
+ */
+function clearListLocalStorageByType(typeNameLocalStorage) {
+
+	if (typeNameLocalStorage === 'pracownicy') {
+		setItemLocalStorage('Bocian.biAuditForm.pracownicyIds', []);
+	}
+
+	if (typeNameLocalStorage === 'kontrahenci') {
+		setItemLocalStorage('Bocian.biAuditForm.kontrahenciIds', []);
+
+	}
+	// update count selected item
+	updateCountItemCheckedByType(typeNameLocalStorage);
+	// unchecked checkbox
+	$('#smad-table-'+typeNameLocalStorage.toUpperCase()+' form').find(':checkbox').prop('checked', false);
+}
+
+/**
+ * Update count selected pracowniyc/kontrahenci
+ */
+function updateCountItemCheckedByType(typeNameLocalStorage) {
+  var countId = 0;
+
+	if (typeNameLocalStorage === 'pracownicy') {
+		var countPracownicy = getItemLocalStorage('Bocian.biAuditForm.pracownicyIds');
+
+		if (countPracownicy !== null || countPracownicy !== undefined) {
+			return countId;
+		}
+
+		countId = Object.keys(countPracownicy).length;
+		$('#count-selected-item-pracownicy').text(countId);
+	}
+
+	if (typeNameLocalStorage === 'kontrahenci') {
+		var countKontrahenci = getItemLocalStorage('Bocian.biAuditForm.kontrahenciIds');
+
+
+		if (countKontrahenci !== null || countKontrahenci !== undefined) {
+			return countId;
+		}
+
+		countId = Object.keys(countKontrahenci).length;
+		$('#count-selected-item-kontrahenci').text(countId);
+	}
+
+	return countId;
+}
+
 // Pagination
 var Pagination = {
 
@@ -1482,3 +1532,4 @@ global.addKontrahenciToGroup = addKontrahenciToGroup;
 
 global.showViewUploadFile = showViewUploadFile;
 global.parseCsvFile = parseCsvFile;
+global.clearListLocalStorageByType = clearListLocalStorageByType;

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini