Minor changes
- using http_client library instead of libcurl directly - using implicit conversion to JSON_STRING to improve code readability - use ARRAYED_LIST instead of LINKED_LIST .. for performance. - cosmetic .. but still a lot of feature clauses are missing, comments, assertions ...
This commit is contained in:
@@ -9,7 +9,7 @@ deferred class
|
||||
|
||||
feature -- Update event
|
||||
|
||||
set_on_update_agent (f: PROCEDURE [ANY, TUPLE []])
|
||||
set_on_update_agent (f: PROCEDURE [ANY, TUPLE])
|
||||
do
|
||||
on_update_agent := f
|
||||
end
|
||||
@@ -17,11 +17,11 @@ feature -- Update event
|
||||
update
|
||||
do
|
||||
if attached on_update_agent as a then
|
||||
a.call ([])
|
||||
a.call (Void)
|
||||
end
|
||||
end
|
||||
|
||||
on_update_agent: detachable PROCEDURE [ANY, TUPLE []]
|
||||
on_update_agent: detachable PROCEDURE [ANY, TUPLE]
|
||||
|
||||
feature --State
|
||||
|
||||
@@ -30,27 +30,27 @@ feature --State
|
||||
do
|
||||
create Result.make
|
||||
if attached sort_column as a_sort_column then
|
||||
Result.put (create {JSON_STRING}.make_json (a_sort_column), create {JSON_STRING}.make_json ("sort_column"))
|
||||
Result.put (create {JSON_STRING}.make_json (a_sort_column), "sort_column")
|
||||
else
|
||||
Result.put (create {JSON_NULL}, create {JSON_STRING}.make_json ("sort_column"))
|
||||
Result.put (create {JSON_NULL}, "sort_column")
|
||||
end
|
||||
Result.put (create {JSON_BOOLEAN}.make_boolean (sort_direction), create {JSON_STRING}.make_json ("sort_direction"))
|
||||
Result.put (create {JSON_BOOLEAN}.make_boolean (sort_direction), "sort_direction")
|
||||
end
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
do
|
||||
if attached {JSON_NUMBER} new_state.item (create {JSON_STRING}.make_json ("page")) as new_page then
|
||||
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 (create {JSON_STRING}.make_json ("page_size")) as new_page_size then
|
||||
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 (create {JSON_STRING}.make_json ("sort_column")) as new_sort_column then
|
||||
sort_column := new_sort_column.unescaped_string_32
|
||||
elseif attached {JSON_NULL} new_state.item (create {JSON_STRING}.make_json ("sort_column")) as new_sort_column then
|
||||
sort_column := VOID
|
||||
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
|
||||
sort_column := Void
|
||||
end
|
||||
if attached {JSON_BOOLEAN} new_state.item (create {JSON_STRING}.make_json ("sort_direction")) as new_sort_direction then
|
||||
if attached {JSON_BOOLEAN} new_state.item ("sort_direction") as new_sort_direction then
|
||||
sort_direction := new_sort_direction.item
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
note
|
||||
description: "Summary description for {WSF_ENTITY}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_ENTITY
|
||||
|
||||
feature
|
||||
feature -- Access
|
||||
|
||||
get (field: STRING): detachable ANY
|
||||
item (a_field: READABLE_STRING_GENERAL): detachable ANY
|
||||
-- Value for field item `a_field'.
|
||||
deferred
|
||||
end
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@ class
|
||||
WSF_GRID_COLUMN
|
||||
|
||||
create
|
||||
make_column
|
||||
make
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make_column (a_header, a_field: STRING)
|
||||
make (a_header, a_field: STRING)
|
||||
do
|
||||
header := a_header
|
||||
field_name := a_field
|
||||
@@ -31,7 +31,7 @@ feature
|
||||
|
||||
render_column (e: WSF_ENTITY): STRING
|
||||
do
|
||||
if attached e.get (field_name) as data then
|
||||
if attached e.item (field_name) as data then
|
||||
Result := data.out
|
||||
else
|
||||
Result := "[VOID]"
|
||||
|
||||
@@ -10,16 +10,18 @@ class
|
||||
inherit
|
||||
|
||||
WSF_GRID_COLUMN
|
||||
rename
|
||||
make as make_column
|
||||
redefine
|
||||
render_column
|
||||
end
|
||||
|
||||
create
|
||||
make_image_column
|
||||
make
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make_image_column (a_header, a_field: STRING)
|
||||
make (a_header, a_field: STRING)
|
||||
do
|
||||
make_column (a_header, a_field)
|
||||
end
|
||||
@@ -28,7 +30,7 @@ feature
|
||||
|
||||
render_column (e: WSF_ENTITY): STRING
|
||||
do
|
||||
if attached e.get (field_name) as data then
|
||||
if attached e.item (field_name) as data then
|
||||
Result := "<img src=%"" + data.out + "%" />"
|
||||
else
|
||||
Result := "[VOID]"
|
||||
|
||||
@@ -58,7 +58,7 @@ feature
|
||||
|
||||
update
|
||||
do
|
||||
state_changes.replace (create {JSON_STRING}.make_json (render), create {JSON_STRING}.make_json ("_html"))
|
||||
state_changes.replace (create {JSON_STRING}.make_json (render), "_html")
|
||||
end
|
||||
|
||||
render: STRING
|
||||
|
||||
@@ -34,14 +34,14 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
|
||||
update
|
||||
do
|
||||
state_changes.replace (create {JSON_STRING}.make_json (render_body), create {JSON_STRING}.make_json ("_body"))
|
||||
state_changes.replace (datasource.state, create {JSON_STRING}.make_json ("datasource"))
|
||||
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
|
||||
do
|
||||
if attached {JSON_OBJECT} new_state.item (create {JSON_STRING}.make_json ("datasource")) as datasource_state then
|
||||
if attached {JSON_OBJECT} new_state.item ("datasource") as datasource_state then
|
||||
datasource.set_state (datasource_state)
|
||||
end
|
||||
end
|
||||
@@ -50,7 +50,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
-- Return state which contains the current html and if there is an event handle attached
|
||||
do
|
||||
create Result.make
|
||||
Result.put (datasource.state, create {JSON_STRING}.make_json ("datasource"))
|
||||
Result.put (datasource.state, "datasource")
|
||||
end
|
||||
|
||||
feature --EVENT HANDLING
|
||||
|
||||
Reference in New Issue
Block a user