Browse Source

Fix image uploads form

Vova Tkach 5 years ago
parent
commit
118d19a771

+ 0 - 1
assets/cp.scripts.js

@@ -3867,7 +3867,6 @@
 						file: filename,
 						file: filename,
 					}
 					}
 				}).done(function(data) {
 				}).done(function(data) {
-					$(button).parent().remove();
 					if(IsDebugMode()) console.log('done', data);
 					if(IsDebugMode()) console.log('done', data);
 					AjaxDone(data);
 					AjaxDone(data);
 				}).fail(function(xhr, status, error) {
 				}).fail(function(xhr, status, error) {

File diff suppressed because it is too large
+ 0 - 0
assets/cp.scripts.js.go


+ 2 - 2
modules/module_shop.go

@@ -241,7 +241,7 @@ func (this *Modules) shop_GetAllProductImages(wrap *wrapper.Wrapper, product_id
 		for rows.Next() {
 		for rows.Next() {
 			err = rows.Scan(scan...)
 			err = rows.Scan(scan...)
 			if err == nil {
 			if err == nil {
-				result += `<div><a href="/products/images/` + html.EscapeString(string(values[0])) + `/` + html.EscapeString(string(values[1])) + `" target="_blank">` + html.EscapeString(string(values[1])) + `</a>, <a href="javascript:fave.ShopProductsDeleteImage(this, ` + html.EscapeString(string(values[0])) + `, '` + html.EscapeString(string(values[1])) + `');">Delete</a></div>`
+				result += `<div class="attached-img"><a href="/products/images/` + html.EscapeString(string(values[0])) + `/` + html.EscapeString(string(values[1])) + `" target="_blank">` + html.EscapeString(string(values[1])) + `</a>, <a href="javascript:fave.ShopProductsDeleteImage(this, ` + html.EscapeString(string(values[0])) + `, '` + html.EscapeString(string(values[1])) + `');">Delete</a></div>`
 			}
 			}
 		}
 		}
 	}
 	}
@@ -898,7 +898,7 @@ func (this *Modules) RegisterModule_Shop() *Module {
 							this.shop_GetAllProductImages(wrap, data.A_id) +
 							this.shop_GetAllProductImages(wrap, data.A_id) +
 							`</div>` +
 							`</div>` +
 							`<div class="list-button position-relative">` +
 							`<div class="list-button position-relative">` +
-							`<input class="form-control" type="file" id="file" name="file" /><button type="button" class="btn btn-success btn-dynamic-remove" onclick="fave.ShopProductsUploadImage('shop-upload-image', ` + utils.IntToStr(data.A_id) + `, 'file');">Upload</button>` +
+							`<input class="form-control" type="file" id="file" name="file" style="font-size:13px;" /><button type="button" class="btn btn-success btn-dynamic-remove" onclick="fave.ShopProductsUploadImage('shop-upload-image', ` + utils.IntToStr(data.A_id) + `, 'file');">Upload</button>` +
 							`</div>` +
 							`</div>` +
 							`</div>` +
 							`</div>` +
 							`</div>` +
 							`</div>` +

+ 2 - 0
modules/module_shop_act_upload_delete.go

@@ -49,5 +49,7 @@ func (this *Modules) RegisterAction_ShopUploadDelete() *Action {
 			wrap.MsgError(err.Error())
 			wrap.MsgError(err.Error())
 			return
 			return
 		}
 		}
+
+		wrap.Write(`$('#list-images a').each(function(i, e) { if(e.innerHTML == '` + pf_file + `') { $(e).parent().remove(); return; } });`)
 	})
 	})
 }
 }

+ 1 - 8
modules/module_shop_act_upload_image.go

@@ -92,13 +92,6 @@ func (this *Modules) RegisterAction_ShopUploadImage() *Action {
 			return
 			return
 		}
 		}
 
 
-		wrap.Write(`Some!`)
-
-		// wrap.Write(`if($('#prod_attr_` + pf_id + `').length > 0) {`)
-		// wrap.Write(`$('#prod_attr_` + pf_id + ` select').prop('disabled', false).prop('multiple', true);`)
-		// wrap.Write(`$('#prod_attr_` + pf_id + ` select').html('` + options + `');`)
-		// wrap.Write(`$('#prod_attr_` + pf_id + ` select').selectpicker({});`)
-		// wrap.Write(`$('#prod_attr_` + pf_id + ` button').prop('disabled', false);`)
-		// wrap.Write(`}`)
+		wrap.Write(`$('#list-images').append('<div class="attached-img"><a href="/products/images/` + pf_id + `/` + target_file_name + `" target="_blank">` + target_file_name + `</a>, <a href="javascript:fave.ShopProductsDeleteImage(this, ` + pf_id + `, \'` + target_file_name + `\');">Delete</a></div>');`)
 	})
 	})
 }
 }

Some files were not shown because too many files changed in this diff