Changed creation procedures
This commit is contained in:
@@ -18,7 +18,7 @@ feature {NONE}
|
|||||||
|
|
||||||
make_button (n: STRING; t: STRING)
|
make_button (n: STRING; t: STRING)
|
||||||
do
|
do
|
||||||
make (n)
|
make (n, "button")
|
||||||
text := t
|
text := t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ feature {NONE}
|
|||||||
create state_changes.make
|
create state_changes.make
|
||||||
ensure
|
ensure
|
||||||
attached state_changes
|
attached state_changes
|
||||||
|
attached css_class
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||||
|
|||||||
@@ -12,9 +12,14 @@ inherit
|
|||||||
WSF_MULTI_CONTROL
|
WSF_MULTI_CONTROL
|
||||||
|
|
||||||
create
|
create
|
||||||
make, make_with_controls
|
make_form_control
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE}
|
||||||
|
|
||||||
|
make_form_control (n: STRING)
|
||||||
|
do
|
||||||
|
make_multi_control (n)
|
||||||
|
tag_name := "form"
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
note
|
|
||||||
description: "Summary description for {WSF_INPUT_CONTROL}."
|
|
||||||
author: ""
|
|
||||||
date: "$Date$"
|
|
||||||
revision: "$Revision$"
|
|
||||||
|
|
||||||
class
|
|
||||||
WSF_INPUT_CONTROL
|
|
||||||
|
|
||||||
inherit
|
|
||||||
|
|
||||||
WSF_CONTROL
|
|
||||||
|
|
||||||
create
|
|
||||||
make_input
|
|
||||||
|
|
||||||
feature {NONE}
|
|
||||||
|
|
||||||
make_input (n, t, v: STRING)
|
|
||||||
do
|
|
||||||
make (n)
|
|
||||||
type := t
|
|
||||||
value := v
|
|
||||||
end
|
|
||||||
|
|
||||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|
||||||
|
|
||||||
set_state (new_state: JSON_OBJECT)
|
|
||||||
-- Restore value from json
|
|
||||||
do
|
|
||||||
if attached {JSON_STRING} new_state.item (create {JSON_STRING}.make_json ("value")) as new_value then
|
|
||||||
value := new_value.unescaped_string_32
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
state: JSON_OBJECT
|
|
||||||
-- Return state which contains the current value and if there is an event handle attached
|
|
||||||
do
|
|
||||||
create Result.make
|
|
||||||
Result.put (create {JSON_STRING}.make_json (value), create {JSON_STRING}.make_json ("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 input 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
|
|
||||||
|
|
||||||
render: STRING
|
|
||||||
do
|
|
||||||
Result := "<input type=%"" + type + "%" data-name=%"" + control_name + "%" data-type=%"WSF_TEXT_CONTROL%" value=%"" + value + "%" />"
|
|
||||||
end
|
|
||||||
|
|
||||||
set_value (v: STRING)
|
|
||||||
do
|
|
||||||
if not v.is_equal (value) then
|
|
||||||
value := v
|
|
||||||
state_changes.replace (create {JSON_STRING}.make_json (value), create {JSON_STRING}.make_json ("value"))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
feature
|
|
||||||
|
|
||||||
type: STRING
|
|
||||||
|
|
||||||
value: STRING
|
|
||||||
|
|
||||||
change_event: detachable PROCEDURE [ANY, TUPLE []]
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -11,32 +11,23 @@ inherit
|
|||||||
|
|
||||||
WSF_CONTROL
|
WSF_CONTROL
|
||||||
redefine
|
redefine
|
||||||
make,
|
|
||||||
read_state,
|
read_state,
|
||||||
read_state_changes,
|
read_state_changes,
|
||||||
load_state
|
load_state
|
||||||
end
|
end
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make_multi_control
|
||||||
|
|
||||||
feature {NONE}
|
feature {NONE}
|
||||||
|
|
||||||
controls: LINKED_LIST [WSF_CONTROL]
|
controls: LINKED_LIST [WSF_CONTROL]
|
||||||
|
|
||||||
make (n: STRING)
|
make_multi_control (n: STRING)
|
||||||
do
|
do
|
||||||
Precursor (n)
|
make (n, "div")
|
||||||
controls := create {LINKED_LIST [WSF_CONTROL]}.make;
|
controls := create {LINKED_LIST [WSF_CONTROL]}.make;
|
||||||
end
|
end
|
||||||
|
|
||||||
make_with_controls (n: STRING; c: LINKED_LIST [WSF_CONTROL])
|
|
||||||
do
|
|
||||||
control_name := n
|
|
||||||
controls := c
|
|
||||||
create state_changes.make
|
|
||||||
end
|
|
||||||
|
|
||||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||||
|
|
||||||
load_state (new_states: JSON_OBJECT)
|
load_state (new_states: JSON_OBJECT)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ feature {NONE}
|
|||||||
|
|
||||||
make_text (n: STRING; v: STRING)
|
make_text (n: STRING; v: STRING)
|
||||||
do
|
do
|
||||||
make (n)
|
make (n, "input")
|
||||||
text := v
|
text := v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class
|
|||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
WSF_CONTROL
|
WSF_TEXT_CONTROL
|
||||||
|
|
||||||
create
|
create
|
||||||
make_textarea
|
make_textarea
|
||||||
@@ -18,64 +18,7 @@ feature {NONE}
|
|||||||
|
|
||||||
make_textarea (n, t: STRING)
|
make_textarea (n, t: STRING)
|
||||||
do
|
do
|
||||||
make (n)
|
make_text (n, t)
|
||||||
text := t
|
tag_name := "textarea"
|
||||||
end
|
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
|
|
||||||
|
|
||||||
render: STRING
|
|
||||||
do
|
|
||||||
Result := "<textarea data-name=%"" + control_name + "%" data-type=%"WSF_TEXTAREA_CONTROL%">" + text + "</textarea>"
|
|
||||||
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
|
|
||||||
|
|
||||||
feature
|
|
||||||
|
|
||||||
text: STRING
|
|
||||||
|
|
||||||
change_event: detachable PROCEDURE [ANY, TUPLE []]
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user