Added comments to autocompletion, input, navbar, progressbar, validator, webcontrol. Some more little changes.
This commit is contained in:
@@ -16,16 +16,17 @@ create
|
|||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make ()
|
make
|
||||||
|
-- Initialize
|
||||||
do
|
do
|
||||||
template := "<div class=%"clearfix%" style=%"min-width:250px%"><img src=%"http://api.randomuser.me/0.2/portraits/{{=img}}.jpg%" style=%"max-width:50px;margin-right:10px%" class=%"img-circle pull-left%"> <b>{{=value}}</b><br /><small>{{=company}}</small></div>";
|
template := "<div class=%"clearfix%" style=%"min-width:250px%"><img src=%"http://api.randomuser.me/0.2/portraits/{{=img}}.jpg%" style=%"max-width:50px;margin-right:10px%" class=%"img-circle pull-left%"> <b>{{=value}}</b><br /><small>{{=company}}</small></div>";
|
||||||
list := <<["Zelma Hays","Applideck","women/13"],["Little Dixon","Centregy","men/20"],["Marta Fuentes","Papricut","women/11"],["Aileen Dillon","Neteria","women/9"],["Noel Melendez","Corporana","men/19"],["Gutierrez Francis","Capscreen","men/3"],["Valerie Weiss","Zizzle","women/9"],["Mabel Hammond","Pyramax","women/19"],["Mckay Logan","Providco","men/17"],["Hazel Colon","Translink","women/14"],["Margery Whitney","Tropoli","women/21"],["Saundra Neal","Geekmosis","women/20"],["Meghan Pittman","Micronaut","women/16"],["Adrienne Woodward","Mixers","women/8"],["Harriett Macdonald","Anarco","women/4"],["Velasquez Curtis","Zensus","men/4"],["Victoria Greene","Zorromop","women/10"],["Hood Barron","Kangle","men/2"],["Mccullough Cross","Kindaloo","men/15"],["Porter Hart","Kongle","men/15"],["Fox Bryant","Columella","men/17"],["Singleton Knapp","Marketoid","men/10"],["Gracie Lane","Solgan","women/15"],["Randall Cobb","Barkarama","men/7"],["Miranda Brooks","Earwax","men/1"],["Teresa Taylor","Stockpost","women/6"]>>
|
list := <<["Zelma Hays", "Applideck", "women/13"], ["Little Dixon", "Centregy", "men/20"], ["Marta Fuentes", "Papricut", "women/11"], ["Aileen Dillon", "Neteria", "women/9"], ["Noel Melendez", "Corporana", "men/19"], ["Gutierrez Francis", "Capscreen", "men/3"], ["Valerie Weiss", "Zizzle", "women/9"], ["Mabel Hammond", "Pyramax", "women/19"], ["Mckay Logan", "Providco", "men/17"], ["Hazel Colon", "Translink", "women/14"], ["Margery Whitney", "Tropoli", "women/21"], ["Saundra Neal", "Geekmosis", "women/20"], ["Meghan Pittman", "Micronaut", "women/16"], ["Adrienne Woodward", "Mixers", "women/8"], ["Harriett Macdonald", "Anarco", "women/4"], ["Velasquez Curtis", "Zensus", "men/4"], ["Victoria Greene", "Zorromop", "women/10"], ["Hood Barron", "Kangle", "men/2"], ["Mccullough Cross", "Kindaloo", "men/15"], ["Porter Hart", "Kongle", "men/15"], ["Fox Bryant", "Columella", "men/17"], ["Singleton Knapp", "Marketoid", "men/10"], ["Gracie Lane", "Solgan", "women/15"], ["Randall Cobb", "Barkarama", "men/7"], ["Miranda Brooks", "Earwax", "men/1"], ["Teresa Taylor", "Stockpost", "women/6"]>>
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Implementation
|
feature -- Implementation
|
||||||
|
|
||||||
autocompletion (input: STRING): JSON_ARRAY
|
autocompletion (input: STRING): JSON_ARRAY
|
||||||
|
-- Implementation
|
||||||
local
|
local
|
||||||
o: JSON_OBJECT
|
o: JSON_OBJECT
|
||||||
do
|
do
|
||||||
@@ -46,5 +47,6 @@ feature -- Implementation
|
|||||||
end
|
end
|
||||||
|
|
||||||
list: ITERABLE [TUPLE [STRING, STRING]]
|
list: ITERABLE [TUPLE [STRING, STRING]]
|
||||||
|
-- List of contacts
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ create
|
|||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make ()
|
make
|
||||||
|
-- Initialize
|
||||||
do
|
do
|
||||||
template := "<img src=%"http://www.famfamfam.com/lab/icons/flags/icons/gif/{{=flag}}.gif%"> {{=value}}";
|
template := "<img src=%"http://www.famfamfam.com/lab/icons/flags/icons/gif/{{=flag}}.gif%"> {{=value}}";
|
||||||
end
|
end
|
||||||
@@ -24,6 +25,7 @@ feature {NONE} -- Initialization
|
|||||||
feature -- Implementation
|
feature -- Implementation
|
||||||
|
|
||||||
autocompletion (input: STRING): JSON_ARRAY
|
autocompletion (input: STRING): JSON_ARRAY
|
||||||
|
-- Implementation
|
||||||
local
|
local
|
||||||
list: ITERABLE [TUPLE [STRING, STRING]]
|
list: ITERABLE [TUPLE [STRING, STRING]]
|
||||||
o: JSON_OBJECT
|
o: JSON_OBJECT
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ create
|
|||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make
|
make
|
||||||
|
-- Initialize
|
||||||
do
|
do
|
||||||
template := "{{=value}}";
|
template := "{{=value}}";
|
||||||
end
|
end
|
||||||
@@ -24,11 +25,11 @@ feature {NONE} -- Initialization
|
|||||||
feature -- Implementation
|
feature -- Implementation
|
||||||
|
|
||||||
autocompletion (input: STRING): JSON_ARRAY
|
autocompletion (input: STRING): JSON_ARRAY
|
||||||
|
-- Implementation
|
||||||
local
|
local
|
||||||
cl: LIBCURL_HTTP_CLIENT
|
cl: LIBCURL_HTTP_CLIENT
|
||||||
sess: HTTP_CLIENT_SESSION
|
sess: HTTP_CLIENT_SESSION
|
||||||
l_json: detachable READABLE_STRING_8
|
l_json: detachable READABLE_STRING_8
|
||||||
|
|
||||||
o: JSON_OBJECT
|
o: JSON_OBJECT
|
||||||
json_parser: JSON_PARSER
|
json_parser: JSON_PARSER
|
||||||
query_str: STRING
|
query_str: STRING
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ note
|
|||||||
deferred class
|
deferred class
|
||||||
WSF_AUTOCOMPLETION
|
WSF_AUTOCOMPLETION
|
||||||
|
|
||||||
feature
|
feature -- Access
|
||||||
|
|
||||||
autocompletion (input: STRING): JSON_ARRAY
|
autocompletion (input: STRING): JSON_ARRAY
|
||||||
|
-- JSON array of suggestions that fit the specific input
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
template: detachable STRING
|
template: detachable STRING
|
||||||
|
-- Customizable template
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ inherit
|
|||||||
create
|
create
|
||||||
make
|
make
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make (l: ITERABLE [STRING])
|
make (l: ITERABLE [STRING])
|
||||||
|
-- Initialize
|
||||||
do
|
do
|
||||||
list := l
|
list := l
|
||||||
end
|
end
|
||||||
@@ -24,6 +25,7 @@ feature {NONE}
|
|||||||
feature -- Implementation
|
feature -- Implementation
|
||||||
|
|
||||||
autocompletion (input: STRING): JSON_ARRAY
|
autocompletion (input: STRING): JSON_ARRAY
|
||||||
|
-- Implementation
|
||||||
local
|
local
|
||||||
o: JSON_OBJECT
|
o: JSON_OBJECT
|
||||||
do
|
do
|
||||||
@@ -33,14 +35,13 @@ feature -- Implementation
|
|||||||
loop
|
loop
|
||||||
if c.item.as_lower.has_substring (input.as_lower) then
|
if c.item.as_lower.has_substring (input.as_lower) then
|
||||||
create o.make
|
create o.make
|
||||||
o.put (create {JSON_STRING}.make_json(c.item), "value")
|
o.put (create {JSON_STRING}.make_json (c.item), "value")
|
||||||
Result.add (o)
|
Result.add (o)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
|
||||||
|
|
||||||
list: ITERABLE [STRING]
|
list: ITERABLE [STRING]
|
||||||
|
-- List containing suggestions
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ inherit
|
|||||||
create
|
create
|
||||||
make_autocomplete, make_autocomplete_with_agent
|
make_autocomplete, make_autocomplete_with_agent
|
||||||
|
|
||||||
feature {NONE} -- Creation
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_autocomplete (n: STRING; c: WSF_AUTOCOMPLETION)
|
make_autocomplete (n: STRING; c: WSF_AUTOCOMPLETION)
|
||||||
|
-- Initialize with specified name and autocompletion
|
||||||
do
|
do
|
||||||
make_autocomplete_with_agent (n, agent c.autocompletion)
|
make_autocomplete_with_agent (n, agent c.autocompletion)
|
||||||
if attached c.template as t then
|
if attached c.template as t then
|
||||||
@@ -29,6 +30,7 @@ feature {NONE} -- Creation
|
|||||||
end
|
end
|
||||||
|
|
||||||
make_autocomplete_with_agent (n: STRING; c: FUNCTION [ANY, TUPLE [STRING], JSON_ARRAY])
|
make_autocomplete_with_agent (n: STRING; c: FUNCTION [ANY, TUPLE [STRING], JSON_ARRAY])
|
||||||
|
-- Initialize with specified name and autocompletion function
|
||||||
do
|
do
|
||||||
make_input (n, "")
|
make_input (n, "")
|
||||||
create_json_list := c
|
create_json_list := c
|
||||||
@@ -53,7 +55,7 @@ feature -- Callback
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Autocomplete
|
feature -- Properties
|
||||||
|
|
||||||
create_json_list: FUNCTION [ANY, TUPLE [STRING], JSON_ARRAY]
|
create_json_list: FUNCTION [ANY, TUPLE [STRING], JSON_ARRAY]
|
||||||
|
|
||||||
|
|||||||
@@ -14,16 +14,17 @@ inherit
|
|||||||
create
|
create
|
||||||
make_checkbox
|
make_checkbox
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_checkbox (n: STRING; l: STRING; c: STRING)
|
make_checkbox (n, l, c: STRING)
|
||||||
|
-- Initialize with specified control name,
|
||||||
do
|
do
|
||||||
make_control (n, "input")
|
make_control (n, "input")
|
||||||
label := l
|
label := l
|
||||||
checked_value := c
|
checked_value := c
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||||
|
|
||||||
set_state (new_state: JSON_OBJECT)
|
set_state (new_state: JSON_OBJECT)
|
||||||
-- Restore text from json
|
-- Restore text from json
|
||||||
@@ -42,7 +43,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|||||||
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), "callback_change")
|
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), "callback_change")
|
||||||
end
|
end
|
||||||
|
|
||||||
feature --EVENT HANDLING
|
feature --Event handling
|
||||||
|
|
||||||
set_change_event (e: attached like change_event)
|
set_change_event (e: attached like change_event)
|
||||||
-- Set text change event handle
|
-- Set text change event handle
|
||||||
@@ -77,14 +78,18 @@ feature -- Implementation
|
|||||||
Result := checked
|
Result := checked
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature -- Properties
|
||||||
|
|
||||||
label: STRING
|
label: STRING
|
||||||
|
-- The label of the checkbox control
|
||||||
|
|
||||||
checked: BOOLEAN
|
checked: BOOLEAN
|
||||||
|
-- The checked value of the checkbox control
|
||||||
|
|
||||||
checked_value: STRING
|
checked_value: STRING
|
||||||
|
-- String checked value
|
||||||
|
|
||||||
change_event: detachable PROCEDURE [ANY, TUPLE]
|
change_event: detachable PROCEDURE [ANY, TUPLE]
|
||||||
|
-- Function to be executed on change
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,14 +21,15 @@ inherit
|
|||||||
create
|
create
|
||||||
make_checkbox_list_control
|
make_checkbox_list_control
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initializaton
|
||||||
|
|
||||||
make_checkbox_list_control (n: STRING)
|
make_checkbox_list_control (n: STRING)
|
||||||
|
-- Initialize with specified control name
|
||||||
do
|
do
|
||||||
make_multi_control (n)
|
make_multi_control (n)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature -- Implementation
|
||||||
|
|
||||||
value: LIST [STRING]
|
value: LIST [STRING]
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -14,16 +14,17 @@ inherit
|
|||||||
create
|
create
|
||||||
make_input
|
make_input
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_input (n: STRING; v: STRING)
|
make_input (n, v: STRING)
|
||||||
|
-- Initialize with specified name and value
|
||||||
do
|
do
|
||||||
make_control (n, "input")
|
make_control (n, "input")
|
||||||
type := "text"
|
type := "text"
|
||||||
text := v
|
text := v
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||||
|
|
||||||
set_state (new_state: JSON_OBJECT)
|
set_state (new_state: JSON_OBJECT)
|
||||||
-- Restore text from json
|
-- Restore text from json
|
||||||
@@ -41,7 +42,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|||||||
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), "callback_change")
|
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), "callback_change")
|
||||||
end
|
end
|
||||||
|
|
||||||
feature --EVENT HANDLING
|
feature --Event handling
|
||||||
|
|
||||||
set_change_event (e: attached like change_event)
|
set_change_event (e: attached like change_event)
|
||||||
-- Set text change event handle
|
-- Set text change event handle
|
||||||
@@ -58,14 +59,17 @@ feature --EVENT HANDLING
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Implementation
|
feature -- Rendering
|
||||||
|
|
||||||
render: STRING
|
render: STRING
|
||||||
do
|
do
|
||||||
Result := render_tag ("", "type=%"" + type + "%" value=%"" + text + "%"")
|
Result := render_tag ("", "type=%"" + type + "%" value=%"" + text + "%"")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Change
|
||||||
|
|
||||||
set_text (t: STRING)
|
set_text (t: STRING)
|
||||||
|
-- Set text to be displayed
|
||||||
do
|
do
|
||||||
if not t.same_string (text) then
|
if not t.same_string (text) then
|
||||||
text := t
|
text := t
|
||||||
@@ -73,17 +77,22 @@ feature -- Implementation
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Implementation
|
||||||
|
|
||||||
value: STRING
|
value: STRING
|
||||||
do
|
do
|
||||||
Result := text
|
Result := text
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature -- Properties
|
||||||
|
|
||||||
text: STRING
|
text: STRING
|
||||||
|
-- Text to be displayed
|
||||||
|
|
||||||
type: STRING
|
type: STRING
|
||||||
|
-- Type of this input control
|
||||||
|
|
||||||
change_event: detachable PROCEDURE [ANY, TUPLE]
|
change_event: detachable PROCEDURE [ANY, TUPLE]
|
||||||
|
-- Procedure to be execued on change
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ inherit
|
|||||||
create
|
create
|
||||||
make_password
|
make_password
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_password (n: STRING; v: STRING)
|
make_password (n, v: STRING)
|
||||||
|
-- Initialize with specified control name and text
|
||||||
do
|
do
|
||||||
make_input (n, v)
|
make_input (n, v)
|
||||||
type := "password"
|
type := "password"
|
||||||
|
|||||||
@@ -17,15 +17,16 @@ inherit
|
|||||||
create
|
create
|
||||||
make_textarea
|
make_textarea
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_textarea (n, t: STRING)
|
make_textarea (n, t: STRING)
|
||||||
|
-- Initialize with specified control name and text to be displayed in this textarea
|
||||||
do
|
do
|
||||||
make_input (n, t)
|
make_input (n, t)
|
||||||
tag_name := "textarea"
|
tag_name := "textarea"
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature -- Rendering
|
||||||
|
|
||||||
render: STRING
|
render: STRING
|
||||||
do
|
do
|
||||||
|
|||||||
@@ -9,47 +9,19 @@ class
|
|||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
WSF_STATELESS_MULTI_CONTROL
|
||||||
|
|
||||||
create
|
create
|
||||||
make_navbar
|
make_navbar
|
||||||
|
|
||||||
feature
|
|
||||||
|
|
||||||
collapse: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
|
||||||
|
|
||||||
nav: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
|
||||||
|
|
||||||
nav_right: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
|
||||||
|
|
||||||
feature
|
|
||||||
|
|
||||||
add_element (c: WSF_STATELESS_CONTROL)
|
|
||||||
do
|
|
||||||
add_element_to_nav (c, nav)
|
|
||||||
end
|
|
||||||
|
|
||||||
add_element_right (c: WSF_STATELESS_CONTROL)
|
|
||||||
do
|
|
||||||
add_element_to_nav (c, nav_right)
|
|
||||||
end
|
|
||||||
|
|
||||||
add_element_to_nav (e: WSF_STATELESS_CONTROL; n: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL])
|
|
||||||
local
|
|
||||||
li: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
|
||||||
do
|
|
||||||
create li.make_with_tag_name ("li")
|
|
||||||
li.add_control (e)
|
|
||||||
n.add_control (li)
|
|
||||||
end
|
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_navbar (b: STRING)
|
make_navbar (b: STRING)
|
||||||
|
-- Initialize with specified brand string
|
||||||
local
|
local
|
||||||
container: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
container: WSF_STATELESS_MULTI_CONTROL
|
||||||
header: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
header: WSF_STATELESS_MULTI_CONTROL
|
||||||
collapse_button: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
collapse_button: WSF_STATELESS_MULTI_CONTROL
|
||||||
brand: WSF_BASIC_CONTROL
|
brand: WSF_BASIC_CONTROL
|
||||||
icon_bar: WSF_BASIC_CONTROL
|
icon_bar: WSF_BASIC_CONTROL
|
||||||
do
|
do
|
||||||
@@ -70,10 +42,9 @@ feature {NONE} -- Initialization
|
|||||||
collapse_button.add_control (icon_bar)
|
collapse_button.add_control (icon_bar)
|
||||||
collapse_button.add_control (icon_bar)
|
collapse_button.add_control (icon_bar)
|
||||||
collapse_button.add_control (icon_bar)
|
collapse_button.add_control (icon_bar)
|
||||||
-- collapse_button.set_attributes ("data-target=%".navbar-collapse%" data-toggle=%"collapse%" type=%"button%"")
|
|
||||||
brand.add_class ("navbar-brand")
|
brand.add_class ("navbar-brand")
|
||||||
brand.set_attributes ("href=%"#%"")
|
brand.set_attributes ("href=%"#%"")
|
||||||
brand.set_content (b)
|
brand.set_body (b)
|
||||||
header.add_control (collapse_button)
|
header.add_control (collapse_button)
|
||||||
header.add_control (brand)
|
header.add_control (brand)
|
||||||
nav.add_class ("nav navbar-nav")
|
nav.add_class ("nav navbar-nav")
|
||||||
@@ -86,4 +57,15 @@ feature {NONE} -- Initialization
|
|||||||
add_control (container)
|
add_control (container)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Properties
|
||||||
|
|
||||||
|
collapse: WSF_STATELESS_MULTI_CONTROL
|
||||||
|
-- Content of collapsable navbar
|
||||||
|
|
||||||
|
nav: WSF_STATELESS_MULTI_CONTROL
|
||||||
|
-- Middle nav
|
||||||
|
|
||||||
|
nav_right: WSF_STATELESS_MULTI_CONTROL
|
||||||
|
-- Right nav
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ create
|
|||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_progress (n: STRING)
|
make_progress (n: STRING)
|
||||||
|
-- Initialize with specified control name
|
||||||
do
|
do
|
||||||
make_control (n, "div")
|
make_control (n, "div")
|
||||||
add_class ("progress")
|
add_class ("progress")
|
||||||
@@ -24,6 +25,7 @@ feature {NONE} -- Initialization
|
|||||||
end
|
end
|
||||||
|
|
||||||
make_progress_with_source (n: STRING; p: WSF_PROGRESSSOURCE)
|
make_progress_with_source (n: STRING; p: WSF_PROGRESSSOURCE)
|
||||||
|
-- Initialize with specified control name and progresssource
|
||||||
do
|
do
|
||||||
make_progress (n)
|
make_progress (n)
|
||||||
progress_source := p
|
progress_source := p
|
||||||
@@ -64,21 +66,18 @@ feature -- Rendering
|
|||||||
Result := render_tag (Result, "")
|
Result := render_tag (Result, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
feature --Change progress
|
feature -- Change
|
||||||
|
|
||||||
set_progress (p: INTEGER)
|
set_progress (p: INTEGER)
|
||||||
|
-- Set current progress value to specified value. Must be between 0 and 100. Must only be called when no progresssource has been set to this progress control
|
||||||
require
|
require
|
||||||
no_progress_source: not (attached progress_source)
|
no_progress_source: not (attached progress_source) and p >= 0 and p <= 100
|
||||||
do
|
do
|
||||||
progress := p
|
progress := p
|
||||||
state_changes.put (create {JSON_NUMBER}.make_integer (progress), "progress")
|
state_changes.put (create {JSON_NUMBER}.make_integer (progress), "progress")
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature -- Implementation
|
||||||
|
|
||||||
progress_source: detachable WSF_PROGRESSSOURCE
|
|
||||||
|
|
||||||
progress: INTEGER
|
|
||||||
|
|
||||||
progress_value: INTEGER
|
progress_value: INTEGER
|
||||||
do
|
do
|
||||||
@@ -88,4 +87,10 @@ feature
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Properties
|
||||||
|
|
||||||
|
progress_source: detachable WSF_PROGRESSSOURCE
|
||||||
|
|
||||||
|
progress: INTEGER
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ note
|
|||||||
deferred class
|
deferred class
|
||||||
WSF_PROGRESSSOURCE
|
WSF_PROGRESSSOURCE
|
||||||
|
|
||||||
feature
|
feature -- Specification
|
||||||
|
|
||||||
progress: INTEGER
|
progress: INTEGER
|
||||||
|
-- Current value of progress between 0 and 100 of this progresssource
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ inherit
|
|||||||
create
|
create
|
||||||
make_decimal_validator
|
make_decimal_validator
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_decimal_validator (e: STRING)
|
make_decimal_validator (e: STRING)
|
||||||
|
-- Initialize with specified error message which will be displayed on validation failure
|
||||||
do
|
do
|
||||||
make_regexp_validator ("^[0-9]+(\.[0-9]*)?$|^\.[0-9]+$", e)
|
make_regexp_validator ("^[0-9]+(\.[0-9]*)?$|^\.[0-9]+$", e)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ inherit
|
|||||||
create
|
create
|
||||||
make_email_validator
|
make_email_validator
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_email_validator (e: STRING)
|
make_email_validator (e: STRING)
|
||||||
|
-- Initialize with specified error message which will be displayed on validation failure
|
||||||
do
|
do
|
||||||
make_regexp_validator ("^[a-zA-Z0-9._%%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}$", e)
|
make_regexp_validator ("^[a-zA-Z0-9._%%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}$", e)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,9 +17,10 @@ inherit
|
|||||||
create
|
create
|
||||||
make_max_validator
|
make_max_validator
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_max_validator (m: INTEGER; e: STRING)
|
make_max_validator (m: INTEGER; e: STRING)
|
||||||
|
-- Initialize with specified maximum and error message which will be displayed on validation failure
|
||||||
do
|
do
|
||||||
make (e)
|
make (e)
|
||||||
max := m
|
max := m
|
||||||
@@ -32,7 +33,7 @@ feature -- Implementation
|
|||||||
Result := input.count < max or input.count = max
|
Result := input.count < max or input.count = max
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature -- State
|
||||||
|
|
||||||
state: JSON_OBJECT
|
state: JSON_OBJECT
|
||||||
do
|
do
|
||||||
@@ -40,6 +41,9 @@ feature
|
|||||||
Result.put (create {JSON_NUMBER}.make_integer (max), "max")
|
Result.put (create {JSON_NUMBER}.make_integer (max), "max")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Properties
|
||||||
|
|
||||||
max: INTEGER
|
max: INTEGER
|
||||||
|
-- The maximal allowed value
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ note
|
|||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
class
|
class
|
||||||
WSF_MIN_VALIDATOR[G]
|
WSF_MIN_VALIDATOR [G]
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
WSF_VALIDATOR [LIST[G]]
|
|
||||||
|
WSF_VALIDATOR [LIST [G]]
|
||||||
redefine
|
redefine
|
||||||
state
|
state
|
||||||
end
|
end
|
||||||
@@ -16,9 +17,10 @@ inherit
|
|||||||
create
|
create
|
||||||
make_min_validator
|
make_min_validator
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_min_validator (m:INTEGER; e: STRING)
|
make_min_validator (m: INTEGER; e: STRING)
|
||||||
|
-- Initialize with specified minimum and error message which will be displayed on validation failure
|
||||||
do
|
do
|
||||||
make (e)
|
make (e)
|
||||||
min := m
|
min := m
|
||||||
@@ -26,13 +28,12 @@ feature {NONE}
|
|||||||
|
|
||||||
feature -- Implementation
|
feature -- Implementation
|
||||||
|
|
||||||
is_valid (input:LIST[G]): BOOLEAN
|
is_valid (input: LIST [G]): BOOLEAN
|
||||||
do
|
do
|
||||||
Result:= input.count > min or input.count = min
|
Result := input.count > min or input.count = min
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature -- State
|
||||||
|
|
||||||
state: JSON_OBJECT
|
state: JSON_OBJECT
|
||||||
do
|
do
|
||||||
@@ -40,6 +41,9 @@ feature
|
|||||||
Result.put (create {JSON_NUMBER}.make_integer (min), "min")
|
Result.put (create {JSON_NUMBER}.make_integer (min), "min")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Propertiess
|
||||||
|
|
||||||
min: INTEGER
|
min: INTEGER
|
||||||
|
-- The minimal allowed value
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ inherit
|
|||||||
create
|
create
|
||||||
make_with_message
|
make_with_message
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_with_message (e: STRING)
|
make_with_message (e: STRING)
|
||||||
|
-- Initialize with specified error message which will be displayed on validation failure
|
||||||
do
|
do
|
||||||
make_regexp_validator ("", e)
|
make_regexp_validator ("", e)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,9 +17,10 @@ inherit
|
|||||||
create
|
create
|
||||||
make_regexp_validator
|
make_regexp_validator
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_regexp_validator (r, e: STRING)
|
make_regexp_validator (r, e: STRING)
|
||||||
|
-- Initialize with specified regular expression and error message which will be displayed on validation failure
|
||||||
do
|
do
|
||||||
make (e)
|
make (e)
|
||||||
regexp_string := r
|
regexp_string := r
|
||||||
@@ -37,7 +38,7 @@ feature -- Implementation
|
|||||||
Result := regexp.matches (input)
|
Result := regexp.matches (input)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature -- State
|
||||||
|
|
||||||
state: JSON_OBJECT
|
state: JSON_OBJECT
|
||||||
do
|
do
|
||||||
@@ -47,6 +48,8 @@ feature
|
|||||||
Result.put (create {JSON_STRING}.make_json (error), "error")
|
Result.put (create {JSON_STRING}.make_json (error), "error")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Properties
|
||||||
|
|
||||||
regexp_string: STRING
|
regexp_string: STRING
|
||||||
|
|
||||||
regexp: REGULAR_EXPRESSION
|
regexp: REGULAR_EXPRESSION
|
||||||
|
|||||||
@@ -7,13 +7,15 @@ note
|
|||||||
deferred class
|
deferred class
|
||||||
WSF_VALIDATABLE
|
WSF_VALIDATABLE
|
||||||
|
|
||||||
feature
|
feature -- Specification
|
||||||
|
|
||||||
validate
|
validate
|
||||||
|
-- Perform validation
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
is_valid: BOOLEAN
|
is_valid: BOOLEAN
|
||||||
|
-- Result of last validation
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -7,16 +7,18 @@ note
|
|||||||
deferred class
|
deferred class
|
||||||
WSF_VALIDATOR [G]
|
WSF_VALIDATOR [G]
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make (e: STRING)
|
make (e: STRING)
|
||||||
|
-- Initialize with specified error message to be displayed on validation failure
|
||||||
do
|
do
|
||||||
error := e
|
error := e
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature -- Access
|
||||||
|
|
||||||
state: JSON_OBJECT
|
state: JSON_OBJECT
|
||||||
|
-- JSON state of this validator
|
||||||
do
|
do
|
||||||
create Result.make
|
create Result.make
|
||||||
Result.put (create {JSON_STRING}.make_json (generator), "name")
|
Result.put (create {JSON_STRING}.make_json (generator), "name")
|
||||||
@@ -24,9 +26,12 @@ feature
|
|||||||
end
|
end
|
||||||
|
|
||||||
is_valid (input: G): BOOLEAN
|
is_valid (input: G): BOOLEAN
|
||||||
|
-- Perform validation on given input and tell whether validation was successful or not
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Properties
|
||||||
|
|
||||||
error: STRING
|
error: STRING
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,46 +12,52 @@ inherit
|
|||||||
WSF_STATELESS_CONTROL
|
WSF_STATELESS_CONTROL
|
||||||
|
|
||||||
create
|
create
|
||||||
make_control,
|
make_control, make_with_body
|
||||||
make_with_body
|
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_control (t: STRING)
|
make_control (t: STRING)
|
||||||
|
-- Initialize
|
||||||
do
|
do
|
||||||
make_with_body (t, "", "")
|
make_with_body (t, "", "")
|
||||||
end
|
end
|
||||||
|
|
||||||
make_with_body (t,attr,a_content: STRING)
|
make_with_body (t, attr, b: STRING)
|
||||||
|
-- Initialize with specific attributes and body
|
||||||
do
|
do
|
||||||
make (t)
|
make (t)
|
||||||
attributes := attr
|
attributes := attr
|
||||||
content := a_content
|
body := b
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
attributes: STRING
|
attributes: STRING
|
||||||
|
-- Attributes string of this control
|
||||||
|
|
||||||
content: STRING
|
body: STRING
|
||||||
|
-- Body of this control
|
||||||
|
|
||||||
feature -- Rendering
|
feature -- Rendering
|
||||||
|
|
||||||
render: STRING
|
render: STRING
|
||||||
|
-- HTML representation of this control
|
||||||
do
|
do
|
||||||
Result := render_tag (content, attributes)
|
Result := render_tag (body, attributes)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature
|
||||||
|
|
||||||
set_attributes (a: STRING)
|
set_attributes (a: STRING)
|
||||||
|
-- Set the attributes string of this control
|
||||||
do
|
do
|
||||||
attributes := a
|
attributes := a
|
||||||
end
|
end
|
||||||
|
|
||||||
set_content (c: STRING)
|
set_body (b: STRING)
|
||||||
|
-- Set the body of this control
|
||||||
do
|
do
|
||||||
content := c
|
body := b
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ inherit
|
|||||||
create
|
create
|
||||||
make_button
|
make_button
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_button (n: STRING; t: STRING)
|
make_button (n: STRING; t: STRING)
|
||||||
|
-- Initialize with specified control name and text
|
||||||
do
|
do
|
||||||
make_control (n, "button")
|
make_control (n, "button")
|
||||||
add_class ("btn")
|
add_class ("btn")
|
||||||
@@ -24,7 +25,7 @@ feature {NONE}
|
|||||||
text := t
|
text := t
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||||
|
|
||||||
set_state (new_state: JSON_OBJECT)
|
set_state (new_state: JSON_OBJECT)
|
||||||
-- Restore text from json
|
-- Restore text from json
|
||||||
@@ -42,7 +43,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|||||||
Result.put (create {JSON_BOOLEAN}.make_boolean (attached click_event), "callback_click")
|
Result.put (create {JSON_BOOLEAN}.make_boolean (attached click_event), "callback_click")
|
||||||
end
|
end
|
||||||
|
|
||||||
feature --EVENT HANDLING
|
feature --Event handling
|
||||||
|
|
||||||
set_click_event (e: attached like click_event)
|
set_click_event (e: attached like click_event)
|
||||||
-- Set button click event handle
|
-- Set button click event handle
|
||||||
@@ -57,14 +58,18 @@ feature --EVENT HANDLING
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature -- Rendering
|
||||||
|
|
||||||
render: STRING
|
render: STRING
|
||||||
|
-- HTML representation of this control
|
||||||
do
|
do
|
||||||
Result := render_tag (text, "")
|
Result := render_tag (text, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Change
|
||||||
|
|
||||||
set_text (t: STRING)
|
set_text (t: STRING)
|
||||||
|
-- Set text of that button
|
||||||
do
|
do
|
||||||
if not t.same_string (text) then
|
if not t.same_string (text) then
|
||||||
text := t
|
text := t
|
||||||
@@ -72,10 +77,12 @@ feature
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature -- Properties
|
||||||
|
|
||||||
text: STRING
|
text: STRING
|
||||||
|
-- The text currently displayed on this button
|
||||||
|
|
||||||
click_event: detachable PROCEDURE [ANY, TUPLE]
|
click_event: detachable PROCEDURE [ANY, TUPLE]
|
||||||
|
-- Event that is executed when button is clicked
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ feature
|
|||||||
|
|
||||||
control_name: STRING
|
control_name: STRING
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_control (n, a_tag_name: STRING)
|
make_control (n, a_tag_name: STRING)
|
||||||
|
-- Initialize with specified control name and tag
|
||||||
do
|
do
|
||||||
make (a_tag_name)
|
make (a_tag_name)
|
||||||
control_name := n
|
control_name := n
|
||||||
@@ -68,11 +69,13 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|||||||
feature -- Rendering
|
feature -- Rendering
|
||||||
|
|
||||||
render_tag (body, attrs: STRING): STRING
|
render_tag (body, attrs: STRING): STRING
|
||||||
|
-- Render this control with the specified body and attributes
|
||||||
do
|
do
|
||||||
Result := render_tag_with_generator_name (generator, body, attrs)
|
Result := render_tag_with_generator_name (generator, body, attrs)
|
||||||
end
|
end
|
||||||
|
|
||||||
render_tag_with_generator_name (a_generator, body, attrs: STRING): STRING
|
render_tag_with_generator_name (a_generator, body, attrs: STRING): STRING
|
||||||
|
-- Render this control with the specified generator name, body and attributes
|
||||||
local
|
local
|
||||||
css_classes_string: STRING
|
css_classes_string: STRING
|
||||||
l_attributes: STRING
|
l_attributes: STRING
|
||||||
|
|||||||
@@ -16,9 +16,10 @@ inherit
|
|||||||
create
|
create
|
||||||
make_form_control
|
make_form_control
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_form_control (n: STRING)
|
make_form_control (n: STRING)
|
||||||
|
-- Initialize
|
||||||
do
|
do
|
||||||
make_multi_control (n)
|
make_multi_control (n)
|
||||||
tag_name := "form"
|
tag_name := "form"
|
||||||
@@ -27,6 +28,7 @@ feature {NONE}
|
|||||||
feature -- Validation
|
feature -- Validation
|
||||||
|
|
||||||
validate
|
validate
|
||||||
|
-- Perform form validation
|
||||||
do
|
do
|
||||||
is_valid := True
|
is_valid := True
|
||||||
across
|
across
|
||||||
@@ -44,5 +46,6 @@ feature -- Validation
|
|||||||
end
|
end
|
||||||
|
|
||||||
is_valid: BOOLEAN
|
is_valid: BOOLEAN
|
||||||
|
-- Tells whether the last validation was valid
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,14 +21,16 @@ inherit
|
|||||||
create
|
create
|
||||||
make_form_element, make_form_element_with_validators
|
make_form_element, make_form_element_with_validators
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_form_element (a_label: STRING; c: WSF_VALUE_CONTROL [G])
|
make_form_element (a_label: STRING; c: WSF_VALUE_CONTROL [G])
|
||||||
|
-- Initialize form element control with a specific label and value control
|
||||||
do
|
do
|
||||||
make_form_element_with_validators (a_label, c, create {ARRAYED_LIST [WSF_VALIDATOR [G]]}.make (0))
|
make_form_element_with_validators (a_label, c, create {ARRAYED_LIST [WSF_VALIDATOR [G]]}.make (0))
|
||||||
end
|
end
|
||||||
|
|
||||||
make_form_element_with_validators (a_label: STRING; c: WSF_VALUE_CONTROL [G]; v: LIST [WSF_VALIDATOR [G]])
|
make_form_element_with_validators (a_label: STRING; c: WSF_VALUE_CONTROL [G]; v: LIST [WSF_VALIDATOR [G]])
|
||||||
|
-- Initialize form element control with a specific label, value control and list of validators
|
||||||
do
|
do
|
||||||
make_control (c.control_name + "_container", "div")
|
make_control (c.control_name + "_container", "div")
|
||||||
add_class ("form-group")
|
add_class ("form-group")
|
||||||
@@ -44,7 +46,7 @@ feature {NONE}
|
|||||||
error := ""
|
error := ""
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||||
|
|
||||||
load_state (new_states: JSON_OBJECT)
|
load_state (new_states: JSON_OBJECT)
|
||||||
-- Pass new_states to subcontrols
|
-- Pass new_states to subcontrols
|
||||||
@@ -54,6 +56,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|||||||
end
|
end
|
||||||
|
|
||||||
set_state (new_state: JSON_OBJECT)
|
set_state (new_state: JSON_OBJECT)
|
||||||
|
-- Set new state
|
||||||
do
|
do
|
||||||
value_control.set_state (new_state)
|
value_control.set_state (new_state)
|
||||||
end
|
end
|
||||||
@@ -73,7 +76,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|||||||
end
|
end
|
||||||
|
|
||||||
state: JSON_OBJECT
|
state: JSON_OBJECT
|
||||||
--Read state
|
-- Read state
|
||||||
local
|
local
|
||||||
validator_description: JSON_ARRAY
|
validator_description: JSON_ARRAY
|
||||||
do
|
do
|
||||||
@@ -88,7 +91,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|||||||
Result.put (validator_description, "validators")
|
Result.put (validator_description, "validators")
|
||||||
end
|
end
|
||||||
|
|
||||||
feature --EVENT HANDLING
|
feature -- Event handling
|
||||||
|
|
||||||
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
||||||
-- Pass callback to subcontrols
|
-- Pass callback to subcontrols
|
||||||
@@ -102,9 +105,10 @@ feature --EVENT HANDLING
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature --Implementation
|
feature -- Implementation
|
||||||
|
|
||||||
render: STRING
|
render: STRING
|
||||||
|
-- HTML Respresentation of this form element control
|
||||||
local
|
local
|
||||||
body: STRING
|
body: STRING
|
||||||
do
|
do
|
||||||
@@ -121,17 +125,20 @@ feature --Implementation
|
|||||||
feature -- Validation
|
feature -- Validation
|
||||||
|
|
||||||
add_validator (v: WSF_VALIDATOR [G])
|
add_validator (v: WSF_VALIDATOR [G])
|
||||||
|
-- Add an additional validator that will check the input of the value control of this form element control on validation
|
||||||
do
|
do
|
||||||
validators.extend (v)
|
validators.extend (v)
|
||||||
end
|
end
|
||||||
|
|
||||||
set_error (e: STRING)
|
set_error (e: STRING)
|
||||||
|
-- Set the error message that will be displayed upon failure of client side validation
|
||||||
do
|
do
|
||||||
error := e
|
error := e
|
||||||
state_changes.replace (create {JSON_STRING}.make_json (e), "error")
|
state_changes.replace (create {JSON_STRING}.make_json (e), "error")
|
||||||
end
|
end
|
||||||
|
|
||||||
validate
|
validate
|
||||||
|
-- Perform validation
|
||||||
local
|
local
|
||||||
current_value: G
|
current_value: G
|
||||||
do
|
do
|
||||||
@@ -153,15 +160,20 @@ feature -- Validation
|
|||||||
end
|
end
|
||||||
|
|
||||||
is_valid: BOOLEAN
|
is_valid: BOOLEAN
|
||||||
|
-- Tells whether the last validation was successful or not
|
||||||
|
|
||||||
feature
|
feature -- Properties
|
||||||
|
|
||||||
value_control: WSF_VALUE_CONTROL [G]
|
value_control: WSF_VALUE_CONTROL [G]
|
||||||
|
-- The value control associated with this form element control
|
||||||
|
|
||||||
validators: LIST [WSF_VALIDATOR [G]]
|
validators: LIST [WSF_VALIDATOR [G]]
|
||||||
|
-- The validators which check the input when validaton is performed
|
||||||
|
|
||||||
label: STRING
|
label: STRING
|
||||||
|
-- The label of this form element control
|
||||||
|
|
||||||
error: STRING
|
error: STRING
|
||||||
|
-- The error message that is displayed when client side validation fails
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,15 +14,16 @@ inherit
|
|||||||
create
|
create
|
||||||
make_html
|
make_html
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_html (n, t, v: STRING)
|
make_html (n, t, v: STRING)
|
||||||
|
-- Initialize
|
||||||
do
|
do
|
||||||
make_control (n, t)
|
make_control (n, t)
|
||||||
html := v
|
html := v
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||||
|
|
||||||
set_state (new_state: JSON_OBJECT)
|
set_state (new_state: JSON_OBJECT)
|
||||||
-- Restore html from json
|
-- Restore html from json
|
||||||
@@ -39,7 +40,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|||||||
Result.put (create {JSON_STRING}.make_json (html), "html")
|
Result.put (create {JSON_STRING}.make_json (html), "html")
|
||||||
end
|
end
|
||||||
|
|
||||||
feature --EVENT HANDLING
|
feature --Event handling
|
||||||
|
|
||||||
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
||||||
do
|
do
|
||||||
@@ -48,6 +49,7 @@ feature --EVENT HANDLING
|
|||||||
feature -- Implementation
|
feature -- Implementation
|
||||||
|
|
||||||
render: STRING
|
render: STRING
|
||||||
|
-- HTML representation of this html control
|
||||||
do
|
do
|
||||||
Result := render_tag (html, "")
|
Result := render_tag (html, "")
|
||||||
end
|
end
|
||||||
@@ -65,7 +67,7 @@ feature -- Implementation
|
|||||||
Result := html
|
Result := html
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature -- Properties
|
||||||
|
|
||||||
html: STRING
|
html: STRING
|
||||||
|
|
||||||
|
|||||||
@@ -22,17 +22,19 @@ create
|
|||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_multi_control (n: STRING)
|
make_multi_control (n: STRING)
|
||||||
|
-- Initialize with specified control name and default tag "div"
|
||||||
do
|
do
|
||||||
make_with_tag_name (n, "div")
|
make_with_tag_name (n, "div")
|
||||||
end
|
end
|
||||||
|
|
||||||
make_with_tag_name (n, t: STRING)
|
make_with_tag_name (n, t: STRING)
|
||||||
|
-- Initialize with specified control name and tag
|
||||||
do
|
do
|
||||||
make_control (n, t)
|
make_control (n, t)
|
||||||
controls := create {LINKED_LIST [G]}.make;
|
controls := create {LINKED_LIST [G]}.make;
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||||
|
|
||||||
load_state (new_states: JSON_OBJECT)
|
load_state (new_states: JSON_OBJECT)
|
||||||
-- Pass new_states to subcontrols
|
-- Pass new_states to subcontrols
|
||||||
@@ -84,7 +86,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|||||||
create Result.make
|
create Result.make
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- EVENT HANDLING
|
feature -- Event handling
|
||||||
|
|
||||||
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
||||||
-- Pass callback to subcontrols
|
-- Pass callback to subcontrols
|
||||||
@@ -101,9 +103,10 @@ feature -- EVENT HANDLING
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature -- Rendering
|
||||||
|
|
||||||
render: STRING
|
render: STRING
|
||||||
|
-- HTML representation of this multi control
|
||||||
do
|
do
|
||||||
Result := ""
|
Result := ""
|
||||||
across
|
across
|
||||||
@@ -114,13 +117,19 @@ feature
|
|||||||
Result := render_tag (Result, "")
|
Result := render_tag (Result, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
add_control (c: detachable G)
|
feature -- Change
|
||||||
|
|
||||||
|
add_control (c: detachable G)
|
||||||
|
-- Add a control to this multi control
|
||||||
do
|
do
|
||||||
if attached c as d then
|
if attached c as d then
|
||||||
controls.put_front (d)
|
controls.put_front (d)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Properties
|
||||||
|
|
||||||
controls: LINKED_LIST [G]
|
controls: LINKED_LIST [G]
|
||||||
|
-- List of current controls in this multi control
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ deferred class
|
|||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make (req: WSF_REQUEST; res: WSF_RESPONSE)
|
make (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
-- Initialize
|
||||||
do
|
do
|
||||||
request := req
|
request := req
|
||||||
response := res
|
response := res
|
||||||
@@ -19,10 +20,12 @@ feature {NONE} -- Initialization
|
|||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
request: WSF_REQUEST
|
request: WSF_REQUEST
|
||||||
|
-- The request
|
||||||
|
|
||||||
response: WSF_RESPONSE
|
response: WSF_RESPONSE
|
||||||
|
-- The response
|
||||||
|
|
||||||
feature
|
feature -- Specific implementation
|
||||||
|
|
||||||
initialize_controls
|
initialize_controls
|
||||||
-- Initalize all the controls, all the event handles must be set in this function.
|
-- Initalize all the controls, all the event handles must be set in this function.
|
||||||
@@ -36,7 +39,7 @@ feature
|
|||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature -- Implementation
|
||||||
|
|
||||||
execute
|
execute
|
||||||
-- Entry Point: If request is a callback, restore control states and execute handle then return new state json.
|
-- Entry Point: If request is a callback, restore control states and execute handle then return new state json.
|
||||||
@@ -108,8 +111,9 @@ feature
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Root control
|
||||||
|
|
||||||
control: WSF_CONTROL
|
control: WSF_CONTROL
|
||||||
|
-- The root control of this page
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ note
|
|||||||
deferred class
|
deferred class
|
||||||
WSF_STATELESS_CONTROL
|
WSF_STATELESS_CONTROL
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make (a_tag_name: STRING)
|
make (a_tag_name: STRING)
|
||||||
|
-- Initialize with specified tag
|
||||||
do
|
do
|
||||||
tag_name := a_tag_name
|
tag_name := a_tag_name
|
||||||
create css_classes.make (0)
|
create css_classes.make (0)
|
||||||
@@ -20,19 +21,25 @@ feature {NONE}
|
|||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
tag_name: STRING
|
tag_name: STRING
|
||||||
|
-- The tag name
|
||||||
|
|
||||||
css_classes: ARRAYED_LIST [STRING]
|
css_classes: ARRAYED_LIST [STRING]
|
||||||
|
-- List of classes (appear in the "class" attribute)
|
||||||
|
|
||||||
--TODO: Maybe improve
|
-- TODO: Maybe improve
|
||||||
|
|
||||||
feature -- Change
|
feature -- Change
|
||||||
|
|
||||||
add_class (c: STRING)
|
add_class (c: STRING)
|
||||||
|
-- Add a css class to this control
|
||||||
do
|
do
|
||||||
css_classes.force (c)
|
css_classes.force (c)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Rendering
|
||||||
|
|
||||||
render_tag (body, attrs: STRING): STRING
|
render_tag (body, attrs: STRING): STRING
|
||||||
|
-- Generate HTML of this control with the specified body and attributes
|
||||||
local
|
local
|
||||||
css_classes_string: STRING
|
css_classes_string: STRING
|
||||||
do
|
do
|
||||||
@@ -46,6 +53,7 @@ feature -- Change
|
|||||||
end
|
end
|
||||||
|
|
||||||
render_tag_with_tagname (tag, body, attrs, css_classes_string: STRING): STRING
|
render_tag_with_tagname (tag, body, attrs, css_classes_string: STRING): STRING
|
||||||
|
-- Generate HTML of the specified tag with specified body, attributes and css classes
|
||||||
local
|
local
|
||||||
l_attributes: STRING
|
l_attributes: STRING
|
||||||
do
|
do
|
||||||
@@ -56,13 +64,7 @@ feature -- Change
|
|||||||
l_attributes.append_character ('%"')
|
l_attributes.append_character ('%"')
|
||||||
end
|
end
|
||||||
Result := "<" + tag + " " + l_attributes
|
Result := "<" + tag + " " + l_attributes
|
||||||
if
|
if body.is_empty and not tag.same_string ("textarea") and not tag.same_string ("span") and not tag.same_string ("button") and not tag.same_string ("ul") then
|
||||||
body.is_empty and
|
|
||||||
not tag.same_string ("textarea") and
|
|
||||||
not tag.same_string ("span") and
|
|
||||||
not tag.same_string ("button") and
|
|
||||||
not tag.same_string ("ul")
|
|
||||||
then
|
|
||||||
Result.append (" />")
|
Result.append (" />")
|
||||||
else
|
else
|
||||||
Result.append (" >" + body + "</" + tag + ">")
|
Result.append (" >" + body + "</" + tag + ">")
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ note
|
|||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
class
|
class
|
||||||
WSF_STATELESS_MULTI_CONTROL [G -> WSF_STATELESS_CONTROL]
|
WSF_STATELESS_MULTI_CONTROL
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
@@ -17,19 +17,22 @@ create
|
|||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_multi_control
|
make_multi_control
|
||||||
|
-- Initialize with default tag "div"
|
||||||
do
|
do
|
||||||
make_with_tag_name ("div")
|
make_with_tag_name ("div")
|
||||||
end
|
end
|
||||||
|
|
||||||
make_with_tag_name (t: STRING)
|
make_with_tag_name (t: STRING)
|
||||||
|
-- Initialize with specified tag
|
||||||
do
|
do
|
||||||
make (t)
|
make (t)
|
||||||
controls := create {LINKED_LIST [G]}.make;
|
controls := create {LINKED_LIST [WSF_STATELESS_CONTROL]}.make;
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature -- Rendering
|
||||||
|
|
||||||
render: STRING
|
render: STRING
|
||||||
|
-- HTML representation of this stateless multi control
|
||||||
do
|
do
|
||||||
Result := ""
|
Result := ""
|
||||||
across
|
across
|
||||||
@@ -40,11 +43,17 @@ feature
|
|||||||
Result := render_tag (Result, "")
|
Result := render_tag (Result, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
add_control (c: G)
|
feature -- Change
|
||||||
|
|
||||||
|
add_control (c: WSF_STATELESS_CONTROL)
|
||||||
|
-- Add control to this stateless multi control
|
||||||
do
|
do
|
||||||
controls.put_front (c)
|
controls.put_front (c)
|
||||||
end
|
end
|
||||||
|
|
||||||
controls: LINKED_LIST [G]
|
feature -- Properties
|
||||||
|
|
||||||
|
controls: LINKED_LIST [WSF_STATELESS_CONTROL]
|
||||||
|
-- List of controls
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,9 +11,10 @@ inherit
|
|||||||
|
|
||||||
WSF_CONTROL
|
WSF_CONTROL
|
||||||
|
|
||||||
feature
|
feature -- Access
|
||||||
|
|
||||||
value: G
|
value: G
|
||||||
|
-- The current value of this control
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user