Jelajahi Sumber

TableAjax fix bug in upload file from scan (see #52) - tab event

Piotr Labudda 11 tahun lalu
induk
melakukan
19a0ba803f
2 mengubah file dengan 16 tambahan dan 13 penghapusan
  1. 15 13
      SE/se-lib/TableAjax.php
  2. 1 0
      SE/se-lib/tmpl/_layout_gora.php

+ 15 - 13
SE/se-lib/TableAjax.php

@@ -4453,19 +4453,6 @@ jQuery(document).ready(function(){
 					<?php endif; ?>
 				</div>
 			</div>
-			<script>
-				$('#FILES_TAB_<?php echo $this->_htmlID; ?> a').click(function (e) {
-					e.preventDefault();
-					$(this).tab('show');
-				})
-				.on('shown', function (e) {
-					var fileSource = $(e.target).data('toggle')
-						, frm = jQuery('#FILES_FRM_<?php echo $this->_htmlID; ?>').get(0);
-					if (frm['M_DIST_UPLOAD_SOURCE']) {
-						frm['M_DIST_UPLOAD_SOURCE'].value = fileSource;
-					}
-				})
-			</script>
 
 			<br>
 
@@ -4716,10 +4703,22 @@ function fileListActions<?php echo $this->_htmlID; ?>() {
 }
 
 jQuery(document).ready(function(){
+	$('#FILES_TAB_<?php echo $this->_htmlID; ?> a').click(function (e) {
+		e.preventDefault();
+		$(this).tab('show');
+	})
+	.on('shown.bs.tab', function (e) {
+		var fileSource = $(e.target).data('toggle')
+			, frm = jQuery('#FILES_FRM_<?php echo $this->_htmlID; ?>').get(0);
+		if (frm['M_DIST_UPLOAD_SOURCE']) {
+			frm['M_DIST_UPLOAD_SOURCE'].value = fileSource;
+		}
+	})
 
 	jQuery('#FILES_FRM_<?php echo $this->_htmlID; ?>').ajaxForm({
 		url: 'index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_cls=<?php echo __CLASS__; ?>&_hash=<?php echo $this->_htmlID; ?>&_task=FILES_UPLOAD&ID=<?php echo $record->ID; ?>',
 		beforeSubmit: function(args, $form, options) {
+			//console.log('#FILES_FRM_<?php echo $this->_htmlID; ?>.ajaxForm->beforeSubmit()...');
 			var argsMap = [];
 			args.map(function(v, k) {
 				argsMap[v.name] = v.value;
@@ -4727,11 +4726,13 @@ jQuery(document).ready(function(){
 			// validate
 			if (argsMap['M_DIST_UPLOAD_SOURCE'] == 'local') {
 				if (!argsMap['M_DIST_FILES_NAME']) {
+					//console.log('#FILES_FRM_<?php echo $this->_htmlID; ?>.ajaxForm->beforeSubmit() M_DIST_UPLOAD_SOURCE=local && !M_DIST_FILES_NAME');
 					return false;
 				}
 			}
 			else if (argsMap['M_DIST_UPLOAD_SOURCE'] == 'scan') {
 				if (!argsMap['SCANS_COLUMN_ADD']) {
+					//console.log('#FILES_FRM_<?php echo $this->_htmlID; ?>.ajaxForm->beforeSubmit() M_DIST_UPLOAD_SOURCE=scan && !SCANS_COLUMN_ADD');
 					return false;
 				}
 			}
@@ -4743,6 +4744,7 @@ jQuery(document).ready(function(){
 			$out.html('Wysyłanie...');
 		},
 		success: function(data) {
+			//console.log('#FILES_FRM_<?php echo $this->_htmlID; ?>.ajaxForm->success()...');
 			var $out = $('#FRM_UPLOAD_RESULTS_<?php echo $this->_htmlID; ?>');
 			var btnClose = '<button type="button" class="close" data-dismiss="alert"><i class="glyphicon glyphicon-remove"></i></button>';
 			if (typeof data == 'object') {

+ 1 - 0
SE/se-lib/tmpl/_layout_gora.php

@@ -14,6 +14,7 @@
 	<link rel="stylesheet" href="stuff/main.css" type="text/css" />
 	<script src="stuff/jquery-2.1.0.min.js"></script>
 	<script src="stuff/jquery-plugins.js"></script>
+	<script src="stuff/jquery.form.js"></script>
 	<script src="stuff/jquery.autosize.min.js"></script>
 	<script src="stuff/bootstrap/js/bootstrap.min.js"></script>
 	<script src="stuff/jquery.selectize/js/standalone/selectize.min.js"></script>