Jelajahi Sumber

#35 add btn 'Dodaj do filtra'

Piotr Labudda 11 tahun lalu
induk
melakukan
96e450989b
1 mengubah file dengan 46 tambahan dan 0 penghapusan
  1. 46 0
      SE/se-lib/ProcesMenu.php

+ 46 - 0
SE/se-lib/ProcesMenu.php

@@ -438,8 +438,54 @@ class ProcesMenu {
 												echo $typeSpecialZasob->showFormItem($tblID = -1, $fldName, $selValue = '', $fldParams);
 												echo $typeSpecialZasob->showFormItem($tblID = -1, $fldName, $selValue = '', $fldParams);
 											?>
 											?>
 											<input class="btn btn-mini btn-primary" type="submit" value="Wybierz" />
 											<input class="btn btn-mini btn-primary" type="submit" value="Wybierz" />
+											<input class="pull-right btn btn-mini btn-default" type="submit" id="ProcesMenuZasobFltrAdd" value="Dodaj do filtra" />
 											<script>
 											<script>
 jQuery(document).ready(function() {
 jQuery(document).ready(function() {
+	if ('procesy5.php' === window.location.pathname.substr(-12)
+			&& (pos = window.location.search.search('&filtr_id=')) > 0
+		 ) {
+		jQuery('#ProcesMenuZasobFltrAdd').on('click', function(e) {
+			var frm = jQuery(this).get(0).form;
+			var fldNode = frm['<?php echo $fldParams['formFieldName']; ?>'],
+				fltrId = '';
+			if (fldNode && '' != fldNode.value) {
+				fltrId = fldNode.value;
+			} else {
+				return;
+			}
+			if ('procesy5.php' === window.location.pathname.substr(-12)) {
+				var pos = 0, fltrIds = '';
+				if ((pos = window.location.search.search('&filtr_id=')) > 0) {
+					pos += 10;
+					console.log('pos:', pos);
+					fltrIds = window.location.search.substr(pos);
+					if ((pos = fltrIds.search('&')) > 0) {
+						fltrIds = fltrIds.substr(0, pos);
+					}
+					if (fltrIds) {
+						fltrIds = decodeURIComponent(fltrIds);
+						fltrIds += ',' + fltrId;
+						if (fldNode.selectize) {
+							fldNode.selectize.addOption({id: fltrIds, name: fltrIds});
+							fldNode.selectize.setValue(fltrIds, true);
+						}
+					}
+				}
+			}
+		});
+	} else {
+		jQuery('#ProcesMenuZasobFltrAdd').hide();
+	}
+
+	jQuery('#ProcesMenuZasobFrm').on('submit', function(e) {
+		var frm = jQuery(this).get(0),
+				fldNode = frm['<?php echo $fldParams['formFieldName']; ?>'];
+		if (fldNode && '' != fldNode.value) {
+			return true;
+		} else {
+			return false;
+		}
+	});
 	jQuery('#ProcesMenuZasobDropdownLink').on('click', function(e) {
 	jQuery('#ProcesMenuZasobDropdownLink').on('click', function(e) {
 		setTimeout(function(){
 		setTimeout(function(){
 			jQuery('#ts-<?php echo $fldName; ?>')
 			jQuery('#ts-<?php echo $fldName; ?>')