Merged remote-tracking branch 'jvelilla/roc_pg' into pagination

Renamed pagination related classes, and moved them to cms library under "support" cluster.
This commit is contained in:
2015-05-31 22:43:19 +02:00
8 changed files with 327 additions and 25 deletions

View File

@@ -148,19 +148,15 @@ feature -- Permissions system
feature -- Query: module
module (a_type: TYPE [detachable CMS_MODULE]): detachable CMS_MODULE
module (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE
-- Enabled module typed `a_type', if any.
--| usage: if attached module ({FOO_MODULE}) as mod then ...
local
t: STRING_8
-- t: STRING_8
l_type: TYPE [detachable CMS_MODULE]
do
t := a_type.name
if t.starts_with ("!") then
t.remove_head (1)
elseif t.starts_with ("?") then
t.remove_head (1)
end
-- t := type_name_without_annotation (a_type)
across
setup.modules as ic
until
@@ -173,8 +169,12 @@ feature -- Query: module
l_type := Result.generating_type
if a_type ~ l_type then
-- Found
elseif t.same_string (l_type.name) then
elseif
attached a_type.attempt (Result) and then attached l_type.generating_type.attempt (a_type)
then
-- Found
-- elseif t.same_string (type_name_without_annotation (l_type)) then
-- -- Found
else
Result := Void
end
@@ -322,6 +322,41 @@ feature {NONE}-- Implemenation
internal_user_api: detachable like user_api
-- Cached value for `user_api'.
type_name_without_annotation (a_type: TYPE [detachable ANY]): STRING
-- Type name for `a_type, without any annotation.
-- Used by `module' to search by type.
local
i,j,n: INTEGER
c: CHARACTER
do
create Result.make_from_string (a_type.name)
from
i := 1
n := Result.count
until
i > n
loop
c := Result[i]
if c = '!' or c = '?' then
Result.remove (i)
n := n - 1
elseif c.is_lower then
j := Result.index_of (' ', i + 1)
if j > 0 then
Result.remove_substring (i, j)
n := n - (j - i)
end
else
i := i + 1
end
end
if Result.starts_with ("!") or Result.starts_with ("?") then
Result.remove_head (1)
elseif Result.starts_with ("detachable ") then
Result.remove_head (11)
end
end
feature -- Environment
module_configuration (a_module_name: READABLE_STRING_GENERAL; a_name: detachable READABLE_STRING_GENERAL): detachable CONFIG_READER

View File

@@ -1,6 +1,5 @@
note
description: "Summary description for {CMS_MODULE_COLLECTION}."
author: ""
description: "Collection of CMS modules."
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
revision: "$Revision: 96596 $"

View File

@@ -0,0 +1,55 @@
note
description: "Pagination parameters with order capability"
date: "$Date$"
revision: "$Revision$"
class
CMS_ORDERED_PAGINATION
inherit
CMS_PAGINATION
create
make
feature -- Access
order_by: detachable READABLE_STRING_8
-- field to order by.
order_ascending: BOOLEAN
-- is ascending ordering?
feature -- Element change
set_ascending_order_by_field (a_field: detachable READABLE_STRING_8)
-- Pager with a order_by `a_field' asc.
do
if a_field /= Void then
order_by := a_field
order_ascending := True
else
order_by := Void
end
ensure
order_by_unset: a_field = Void implies order_by = Void
order_by_set: a_field /= Void implies attached order_by as l_order_by and then l_order_by.same_string (a_field)
asc_true: order_ascending
end
set_descending_order_by_field (a_field: detachable READABLE_STRING_8)
-- Pager sorting descending with field `a_field' if set, otherwise remove sorting.
do
if a_field /= Void then
order_by := a_field
order_ascending := False
else
order_by := Void
end
ensure
order_by_unset: a_field = Void implies order_by = Void
order_by_set: a_field /= Void implies attached order_by as l_order_by and then l_order_by.same_string (a_field)
asc_fasle: not order_ascending
end
end

View File

@@ -0,0 +1,50 @@
note
description: "Pagination parameters"
date: "$Date$"
revision: "$Revision$"
class
CMS_PAGINATION
create
make
feature {NONE} -- Initialization
make (a_offset: NATURAL; a_size: NATURAL)
do
offset := a_offset
size := a_size
ensure
size_set: size = a_size
offset_set: offset = a_offset
end
feature -- Access
size: NATURAL assign set_size
-- Number of items per page.
offset: NATURAL assign set_offset
-- lower index of `items' pagination.
feature -- Element change
set_size (a_size: NATURAL)
-- Set `size' with `a_size'.
do
size := a_size
ensure
size_set: size = a_size
end
set_offset (a_offset: NATURAL)
-- Set offset with `a_offset'.
do
offset := a_offset
ensure
limit_set: offset = a_offset
end
end