Completed a previous commit, especially to web form library (WSF_FORM).

Updated EiffelStudio wizard.
This commit is contained in:
2020-10-02 15:29:20 +02:00
parent c0de4a5bf7
commit 37644e66bb
28 changed files with 391 additions and 147 deletions

View File

@@ -18,7 +18,7 @@ feature -- Core
deferred
end
based_path (p: STRING): STRING
based_path (p: READABLE_STRING_8): STRING
-- Path `p' in the context of the `base_url'
do
if attached base_url as l_base_url then
@@ -32,7 +32,7 @@ feature -- Core
end
end
else
Result := p
Result := p.to_string_8
end
end
@@ -106,7 +106,8 @@ feature -- Conversion
url (a_path: READABLE_STRING_8; opts: detachable WSF_API_OPTIONS): STRING
local
q,f: detachable STRING_8
q: detachable STRING_8
f: detachable READABLE_STRING_8
l_abs: BOOLEAN
do
l_abs := False
@@ -115,7 +116,7 @@ feature -- Conversion
l_abs := opts.boolean_item ("absolute", l_abs)
if attached opts.item ("query") as l_query then
if attached {READABLE_STRING_8} l_query as s_value then
q := s_value
q := s_value.to_string_8
elseif attached {ITERABLE [TUPLE [key, value: READABLE_STRING_GENERAL]]} l_query as lst then
create q.make_empty
across
@@ -154,16 +155,18 @@ feature -- Conversion
end
end
else
Result := a_path
Result := a_path.to_string_8
end
else
Result := based_path (a_path)
end
if q /= Void then
Result.append ("?" + q)
Result.append_character ('?')
Result.append (q)
end
if f /= Void then
Result.append ("#" + f)
Result.append_character ('#')
Result.append (f)
end
end

View File

@@ -26,6 +26,31 @@ feature -- Access
input_type: STRING = "date"
feature -- Element change
set_date_value (dt: DATE)
-- Set value using date `dt`.
local
y,m,d: INTEGER
s: STRING
do
y := dt.year
m := dt.month
d := dt.day
create s.make (10)
s.append_integer (y)
s.append_character ('-')
if m <= 9 then
s.append_character ('0')
end
s.append_integer (m)
s.append_character ('-')
if d <= 9 then
s.append_character ('0')
end
s.append_integer (d)
set_text_value (s)
end
feature {NONE} -- Conversion

View File

@@ -15,7 +15,7 @@ inherit
redefine
set_value,
specific_input_attributes_string,
append_child_to_html
append_item_to_html
end
WSF_FORM_SELECTABLE_ITEM
@@ -97,14 +97,30 @@ feature -- Change
feature {NONE} -- Implementation
append_child_to_html (a_theme: WSF_THEME; a_html: STRING_8)
-- Specific child element if any.
--| To redefine if needed
append_item_to_html (a_theme: WSF_THEME; a_html: STRING_8)
do
Precursor (a_theme, a_html)
append_label_to_html (a_theme, a_html)
end
append_label_to_html (a_theme: WSF_THEME; a_html: STRING_8)
-- Specific label element if any.
local
s: READABLE_STRING_8
do
if attached raw_title as t then
a_html.append (t)
s := t
elseif attached title as t then
a_html.append (a_theme.html_encoded (t))
s := a_theme.html_encoded (t)
end
if s /= Void then
if attached css_id as l_id then
a_html.append ("<label for=%""+ l_id +"%">")
else
a_html.append ("<label>")
end
a_html.append (s)
a_html.append ("</label>")
end
end

View File

@@ -109,6 +109,7 @@ feature -- Conversion
local
l_is_already_selected: BOOLEAN
h: detachable STRING_8
l_item_html_text: READABLE_STRING_8
do
a_html.append ("<select name=%""+ name +"%" ")
if css_id = Void then
@@ -128,7 +129,7 @@ feature -- Conversion
across
options as o
loop
a_html.append ("<option value=%"" + o.item.value + "%" ")
a_html.append ("<option value=%"" + html_encoded_string (o.item.value) + "%" ")
-- if not l_is_already_selected then
if
o.item.is_selected
@@ -137,12 +138,13 @@ feature -- Conversion
a_html.append (" selected=%"selected%"")
end
-- end
a_html.append (">" + o.item.text + "</option>%N")
l_item_html_text := html_encoded_string (o.item.text)
a_html.append (">" + l_item_html_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>")
h.append ("<div id=%"" + name + "-" + html_encoded_string (o.item.value) + "%" class=%"option%"><strong>"+ l_item_html_text +"</strong>:"+ d + "</div>")
end
end
a_html.append ("</select>%N")

View File

@@ -17,14 +17,14 @@ create
feature {NONE} -- Initialization
make (a_value: READABLE_STRING_GENERAL; a_text: detachable like text)
make (a_value: READABLE_STRING_GENERAL; a_text: detachable READABLE_STRING_GENERAL)
-- Initialize `Current'.
do
value := a_value.as_string_32
if a_text = Void then
text := html_encoder.general_encoded_string (a_value)
else
text := a_text
text := a_text.to_string_32
end
end
@@ -37,16 +37,16 @@ feature -- Status
Result := value.same_string_general (v)
end
is_same_text (v: like text): BOOLEAN
is_same_text (v: READABLE_STRING_GENERAL): BOOLEAN
do
Result := text.same_string (v)
Result := v.same_string (text)
end
feature -- Access
value: READABLE_STRING_32
text: READABLE_STRING_8
text: READABLE_STRING_32
description: detachable READABLE_STRING_8

View File

@@ -42,6 +42,20 @@ feature -- Change
Precursor (i)
end
set_field_text_value (a_name: READABLE_STRING_GENERAL; a_text_value: detachable READABLE_STRING_GENERAL)
-- Set recursively text value of input fields named `a_name` to value `a_text_value`.
do
across
items as ic
loop
if attached {WSF_FORM_INPUT} ic.item as l_input and then l_input.name.same_string_general (a_name) then
l_input.set_text_value (a_text_value)
elseif attached {WSF_FORM_COMPOSITE} ic.item as l_composite then
l_composite.set_field_text_value (a_name, a_text_value)
end
end
end
feature {NONE} -- Implementation: Items
container_has_field (a_container: ITERABLE [WSF_WIDGET]; a_name: READABLE_STRING_GENERAL): BOOLEAN

View File

@@ -62,14 +62,16 @@ feature -- Access
table_item (a_name: READABLE_STRING_GENERAL): detachable WSF_TABLE
local
s,k: READABLE_STRING_GENERAL
s: STRING_32
k: READABLE_STRING_GENERAL
p,q: INTEGER
do
if attached {WSF_TABLE} item (a_name) as tb then
Result := tb
else
s := a_name + "["
create Result.make (a_name.to_string_8) -- FIXME
create s.make_from_string_general (a_name)
s.append_character ('[')
create Result.make (a_name)
across
items as c
loop

View File

@@ -35,7 +35,10 @@ feature -- Status report
debug_output: STRING
-- String that should be displayed in debugger to represent `Current'.
do
Result := name + " {" + generator + "}"
create Result.make_from_string (name)
Result.append (" {")
Result.append (generator)
Result.append_character ('}')
end
feature -- Validation

View File

@@ -58,10 +58,10 @@ feature -- Element Change
is_valid_number: a_val.is_integer
do
if a_val.is_string_32 then
min := html_encoder.encoded_string (a_val.as_string_32)
elseif a_val.is_string_8 then
min := a_val.as_string_8
end
min := html_encoder.encoded_string (a_val.to_string_32)
elseif a_val.is_string_8 then
min := a_val.to_string_8
end
ensure
min_set: attached min as l_min implies l_min.same_string_general (a_val)
end
@@ -72,10 +72,10 @@ feature -- Element Change
is_valid_number: a_val.is_integer
do
if a_val.is_string_32 then
max := html_encoder.encoded_string (a_val.as_string_32)
elseif a_val.is_string_8 then
max := a_val.as_string_8
end
max := html_encoder.encoded_string (a_val.to_string_32)
elseif a_val.is_string_8 then
max := a_val.to_string_8
end
ensure
max_set: attached max as l_max implies l_max.same_string_general (a_val)
end
@@ -84,12 +84,12 @@ feature -- Element Change
-- Set `step' with `a_val'.
require
is_valid_sequence: a_val.is_number_sequence or else a_val.is_real_sequence
do
if a_val.is_string_32 then
step := html_encoder.encoded_string (a_val.as_string_32)
elseif a_val.is_string_8 then
step := a_val.as_string_8
end
do
if a_val.is_string_32 then
step := html_encoder.encoded_string (a_val.to_string_32)
elseif a_val.is_string_8 then
step := a_val.to_string_8
end
ensure
step_set: attached step as l_step implies l_step.same_string_general (a_val)
end

View File

@@ -9,7 +9,7 @@ class
feature -- Converter
html_encoded_string (s: READABLE_STRING_GENERAL): READABLE_STRING_8
html_encoded_string (s: READABLE_STRING_GENERAL): STRING_8
do
Result := html_encoder.general_encoded_string (s)
end

View File

@@ -166,6 +166,19 @@ feature -- Change
end
end
remove (i: WSF_WIDGET)
-- Remove widget `i` from Current, recursively.
do
items.prune_all (i)
across
items as ic
loop
if attached {WSF_WIDGET_COMPOSITE} ic.item as l_comp then
l_comp.remove (i)
end
end
end
extend (i: WSF_WIDGET)
do
items.force (i)

View File

@@ -30,7 +30,7 @@ feature -- Change
lst.compare_objects
html_attributes := lst
end
lst.force (a_value, a_name)
lst.force (a_value, a_name.to_string_8)
end
remove_html_attribute (a_name: READABLE_STRING_8)
@@ -41,7 +41,7 @@ feature -- Change
do
lst := html_attributes
if lst /= Void then
lst.remove (a_name)
lst.remove (a_name.to_string_8)
end
end

View File

@@ -9,8 +9,8 @@
</file_rule>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="encoder" location="..\..\text\encoder\encoder.ecf"/>
<library name="uri_template" location="..\..\text\parser\uri_template\uri_template.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
<library name="uri_template" location="..\..\text\parser\uri_template\uri_template.ecf"/>
<library name="wsf" location="..\wsf\wsf.ecf"/>
<cluster name="api" location=".\api\" recursive="true"/>
<cluster name="css" location=".\css\" recursive="true"/>