Test the new controls
This commit is contained in:
@@ -27,13 +27,13 @@ feature
|
||||
create textbox1.make_text ("txtBox1", "1")
|
||||
create textbox2.make_text ("txtBox2", "2")
|
||||
create button1.make_button ("sample_button1", "SUM")
|
||||
create textbox_result.make_text ("txtBox3", "")
|
||||
create textbox_result.make_textarea ("txtBox3", "")
|
||||
button1.set_click_event (agent handle_click)
|
||||
create form.make_form_control ("panel")
|
||||
form.add_control (create {WSF_FORM_ELEMENT_CONTROL[STRING]}.make_form_element("Number1",textbox1))
|
||||
form.add_control (textbox2)
|
||||
form.add_control (create {WSF_FORM_ELEMENT_CONTROL[STRING]}.make_form_element("Number2",textbox2))
|
||||
form.add_control (button1)
|
||||
form.add_control (textbox_result)
|
||||
form.add_control (create {WSF_FORM_ELEMENT_CONTROL[STRING]}.make_form_element("Result",textbox_result))
|
||||
control := form
|
||||
end
|
||||
|
||||
@@ -52,6 +52,6 @@ feature
|
||||
|
||||
textbox2: WSF_TEXT_CONTROL
|
||||
|
||||
textbox_result: WSF_TEXT_CONTROL
|
||||
textbox_result: WSF_TEXTAREA_CONTROL
|
||||
|
||||
end
|
||||
|
||||
@@ -27,7 +27,8 @@ controls = {}
|
||||
class WSF_BUTTON_CONTROL extends WSF_CONTROL
|
||||
attach_events: ()->
|
||||
self = @
|
||||
@$el.click ()->
|
||||
@$el.click (e)->
|
||||
e.preventDefault()
|
||||
self.click()
|
||||
click: ()->
|
||||
if window.states[@control_name]['callback_click']
|
||||
|
||||
@@ -53,7 +53,8 @@
|
||||
WSF_BUTTON_CONTROL.prototype.attach_events = function() {
|
||||
var self;
|
||||
self = this;
|
||||
return this.$el.click(function() {
|
||||
return this.$el.click(function(e) {
|
||||
e.preventDefault();
|
||||
return self.click();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -92,7 +92,7 @@ feature
|
||||
css_classes_string := " class=%"" + css_classes_string + "%""
|
||||
end
|
||||
Result := "<" + tag_name + " data-name=%"" + control_name + "%" data-type=%"" + generator + "%" " + attributes + css_classes_string
|
||||
if body.is_empty then
|
||||
if body.is_empty and not tag_name.is_equal("textarea") then
|
||||
Result := Result + " />"
|
||||
else
|
||||
Result := Result + " >" + body + "</" + tag_name + ">"
|
||||
|
||||
@@ -12,22 +12,21 @@ inherit
|
||||
WSF_CONTROL
|
||||
|
||||
create
|
||||
make_form_element,
|
||||
make_form_element_with_validators
|
||||
make_form_element, make_form_element_with_validators
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make_form_element (a_label:STRING; c: WSF_VALUE_CONTROL [G])
|
||||
make_form_element (a_label: STRING; c: WSF_VALUE_CONTROL [G])
|
||||
local
|
||||
a_validators: LINKED_LIST [WSF_VALIDATOR [G]]
|
||||
do
|
||||
create a_validators.make
|
||||
make_form_element_with_validators(a_label,c,a_validators)
|
||||
make_form_element_with_validators (a_label, c, a_validators)
|
||||
end
|
||||
|
||||
make_form_element_with_validators (a_label: STRING; c: WSF_VALUE_CONTROL [G]; v: LINKED_LIST [WSF_VALIDATOR [G]])
|
||||
do
|
||||
make (c.control_name+"_container", "div")
|
||||
make (c.control_name + "_container", "div")
|
||||
add_class ("form-group")
|
||||
c.add_class ("form-control")
|
||||
value_control := c
|
||||
@@ -64,6 +63,15 @@ feature --Implementation
|
||||
value_control.handle_callback (cname, event)
|
||||
end
|
||||
|
||||
read_state_changes (states: JSON_OBJECT)
|
||||
-- Add a new entry in the `states_changes` JSON object with the `control_name` as key and the `state` as value
|
||||
do
|
||||
if state_changes.count > 0 then
|
||||
states.put (state_changes, create {JSON_STRING}.make_json (control_name))
|
||||
end
|
||||
value_control.read_state_changes (states)
|
||||
end
|
||||
|
||||
render: STRING
|
||||
local
|
||||
body: STRING
|
||||
|
||||
@@ -77,6 +77,8 @@ feature
|
||||
create states.make
|
||||
control.read_state (states)
|
||||
data := "<html><head>"
|
||||
data.append ("<link href=%"//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css%" rel=%"stylesheet%">")
|
||||
|
||||
data.append ("</head><body>")
|
||||
data.append (control.render)
|
||||
data.append ("<script type=%"text/javascript%">window.states=")
|
||||
@@ -84,7 +86,6 @@ feature
|
||||
data.append (";</script>")
|
||||
data.append ("<script src=%"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js%"></script>")
|
||||
data.append ("<script src=%"/widget.js%"></script>")
|
||||
data.append ("<link href=%"//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css%" rel=%"stylesheet%">")
|
||||
data.append ("</body></html>")
|
||||
create page.make
|
||||
page.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "text/html"]>>)
|
||||
|
||||
Reference in New Issue
Block a user