Fix load state error
This commit is contained in:
@@ -37,7 +37,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
Result.put_boolean (sort_direction, "sort_direction")
|
||||
end
|
||||
|
||||
set_state (new_state: WSF_JSON_OBJECT)
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore sort_column and sort_direction from json
|
||||
do
|
||||
if attached {JSON_STRING} new_state.item ("sort_column") as new_sort_column then
|
||||
|
||||
@@ -44,7 +44,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
Result.put_integer (row_count, "row_count")
|
||||
end
|
||||
|
||||
set_state (new_state: WSF_JSON_OBJECT)
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore page, page_size and row_count from json
|
||||
do
|
||||
Precursor (new_state)
|
||||
|
||||
@@ -32,7 +32,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
create Result.make
|
||||
end
|
||||
|
||||
set_state (new_state: WSF_JSON_OBJECT)
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- There is no state to restore states
|
||||
do
|
||||
end
|
||||
|
||||
@@ -38,10 +38,10 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
state_changes.replace (datasource.state, "datasource")
|
||||
end
|
||||
|
||||
set_state (new_state: WSF_JSON_OBJECT)
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore datasource state from json
|
||||
do
|
||||
if attached {WSF_JSON_OBJECT} new_state.item ("datasource") as datasource_state then
|
||||
if attached {JSON_OBJECT} new_state.item ("datasource") as datasource_state then
|
||||
datasource.set_state (datasource_state)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
set_state (new_state: WSF_JSON_OBJECT)
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore text from json
|
||||
do
|
||||
if attached {JSON_BOOLEAN} new_state.item ("checked") as new_checked then
|
||||
|
||||
@@ -26,7 +26,7 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
set_state (new_state: WSF_JSON_OBJECT)
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore text from json
|
||||
do
|
||||
if attached {JSON_STRING} new_state.item ("text") as new_text then
|
||||
|
||||
@@ -33,7 +33,7 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature -- State handling
|
||||
|
||||
set_state (new_state: WSF_JSON_OBJECT)
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
do
|
||||
if attached {JSON_NUMBER} new_state.item ("progress") as new_progress then
|
||||
progress := new_progress.item.to_integer
|
||||
|
||||
@@ -29,7 +29,7 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature -- State handling
|
||||
|
||||
set_state (new_state: WSF_JSON_OBJECT)
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
do
|
||||
end
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
set_state (new_state: WSF_JSON_OBJECT)
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore text from json
|
||||
do
|
||||
if attached {JSON_STRING} new_state.item ("text") as new_text then
|
||||
|
||||
@@ -62,15 +62,15 @@ feature -- Actions
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
|
||||
load_state (new_states: WSF_JSON_OBJECT)
|
||||
load_state (new_states: JSON_OBJECT)
|
||||
-- Select state stored with `control_name` as key
|
||||
do
|
||||
if attached {WSF_JSON_OBJECT} new_states.item ("state") as new_state_obj then
|
||||
if attached {JSON_OBJECT} new_states.item ("state") as new_state_obj then
|
||||
set_state (new_state_obj)
|
||||
end
|
||||
end
|
||||
|
||||
set_state (new_state: WSF_JSON_OBJECT)
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Before we process the callback. We restore the state of control.
|
||||
deferred
|
||||
end
|
||||
|
||||
@@ -48,16 +48,16 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
load_state (new_states: WSF_JSON_OBJECT)
|
||||
load_state (new_states: JSON_OBJECT)
|
||||
-- Pass new_states to subcontrols
|
||||
do
|
||||
Precursor (new_states)
|
||||
if attached {WSF_JSON_OBJECT} new_states.item ("controls") as ct and then attached {WSF_JSON_OBJECT} ct.item (value_control.control_name) as value_state then
|
||||
if attached {JSON_OBJECT} new_states.item ("controls") as ct and then attached {JSON_OBJECT} ct.item (value_control.control_name) as value_state then
|
||||
value_control.load_state (value_state)
|
||||
end
|
||||
end
|
||||
|
||||
set_state (new_state: WSF_JSON_OBJECT)
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Set new state
|
||||
do
|
||||
value_control.set_state (new_state)
|
||||
|
||||
@@ -25,7 +25,7 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
set_state (new_state: WSF_JSON_OBJECT)
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore html from json
|
||||
do
|
||||
if attached {JSON_STRING} new_state.item ("html") as new_html then
|
||||
|
||||
@@ -36,16 +36,16 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
load_state (new_states: WSF_JSON_OBJECT)
|
||||
load_state (new_states: JSON_OBJECT)
|
||||
-- Pass new_states to subcontrols
|
||||
do
|
||||
Precursor (new_states)
|
||||
if attached {WSF_JSON_OBJECT} new_states.item ("controls") as ct then
|
||||
if attached {JSON_OBJECT} new_states.item ("controls") as ct then
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
if attached {WSF_CONTROL} c.item as cont then
|
||||
if attached {WSF_JSON_OBJECT} ct.item (cont.control_name) as value_state then
|
||||
if attached {JSON_OBJECT} ct.item (cont.control_name) as value_state then
|
||||
cont.load_state (value_state)
|
||||
end
|
||||
end
|
||||
@@ -53,7 +53,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
end
|
||||
end
|
||||
|
||||
set_state (new_state: WSF_JSON_OBJECT)
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Before we process the callback. We restore the state of control.
|
||||
do
|
||||
end
|
||||
|
||||
@@ -70,7 +70,7 @@ feature -- Implementation
|
||||
create states.make_empty
|
||||
request.read_input_data_into (states)
|
||||
create json_parser.make_parser (states)
|
||||
if attached {WSF_JSON_OBJECT} json_parser.parse_json as sp then
|
||||
if attached {JSON_OBJECT} json_parser.parse_json as sp then
|
||||
set_state (sp)
|
||||
end
|
||||
handle_callback (event_control_name, event, event_parameter)
|
||||
@@ -161,9 +161,9 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
Result.put_string (request.query_string, "url_params")
|
||||
end
|
||||
|
||||
set_state (sp: WSF_JSON_OBJECT)
|
||||
set_state (sp: JSON_OBJECT)
|
||||
do
|
||||
if attached {WSF_JSON_OBJECT} sp.item ("controls") as ct and then attached {WSF_JSON_OBJECT} ct.item (control.control_name) as value_state then
|
||||
if attached {JSON_OBJECT} sp.item ("controls") as ct and then attached {JSON_OBJECT} ct.item (control.control_name) as value_state then
|
||||
control.load_state (value_state)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,10 +31,12 @@ Mini =
|
||||
{
|
||||
render:template(t)
|
||||
}
|
||||
loaded = {}
|
||||
lazy_load = (requirements,fn,that)->
|
||||
if not that?
|
||||
that = window
|
||||
return ()->
|
||||
a = arguments
|
||||
if not args?
|
||||
args = []
|
||||
counter = requirements.length + 1
|
||||
@@ -42,10 +44,15 @@ lazy_load = (requirements,fn,that)->
|
||||
done = ()->
|
||||
counter = counter - 1
|
||||
if counter == 0
|
||||
fn.apply(that,arguments)
|
||||
fn.apply(that,a)
|
||||
return
|
||||
for r in requirements
|
||||
$.cachedScript(r).done(done)
|
||||
if loaded[r]?
|
||||
done()
|
||||
else
|
||||
$.cachedScript(r).done ()->
|
||||
done()
|
||||
loaded[r] = true
|
||||
done()
|
||||
|
||||
build_control = (control_name, state, control)->
|
||||
|
||||
@@ -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_CONTROL, WSF_FORM_ELEMENT_CONTROL, WSF_GRID_CONTROL, WSF_HTML_CONTROL, WSF_INPUT_CONTROL, WSF_MAX_VALIDATOR, WSF_MIN_VALIDATOR, WSF_PAGE_CONTROL, WSF_PAGINATION_CONTROL, WSF_PROGRESS_CONTROL, WSF_REGEXP_VALIDATOR, WSF_REPEATER_CONTROL, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, build_control, cache, controls, lazy_load, show_alert, start_modal, template, tmpl,
|
||||
var Mini, WSF_AUTOCOMPLETE_CONTROL, WSF_BUTTON_CONTROL, WSF_CHECKBOX_CONTROL, WSF_CHECKBOX_LIST_CONTROL, WSF_CONTROL, WSF_FORM_ELEMENT_CONTROL, WSF_GRID_CONTROL, WSF_HTML_CONTROL, WSF_INPUT_CONTROL, WSF_MAX_VALIDATOR, WSF_MIN_VALIDATOR, WSF_PAGE_CONTROL, WSF_PAGINATION_CONTROL, WSF_PROGRESS_CONTROL, WSF_REGEXP_VALIDATOR, WSF_REPEATER_CONTROL, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, build_control, cache, controls, lazy_load, loaded, show_alert, start_modal, 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; };
|
||||
|
||||
@@ -49,12 +49,15 @@ Mini = {
|
||||
}
|
||||
};
|
||||
|
||||
loaded = {};
|
||||
|
||||
lazy_load = function(requirements, fn, that) {
|
||||
if (that == null) {
|
||||
that = window;
|
||||
}
|
||||
return function() {
|
||||
var args, counter, done, r, self, _i, _len;
|
||||
var a, args, counter, done, r, self, _i, _len;
|
||||
a = arguments;
|
||||
if (typeof args === "undefined" || args === null) {
|
||||
args = [];
|
||||
}
|
||||
@@ -63,12 +66,19 @@ lazy_load = function(requirements, fn, that) {
|
||||
done = function() {
|
||||
counter = counter - 1;
|
||||
if (counter === 0) {
|
||||
fn.apply(that, arguments);
|
||||
fn.apply(that, a);
|
||||
}
|
||||
};
|
||||
for (_i = 0, _len = requirements.length; _i < _len; _i++) {
|
||||
r = requirements[_i];
|
||||
$.cachedScript(r).done(done);
|
||||
if (loaded[r] != null) {
|
||||
done();
|
||||
} else {
|
||||
$.cachedScript(r).done(function() {
|
||||
done();
|
||||
return loaded[r] = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
return done();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user