Changed structure
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CHECKBOX_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_CHECKBOX_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WSF_VALUE_CONTROL [BOOLEAN]
|
||||
|
||||
create
|
||||
make_checkbox
|
||||
|
||||
feature {NONE}
|
||||
|
||||
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
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore text from json
|
||||
do
|
||||
if attached {JSON_BOOLEAN} new_state.item (create {JSON_STRING}.make_json ("checked")) as new_checked then
|
||||
checked := new_checked.item
|
||||
end
|
||||
end
|
||||
|
||||
state: JSON_OBJECT
|
||||
-- Return state which contains the current text and if there is an event handle attached
|
||||
do
|
||||
create Result.make
|
||||
Result.put (create {JSON_BOOLEAN}.make_boolean (checked), create {JSON_STRING}.make_json ("checked"))
|
||||
Result.put (create {JSON_STRING}.make_json (checked_value), create {JSON_STRING}.make_json ("checked_value"))
|
||||
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), create {JSON_STRING}.make_json ("callback_change"))
|
||||
end
|
||||
|
||||
feature --EVENT HANDLING
|
||||
|
||||
set_change_event (e: attached like change_event)
|
||||
-- Set text change event handle
|
||||
do
|
||||
change_event := e
|
||||
end
|
||||
|
||||
handle_callback (cname: STRING; event: STRING)
|
||||
do
|
||||
if Current.control_name.is_equal (cname) and attached change_event as cevent then
|
||||
if event.is_equal ("change") then
|
||||
cevent.call ([])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
render: STRING
|
||||
local
|
||||
attributes: STRING
|
||||
do
|
||||
attributes := "type=%"checkbox%""
|
||||
if checked then
|
||||
attributes := attributes + " checked"
|
||||
end
|
||||
Result := render_tag_with_tagname ("div", render_tag_with_tagname ("label", render_tag ("", attributes) + " " + label, "", ""), "", "checkbox")
|
||||
end
|
||||
|
||||
value: BOOLEAN
|
||||
do
|
||||
Result := checked
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
label: STRING
|
||||
|
||||
checked: BOOLEAN
|
||||
|
||||
checked_value: STRING
|
||||
|
||||
change_event: detachable PROCEDURE [ANY, TUPLE []]
|
||||
|
||||
end
|
||||
@@ -0,0 +1,48 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CHECKBOX_LIST_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_CHECKBOX_LIST_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
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
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make_checkbox_list_control (n: STRING)
|
||||
do
|
||||
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
|
||||
89
library/server/wsf_html/webcontrol/input/wsf_input_control.e
Normal file
89
library/server/wsf_html/webcontrol/input/wsf_input_control.e
Normal file
@@ -0,0 +1,89 @@
|
||||
note
|
||||
description: "Summary description for {WSF_TEXT_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_INPUT_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WSF_VALUE_CONTROL [STRING]
|
||||
|
||||
create
|
||||
make_input
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make_input (n: STRING; v: STRING)
|
||||
do
|
||||
make (n, "input")
|
||||
type := "text"
|
||||
text := v
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore text from json
|
||||
do
|
||||
if attached {JSON_STRING} new_state.item (create {JSON_STRING}.make_json ("text")) as new_text then
|
||||
text := new_text.unescaped_string_32
|
||||
end
|
||||
end
|
||||
|
||||
state: JSON_OBJECT
|
||||
-- Return state which contains the current text and if there is an event handle attached
|
||||
do
|
||||
create Result.make
|
||||
Result.put (create {JSON_STRING}.make_json (text), create {JSON_STRING}.make_json ("text"))
|
||||
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), create {JSON_STRING}.make_json ("callback_change"))
|
||||
end
|
||||
|
||||
feature --EVENT HANDLING
|
||||
|
||||
set_change_event (e: attached like change_event)
|
||||
-- Set text change event handle
|
||||
do
|
||||
change_event := e
|
||||
end
|
||||
|
||||
handle_callback (cname: STRING; event: STRING)
|
||||
do
|
||||
if Current.control_name.is_equal (cname) and attached change_event as cevent then
|
||||
if event.is_equal ("change") then
|
||||
cevent.call ([])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
render: STRING
|
||||
do
|
||||
Result := render_tag ("", "type=%"" + type + "%" value=%"" + text + "%"")
|
||||
end
|
||||
|
||||
set_text (t: STRING)
|
||||
do
|
||||
if not t.is_equal (text) then
|
||||
text := t
|
||||
state_changes.replace (create {JSON_STRING}.make_json (text), create {JSON_STRING}.make_json ("text"))
|
||||
end
|
||||
end
|
||||
|
||||
value: STRING
|
||||
do
|
||||
Result := text
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
text: STRING
|
||||
|
||||
type: STRING
|
||||
|
||||
change_event: detachable PROCEDURE [ANY, TUPLE []]
|
||||
|
||||
end
|
||||
@@ -0,0 +1,25 @@
|
||||
note
|
||||
description: "Summary description for {WSF_PASSWORD_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_PASSWORD_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WSF_INPUT_CONTROL
|
||||
|
||||
create
|
||||
make_password
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make_password (n: STRING; v: STRING)
|
||||
do
|
||||
make_input (n, v)
|
||||
type := "password"
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,35 @@
|
||||
note
|
||||
description: "Summary description for {WSF_TEXT_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_TEXTAREA_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WSF_INPUT_CONTROL
|
||||
redefine
|
||||
render
|
||||
end
|
||||
|
||||
create
|
||||
make_textarea
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make_textarea (n, t: STRING)
|
||||
do
|
||||
make_input (n, t)
|
||||
tag_name := "textarea"
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
render: STRING
|
||||
do
|
||||
Result := render_tag (text, "")
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user