Fix upload state

This commit is contained in:
YNH Webdev
2014-01-25 18:00:31 +01:00
parent d82cacc18f
commit 13349d07a8
3 changed files with 14 additions and 7 deletions

View File

@@ -42,7 +42,7 @@ feature
add_control (c: WSF_STATELESS_CONTROL) add_control (c: WSF_STATELESS_CONTROL)
do do
Precursor (c) Precursor (c)
if attached {WSF_FORM_ELEMENT_CONTROL[ANY]} c as fec then if attached {WSF_FORM_ELEMENT_CONTROL[detachable ANY]} c as fec then
fec.set_label_width (label_width) fec.set_label_width (label_width)
end end
end end

View File

@@ -420,6 +420,7 @@ class WSF_FILE_CONTROL extends WSF_CONTROL
self = @ self = @
@$el.change ()-> @$el.change ()->
self.change() self.change()
@refresh()
change: ()-> change: ()->
#update local state #update local state
@@ -461,7 +462,7 @@ class WSF_FILE_CONTROL extends WSF_CONTROL
refresh: ()-> refresh: ()->
if @uploading if @uploading
return return
@progressbar.remove() @progressbar?.remove()
@$el.parent().find("p").remove() @$el.parent().find("p").remove()
if @state['file_id'] != null if @state['file_id'] != null
@$el.hide() @$el.hide()
@@ -472,7 +473,7 @@ class WSF_FILE_CONTROL extends WSF_CONTROL
removebtn = $("<button />").text("Remove").addClass("btn btn-xs btn-danger") removebtn = $("<button />").text("Remove").addClass("btn btn-xs btn-danger")
self = @ self = @
removebtn.click ()-> removebtn.click ()->
self.progressbar.remove() self.progressbar?.remove()
self.$el.parent().find("p").remove() self.$el.parent().find("p").remove()
self.$el.show() self.$el.show()
self.$el.val('') self.$el.val('')

View File

@@ -667,9 +667,10 @@ WSF_FILE_CONTROL = (function(_super) {
var self; var self;
WSF_FILE_CONTROL.__super__.attach_events.apply(this, arguments); WSF_FILE_CONTROL.__super__.attach_events.apply(this, arguments);
self = this; self = this;
return this.$el.change(function() { this.$el.change(function() {
return self.change(); return self.change();
}); });
return this.refresh();
}; };
WSF_FILE_CONTROL.prototype.change = function() { WSF_FILE_CONTROL.prototype.change = function() {
@@ -722,11 +723,13 @@ WSF_FILE_CONTROL = (function(_super) {
}; };
WSF_FILE_CONTROL.prototype.refresh = function() { WSF_FILE_CONTROL.prototype.refresh = function() {
var fname, removebtn, self; var fname, removebtn, self, _ref;
if (this.uploading) { if (this.uploading) {
return; return;
} }
this.progressbar.remove(); if ((_ref = this.progressbar) != null) {
_ref.remove();
}
this.$el.parent().find("p").remove(); this.$el.parent().find("p").remove();
if (this.state['file_id'] !== null) { if (this.state['file_id'] !== null) {
this.$el.hide(); this.$el.hide();
@@ -737,7 +740,10 @@ WSF_FILE_CONTROL = (function(_super) {
removebtn = $("<button />").text("Remove").addClass("btn btn-xs btn-danger"); removebtn = $("<button />").text("Remove").addClass("btn btn-xs btn-danger");
self = this; self = this;
removebtn.click(function() { removebtn.click(function() {
self.progressbar.remove(); var _ref1;
if ((_ref1 = self.progressbar) != null) {
_ref1.remove();
}
self.$el.parent().find("p").remove(); self.$el.parent().find("p").remove();
self.$el.show(); self.$el.show();
self.$el.val(''); self.$el.val('');