Updated code based on comments
This commit is contained in:
@@ -1,44 +0,0 @@
|
|||||||
note
|
|
||||||
description: "Paginator builder for CMS nodes."
|
|
||||||
date: "$Date$"
|
|
||||||
revision: "$Revision$"
|
|
||||||
|
|
||||||
class
|
|
||||||
NODE_PAGE_BUILDER
|
|
||||||
|
|
||||||
inherit
|
|
||||||
|
|
||||||
NODE_PAGINATION_BUILDER [CMS_NODE]
|
|
||||||
|
|
||||||
CMS_NODE_HANDLER
|
|
||||||
redefine
|
|
||||||
make
|
|
||||||
end
|
|
||||||
create
|
|
||||||
make
|
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
|
||||||
|
|
||||||
make (a_api: CMS_API; a_module_api: CMS_NODE_API)
|
|
||||||
-- Create an object.
|
|
||||||
do
|
|
||||||
Precursor (a_api, a_module_api)
|
|
||||||
limit := 5
|
|
||||||
offset := 0
|
|
||||||
ensure then
|
|
||||||
limit_set: limit = 5
|
|
||||||
offset_set: offset = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
feature -- Pager
|
|
||||||
|
|
||||||
list: LIST [CMS_NODE]
|
|
||||||
-- <Precursor>.
|
|
||||||
do
|
|
||||||
--NOTE: the current implementation does not use
|
|
||||||
-- order by and ordering.
|
|
||||||
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
|
|
||||||
Result := node_api.recent_nodes (offset.as_integer_32, limit.as_integer_32)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
note
|
|
||||||
description: "Generic Node Pagination Builder Interface"
|
|
||||||
date: "$Date$"
|
|
||||||
revision: "$Revision$"
|
|
||||||
|
|
||||||
deferred class
|
|
||||||
NODE_PAGINATION_BUILDER [G]
|
|
||||||
|
|
||||||
feature -- Access
|
|
||||||
|
|
||||||
set_limit (a_limit: NATURAL)
|
|
||||||
-- Set limit with `a_limit'.
|
|
||||||
do
|
|
||||||
limit := a_limit
|
|
||||||
ensure
|
|
||||||
limit_set: limit = a_limit
|
|
||||||
end
|
|
||||||
|
|
||||||
set_offset (a_offset: NATURAL)
|
|
||||||
-- Set offset with `a_offset'.
|
|
||||||
do
|
|
||||||
offset := a_offset
|
|
||||||
ensure
|
|
||||||
limit_set: offset = a_offset
|
|
||||||
end
|
|
||||||
|
|
||||||
set_order_by_asc (a_field: READABLE_STRING_32)
|
|
||||||
-- Pager with a order_by `a_field' asc.
|
|
||||||
do
|
|
||||||
order_by := a_field
|
|
||||||
order_ascending := True
|
|
||||||
ensure
|
|
||||||
order_by_set: attached order_by as l_order_by implies l_order_by = a_field
|
|
||||||
asc_true: order_ascending
|
|
||||||
end
|
|
||||||
|
|
||||||
set_order_by_desc (a_field: READABLE_STRING_32)
|
|
||||||
-- Pager with a order_by `a_field' desc.
|
|
||||||
do
|
|
||||||
order_by := a_field
|
|
||||||
order_ascending := False
|
|
||||||
ensure
|
|
||||||
order_by_set: attached order_by as l_order_by implies l_order_by = a_field
|
|
||||||
asc_fasle: not order_ascending
|
|
||||||
end
|
|
||||||
|
|
||||||
feature -- Pager
|
|
||||||
|
|
||||||
list: LIST[G]
|
|
||||||
-- List of G with filters.
|
|
||||||
deferred
|
|
||||||
end
|
|
||||||
|
|
||||||
feature -- Access
|
|
||||||
|
|
||||||
limit: NATURAL
|
|
||||||
-- Number of rows per page.
|
|
||||||
|
|
||||||
offset: NATURAL
|
|
||||||
-- rows starting from the next row to the given OFFSET.
|
|
||||||
|
|
||||||
order_by: detachable STRING
|
|
||||||
-- field to order by
|
|
||||||
|
|
||||||
order_ascending: BOOLEAN
|
|
||||||
-- is ascending ordering?
|
|
||||||
end
|
|
||||||
@@ -41,7 +41,7 @@ feature -- HTTP Methods
|
|||||||
s: STRING
|
s: STRING
|
||||||
n: CMS_NODE
|
n: CMS_NODE
|
||||||
lnk: CMS_LOCAL_LINK
|
lnk: CMS_LOCAL_LINK
|
||||||
pager: NODE_PAGE_BUILDER
|
pager: CMS_NODE_PAGINATION_BUILDER
|
||||||
number_of_pages: INTEGER_64
|
number_of_pages: INTEGER_64
|
||||||
current_page: INTEGER
|
current_page: INTEGER
|
||||||
do
|
do
|
||||||
|
|||||||
Reference in New Issue
Block a user