Finalize WSF_DYNAMIC_MULTI_CONTROL
This commit is contained in:
@@ -26,6 +26,7 @@ feature {NONE} -- Initialization
|
||||
do
|
||||
Precursor (tag)
|
||||
create items.make_array
|
||||
create pending_removes.make (1)
|
||||
end
|
||||
|
||||
feature {WSF_DYNAMIC_MULTI_CONTROL} -- Iternal functions
|
||||
@@ -36,11 +37,51 @@ feature {WSF_DYNAMIC_MULTI_CONTROL} -- Iternal functions
|
||||
controls.extend (c)
|
||||
if attached {WSF_CONTROL} c as d then
|
||||
d.control_id := id
|
||||
max_id := id.max (max_id)
|
||||
end
|
||||
max_id := id.max (max_id)
|
||||
items_changed := True
|
||||
end
|
||||
|
||||
execute_pending_removes
|
||||
local
|
||||
found: BOOLEAN
|
||||
fitem: detachable G
|
||||
frow: detachable JSON_OBJECT
|
||||
do
|
||||
across
|
||||
pending_removes as id
|
||||
loop
|
||||
across
|
||||
controls as c
|
||||
until
|
||||
found
|
||||
loop
|
||||
if c.item.control_id = id.item then
|
||||
fitem := c.item
|
||||
found := True
|
||||
end
|
||||
end
|
||||
if attached fitem as i then
|
||||
controls.prune (i)
|
||||
end
|
||||
found := False
|
||||
across
|
||||
items.array_representation as c
|
||||
until
|
||||
found
|
||||
loop
|
||||
if attached {JSON_OBJECT} c.item as row and then attached {JSON_NUMBER} row.item ("id") as rid and then rid.item.to_integer_32 = id.item then
|
||||
frow := row
|
||||
found := True
|
||||
end
|
||||
end
|
||||
if attached frow as r then
|
||||
items.array_representation.prune (r)
|
||||
end
|
||||
items_changed := True
|
||||
end
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
@@ -89,12 +130,19 @@ feature
|
||||
end
|
||||
end
|
||||
|
||||
remove_control_by_id (id: INTEGER)
|
||||
--Add removes to pending removes list
|
||||
do
|
||||
pending_removes.extend (id)
|
||||
end
|
||||
|
||||
read_state_changes (states: WSF_JSON_OBJECT)
|
||||
local
|
||||
new_state: WSF_JSON_OBJECT
|
||||
sub_state: WSF_JSON_OBJECT
|
||||
do
|
||||
Precursor (states)
|
||||
execute_pending_removes
|
||||
if items_changed then
|
||||
new_state := state
|
||||
create sub_state.make
|
||||
@@ -114,8 +162,13 @@ feature
|
||||
|
||||
items: JSON_ARRAY
|
||||
|
||||
pending_removes: ARRAYED_LIST [INTEGER]
|
||||
|
||||
items_changed: BOOLEAN
|
||||
|
||||
max_id: INTEGER
|
||||
|
||||
invariant
|
||||
all_items_exist: items.count = controls.count
|
||||
|
||||
end
|
||||
|
||||
@@ -14,7 +14,8 @@ inherit
|
||||
add_control,
|
||||
set_control_name_prefix,
|
||||
handle_callback,
|
||||
set_control_id
|
||||
set_control_id,
|
||||
render_tag
|
||||
end
|
||||
|
||||
create
|
||||
@@ -65,6 +66,20 @@ feature
|
||||
end
|
||||
end
|
||||
|
||||
render_tag (body: STRING; attrs: detachable STRING): STRING
|
||||
-- Generate HTML of this control with the specified body and attributes
|
||||
local
|
||||
css_classes_string: STRING
|
||||
do
|
||||
create css_classes_string.make_empty
|
||||
across
|
||||
css_classes as c
|
||||
loop
|
||||
css_classes_string.append (" " + c.item)
|
||||
end
|
||||
Result := render_tag_with_tagname (tag_name, body, attrs, css_classes_string)
|
||||
end
|
||||
|
||||
feature -- Event handling
|
||||
|
||||
handle_callback (cname: LIST [STRING]; event: STRING; event_parameter: detachable ANY)
|
||||
|
||||
Reference in New Issue
Block a user