Update based on comments
This commit is contained in:
44
modules/node/handler/cms_node_pagination_builder.e
Normal file
44
modules/node/handler/cms_node_pagination_builder.e
Normal file
@@ -0,0 +1,44 @@
|
||||
note
|
||||
description: "Paginator builder for CMS nodes."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_NODE_PAGINATION_BUILDER
|
||||
|
||||
inherit
|
||||
|
||||
CMS_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: ITERABLE [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
|
||||
67
modules/node/handler/cms_pagination_builder.e
Normal file
67
modules/node/handler/cms_pagination_builder.e
Normal file
@@ -0,0 +1,67 @@
|
||||
note
|
||||
description: "Generic Pagination Builder Interface"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_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_ascending_order (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_descending_order (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: ITERABLE[G]
|
||||
-- Iterable 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
|
||||
Reference in New Issue
Block a user