First working checkbox list
This commit is contained in:
@@ -16,10 +16,11 @@ create
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make_checkbox (n: STRING; l: STRING)
|
||||
make_checkbox (n: STRING; l: STRING; c: STRING)
|
||||
do
|
||||
make (n, "input")
|
||||
label := l
|
||||
checked_value := c
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
@@ -67,7 +68,7 @@ feature -- Implementation
|
||||
if checked then
|
||||
attributes := attributes + " checked"
|
||||
end
|
||||
Result := render_tag ("", attributes)
|
||||
Result := render_tag_with_tagname ("div",render_tag_with_tagname ("label", render_tag ("", attributes) + " " + label, "",""), "","checkbox")
|
||||
end
|
||||
|
||||
value: BOOLEAN
|
||||
@@ -81,6 +82,8 @@ feature
|
||||
|
||||
checked: BOOLEAN
|
||||
|
||||
checked_value: STRING
|
||||
|
||||
change_event: detachable PROCEDURE [ANY, TUPLE []]
|
||||
|
||||
end
|
||||
|
||||
@@ -9,7 +9,14 @@ class
|
||||
|
||||
inherit
|
||||
|
||||
WSF_MULTI_CONTROL[WSF_CHECKBOX_CONTROL]
|
||||
WSF_VALUE_CONTROL [LIST [STRING]]
|
||||
undefine
|
||||
load_state,
|
||||
read_state,
|
||||
read_state_changes
|
||||
end
|
||||
|
||||
WSF_MULTI_CONTROL [WSF_CHECKBOX_CONTROL]
|
||||
|
||||
create
|
||||
make_checkbox_list_control
|
||||
@@ -21,4 +28,21 @@ feature {NONE}
|
||||
make_multi_control (n)
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
value: LIST [STRING]
|
||||
local
|
||||
l: LINKED_LIST [STRING]
|
||||
do
|
||||
create l.make
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
if c.item.value then
|
||||
l.extend (c.item.checked_value)
|
||||
end
|
||||
end
|
||||
Result := l
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -88,15 +88,22 @@ feature
|
||||
loop
|
||||
css_classes_string := css_classes_string + " " + c.item
|
||||
end
|
||||
if not css_classes_string.is_empty then
|
||||
css_classes_string := " class=%"" + css_classes_string + "%""
|
||||
end
|
||||
Result:=render_tag_with_tagname(tag_name,body,attributes,css_classes_string)
|
||||
end
|
||||
|
||||
Result := "<" + tag_name + " id=%"" + control_name + "%" data-name=%"" + control_name + "%" data-type=%"" + generator + "%" " + attributes + css_classes_string
|
||||
if body.is_empty and not tag_name.is_equal("textarea") then
|
||||
render_tag_with_tagname (tag, body, attributes,css_classes_string: STRING): STRING
|
||||
local
|
||||
l_attributes: STRING
|
||||
do
|
||||
l_attributes:=attributes
|
||||
if not css_classes_string.is_empty then
|
||||
l_attributes := " class=%"" + css_classes_string + "%""
|
||||
end
|
||||
Result := "<" + tag + " id=%"" + control_name + "%" data-name=%"" + control_name + "%" data-type=%"" + generator + "%" " + l_attributes
|
||||
if body.is_empty and not tag.is_equal ("textarea") then
|
||||
Result := Result + " />"
|
||||
else
|
||||
Result := Result + " >" + body + "</" + tag_name + ">"
|
||||
Result := Result + " >" + body + "</" + tag + ">"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -31,7 +31,10 @@ feature {NONE}
|
||||
do
|
||||
make (c.control_name + "_container", "div")
|
||||
add_class ("form-group")
|
||||
c.add_class ("form-control")
|
||||
if attached {WSF_TEXT_CONTROL}c or attached {WSF_TEXTAREA_CONTROL}c then
|
||||
c.add_class ("form-control")
|
||||
|
||||
end
|
||||
value_control := c
|
||||
validators := v
|
||||
label := a_label
|
||||
|
||||
Reference in New Issue
Block a user