Added wsf_html documentation in the doc/workbook.
Also improved the structure of `wsf_html` library. Added a few widgets.
This commit is contained in:
154
library/server/wsf_html/form/select/wsf_form_select.e
Normal file
154
library/server/wsf_html/form/select/wsf_form_select.e
Normal file
@@ -0,0 +1,154 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_SELECT}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_SELECT
|
||||
|
||||
inherit
|
||||
WSF_FORM_FIELD
|
||||
|
||||
WSF_FORM_UTILITY
|
||||
|
||||
WSF_WITH_HTML_ATTRIBUTE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_name: like name)
|
||||
do
|
||||
name := a_name
|
||||
create options.make (0)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
options: ARRAYED_LIST [WSF_FORM_SELECT_OPTION]
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_text_by_value (a_text: detachable READABLE_STRING_GENERAL)
|
||||
local
|
||||
opt: WSF_FORM_SELECT_OPTION
|
||||
l_found: BOOLEAN
|
||||
v: READABLE_STRING_8
|
||||
do
|
||||
if a_text /= Void then
|
||||
v := html_encoded_string (a_text.to_string_32)
|
||||
across
|
||||
options as o
|
||||
loop
|
||||
if o.item.is_same_value (v) then
|
||||
l_found := True
|
||||
o.item.set_is_selected (True)
|
||||
else
|
||||
o.item.set_is_selected (False)
|
||||
end
|
||||
end
|
||||
if not l_found then
|
||||
create opt.make (v, Void)
|
||||
opt.set_is_selected (True)
|
||||
add_option (opt)
|
||||
end
|
||||
else
|
||||
across
|
||||
options as o
|
||||
loop
|
||||
o.item.set_is_selected (False)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
select_value_by_text (a_text: detachable READABLE_STRING_GENERAL)
|
||||
local
|
||||
l_found: BOOLEAN
|
||||
v: READABLE_STRING_8
|
||||
do
|
||||
if a_text /= Void then
|
||||
v := html_encoded_string (a_text.to_string_32)
|
||||
across
|
||||
options as o
|
||||
loop
|
||||
if o.item.is_same_text (v) then
|
||||
l_found := True
|
||||
o.item.set_is_selected (True)
|
||||
else
|
||||
o.item.set_is_selected (False)
|
||||
end
|
||||
end
|
||||
else
|
||||
across
|
||||
options as o
|
||||
loop
|
||||
o.item.set_is_selected (False)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set_value (v: detachable WSF_VALUE)
|
||||
do
|
||||
if attached {WSF_STRING} v as s then
|
||||
set_text_by_value (s.value)
|
||||
else
|
||||
set_text_by_value (Void)
|
||||
end
|
||||
end
|
||||
|
||||
add_option (opt: WSF_FORM_SELECT_OPTION)
|
||||
do
|
||||
options.force (opt)
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
append_item_to_html (a_theme: WSF_THEME; a_html: STRING_8)
|
||||
local
|
||||
l_is_already_selected: BOOLEAN
|
||||
h: detachable STRING_8
|
||||
do
|
||||
a_html.append ("<select name=%""+ name +"%" ")
|
||||
if css_id = Void then
|
||||
set_css_id (name + "-select")
|
||||
end
|
||||
append_css_class_to (a_html, Void)
|
||||
append_css_id_to (a_html)
|
||||
append_css_style_to (a_html)
|
||||
append_html_attributes_to (a_html)
|
||||
|
||||
if is_readonly then
|
||||
a_html.append (" readonly=%"readonly%" />")
|
||||
else
|
||||
a_html.append ("/>")
|
||||
end
|
||||
|
||||
across
|
||||
options as o
|
||||
loop
|
||||
a_html.append ("<option value=%"" + o.item.value + "%" ")
|
||||
-- if not l_is_already_selected then
|
||||
if
|
||||
o.item.is_selected
|
||||
then
|
||||
l_is_already_selected := True
|
||||
a_html.append (" selected=%"selected%"")
|
||||
end
|
||||
-- end
|
||||
a_html.append (">" + o.item.text + "</option>%N")
|
||||
if attached o.item.description as d then
|
||||
if h = Void then
|
||||
create h.make_empty
|
||||
end
|
||||
h.append ("<div id=%"" + name + "-" + o.item.value + "%" class=%"option%"><strong>"+ o.item.text +"</strong>:"+ d + "</div>")
|
||||
end
|
||||
end
|
||||
a_html.append ("</select>%N")
|
||||
if h /= Void then
|
||||
a_html.append ("<div class=%"select help collapsible%" id=%"" + name + "-help%">" + h + "</div>%N")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
63
library/server/wsf_html/form/select/wsf_form_select_option.e
Normal file
63
library/server/wsf_html/form/select/wsf_form_select_option.e
Normal file
@@ -0,0 +1,63 @@
|
||||
note
|
||||
description : "Objects that ..."
|
||||
author : "$Author$"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_SELECT_OPTION
|
||||
|
||||
inherit
|
||||
WSF_FORM_SELECTABLE_ITEM
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_value: like value; a_text: detachable like text)
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
value := a_value
|
||||
if a_text = Void then
|
||||
text := a_value
|
||||
else
|
||||
text := a_text
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status
|
||||
|
||||
is_selected: BOOLEAN
|
||||
|
||||
is_same_value (v: READABLE_STRING_32): BOOLEAN
|
||||
do
|
||||
Result := value.same_string (v)
|
||||
end
|
||||
|
||||
is_same_text (v: like text): BOOLEAN
|
||||
do
|
||||
Result := text.same_string (v)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
value: READABLE_STRING_32
|
||||
|
||||
text: READABLE_STRING_8
|
||||
|
||||
description: detachable READABLE_STRING_8
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_is_selected (b: like is_selected)
|
||||
do
|
||||
is_selected := b
|
||||
end
|
||||
|
||||
set_description (d: like description)
|
||||
do
|
||||
description := d
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,25 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_SELECTABLE_ITEM}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_FORM_SELECTABLE_ITEM
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_selected : BOOLEAN
|
||||
deferred
|
||||
end
|
||||
|
||||
is_same_value (v: READABLE_STRING_32): BOOLEAN
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_is_selected (b: like is_selected)
|
||||
deferred
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user