Move project to wsf_js_widget
This commit is contained in:
82
library/server/wsf_js_widget/grid/wsf_datasource.e
Normal file
82
library/server/wsf_js_widget/grid/wsf_datasource.e
Normal file
@@ -0,0 +1,82 @@
|
||||
note
|
||||
description: "Summary description for {WSF_DATASOURCE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_DATASOURCE [G -> WSF_ENTITY]
|
||||
|
||||
feature -- Update event
|
||||
|
||||
set_on_update_agent (f: PROCEDURE [ANY, TUPLE])
|
||||
do
|
||||
on_update_agent := f
|
||||
end
|
||||
|
||||
update
|
||||
do
|
||||
if attached on_update_agent as a then
|
||||
a.call (Void)
|
||||
end
|
||||
end
|
||||
|
||||
on_update_agent: detachable PROCEDURE [ANY, TUPLE]
|
||||
|
||||
feature --State
|
||||
|
||||
state: JSON_OBJECT
|
||||
-- Return state which contains the current html and if there is an event handle attached
|
||||
do
|
||||
create Result.make
|
||||
if attached sort_column as a_sort_column then
|
||||
Result.put (create {JSON_STRING}.make_json (a_sort_column), "sort_column")
|
||||
else
|
||||
Result.put (create {JSON_NULL}, "sort_column")
|
||||
end
|
||||
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 ("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
|
||||
sort_column := Void
|
||||
end
|
||||
if attached {JSON_BOOLEAN} new_state.item ("sort_direction") as new_sort_direction then
|
||||
sort_direction := new_sort_direction.item
|
||||
end
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
set_sort_column (a_sort_column: like sort_column)
|
||||
do
|
||||
sort_column := a_sort_column
|
||||
end
|
||||
|
||||
set_sort_direction (a_sort_direction: like sort_direction)
|
||||
do
|
||||
sort_direction := a_sort_direction
|
||||
end
|
||||
|
||||
page: INTEGER
|
||||
|
||||
page_size: INTEGER
|
||||
|
||||
sort_column: detachable STRING
|
||||
|
||||
sort_direction: BOOLEAN
|
||||
|
||||
data: ITERABLE [G]
|
||||
deferred
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user