- Add event paramenter
- Implement Paging control
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
note
|
||||
description: "Summary description for {WSF_PAGABLE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_PAGABLE_DATASOURCE [G -> WSF_ENTITY]
|
||||
|
||||
inherit
|
||||
|
||||
WSF_DATASOURCE [G]
|
||||
redefine
|
||||
state,
|
||||
set_state
|
||||
end
|
||||
|
||||
feature --States
|
||||
|
||||
state: JSON_OBJECT
|
||||
-- Return state which contains the current html and if there is an event handle attached
|
||||
do
|
||||
Result := Precursor
|
||||
Result.put (create {JSON_NUMBER}.make_integer (page), create {JSON_STRING}.make_json ("page"))
|
||||
Result.put (create {JSON_NUMBER}.make_integer (page_size), create {JSON_STRING}.make_json ("page_size"))
|
||||
Result.put (create {JSON_NUMBER}.make_integer (row_count), create {JSON_STRING}.make_json ("row_count"))
|
||||
end
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
do
|
||||
Precursor (new_state)
|
||||
if attached {JSON_NUMBER} new_state.item (create {JSON_STRING}.make_json ("page")) as new_page then
|
||||
page := new_page.item.to_integer
|
||||
end
|
||||
if attached {JSON_NUMBER} new_state.item (create {JSON_STRING}.make_json ("page_size")) as new_page_size then
|
||||
page_size := new_page_size.item.to_integer
|
||||
end
|
||||
if attached {JSON_NUMBER} new_state.item (create {JSON_STRING}.make_json ("row_count")) as new_row_count then
|
||||
row_count := new_row_count.item.to_integer
|
||||
end
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
set_page (p: INTEGER)
|
||||
do
|
||||
page := p.min (page_count).max (1)
|
||||
end
|
||||
|
||||
row_count: INTEGER
|
||||
|
||||
page_count: INTEGER
|
||||
do
|
||||
Result := (row_count / page_size).ceiling
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user