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)
do
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)
end
end

View File

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

View File

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