Redesign states and implement generated control_name

This commit is contained in:
YNH Webdev
2013-11-08 00:03:02 +01:00
parent c9102af0aa
commit 86339d8163
33 changed files with 433 additions and 153 deletions

View File

@@ -9,7 +9,7 @@ class
inherit
WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
WSF_MULTI_CONTROL [WSF_NAVLIST_ITEM_CONTROL]
rename
make as make_multi_control
end
@@ -19,9 +19,9 @@ create
feature {NONE} -- Initialization
make (n: STRING)
make
do
make_multi_control (n)
make_multi_control
add_class ("list-group")
end
@@ -31,7 +31,16 @@ feature -- Change
local
c: WSF_NAVLIST_ITEM_CONTROL
do
create c.make (control_name + "_item_" + controls.count.out, link, text)
create c.make (link, text)
add_control(c)
end
add_button (event:attached like {WSF_BUTTON_CONTROL}.click_event; text: STRING)
local
c: WSF_NAVLIST_ITEM_CONTROL
do
create c.make ("", text)
c.set_click_event(event)
add_control(c)
end

View File

@@ -12,6 +12,9 @@ inherit
WSF_BUTTON_CONTROL
rename
make as make_button
redefine
set_state,
state
end
create
@@ -19,12 +22,41 @@ create
feature {NONE} -- Initialization
make (n, link, t: STRING)
make ( link, t: STRING)
do
make_control (n, "a")
make_control ("a")
text := t
attributes := "href=%"" + link + "%"";
add_class ("list-group-item")
end
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
set_state (new_state: JSON_OBJECT)
-- Restore text from json
do
Precursor {WSF_BUTTON_CONTROL}(new_state)
if attached {JSON_BOOLEAN} new_state.item ("active") as new_active then
active := new_active.item
end
end
state: WSF_JSON_OBJECT
-- Return state which contains the current text and if there is an event handle attached
do
Result := Precursor {WSF_BUTTON_CONTROL}
Result.put_boolean (true, "active")
end
feature -- Change
set_active (a: BOOLEAN)
-- Set text of that button
do
active := a
state_changes.replace (create {JSON_BOOLEAN}.make_boolean (a), "active")
end
feature -- Properties
active: BOOLEAN
end