Add comments to grid controls
This commit is contained in:
@@ -7,26 +7,26 @@ note
|
||||
deferred class
|
||||
WSF_DATASOURCE [G -> WSF_ENTITY]
|
||||
|
||||
feature -- Update event
|
||||
feature --Event handling
|
||||
|
||||
set_on_update_agent (f: PROCEDURE [ANY, TUPLE])
|
||||
--Set update listener
|
||||
do
|
||||
on_update_agent := f
|
||||
end
|
||||
|
||||
update
|
||||
--Trigger update listener
|
||||
do
|
||||
if attached on_update_agent as a then
|
||||
a.call (Void)
|
||||
end
|
||||
end
|
||||
|
||||
on_update_agent: detachable PROCEDURE [ANY, TUPLE]
|
||||
|
||||
feature --State
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
state: JSON_OBJECT
|
||||
-- Return state which contains the current html and if there is an event handle attached
|
||||
-- Return state which contains the current sort_column and sort_direction
|
||||
do
|
||||
create Result.make
|
||||
if attached sort_column as a_sort_column then
|
||||
@@ -38,13 +38,8 @@ feature --State
|
||||
end
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore sort_column and sort_direction from json
|
||||
do
|
||||
if attached {JSON_NUMBER} new_state.item ("page") as new_page then
|
||||
page := new_page.integer_type
|
||||
end
|
||||
if attached {JSON_NUMBER} new_state.item ("page_size") as new_page_size then
|
||||
page_size := new_page_size.integer_type
|
||||
end
|
||||
if attached {JSON_STRING} new_state.item ("sort_column") as new_sort_column then
|
||||
sort_column := new_sort_column.unescaped_string_32 -- Implicit Conversion !
|
||||
elseif attached {JSON_NULL} new_state.item ("sort_column") as new_sort_column then
|
||||
@@ -55,21 +50,21 @@ feature --State
|
||||
end
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Change
|
||||
|
||||
set_sort_column (a_sort_column: like sort_column)
|
||||
-- Set the column by which the data should be sorted
|
||||
do
|
||||
sort_column := a_sort_column
|
||||
end
|
||||
|
||||
set_sort_direction (a_sort_direction: like sort_direction)
|
||||
-- Set the sorting direction
|
||||
do
|
||||
sort_direction := a_sort_direction
|
||||
end
|
||||
|
||||
page: INTEGER
|
||||
|
||||
page_size: INTEGER
|
||||
feature -- Properties
|
||||
|
||||
sort_column: detachable STRING
|
||||
|
||||
@@ -79,4 +74,6 @@ feature
|
||||
deferred
|
||||
end
|
||||
|
||||
on_update_agent: detachable PROCEDURE [ANY, TUPLE]
|
||||
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ class
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE}
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_header, a_field: STRING)
|
||||
do
|
||||
@@ -19,7 +19,19 @@ feature {NONE}
|
||||
sorting_name := a_field
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Render
|
||||
|
||||
render_column (e: WSF_ENTITY): STRING
|
||||
-- Return the rendered column cell for a specific entity (row)
|
||||
do
|
||||
if attached e.item (field_name) as data then
|
||||
Result := data.out
|
||||
else
|
||||
Result := "[VOID]"
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
header: STRING
|
||||
|
||||
@@ -29,13 +41,4 @@ feature
|
||||
|
||||
field_name: STRING
|
||||
|
||||
render_column (e: WSF_ENTITY): STRING
|
||||
do
|
||||
if attached e.item (field_name) as data then
|
||||
Result := data.out
|
||||
else
|
||||
Result := "[VOID]"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ inherit
|
||||
create
|
||||
make_grid
|
||||
|
||||
feature {NONE}
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_grid (n: STRING; a_columns: ITERABLE [WSF_GRID_COLUMN]; a_datasource: WSF_DATASOURCE [G])
|
||||
do
|
||||
@@ -25,9 +25,10 @@ feature {NONE}
|
||||
columns := a_columns
|
||||
end
|
||||
|
||||
feature -- Implementation
|
||||
feature -- Render
|
||||
|
||||
render_item (item: G): STRING
|
||||
-- Render table row
|
||||
do
|
||||
Result := ""
|
||||
across
|
||||
@@ -39,6 +40,7 @@ feature -- Implementation
|
||||
end
|
||||
|
||||
render_header: STRING
|
||||
-- Render table header
|
||||
do
|
||||
Result := ""
|
||||
across
|
||||
@@ -50,6 +52,7 @@ feature -- Implementation
|
||||
end
|
||||
|
||||
render: STRING
|
||||
-- Render entre table and subcontrols
|
||||
local
|
||||
table: STRING
|
||||
do
|
||||
@@ -58,12 +61,12 @@ feature -- Implementation
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
Result := c.item.render + Result
|
||||
Result.append (c.item.render)
|
||||
end
|
||||
Result := render_tag (table + Result, "")
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Properties
|
||||
|
||||
columns: ITERABLE [WSF_GRID_COLUMN]
|
||||
|
||||
|
||||
@@ -19,16 +19,17 @@ inherit
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE}
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_header, a_field: STRING)
|
||||
do
|
||||
make_column (a_header, a_field)
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Render
|
||||
|
||||
render_column (e: WSF_ENTITY): STRING
|
||||
-- Return the rendered column image cell for a specific entity (row)
|
||||
do
|
||||
if attached e.item (field_name) as data then
|
||||
Result := "<img src=%"" + data.out + "%" />"
|
||||
|
||||
@@ -16,29 +16,27 @@ inherit
|
||||
update
|
||||
end
|
||||
|
||||
feature -- Update event
|
||||
feature --Event handling
|
||||
|
||||
set_on_update_page_agent (f: PROCEDURE [ANY, TUPLE])
|
||||
--Set paging update listener
|
||||
do
|
||||
on_update_page_agent := f
|
||||
end
|
||||
|
||||
update
|
||||
--Trigger update listeners
|
||||
do
|
||||
if attached on_update_agent as a then
|
||||
a.call (Void)
|
||||
end
|
||||
Precursor
|
||||
if attached on_update_page_agent as a then
|
||||
a.call (Void)
|
||||
end
|
||||
end
|
||||
|
||||
on_update_page_agent: detachable PROCEDURE [ANY, TUPLE]
|
||||
|
||||
feature --States
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
state: JSON_OBJECT
|
||||
-- Return state which contains the current html and if there is an event handle attached
|
||||
-- Return state which contains the current page, page_size and row_count
|
||||
do
|
||||
Result := Precursor
|
||||
Result.put (create {JSON_NUMBER}.make_integer (page), "page")
|
||||
@@ -47,6 +45,7 @@ feature --States
|
||||
end
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore page, page_size and row_count from json
|
||||
do
|
||||
Precursor (new_state)
|
||||
if attached {JSON_NUMBER} new_state.item ("page") as new_page then
|
||||
@@ -60,13 +59,19 @@ feature --States
|
||||
end
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Change
|
||||
|
||||
set_page (p: INTEGER)
|
||||
do
|
||||
page := p.min (page_count).max (1)
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
page: INTEGER
|
||||
|
||||
page_size: INTEGER
|
||||
|
||||
row_count: INTEGER
|
||||
|
||||
page_count: INTEGER
|
||||
@@ -74,4 +79,6 @@ feature
|
||||
Result := (row_count / page_size).ceiling
|
||||
end
|
||||
|
||||
on_update_page_agent: detachable PROCEDURE [ANY, TUPLE]
|
||||
|
||||
end
|
||||
|
||||
@@ -24,21 +24,29 @@ feature {NONE}
|
||||
datasource.set_on_update_page_agent (agent update)
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
state: JSON_OBJECT
|
||||
-- Return state which contains the current html and if there is an event handle attached
|
||||
-- Return empty
|
||||
do
|
||||
create Result.make
|
||||
end
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- There is no state to restore states
|
||||
do
|
||||
end
|
||||
|
||||
feature --EVENT HANDLING
|
||||
update
|
||||
-- Send new renederd control to client on update
|
||||
do
|
||||
state_changes.replace (create {JSON_STRING}.make_json (render), "_html")
|
||||
end
|
||||
|
||||
feature --Event handling
|
||||
|
||||
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
||||
-- Handle goto/next/prev events
|
||||
do
|
||||
if Current.control_name.same_string (cname) then
|
||||
if event.same_string ("next") then
|
||||
@@ -54,14 +62,10 @@ feature --EVENT HANDLING
|
||||
end
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
update
|
||||
do
|
||||
state_changes.replace (create {JSON_STRING}.make_json (render), "_html")
|
||||
end
|
||||
feature -- Render
|
||||
|
||||
render: STRING
|
||||
-- Render paging control
|
||||
local
|
||||
paging_start: INTEGER
|
||||
paging_end: INTEGER
|
||||
@@ -85,7 +89,7 @@ feature
|
||||
Result := render_tag (Result, "")
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Properties
|
||||
|
||||
datasource: WSF_PAGABLE_DATASOURCE [G]
|
||||
|
||||
|
||||
@@ -13,11 +13,10 @@ inherit
|
||||
redefine
|
||||
set_state,
|
||||
state,
|
||||
handle_callback,
|
||||
render
|
||||
end
|
||||
|
||||
feature {NONE}
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_repeater (n: STRING; a_datasource: WSF_DATASOURCE [G])
|
||||
do
|
||||
@@ -30,16 +29,17 @@ feature {NONE}
|
||||
end
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
update
|
||||
-- Send new renederd control to client on update
|
||||
do
|
||||
state_changes.replace (create {JSON_STRING}.make_json (render_body), "_body")
|
||||
state_changes.replace (datasource.state, "datasource")
|
||||
end
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore html from json
|
||||
-- Restore datasource state from json
|
||||
do
|
||||
if attached {JSON_OBJECT} new_state.item ("datasource") as datasource_state then
|
||||
datasource.set_state (datasource_state)
|
||||
@@ -47,26 +47,22 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
end
|
||||
|
||||
state: JSON_OBJECT
|
||||
-- Return state which contains the current html and if there is an event handle attached
|
||||
-- Return state which contains the current datasource state
|
||||
do
|
||||
create Result.make
|
||||
Result.put (datasource.state, "datasource")
|
||||
end
|
||||
|
||||
feature --EVENT HANDLING
|
||||
|
||||
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
||||
do
|
||||
Precursor (cname, event, event_parameter)
|
||||
end
|
||||
|
||||
feature -- Implementation
|
||||
feature -- Rendering
|
||||
|
||||
render_item (item: G): STRING
|
||||
--Render item
|
||||
deferred
|
||||
end
|
||||
|
||||
render_body: STRING
|
||||
--Render Body
|
||||
do
|
||||
Result := ""
|
||||
across
|
||||
@@ -77,6 +73,7 @@ feature -- Implementation
|
||||
end
|
||||
|
||||
render: STRING
|
||||
--Render repeater inclusive paging if paging is available
|
||||
local
|
||||
content: STRING
|
||||
do
|
||||
@@ -91,7 +88,7 @@ feature -- Implementation
|
||||
Result := render_tag_with_generator_name ("WSF_REPEATER_CONTROL", content + Result, "")
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Properties
|
||||
|
||||
datasource: WSF_DATASOURCE [G]
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ feature -- Change
|
||||
set_progress (p: INTEGER)
|
||||
-- Set current progress value to specified value. Must be between 0 and 100. Must only be called when no progresssource has been set to this progress control
|
||||
require
|
||||
no_progress_source: not (attached progress_source) and p >= 0 and p <= 100
|
||||
no_progress_source: not (attached progress_source)
|
||||
valid_input_value: p >= 0 and p <= 100
|
||||
do
|
||||
progress := p
|
||||
state_changes.put (create {JSON_NUMBER}.make_integer (progress), "progress")
|
||||
|
||||
@@ -41,7 +41,7 @@ feature -- State
|
||||
Result.put (create {JSON_NUMBER}.make_integer (min), "min")
|
||||
end
|
||||
|
||||
feature -- Propertiess
|
||||
feature -- Properties
|
||||
|
||||
min: INTEGER
|
||||
-- The minimal allowed value
|
||||
|
||||
@@ -31,7 +31,7 @@ feature {NONE} -- Initialization
|
||||
-- Initialize with specified control name and tag
|
||||
do
|
||||
make_control (n, t)
|
||||
controls := create {LINKED_LIST [G]}.make;
|
||||
controls := create {ARRAYED_LIST [G]}.make(5);
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
@@ -129,7 +129,7 @@ feature -- Change
|
||||
|
||||
feature -- Properties
|
||||
|
||||
controls: LINKED_LIST [G]
|
||||
controls: ARRAYED_LIST [G]
|
||||
-- List of current controls in this multi control
|
||||
|
||||
end
|
||||
|
||||
@@ -20,10 +20,10 @@ feature {NONE} -- Initialization
|
||||
feature -- Access
|
||||
|
||||
request: WSF_REQUEST
|
||||
-- The request
|
||||
-- The http request
|
||||
|
||||
response: WSF_RESPONSE
|
||||
-- The response
|
||||
-- The http response
|
||||
|
||||
feature -- Specific implementation
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ feature {NONE} -- Initialization
|
||||
-- Initialize with specified tag
|
||||
do
|
||||
make (t)
|
||||
controls := create {LINKED_LIST [WSF_STATELESS_CONTROL]}.make;
|
||||
controls := create {ARRAYED_LIST [WSF_STATELESS_CONTROL]}.make (5);
|
||||
end
|
||||
|
||||
feature -- Rendering
|
||||
@@ -53,7 +53,7 @@ feature -- Change
|
||||
|
||||
feature -- Properties
|
||||
|
||||
controls: LINKED_LIST [WSF_STATELESS_CONTROL]
|
||||
controls: ARRAYED_LIST [WSF_STATELESS_CONTROL]
|
||||
-- List of controls
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user