- Add event paramenter
- Implement Paging control
This commit is contained in:
@@ -9,7 +9,7 @@ class
|
||||
|
||||
inherit
|
||||
|
||||
WSF_DATASOURCE [DEMO_DATA]
|
||||
WSF_PAGABLE_DATASOURCE [DEMO_DATA]
|
||||
|
||||
create
|
||||
make_demo
|
||||
@@ -28,11 +28,12 @@ feature
|
||||
do
|
||||
create list.make
|
||||
across
|
||||
((page - 1) * page_size) |..| (page * page_size - 1) as c
|
||||
((page - 1) * page_size) |..| (page * page_size - 1).min(131) as c
|
||||
loop
|
||||
list.extend (create {DEMO_DATA}.make (c.item, "Name" + c.item.out, "desc " + c.item.out))
|
||||
end
|
||||
Result := list
|
||||
row_count:=132
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -18,16 +18,15 @@ feature
|
||||
|
||||
initialize_controls
|
||||
local
|
||||
container: WSF_MULTI_CONTROL[WSF_STATELESS_CONTROL]
|
||||
container: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
navbar: WSF_NAVBAR_CONTROL
|
||||
form: WSF_FORM_CONTROL
|
||||
n1_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||
n2_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||
n3_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||
cats_container: WSF_FORM_ELEMENT_CONTROL [LIST [STRING]]
|
||||
s: FLAG_AUTOCOMPLETION
|
||||
do
|
||||
create s.make(<<["dz", "Algeria"], ["be", "Belgium"] , ["ca", "Canada"],["de", "Deutschland"], ["england", "England"], ["fi", "Finland"], ["gr", "Greece"], ["hu", "Hungary"]>>)
|
||||
create s.make (<<["dz", "Algeria"], ["be", "Belgium"], ["ca", "Canada"], ["de", "Deutschland"], ["england", "England"], ["fi", "Finland"], ["gr", "Greece"], ["hu", "Hungary"]>>)
|
||||
create container.make_multi_control ("container")
|
||||
create navbar.make_navbar ("Sample Page")
|
||||
create textbox1.make_input ("txtBox1", "1")
|
||||
@@ -66,21 +65,19 @@ feature
|
||||
local
|
||||
text: STRING
|
||||
do
|
||||
if attached {WSF_FORM_CONTROL} control as form then
|
||||
form.validate
|
||||
if form.is_valid then
|
||||
text := textbox1.text + " + " + textbox2.text + " = " + (textbox1.text.to_integer_64 + textbox2.text.to_integer_64).out
|
||||
text.append ("<ul>")
|
||||
across
|
||||
cklist.value as s
|
||||
loop
|
||||
text.append ("<li>" + s.item + "</li>")
|
||||
end
|
||||
text.append ("</ul>")
|
||||
textbox_result.set_html (text)
|
||||
else
|
||||
textbox_result.set_html ("VALIDATION ERROR")
|
||||
form.validate
|
||||
if form.is_valid then
|
||||
text := textbox1.text + " + " + textbox2.text + " = " + (textbox1.text.to_integer_64 + textbox2.text.to_integer_64).out
|
||||
text.append ("<ul>")
|
||||
across
|
||||
cklist.value as s
|
||||
loop
|
||||
text.append ("<li>" + s.item + "</li>")
|
||||
end
|
||||
text.append ("</ul>")
|
||||
textbox_result.set_html (text)
|
||||
else
|
||||
textbox_result.set_html ("VALIDATION ERROR")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -100,4 +97,6 @@ feature
|
||||
|
||||
textbox_result: WSF_HTML_CONTROL
|
||||
|
||||
form: WSF_FORM_CONTROL
|
||||
|
||||
end
|
||||
|
||||
@@ -11,11 +11,12 @@ Mini =
|
||||
render:template(t)
|
||||
}
|
||||
|
||||
trigger_callback = (control_name,event)->
|
||||
trigger_callback = (control_name,event,event_parameter)->
|
||||
$.ajax
|
||||
data:
|
||||
control_name: control_name
|
||||
event: event
|
||||
event_parameter: event_parameter
|
||||
states: JSON.stringify(window.states)
|
||||
cache: no
|
||||
.done (new_states)->
|
||||
@@ -247,6 +248,36 @@ class WSF_CHECKBOX_LIST_CONTROL extends WSF_CONTROL
|
||||
result.push(subc.checked_value)
|
||||
return result
|
||||
|
||||
class WSF_PAGINATION_CONTROL extends WSF_CONTROL
|
||||
attach_events: ()->
|
||||
self = @
|
||||
@$el.on 'click', 'a', (e)->
|
||||
e.preventDefault()
|
||||
self.click(e)
|
||||
|
||||
click: (e)->
|
||||
nr = $(e.target).data('nr')
|
||||
if nr == "next"
|
||||
trigger_callback(@control_name, "next")
|
||||
else if nr == "prev"
|
||||
trigger_callback(@control_name, "prev")
|
||||
else
|
||||
trigger_callback(@control_name, "goto", nr)
|
||||
|
||||
update: (state) ->
|
||||
if state._html?
|
||||
@$el.html($(state._html).html())
|
||||
|
||||
class WSF_GRID_CONTROL extends WSF_CONTROL
|
||||
attach_events: ()->
|
||||
self = @
|
||||
|
||||
update: (state) ->
|
||||
if state.datasource?
|
||||
window.states[@control_name]['datasource'] = state.datasource
|
||||
if state._body?
|
||||
@$el.find('tbody').html($(state._body).html())
|
||||
|
||||
#map class name to effective class
|
||||
typemap =
|
||||
"WSF_BUTTON_CONTROL":WSF_BUTTON_CONTROL
|
||||
@@ -257,6 +288,8 @@ typemap =
|
||||
"WSF_FORM_ELEMENT_CONTROL": WSF_FORM_ELEMENT_CONTROL
|
||||
"WSF_HTML_CONTROL": WSF_HTML_CONTROL
|
||||
"WSF_CHECKBOX_LIST_CONTROL": WSF_CHECKBOX_LIST_CONTROL
|
||||
"WSF_PAGINATION_CONTROL": WSF_PAGINATION_CONTROL
|
||||
"WSF_GRID_CONTROL": WSF_GRID_CONTROL
|
||||
|
||||
#create a js class for each control
|
||||
for name,state of window.states
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated by CoffeeScript 1.6.1
|
||||
(function() {
|
||||
var $el, Mini, WSF_AUTOCOMPLETE_CONTROL, WSF_BUTTON_CONTROL, WSF_CHECKBOX_CONTROL, WSF_CHECKBOX_LIST_CONTROL, WSF_CONTROL, WSF_FORM_ELEMENT_CONTROL, WSF_HTML_CONTROL, WSF_INPUT_CONTROL, WSF_MAX_VALIDATOR, WSF_MIN_VALIDATOR, WSF_REGEXP_VALIDATOR, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, cache, controls, name, state, template, tmpl, trigger_callback, type, typemap, validatormap, _ref, _ref1, _ref2,
|
||||
var $el, 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_PAGINATION_CONTROL, WSF_REGEXP_VALIDATOR, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, cache, controls, name, state, template, tmpl, trigger_callback, type, typemap, validatormap, _ref, _ref1, _ref2,
|
||||
__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; };
|
||||
|
||||
@@ -24,11 +24,12 @@
|
||||
}
|
||||
};
|
||||
|
||||
trigger_callback = function(control_name, event) {
|
||||
trigger_callback = function(control_name, event, event_parameter) {
|
||||
return $.ajax({
|
||||
data: {
|
||||
control_name: control_name,
|
||||
event: event,
|
||||
event_parameter: event_parameter,
|
||||
states: JSON.stringify(window.states)
|
||||
},
|
||||
cache: false
|
||||
@@ -463,6 +464,71 @@
|
||||
|
||||
})(WSF_CONTROL);
|
||||
|
||||
WSF_PAGINATION_CONTROL = (function(_super) {
|
||||
|
||||
__extends(WSF_PAGINATION_CONTROL, _super);
|
||||
|
||||
function WSF_PAGINATION_CONTROL() {
|
||||
return WSF_PAGINATION_CONTROL.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
WSF_PAGINATION_CONTROL.prototype.attach_events = function() {
|
||||
var self;
|
||||
self = this;
|
||||
return this.$el.on('click', 'a', function(e) {
|
||||
e.preventDefault();
|
||||
return self.click(e);
|
||||
});
|
||||
};
|
||||
|
||||
WSF_PAGINATION_CONTROL.prototype.click = function(e) {
|
||||
var nr;
|
||||
nr = $(e.target).data('nr');
|
||||
if (nr === "next") {
|
||||
return trigger_callback(this.control_name, "next");
|
||||
} else if (nr === "prev") {
|
||||
return trigger_callback(this.control_name, "prev");
|
||||
} else {
|
||||
return trigger_callback(this.control_name, "goto", nr);
|
||||
}
|
||||
};
|
||||
|
||||
WSF_PAGINATION_CONTROL.prototype.update = function(state) {
|
||||
if (state._html != null) {
|
||||
return this.$el.html($(state._html).html());
|
||||
}
|
||||
};
|
||||
|
||||
return WSF_PAGINATION_CONTROL;
|
||||
|
||||
})(WSF_CONTROL);
|
||||
|
||||
WSF_GRID_CONTROL = (function(_super) {
|
||||
|
||||
__extends(WSF_GRID_CONTROL, _super);
|
||||
|
||||
function WSF_GRID_CONTROL() {
|
||||
return WSF_GRID_CONTROL.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
WSF_GRID_CONTROL.prototype.attach_events = function() {
|
||||
var self;
|
||||
return self = this;
|
||||
};
|
||||
|
||||
WSF_GRID_CONTROL.prototype.update = function(state) {
|
||||
if (state.datasource != null) {
|
||||
window.states[this.control_name]['datasource'] = state.datasource;
|
||||
}
|
||||
if (state._body != null) {
|
||||
return this.$el.find('tbody').html($(state._body).html());
|
||||
}
|
||||
};
|
||||
|
||||
return WSF_GRID_CONTROL;
|
||||
|
||||
})(WSF_CONTROL);
|
||||
|
||||
typemap = {
|
||||
"WSF_BUTTON_CONTROL": WSF_BUTTON_CONTROL,
|
||||
"WSF_INPUT_CONTROL": WSF_INPUT_CONTROL,
|
||||
@@ -471,7 +537,9 @@
|
||||
"WSF_CHECKBOX_CONTROL": WSF_CHECKBOX_CONTROL,
|
||||
"WSF_FORM_ELEMENT_CONTROL": WSF_FORM_ELEMENT_CONTROL,
|
||||
"WSF_HTML_CONTROL": WSF_HTML_CONTROL,
|
||||
"WSF_CHECKBOX_LIST_CONTROL": WSF_CHECKBOX_LIST_CONTROL
|
||||
"WSF_CHECKBOX_LIST_CONTROL": WSF_CHECKBOX_LIST_CONTROL,
|
||||
"WSF_PAGINATION_CONTROL": WSF_PAGINATION_CONTROL,
|
||||
"WSF_GRID_CONTROL": WSF_GRID_CONTROL
|
||||
};
|
||||
|
||||
_ref = window.states;
|
||||
|
||||
Reference in New Issue
Block a user