Add dynamic multicontrol

This commit is contained in:
YNH Webdev
2014-01-26 15:02:06 +01:00
parent 5c9edeeae8
commit 8f148f2a5e
7 changed files with 196 additions and 18 deletions

View File

@@ -280,6 +280,8 @@ class WSF_CONTROL
return @
remove:()->
for control in @controls
control.remove()
console.log "Removed #{@control_name}"
@$el.remove()
@@ -310,6 +312,8 @@ class WSF_PAGE_CONTROL extends WSF_CONTROL
state
remove:()->
for control in @controls
control.remove()
console.log "Removed #{@control_name}"
@$el.remove()
@@ -476,7 +480,7 @@ class WSF_FILE_CONTROL extends WSF_CONTROL
return
@progressbar?.remove()
@$el.parent().find("p, img").remove()
if @state['file_id'] != null
if @state['file_id']?
@$el.hide()
fname = $("""<p></p>""").addClass("form-control-static").text(@state['file_name'])
@$el.parent().append(fname)
@@ -499,6 +503,20 @@ class WSF_FILE_CONTROL extends WSF_CONTROL
@$el.val('')
@change()
class WSF_DYNAMIC_MULTI_CONTROL extends WSF_CONTROL
update: (state)->
console.log state
if state.items? and state.render? and state.newstate?
@state['items'] = state.items
for control in @controls
control.remove()
@$el.html($(state.render).html())
@fullstate.controls = state.newstate
@load_subcontrols()
for control in @controls
control.initialize()
return
class WSF_PASSWORD_CONTROL extends WSF_INPUT_CONTROL

View File

@@ -1,5 +1,5 @@
// Generated by CoffeeScript 1.6.1
var Mini, WSF_AUTOCOMPLETE_CONTROL, WSF_BUTTON_CONTROL, WSF_CHECKBOX_CONTROL, WSF_CHECKBOX_LIST_CONTROL, WSF_CODEVIEW_CONTROL, WSF_CONTROL, WSF_DATE_PICKER_CONTROL, WSF_DROPDOWN_CONTROL, WSF_FILE_CONTROL, WSF_FORM_ELEMENT_CONTROL, WSF_GRID_CONTROL, WSF_HTML_CONTROL, WSF_INPUT_CONTROL, WSF_MAX_VALIDATOR, WSF_MIN_VALIDATOR, WSF_NAVLIST_ITEM_CONTROL, WSF_PAGE_CONTROL, WSF_PAGINATION_CONTROL, WSF_PASSWORD_CONTROL, WSF_PROGRESS_CONTROL, WSF_REGEXP_VALIDATOR, WSF_REPEATER_CONTROL, WSF_SLIDER_CONTROL, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, build_control, cache, controls, lazy_load, loaded, parseSuggestions, redirect, show_alert, start_modal, start_modal_big, template, tmpl,
var Mini, WSF_AUTOCOMPLETE_CONTROL, WSF_BUTTON_CONTROL, WSF_CHECKBOX_CONTROL, WSF_CHECKBOX_LIST_CONTROL, WSF_CODEVIEW_CONTROL, WSF_CONTROL, WSF_DATE_PICKER_CONTROL, WSF_DROPDOWN_CONTROL, WSF_DYNAMIC_MULTI_CONTROL, WSF_FILE_CONTROL, WSF_FORM_ELEMENT_CONTROL, WSF_GRID_CONTROL, WSF_HTML_CONTROL, WSF_INPUT_CONTROL, WSF_MAX_VALIDATOR, WSF_MIN_VALIDATOR, WSF_NAVLIST_ITEM_CONTROL, WSF_PAGE_CONTROL, WSF_PAGINATION_CONTROL, WSF_PASSWORD_CONTROL, WSF_PROGRESS_CONTROL, WSF_REGEXP_VALIDATOR, WSF_REPEATER_CONTROL, WSF_SLIDER_CONTROL, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, build_control, cache, controls, lazy_load, loaded, parseSuggestions, redirect, show_alert, start_modal, start_modal_big, template, tmpl,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
@@ -433,6 +433,12 @@ WSF_CONTROL = (function() {
};
WSF_CONTROL.prototype.remove = function() {
var control, _i, _len, _ref;
_ref = this.controls;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
control = _ref[_i];
control.remove();
}
console.log("Removed " + this.control_name);
return this.$el.remove();
};
@@ -478,6 +484,12 @@ WSF_PAGE_CONTROL = (function(_super) {
};
WSF_PAGE_CONTROL.prototype.remove = function() {
var control, _i, _len, _ref;
_ref = this.controls;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
control = _ref[_i];
control.remove();
}
console.log("Removed " + this.control_name);
return this.$el.remove();
};
@@ -747,7 +759,7 @@ WSF_FILE_CONTROL = (function(_super) {
_ref.remove();
}
this.$el.parent().find("p, img").remove();
if (this.state['file_id'] !== null) {
if (this.state['file_id'] != null) {
this.$el.hide();
fname = $("<p></p>").addClass("form-control-static").text(this.state['file_name']);
this.$el.parent().append(fname);
@@ -782,6 +794,39 @@ WSF_FILE_CONTROL = (function(_super) {
})(WSF_CONTROL);
WSF_DYNAMIC_MULTI_CONTROL = (function(_super) {
__extends(WSF_DYNAMIC_MULTI_CONTROL, _super);
function WSF_DYNAMIC_MULTI_CONTROL() {
return WSF_DYNAMIC_MULTI_CONTROL.__super__.constructor.apply(this, arguments);
}
WSF_DYNAMIC_MULTI_CONTROL.prototype.update = function(state) {
var control, _i, _j, _len, _len1, _ref, _ref1;
console.log(state);
if ((state.items != null) && (state.render != null) && (state.newstate != null)) {
this.state['items'] = state.items;
_ref = this.controls;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
control = _ref[_i];
control.remove();
}
this.$el.html($(state.render).html());
this.fullstate.controls = state.newstate;
this.load_subcontrols();
_ref1 = this.controls;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
control = _ref1[_j];
control.initialize();
}
}
};
return WSF_DYNAMIC_MULTI_CONTROL;
})(WSF_CONTROL);
WSF_PASSWORD_CONTROL = (function(_super) {
__extends(WSF_PASSWORD_CONTROL, _super);