Просмотр исходного кода

update btn generate visinbility after all change on selected counters

Piotr Labudda 6 лет назад
Родитель
Сommit
23b38cee1a
1 измененных файлов с 29 добавлено и 0 удалено
  1. 29 0
      tools/Bocian.php.view.js

+ 29 - 0
tools/Bocian.php.view.js

@@ -3011,6 +3011,35 @@ $(document).ready(function(){
 
 	rootChangeForm();
 	updateTopCounters();
+
+	var unsubscribe = globalRaportStore.subscribe(function () {
+		// TODO: fetch data from globalRaportStore.getState()
+		var idsPracownicy = getListFromLocalStorage('Bocian.biAuditForm.pracownicyIds');
+		var idsKontrahenci = getListFromLocalStorage('Bocian.biAuditForm.kontrahenciIds');
+		var pozostaleOd = getListFromLocalStorage(getSelectedListLocalStorageKey('OD'));
+		var pozostaleDo = getListFromLocalStorage(getSelectedListLocalStorageKey('DO'));
+		var allOdLength = idsPracownicy.length + pozostaleOd.length;
+		var allDoLength = idsKontrahenci.length + pozostaleDo.length;
+		var depthValue = getItemLocalStorage('Bocian.biAuditForm.depth');
+
+		if(DBG) console.warn({totalPracownicy: idsPracownicy.length, totalKontrahenci: idsKontrahenci.length})
+		$('.top--count-selected-item-pracownicy').text(idsPracownicy.length ? '('+idsPracownicy.length+')' : '');
+		$('.top--count-selected-item-kontrahenci').text(idsKontrahenci.length ? '('+idsKontrahenci.length+')' : '');
+		$('.bottom--count-selected-item-pracownicy').text(idsPracownicy.length ? "Wybrano: (" + idsPracownicy.length + ") osób" : '');
+		$('.bottom--count-selected-item-kontrahenci').text(idsKontrahenci.length ? "Wybrano: (" + idsKontrahenci.length + ") podmiotów/kontrahentaów" : '');
+
+		// disable button generate reaport if not choise 'praconwicy' or 'kontrahenci'
+		if ( !allOdLength && !allDoLength ) {
+			$('.smad-generate-reaport-button').addClass('disabled');
+		} else {
+			if ( ( !allOdLength || !allDoLength ) && parseInt(depthValue) > 6 ) {
+				$('.bottom--message-warning-critical-search').text(messageCriticalSearchData);
+			} else {
+				$('.bottom--message-warning-critical-search').text('');
+			}
+			$('.smad-generate-reaport-button').removeClass('disabled');
+		}
+	})
 });
 
 global.hideMoreRecordFunctionsPopover = function() {