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")
|
Result.put_boolean (sort_direction, "sort_direction")
|
||||||
end
|
end
|
||||||
|
|
||||||
set_state (new_state: WSF_JSON_OBJECT)
|
set_state (new_state: JSON_OBJECT)
|
||||||
-- Restore sort_column and sort_direction from json
|
-- Restore sort_column and sort_direction from json
|
||||||
do
|
do
|
||||||
if attached {JSON_STRING} new_state.item ("sort_column") as new_sort_column then
|
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")
|
Result.put_integer (row_count, "row_count")
|
||||||
end
|
end
|
||||||
|
|
||||||
set_state (new_state: WSF_JSON_OBJECT)
|
set_state (new_state: JSON_OBJECT)
|
||||||
-- Restore page, page_size and row_count from json
|
-- Restore page, page_size and row_count from json
|
||||||
do
|
do
|
||||||
Precursor (new_state)
|
Precursor (new_state)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
|||||||
create Result.make
|
create Result.make
|
||||||
end
|
end
|
||||||
|
|
||||||
set_state (new_state: WSF_JSON_OBJECT)
|
set_state (new_state: JSON_OBJECT)
|
||||||
-- There is no state to restore states
|
-- There is no state to restore states
|
||||||
do
|
do
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
|||||||
state_changes.replace (datasource.state, "datasource")
|
state_changes.replace (datasource.state, "datasource")
|
||||||
end
|
end
|
||||||
|
|
||||||
set_state (new_state: WSF_JSON_OBJECT)
|
set_state (new_state: JSON_OBJECT)
|
||||||
-- Restore datasource state from json
|
-- Restore datasource state from json
|
||||||
do
|
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)
|
datasource.set_state (datasource_state)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ feature {NONE} -- Initialization
|
|||||||
|
|
||||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
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
|
-- Restore text from json
|
||||||
do
|
do
|
||||||
if attached {JSON_BOOLEAN} new_state.item ("checked") as new_checked then
|
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
|
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
|
-- Restore text from json
|
||||||
do
|
do
|
||||||
if attached {JSON_STRING} new_state.item ("text") as new_text then
|
if attached {JSON_STRING} new_state.item ("text") as new_text then
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ feature {NONE} -- Initialization
|
|||||||
|
|
||||||
feature -- State handling
|
feature -- State handling
|
||||||
|
|
||||||
set_state (new_state: WSF_JSON_OBJECT)
|
set_state (new_state: JSON_OBJECT)
|
||||||
do
|
do
|
||||||
if attached {JSON_NUMBER} new_state.item ("progress") as new_progress then
|
if attached {JSON_NUMBER} new_state.item ("progress") as new_progress then
|
||||||
progress := new_progress.item.to_integer
|
progress := new_progress.item.to_integer
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ feature {NONE} -- Initialization
|
|||||||
|
|
||||||
feature -- State handling
|
feature -- State handling
|
||||||
|
|
||||||
set_state (new_state: WSF_JSON_OBJECT)
|
set_state (new_state: JSON_OBJECT)
|
||||||
do
|
do
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ feature {NONE} -- Initialization
|
|||||||
|
|
||||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
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
|
-- Restore text from json
|
||||||
do
|
do
|
||||||
if attached {JSON_STRING} new_state.item ("text") as new_text then
|
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
|
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
|
-- Select state stored with `control_name` as key
|
||||||
do
|
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)
|
set_state (new_state_obj)
|
||||||
end
|
end
|
||||||
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.
|
-- Before we process the callback. We restore the state of control.
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -48,16 +48,16 @@ feature {NONE} -- Initialization
|
|||||||
|
|
||||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
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
|
-- Pass new_states to subcontrols
|
||||||
do
|
do
|
||||||
Precursor (new_states)
|
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)
|
value_control.load_state (value_state)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
set_state (new_state: WSF_JSON_OBJECT)
|
set_state (new_state: JSON_OBJECT)
|
||||||
-- Set new state
|
-- Set new state
|
||||||
do
|
do
|
||||||
value_control.set_state (new_state)
|
value_control.set_state (new_state)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ feature {NONE} -- Initialization
|
|||||||
|
|
||||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
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
|
-- Restore html from json
|
||||||
do
|
do
|
||||||
if attached {JSON_STRING} new_state.item ("html") as new_html then
|
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
|
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
|
-- Pass new_states to subcontrols
|
||||||
do
|
do
|
||||||
Precursor (new_states)
|
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
|
across
|
||||||
controls as c
|
controls as c
|
||||||
loop
|
loop
|
||||||
if attached {WSF_CONTROL} c.item as cont then
|
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)
|
cont.load_state (value_state)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -53,7 +53,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
|||||||
end
|
end
|
||||||
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.
|
-- Before we process the callback. We restore the state of control.
|
||||||
do
|
do
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ feature -- Implementation
|
|||||||
create states.make_empty
|
create states.make_empty
|
||||||
request.read_input_data_into (states)
|
request.read_input_data_into (states)
|
||||||
create json_parser.make_parser (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)
|
set_state (sp)
|
||||||
end
|
end
|
||||||
handle_callback (event_control_name, event, event_parameter)
|
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")
|
Result.put_string (request.query_string, "url_params")
|
||||||
end
|
end
|
||||||
|
|
||||||
set_state (sp: WSF_JSON_OBJECT)
|
set_state (sp: JSON_OBJECT)
|
||||||
do
|
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)
|
control.load_state (value_state)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,10 +31,12 @@ Mini =
|
|||||||
{
|
{
|
||||||
render:template(t)
|
render:template(t)
|
||||||
}
|
}
|
||||||
|
loaded = {}
|
||||||
lazy_load = (requirements,fn,that)->
|
lazy_load = (requirements,fn,that)->
|
||||||
if not that?
|
if not that?
|
||||||
that = window
|
that = window
|
||||||
return ()->
|
return ()->
|
||||||
|
a = arguments
|
||||||
if not args?
|
if not args?
|
||||||
args = []
|
args = []
|
||||||
counter = requirements.length + 1
|
counter = requirements.length + 1
|
||||||
@@ -42,10 +44,15 @@ lazy_load = (requirements,fn,that)->
|
|||||||
done = ()->
|
done = ()->
|
||||||
counter = counter - 1
|
counter = counter - 1
|
||||||
if counter == 0
|
if counter == 0
|
||||||
fn.apply(that,arguments)
|
fn.apply(that,a)
|
||||||
return
|
return
|
||||||
for r in requirements
|
for r in requirements
|
||||||
$.cachedScript(r).done(done)
|
if loaded[r]?
|
||||||
|
done()
|
||||||
|
else
|
||||||
|
$.cachedScript(r).done ()->
|
||||||
|
done()
|
||||||
|
loaded[r] = true
|
||||||
done()
|
done()
|
||||||
|
|
||||||
build_control = (control_name, state, control)->
|
build_control = (control_name, state, control)->
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Generated by CoffeeScript 1.6.1
|
// 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,
|
__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; };
|
__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) {
|
lazy_load = function(requirements, fn, that) {
|
||||||
if (that == null) {
|
if (that == null) {
|
||||||
that = window;
|
that = window;
|
||||||
}
|
}
|
||||||
return function() {
|
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) {
|
if (typeof args === "undefined" || args === null) {
|
||||||
args = [];
|
args = [];
|
||||||
}
|
}
|
||||||
@@ -63,12 +66,19 @@ lazy_load = function(requirements, fn, that) {
|
|||||||
done = function() {
|
done = function() {
|
||||||
counter = counter - 1;
|
counter = counter - 1;
|
||||||
if (counter === 0) {
|
if (counter === 0) {
|
||||||
fn.apply(that, arguments);
|
fn.apply(that, a);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
for (_i = 0, _len = requirements.length; _i < _len; _i++) {
|
for (_i = 0, _len = requirements.length; _i < _len; _i++) {
|
||||||
r = requirements[_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();
|
return done();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user