mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 07:45:54 +01:00
Improved pagination info
Some checks are pending
TOC Generator / TOC Generator (push) Waiting to run
Some checks are pending
TOC Generator / TOC Generator (push) Waiting to run
This commit is contained in:
parent
ac6011143c
commit
f22656b6f6
@ -450,7 +450,7 @@ function StrDict: TMVCStringDictionary; overload;
|
||||
function StrDict(const aKeys: array of string; const aValues: array of string)
|
||||
: TMVCStringDictionary; overload;
|
||||
function ObjectDict(const OwnsValues: Boolean = True): IMVCObjectDictionary;
|
||||
function GetPaginationMeta(const CurrPageNumber: UInt32; const CurrPageSize: UInt32;
|
||||
function GetPaginationData(const CurrPageNumber: UInt32; const CurrPageSize: UInt32;
|
||||
const DefaultPageSize: UInt32; const URITemplate: string): TMVCStringDictionary;
|
||||
procedure RaiseSerializationError(const Msg: string);
|
||||
procedure RaiseDeSerializationError(const Msg: string);
|
||||
@ -478,25 +478,31 @@ begin
|
||||
Result := TMVCStringDictionary.Create;
|
||||
end;
|
||||
|
||||
function GetPaginationMeta(const CurrPageNumber: UInt32; const CurrPageSize: UInt32;
|
||||
function GetPaginationData(const CurrPageNumber: UInt32; const CurrPageSize: UInt32;
|
||||
const DefaultPageSize: UInt32; const URITemplate: string): TMVCStringDictionary;
|
||||
var
|
||||
lMetaKeys: array of string;
|
||||
lMetaValues: array of string;
|
||||
begin
|
||||
Insert('curr_page', lMetaKeys, 0);
|
||||
Insert('page_num', lMetaKeys, 0);
|
||||
Insert(CurrPageNumber.ToString(), lMetaValues, 0);
|
||||
|
||||
Insert('page_size', lMetaKeys, 0);
|
||||
Insert(CurrPageSize.ToString(), lMetaValues, 0);
|
||||
|
||||
Insert('default_page_size', lMetaKeys, 0);
|
||||
Insert(DefaultPageSize.ToString(), lMetaValues, 0);
|
||||
|
||||
if CurrPageNumber > 1 then
|
||||
begin
|
||||
Insert('prev_page_uri', lMetaKeys, 0);
|
||||
Insert(Format(URITemplate, [(CurrPageNumber - 1)]), lMetaValues, 0);
|
||||
Insert(URITemplate.Replace('($page)', (CurrPageNumber - 1).ToString), lMetaValues, 0);
|
||||
end;
|
||||
|
||||
if CurrPageSize = DefaultPageSize then
|
||||
begin
|
||||
Insert('next_page_uri', lMetaKeys, 0);
|
||||
Insert(Format(URITemplate, [(CurrPageNumber + 1)]), lMetaValues, 0);
|
||||
Insert(URITemplate.Replace('($page)',(CurrPageNumber + 1).ToString), lMetaValues, 0);
|
||||
end;
|
||||
Result := StrDict(lMetaKeys, lMetaValues);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user