@plone/volto 19.1.6 → 19.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/locales/af/LC_MESSAGES/volto.po +5 -0
- package/locales/af.json +1 -1
- package/locales/ar/LC_MESSAGES/volto.po +5 -0
- package/locales/ar.json +1 -1
- package/locales/bg/LC_MESSAGES/volto.po +5 -0
- package/locales/bg.json +1 -1
- package/locales/bn/LC_MESSAGES/volto.po +5 -0
- package/locales/bn.json +1 -1
- package/locales/ca/LC_MESSAGES/volto.po +5 -0
- package/locales/ca.json +1 -1
- package/locales/cs/LC_MESSAGES/volto.po +5 -0
- package/locales/cs.json +1 -1
- package/locales/cy/LC_MESSAGES/volto.po +5 -0
- package/locales/cy.json +1 -1
- package/locales/da/LC_MESSAGES/volto.po +5 -0
- package/locales/da.json +1 -1
- package/locales/de/LC_MESSAGES/volto.po +5 -0
- package/locales/de.json +1 -1
- package/locales/el/LC_MESSAGES/volto.po +5 -0
- package/locales/el.json +1 -1
- package/locales/en/LC_MESSAGES/volto.po +5 -0
- package/locales/en.json +1 -1
- package/locales/en_AU/LC_MESSAGES/volto.po +5 -0
- package/locales/en_AU.json +1 -1
- package/locales/en_GB/LC_MESSAGES/volto.po +5 -0
- package/locales/en_GB.json +1 -1
- package/locales/eo/LC_MESSAGES/volto.po +5 -0
- package/locales/eo.json +1 -1
- package/locales/es/LC_MESSAGES/volto.po +5 -0
- package/locales/es.json +1 -1
- package/locales/et/LC_MESSAGES/volto.po +5 -0
- package/locales/et.json +1 -1
- package/locales/eu/LC_MESSAGES/volto.po +5 -0
- package/locales/eu.json +1 -1
- package/locales/fa/LC_MESSAGES/volto.po +5 -0
- package/locales/fa.json +1 -1
- package/locales/fi/LC_MESSAGES/volto.po +5 -0
- package/locales/fi.json +1 -1
- package/locales/fr/LC_MESSAGES/volto.po +5 -0
- package/locales/fr.json +1 -1
- package/locales/fu/LC_MESSAGES/volto.po +5 -0
- package/locales/fu.json +1 -1
- package/locales/gl/LC_MESSAGES/volto.po +5 -0
- package/locales/gl.json +1 -1
- package/locales/he/LC_MESSAGES/volto.po +5 -0
- package/locales/he.json +1 -1
- package/locales/hi/LC_MESSAGES/volto.po +5 -0
- package/locales/hi.json +1 -1
- package/locales/hr/LC_MESSAGES/volto.po +5 -0
- package/locales/hr.json +1 -1
- package/locales/hu/LC_MESSAGES/volto.po +5 -0
- package/locales/hu.json +1 -1
- package/locales/hy/LC_MESSAGES/volto.po +5 -0
- package/locales/hy.json +1 -1
- package/locales/id/LC_MESSAGES/volto.po +5 -0
- package/locales/id.json +1 -1
- package/locales/it/LC_MESSAGES/volto.po +5 -0
- package/locales/it.json +1 -1
- package/locales/ja/LC_MESSAGES/volto.po +5 -0
- package/locales/ja.json +1 -1
- package/locales/ka/LC_MESSAGES/volto.po +5 -0
- package/locales/ka.json +1 -1
- package/locales/kn/LC_MESSAGES/volto.po +5 -0
- package/locales/kn.json +1 -1
- package/locales/ko/LC_MESSAGES/volto.po +5 -0
- package/locales/ko.json +1 -1
- package/locales/lt/LC_MESSAGES/volto.po +5 -0
- package/locales/lt.json +1 -1
- package/locales/lv/LC_MESSAGES/volto.po +5 -0
- package/locales/lv.json +1 -1
- package/locales/mi/LC_MESSAGES/volto.po +5 -0
- package/locales/mi.json +1 -1
- package/locales/mk/LC_MESSAGES/volto.po +5 -0
- package/locales/mk.json +1 -1
- package/locales/my/LC_MESSAGES/volto.po +5 -0
- package/locales/my.json +1 -1
- package/locales/nb_NO/LC_MESSAGES/volto.po +5 -0
- package/locales/nb_NO.json +1 -1
- package/locales/nl/LC_MESSAGES/volto.po +5 -0
- package/locales/nl.json +1 -1
- package/locales/nn/LC_MESSAGES/volto.po +5 -0
- package/locales/nn.json +1 -1
- package/locales/pl/LC_MESSAGES/volto.po +5 -0
- package/locales/pl.json +1 -1
- package/locales/pt/LC_MESSAGES/volto.po +5 -0
- package/locales/pt.json +1 -1
- package/locales/pt_BR/LC_MESSAGES/volto.po +5 -0
- package/locales/pt_BR.json +1 -1
- package/locales/rm/LC_MESSAGES/volto.po +5 -0
- package/locales/rm.json +1 -1
- package/locales/ro/LC_MESSAGES/volto.po +5 -0
- package/locales/ro.json +1 -1
- package/locales/ru/LC_MESSAGES/volto.po +5 -0
- package/locales/ru.json +1 -1
- package/locales/sk/LC_MESSAGES/volto.po +5 -0
- package/locales/sk.json +1 -1
- package/locales/sl/LC_MESSAGES/volto.po +5 -0
- package/locales/sl.json +1 -1
- package/locales/sm/LC_MESSAGES/volto.po +5 -0
- package/locales/sm.json +1 -1
- package/locales/sq/LC_MESSAGES/volto.po +5 -0
- package/locales/sq.json +1 -1
- package/locales/sr/LC_MESSAGES/volto.po +5 -0
- package/locales/sr.json +1 -1
- package/locales/sr@cyrl/LC_MESSAGES/volto.po +5 -0
- package/locales/sr@cyrl.json +1 -1
- package/locales/sr@latn/LC_MESSAGES/volto.po +5 -0
- package/locales/sr@latn.json +1 -1
- package/locales/sv/LC_MESSAGES/volto.po +5 -0
- package/locales/sv.json +1 -1
- package/locales/ta/LC_MESSAGES/volto.po +5 -0
- package/locales/ta.json +1 -1
- package/locales/te/LC_MESSAGES/volto.po +5 -0
- package/locales/te.json +1 -1
- package/locales/th/LC_MESSAGES/volto.po +5 -0
- package/locales/th.json +1 -1
- package/locales/to/LC_MESSAGES/volto.po +5 -0
- package/locales/to.json +1 -1
- package/locales/tr/LC_MESSAGES/volto.po +5 -0
- package/locales/tr.json +1 -1
- package/locales/uk/LC_MESSAGES/volto.po +5 -0
- package/locales/uk.json +1 -1
- package/locales/vi/LC_MESSAGES/volto.po +5 -0
- package/locales/vi.json +1 -1
- package/locales/volto.pot +6 -1
- package/locales/zh_CN/LC_MESSAGES/volto.po +5 -0
- package/locales/zh_CN.json +1 -1
- package/locales/zh_Hant/LC_MESSAGES/volto.po +5 -0
- package/locales/zh_Hant.json +1 -1
- package/locales/zh_Hant_HK/LC_MESSAGES/volto.po +5 -0
- package/locales/zh_Hant_HK.json +1 -1
- package/package.json +6 -6
- package/src/actions/querystringsearch/querystringsearch.test.js +107 -0
- package/src/actions/querystringsearch/querystringsearch.ts +135 -0
- package/src/components/manage/Blocks/Listing/getAsyncData.js +5 -0
- package/src/components/manage/Blocks/Listing/withQuerystringResults.jsx +18 -5
- package/src/components/manage/Widgets/QuerystringWidget.jsx +18 -1
- package/src/components/manage/Widgets/QuerystringWidget.test.jsx +11 -0
- package/src/config/server.js +2 -0
- package/src/express-middleware/images.js +0 -1
- package/src/express-middleware/portraits.js +34 -0
- package/src/helpers/Api/PloneBackendAPIResourceWithAuth.js +39 -0
- package/src/helpers/Api/PloneBackendAPIResourceWithAuth.test.js +60 -0
- package/src/helpers/Pagination/Pagination.test.ts +259 -0
- package/src/helpers/Pagination/Pagination.ts +151 -0
- package/types/actions/querystringsearch/querystringsearch.d.ts +51 -3
- package/types/components/manage/Widgets/QuerystringWidget.d.ts +6 -0
- package/types/express-middleware/portraits.d.ts +1 -0
- package/types/helpers/Api/PloneBackendAPIResourceWithAuth.d.ts +1 -0
- package/types/helpers/Pagination/Pagination.d.ts +74 -0
- package/src/actions/querystringsearch/querystringsearch.js +0 -63
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pagination helpers.
|
|
3
|
+
* @module helpers/Pagination/Pagination
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* A value that is meant to represent an integer, but which reaches us from
|
|
7
|
+
* user-editable block settings. The querystring widget stores `offset`,
|
|
8
|
+
* `limit` and `b_size` as JSON schema `number` fields, so a value may arrive
|
|
9
|
+
* as a string (`'3'`), as a float (`3.7`), or not at all.
|
|
10
|
+
*/
|
|
11
|
+
export type IntegerLike = number | string | null | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Compute the `b_start` index for a `@querystring-search` request: the index
|
|
14
|
+
* of the first item the backend should return for the requested page.
|
|
15
|
+
*
|
|
16
|
+
* `offset` shifts the whole result set, letting a listing skip the first N
|
|
17
|
+
* items of its query while paginating over the remainder.
|
|
18
|
+
*
|
|
19
|
+
* Every parameter is coerced to an integer and the result is always a
|
|
20
|
+
* non-negative integer, so a malformed block setting degrades to a sane batch
|
|
21
|
+
* rather than sending `NaN` to the backend. When neither `bSize` nor
|
|
22
|
+
* `defaultPageSize` yields a positive batch size, paging cannot be applied and
|
|
23
|
+
* the result is `offset` alone.
|
|
24
|
+
* @function computeBStart
|
|
25
|
+
* @param {IntegerLike} page 1-based page number. Defaults to the first page.
|
|
26
|
+
* @param {IntegerLike} offset Number of leading items to skip. Defaults to 0.
|
|
27
|
+
* @param {IntegerLike} bSize Batch size configured on the block, if any.
|
|
28
|
+
* @param {IntegerLike} defaultPageSize Batch size to use when bSize is unset.
|
|
29
|
+
* @returns {number} A non-negative integer `b_start` index.
|
|
30
|
+
*/
|
|
31
|
+
export declare function computeBStart(page: IntegerLike, offset: IntegerLike, bSize: IntegerLike, defaultPageSize: IntegerLike): number;
|
|
32
|
+
/**
|
|
33
|
+
* Compute the effective `limit` for a `@querystring-search` request.
|
|
34
|
+
*
|
|
35
|
+
* A listing that skips the first `offset` items still wants `limit` items
|
|
36
|
+
* afterwards, so the backend has to return the skipped items on top of the
|
|
37
|
+
* wanted ones: `offset + limit`.
|
|
38
|
+
*
|
|
39
|
+
* A limit of zero, or one that resolves to no usable number, means "no limit"
|
|
40
|
+
* — matching `plone.app.querystring`'s querybuilder, whose `limit` defaults to
|
|
41
|
+
* 0 and is only applied when truthy. Returning `offset` in that case would cap
|
|
42
|
+
* the batch at the very items the listing is about to skip, leaving it empty.
|
|
43
|
+
* @function computeLimit
|
|
44
|
+
* @param {IntegerLike} offset Number of leading items to skip. Defaults to 0.
|
|
45
|
+
* @param {IntegerLike} limit Number of items the listing wants, if capped.
|
|
46
|
+
* @returns {number | null} A positive integer limit, or null for no limit.
|
|
47
|
+
*/
|
|
48
|
+
export declare function computeLimit(offset: IntegerLike, limit: IntegerLike): number | null;
|
|
49
|
+
/**
|
|
50
|
+
* Compute how many items a listing can actually show.
|
|
51
|
+
*
|
|
52
|
+
* The `items_total` reported by `@querystring-search` is the length of the
|
|
53
|
+
* whole result set: `plone.restapi`'s HypermediaBatch derives it from the
|
|
54
|
+
* sequence length, so `b_start` never reduces it. The items an offset skips
|
|
55
|
+
* are counted in there even though the listing never renders them.
|
|
56
|
+
* @function computeVisibleTotal
|
|
57
|
+
* @param {IntegerLike} total The `items_total` reported by the backend.
|
|
58
|
+
* @param {IntegerLike} offset Number of leading items skipped. Defaults to 0.
|
|
59
|
+
* @returns {number} A non-negative integer count of reachable items.
|
|
60
|
+
*/
|
|
61
|
+
export declare function computeVisibleTotal(total: IntegerLike, offset: IntegerLike): number;
|
|
62
|
+
/**
|
|
63
|
+
* Compute how many pages a listing spans.
|
|
64
|
+
*
|
|
65
|
+
* `total` is expected to be the reachable item count, so pass the result of
|
|
66
|
+
* `computeVisibleTotal` for an offset listing rather than the raw backend
|
|
67
|
+
* total. Otherwise the listing advertises pages that resolve to an empty batch.
|
|
68
|
+
* @function computeTotalPages
|
|
69
|
+
* @param {IntegerLike} total Number of items the listing can show.
|
|
70
|
+
* @param {IntegerLike} bSize Batch size, i.e. items per page.
|
|
71
|
+
* @returns {number} A non-negative integer page count, 0 when there is no
|
|
72
|
+
* usable batch size.
|
|
73
|
+
*/
|
|
74
|
+
export declare function computeTotalPages(total: IntegerLike, bSize: IntegerLike): number;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { GET_QUERYSTRING_RESULTS } from '@plone/volto/constants/ActionTypes';
|
|
2
|
-
import config from '@plone/volto/registry';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Get querystring results.
|
|
6
|
-
* @function getQueryStringResults
|
|
7
|
-
* @param {Object} data Data.
|
|
8
|
-
* @returns {Object} Get querystringsearch results action.
|
|
9
|
-
*/
|
|
10
|
-
export function getQueryStringResults(path, data, subrequest, page) {
|
|
11
|
-
const { settings } = config;
|
|
12
|
-
|
|
13
|
-
// fixes https://github.com/plone/volto/issues/1059
|
|
14
|
-
let requestData = JSON.parse(JSON.stringify(data));
|
|
15
|
-
|
|
16
|
-
if (data?.depth != null) {
|
|
17
|
-
delete requestData.depth;
|
|
18
|
-
requestData.query.forEach((q) => {
|
|
19
|
-
if (q.i === 'path') {
|
|
20
|
-
// fixes https://github.com/plone/volto/issues/8349
|
|
21
|
-
// Skip if depth is already embedded in the path value (e.g. set via object browser)
|
|
22
|
-
const hasEmbeddedDepth = /::\d+$/.test(q.v);
|
|
23
|
-
if (!hasEmbeddedDepth) q.v += '::' + data.depth;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// fixes https://github.com/plone/volto/issues/2397
|
|
29
|
-
if (requestData?.sort_order !== null) {
|
|
30
|
-
if (typeof requestData.sort_order === 'boolean') {
|
|
31
|
-
requestData.sort_order = requestData.sort_order
|
|
32
|
-
? 'descending'
|
|
33
|
-
: 'ascending';
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const query = {
|
|
38
|
-
...requestData,
|
|
39
|
-
...(!requestData.b_size && {
|
|
40
|
-
b_size: settings.defaultPageSize,
|
|
41
|
-
}),
|
|
42
|
-
...(page && {
|
|
43
|
-
b_start: requestData.b_size
|
|
44
|
-
? data.b_size * (page - 1)
|
|
45
|
-
: settings.defaultPageSize * (page - 1),
|
|
46
|
-
}),
|
|
47
|
-
query: requestData?.query,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
type: GET_QUERYSTRING_RESULTS,
|
|
52
|
-
subrequest,
|
|
53
|
-
request: {
|
|
54
|
-
op: settings.querystringSearchGet ? 'get' : 'post',
|
|
55
|
-
path: `${path}/@querystring-search${
|
|
56
|
-
settings.querystringSearchGet
|
|
57
|
-
? `?query=${encodeURIComponent(JSON.stringify(query))}`
|
|
58
|
-
: ''
|
|
59
|
-
}`,
|
|
60
|
-
data: settings.querystringSearchGet ? null : query,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
}
|