Moved to draft

This commit is contained in:
Severin Münger
2013-09-24 15:18:14 +02:00
parent f51201eae1
commit 83329ca4b7
41 changed files with 11 additions and 24 deletions

View File

@@ -0,0 +1,64 @@
note
description: "Summary description for {WSF_AUTOCOMPLETE_CONTROL}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_AUTOCOMPLETE_CONTROL
inherit
WSF_INPUT_CONTROL
redefine
handle_callback,
state
end
create
make_autocomplete, make_autocomplete_with_agent
feature {NONE} -- Initialization
make_autocomplete (n: STRING; c: WSF_AUTOCOMPLETION)
-- Initialize with specified name and autocompletion
do
make_autocomplete_with_agent (n, agent c.autocompletion)
if attached c.template as t then
template := t
end
end
make_autocomplete_with_agent (n: STRING; c: FUNCTION [ANY, TUPLE [STRING], JSON_ARRAY])
-- Initialize with specified name and autocompletion function
do
make_input (n, "")
create_json_list := c
template := "{{=value}}"
end
feature -- State
state: JSON_OBJECT
do
Result := Precursor {WSF_INPUT_CONTROL}
Result.put (create {JSON_STRING}.make_json (template), "template")
end
feature -- Callback
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
do
Precursor {WSF_INPUT_CONTROL} (cname, event, event_parameter)
if cname.same_string (control_name) and event.same_string ("autocomplete") then
state_changes.put (create_json_list.item ([text]), "suggestions")
end
end
feature -- Properties
create_json_list: FUNCTION [ANY, TUPLE [STRING], JSON_ARRAY]
template: STRING
end

View File

@@ -0,0 +1,95 @@
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} -- Initialization
make_checkbox (n, l, c: STRING)
-- Initialize with specified control name,
do
make_control (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 ("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), "checked")
Result.put (create {JSON_STRING}.make_json (checked_value), "checked_value")
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), "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; event_parameter: detachable STRING)
do
if Current.control_name.same_string (cname) and attached change_event as cevent then
if event.same_string ("change") then
cevent.call (Void)
end
end
end
feature -- Implementation
render: STRING
local
attrs: STRING
do
attrs := "type=%"checkbox%""
if checked then
attrs := attrs + " checked"
end
Result := render_tag_with_tagname ("div", render_tag_with_tagname ("label", render_tag ("", attrs) + " " + label, "", ""), "", "checkbox")
end
value: BOOLEAN
do
Result := checked
end
feature -- Properties
label: STRING
-- The label of the checkbox control
checked: BOOLEAN
-- The checked value of the checkbox control
checked_value: STRING
-- String checked value
change_event: detachable PROCEDURE [ANY, TUPLE]
-- Function to be executed on change
end

View File

@@ -0,0 +1,46 @@
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,
full_state,
read_state_changes
end
WSF_MULTI_CONTROL [WSF_CHECKBOX_CONTROL]
create
make_checkbox_list_control
feature {NONE} -- Initializaton
make_checkbox_list_control (n: STRING)
-- Initialize with specified control name
do
make_multi_control (n)
end
feature -- Implementation
value: LIST [STRING]
do
create {ARRAYED_LIST [STRING]} Result.make (0)
across
controls as c
loop
if c.item.value then
Result.extend (c.item.checked_value)
end
end
end
end

View File

@@ -0,0 +1,98 @@
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} -- Initialization
make_input (n, v: STRING)
-- Initialize with specified name and value
do
make_control (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 ("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), "text")
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), "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; event_parameter: detachable STRING)
do
if Current.control_name.same_string (cname) and attached change_event as cevent then
if event.same_string ("change") then
cevent.call (Void)
end
end
end
feature -- Rendering
render: STRING
do
Result := render_tag ("", "type=%"" + type + "%" value=%"" + text + "%"")
end
feature -- Change
set_text (t: STRING)
-- Set text to be displayed
do
if not t.same_string (text) then
text := t
state_changes.replace (create {JSON_STRING}.make_json (text), "text")
end
end
feature -- Implementation
value: STRING
do
Result := text
end
feature -- Properties
text: STRING
-- Text to be displayed
type: STRING
-- Type of this input control
change_event: detachable PROCEDURE [ANY, TUPLE]
-- Procedure to be execued on change
end

View File

@@ -0,0 +1,26 @@
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} -- Initialization
make_password (n, v: STRING)
-- Initialize with specified control name and text
do
make_input (n, v)
type := "password"
end
end

View File

@@ -0,0 +1,36 @@
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} -- Initialization
make_textarea (n, t: STRING)
-- Initialize with specified control name and text to be displayed in this textarea
do
make_input (n, t)
tag_name := "textarea"
end
feature -- Rendering
render: STRING
do
Result := render_tag (text, "")
end
end