Rearrange demo
Add contact autocompletion
This commit is contained in:
50
examples/widgetapp/autocompletion/contact_autocompletion.e
Normal file
50
examples/widgetapp/autocompletion/contact_autocompletion.e
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {CONTACT_AUTOCOMPLETION}."
|
||||||
|
author: ""
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
CONTACT_AUTOCOMPLETION
|
||||||
|
|
||||||
|
inherit
|
||||||
|
|
||||||
|
WSF_AUTOCOMPLETION
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make ()
|
||||||
|
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>";
|
||||||
|
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
|
||||||
|
|
||||||
|
feature -- Implementation
|
||||||
|
|
||||||
|
autocompletion (input: STRING): JSON_ARRAY
|
||||||
|
local
|
||||||
|
o: JSON_OBJECT
|
||||||
|
do
|
||||||
|
create Result.make_array
|
||||||
|
across
|
||||||
|
list as c
|
||||||
|
loop
|
||||||
|
if attached {STRING} c.item.item (1) as value and attached {STRING} c.item.item (3) as img and attached {STRING} c.item.item (2) as company then
|
||||||
|
if value.as_lower.has_substring (input.as_lower) then
|
||||||
|
create o.make
|
||||||
|
o.put (create {JSON_STRING}.make_json (img), "img")
|
||||||
|
o.put (create {JSON_STRING}.make_json (value), "value")
|
||||||
|
o.put (create {JSON_STRING}.make_json (company), "company")
|
||||||
|
Result.add (o)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
list: ITERABLE [TUPLE [STRING, STRING]]
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
note
|
|
||||||
description: "Summary description for {DEMO_DATA}."
|
|
||||||
author: ""
|
|
||||||
date: "$Date$"
|
|
||||||
revision: "$Revision$"
|
|
||||||
|
|
||||||
class
|
|
||||||
DEMO_DATA
|
|
||||||
|
|
||||||
inherit
|
|
||||||
|
|
||||||
WSF_ENTITY
|
|
||||||
|
|
||||||
create
|
|
||||||
make
|
|
||||||
|
|
||||||
feature {NONE}
|
|
||||||
|
|
||||||
make (a_id: INTEGER; a_name, a_description: STRING)
|
|
||||||
do
|
|
||||||
id := a_id
|
|
||||||
name := a_name
|
|
||||||
description := a_description
|
|
||||||
image := "http://placehold.it/20x20&text=" + id.out
|
|
||||||
end
|
|
||||||
|
|
||||||
feature
|
|
||||||
|
|
||||||
id: INTEGER
|
|
||||||
|
|
||||||
name: STRING
|
|
||||||
|
|
||||||
description: STRING
|
|
||||||
|
|
||||||
image: STRING
|
|
||||||
|
|
||||||
get (field: STRING): detachable ANY
|
|
||||||
do
|
|
||||||
if field.is_equal ("id") then
|
|
||||||
Result := id
|
|
||||||
elseif field.is_equal ("name") then
|
|
||||||
Result := name
|
|
||||||
elseif field.is_equal ("description") then
|
|
||||||
Result := description
|
|
||||||
elseif field.is_equal ("image") then
|
|
||||||
Result := image
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
note
|
|
||||||
description: "Summary description for {DEMO_DATASOURCE}."
|
|
||||||
author: ""
|
|
||||||
date: "$Date$"
|
|
||||||
revision: "$Revision$"
|
|
||||||
|
|
||||||
class
|
|
||||||
DEMO_DATASOURCE
|
|
||||||
|
|
||||||
inherit
|
|
||||||
|
|
||||||
WSF_PAGABLE_DATASOURCE [DEMO_DATA]
|
|
||||||
|
|
||||||
create
|
|
||||||
make_demo
|
|
||||||
|
|
||||||
feature
|
|
||||||
|
|
||||||
make_demo
|
|
||||||
do
|
|
||||||
page := 1
|
|
||||||
page_size := 10
|
|
||||||
end
|
|
||||||
|
|
||||||
data: ITERABLE [DEMO_DATA]
|
|
||||||
local
|
|
||||||
list: LINKED_LIST [DEMO_DATA]
|
|
||||||
do
|
|
||||||
create list.make
|
|
||||||
across
|
|
||||||
((page - 1) * page_size + 1) |..| (page * page_size).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
|
|
||||||
@@ -10,9 +10,9 @@ class
|
|||||||
inherit
|
inherit
|
||||||
|
|
||||||
BASE_PAGE
|
BASE_PAGE
|
||||||
redefine
|
redefine
|
||||||
initialize_controls
|
initialize_controls
|
||||||
end
|
end
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
@@ -24,43 +24,60 @@ feature
|
|||||||
n1_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
n1_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||||
n2_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
n2_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||||
n3_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
n3_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||||
|
n4_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||||
|
n5_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||||
cats_container: WSF_FORM_ELEMENT_CONTROL [LIST [STRING]]
|
cats_container: WSF_FORM_ELEMENT_CONTROL [LIST [STRING]]
|
||||||
|
|
||||||
s: FLAG_AUTOCOMPLETION
|
s: FLAG_AUTOCOMPLETION
|
||||||
do
|
do
|
||||||
Precursor
|
Precursor
|
||||||
create s.make (<<["dz", "Algeria"], ["be", "Belgium"], ["ca", "Canada"], ["de", "Deutschland"], ["england", "England"], ["fi", "Finland"], ["gr", "Greece"], ["hu", "Hungary"]>>)
|
|
||||||
|
|
||||||
create textbox1.make_input ("txtBox1", "1")
|
|
||||||
create textbox2.make_input ("txtBox2", "2")
|
|
||||||
create autocompletion1.make_autocomplete ("autocompletion1", s)
|
|
||||||
create button1.make_button ("sample_button1", "SUM")
|
|
||||||
create textbox_result.make_html ("txtBox3", "p", "")
|
|
||||||
create progress.make_progress ("progress1")
|
|
||||||
button1.set_click_event (agent handle_click)
|
|
||||||
button1.add_class ("col-lg-offset-2")
|
|
||||||
create form.make_form_control ("panel")
|
create form.make_form_control ("panel")
|
||||||
form.add_class ("form-horizontal")
|
form.add_class ("form-horizontal")
|
||||||
create cklist.make_checkbox_list_control ("categories")
|
--Number 1
|
||||||
cklist.add_control (create {WSF_CHECKBOX_CONTROL}.make_checkbox ("net", "Network", "net"))
|
create textbox1.make_input ("txtBox1", "1")
|
||||||
cklist.add_control (create {WSF_CHECKBOX_CONTROL}.make_checkbox ("os", "Operating Systems", "os"))
|
|
||||||
create n1_container.make_form_element ("Number1", textbox1)
|
create n1_container.make_form_element ("Number1", textbox1)
|
||||||
n1_container.add_validator (create {WSF_DECIMAL_VALIDATOR}.make_decimal_validator ("Invalid Number"))
|
n1_container.add_validator (create {WSF_DECIMAL_VALIDATOR}.make_decimal_validator ("Invalid Number"))
|
||||||
n1_container.add_validator (create {OWN_VALIDATOR}.make_own)
|
n1_container.add_validator (create {OWN_VALIDATOR}.make_own)
|
||||||
|
form.add_control (n1_container)
|
||||||
|
--Number 2
|
||||||
|
create textbox2.make_input ("txtBox2", "2")
|
||||||
create n2_container.make_form_element ("Number2", textbox2)
|
create n2_container.make_form_element ("Number2", textbox2)
|
||||||
n2_container.add_validator (create {WSF_DECIMAL_VALIDATOR}.make_decimal_validator ("Invalid Number"))
|
n2_container.add_validator (create {WSF_DECIMAL_VALIDATOR}.make_decimal_validator ("Invalid Number"))
|
||||||
create n3_container.make_form_element ("Autoc1", autocompletion1)
|
|
||||||
form.add_control (n1_container)
|
|
||||||
form.add_control (n2_container)
|
form.add_control (n2_container)
|
||||||
|
--Flag autocomplete
|
||||||
|
create s.make (<<["dz", "Algeria"], ["be", "Belgium"], ["ca", "Canada"], ["de", "Deutschland"], ["england", "England"], ["fi", "Finland"], ["gr", "Greece"], ["hu", "Hungary"]>>)
|
||||||
|
create autocompletion1.make_autocomplete ("autocompletion1", s)
|
||||||
|
create n3_container.make_form_element ("Flag Autocomplete", autocompletion1)
|
||||||
form.add_control (n3_container)
|
form.add_control (n3_container)
|
||||||
|
--Contact autocomplete
|
||||||
|
create autocompletion2.make_autocomplete ("autocompletion2", create {CONTACT_AUTOCOMPLETION}.make)
|
||||||
|
create n4_container.make_form_element ("Contact Autocomplete", autocompletion2)
|
||||||
|
form.add_control (n4_container)
|
||||||
|
--Google autocomplete
|
||||||
|
create autocompletion3.make_autocomplete ("autocompletion4", create {GOOGLE_AUTOCOMPLETION}.make)
|
||||||
|
create n5_container.make_form_element ("Google Autocomplete", autocompletion3)
|
||||||
|
form.add_control (n5_container)
|
||||||
|
--Categories
|
||||||
|
create cklist.make_checkbox_list_control ("categories")
|
||||||
|
cklist.add_control (create {WSF_CHECKBOX_CONTROL}.make_checkbox ("net", "Network", "net"))
|
||||||
|
cklist.add_control (create {WSF_CHECKBOX_CONTROL}.make_checkbox ("os", "Operating Systems", "os"))
|
||||||
|
cklist.add_control (create {WSF_CHECKBOX_CONTROL}.make_checkbox ("fmfp", "Formal Methods and Functional Programming", "fmfp"))
|
||||||
create cats_container.make_form_element ("Categories", cklist)
|
create cats_container.make_form_element ("Categories", cklist)
|
||||||
cats_container.add_validator (create {WSF_MIN_VALIDATOR [STRING]}.make_min_validator (1, "Choose at least one category"))
|
cats_container.add_validator (create {WSF_MIN_VALIDATOR [STRING]}.make_min_validator (1, "Choose at least one category"))
|
||||||
cats_container.add_validator (create {WSF_MAX_VALIDATOR [STRING]}.make_max_validator (1, "Choose at most one category"))
|
cats_container.add_validator (create {WSF_MAX_VALIDATOR [STRING]}.make_max_validator (2, "Choose at most two category"))
|
||||||
form.add_control (cats_container)
|
form.add_control (cats_container)
|
||||||
|
--Button 1
|
||||||
|
create button1.make_button ("sample_button1", "Update")
|
||||||
|
button1.set_click_event (agent handle_click)
|
||||||
|
button1.add_class ("col-lg-offset-2")
|
||||||
form.add_control (button1)
|
form.add_control (button1)
|
||||||
form.add_control (create {WSF_FORM_ELEMENT_CONTROL [STRING]}.make_form_element ("Result", textbox_result))
|
--Result
|
||||||
|
create result_html.make_html ("txtBox3", "p", "")
|
||||||
|
form.add_control (create {WSF_FORM_ELEMENT_CONTROL [STRING]}.make_form_element ("Result", result_html))
|
||||||
container.add_control (form)
|
container.add_control (form)
|
||||||
|
|
||||||
|
--Progress bar
|
||||||
|
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h4","","Number1/Number2"))
|
||||||
|
create progress.make_progress ("progress1")
|
||||||
container.add_control (progress)
|
container.add_control (progress)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -70,7 +87,7 @@ feature
|
|||||||
do
|
do
|
||||||
form.validate
|
form.validate
|
||||||
if form.is_valid then
|
if form.is_valid then
|
||||||
progress.set_progress ((textbox1.text.to_integer_64 / textbox2.text.to_integer_64*100).ceiling)
|
progress.set_progress ((textbox1.text.to_integer_64 / textbox2.text.to_integer_64 * 100).ceiling)
|
||||||
text := textbox1.text + " + " + textbox2.text + " = " + (textbox1.text.to_integer_64 + textbox2.text.to_integer_64).out
|
text := textbox1.text + " + " + textbox2.text + " = " + (textbox1.text.to_integer_64 + textbox2.text.to_integer_64).out
|
||||||
text.append ("<ul>")
|
text.append ("<ul>")
|
||||||
across
|
across
|
||||||
@@ -79,9 +96,9 @@ feature
|
|||||||
text.append ("<li>" + s.item + "</li>")
|
text.append ("<li>" + s.item + "</li>")
|
||||||
end
|
end
|
||||||
text.append ("</ul>")
|
text.append ("</ul>")
|
||||||
textbox_result.set_html (text)
|
result_html.set_html (text)
|
||||||
else
|
else
|
||||||
textbox_result.set_html ("VALIDATION ERROR")
|
result_html.set_html ("VALIDATION ERROR")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -97,11 +114,16 @@ feature
|
|||||||
|
|
||||||
autocompletion1: WSF_AUTOCOMPLETE_CONTROL
|
autocompletion1: WSF_AUTOCOMPLETE_CONTROL
|
||||||
|
|
||||||
|
autocompletion2: WSF_AUTOCOMPLETE_CONTROL
|
||||||
|
|
||||||
|
autocompletion3: WSF_AUTOCOMPLETE_CONTROL
|
||||||
|
|
||||||
cklist: WSF_CHECKBOX_LIST_CONTROL
|
cklist: WSF_CHECKBOX_LIST_CONTROL
|
||||||
|
|
||||||
textbox_result: WSF_HTML_CONTROL
|
result_html: WSF_HTML_CONTROL
|
||||||
|
|
||||||
form: WSF_FORM_CONTROL
|
form: WSF_FORM_CONTROL
|
||||||
|
|
||||||
progress: WSF_PROGRESS_CONTROL
|
progress: WSF_PROGRESS_CONTROL
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,7 +22,8 @@
|
|||||||
</option>
|
</option>
|
||||||
<library name="default_nino" location="..\..\library\server\wsf\default\nino-safe.ecf"/>
|
<library name="default_nino" location="..\..\library\server\wsf\default\nino-safe.ecf"/>
|
||||||
<library name="json" location="..\..\contrib\library\text\parser\json\library\json-safe.ecf"/>
|
<library name="json" location="..\..\contrib\library\text\parser\json\library\json-safe.ecf"/>
|
||||||
<cluster name="widgetapp" location=".\" recursive="true"/>
|
<cluster name="widgetapp" location=".\" recursive="true">
|
||||||
|
</cluster>
|
||||||
</target>
|
</target>
|
||||||
<target name="widgetapp_cgi" extends="common">
|
<target name="widgetapp_cgi" extends="common">
|
||||||
<root class="APPLICATION" feature="make_and_launch"/>
|
<root class="APPLICATION" feature="make_and_launch"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user