Add stateless widgets

This commit is contained in:
YNH Webdev
2013-11-06 15:44:31 +01:00
parent 6838089570
commit c9102af0aa
8 changed files with 78 additions and 29 deletions

View File

@@ -9,7 +9,7 @@ class
inherit
WSF_MULTI_CONTROL [WSF_CONTROL]
WSF_STATELESS_MULTI_CONTROL [WSF_CONTROL]
rename
make as make_multi_control
end

View File

@@ -9,7 +9,7 @@ class
inherit
WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
rename
make as make_multi_control,
add_control as add_control_raw
@@ -22,7 +22,7 @@ feature {NONE} -- Initialization
make (n: STRING)
do
make_with_tag_name (n, "div")
make_with_tag_name ("div")
add_class ("row")
end

View File

@@ -43,13 +43,20 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
do
Precursor (new_states)
if attached {JSON_OBJECT} new_states.item ("controls") as ct then
across
controls as c
loop
if attached {WSF_CONTROL} c.item as cont then
if attached {JSON_OBJECT} ct.item (cont.control_name) as value_state then
cont.load_state (value_state)
end
load_subcontrol_state (ct)
end
end
load_subcontrol_state (newstate: JSON_OBJECT)
do
across
controls as c
loop
if attached {WSF_STATELESS_MULTI_CONTROL[WSF_STATELESS_CONTROL]} c.item as cont then
cont.load_subcontrol_state (newstate)
elseif attached {WSF_CONTROL} c.item as cont then
if attached {JSON_OBJECT} newstate.item (cont.control_name) as value_state then
cont.load_state (value_state)
end
end
end
@@ -67,14 +74,21 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
do
Result := Precursor
create controls_state.make
read_subcontrol_state (controls_state)
Result.put (controls_state, "controls")
end
read_subcontrol_state (controls_state: JSON_OBJECT)
do
across
controls as c
loop
if attached {WSF_CONTROL} c.item as cont then
if attached {WSF_STATELESS_MULTI_CONTROL[WSF_STATELESS_CONTROL]} c.item as mcont then
mcont.read_subcontrol_state (controls_state)
elseif attached {WSF_CONTROL} c.item as cont then
controls_state.put (cont.full_state, cont.control_name)
end
end
Result.put (controls_state, "controls")
end
read_state_changes (states: WSF_JSON_OBJECT)
@@ -124,7 +138,9 @@ feature -- Rendering
loop
Result := Result + c.item.render
end
Result := render_tag (Result, "")
if not tag_name.is_empty then
Result := render_tag (Result, "")
end
end
feature -- Change
@@ -137,6 +153,8 @@ feature -- Change
feature -- Properties
stateless: BOOLEAN
controls: ARRAYED_LIST [G]
-- List of current controls in this multi control

View File

@@ -0,0 +1,31 @@
note
description: "Summary description for {WSF_STATELESS_MULTI_CONTROL}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_STATELESS_MULTI_CONTROL [G -> WSF_STATELESS_CONTROL]
inherit
WSF_MULTI_CONTROL [G]
rename
make_with_tag_name as make_with_tag_name_and_name
end
create
make_with_tag_name, make_tag_less
feature {NONE} -- Initialization
make_with_tag_name(t:STRING)
do
make_with_tag_name_and_name("",t)
end
make_tag_less
do
make_with_tag_name_and_name ("", "")
stateless := True
end
end