UNPKG

847 BJavaScriptView Raw
1import { hOP } from "@pnp/core";
2/**
3 * Gets the next order value 1 based for the provided collection
4 *
5 * @param collection Collection of orderable things
6 */
7export function getNextOrder(collection) {
8 return collection.length < 1 ? 1 : (Math.max.apply(null, collection.map(i => i.order)) + 1);
9}
10/**
11 * Normalizes the order value for all the sections, columns, and controls to be 1 based and stepped (1, 2, 3...)
12 *
13 * @param collection The collection to normalize
14 */
15export function reindex(collection) {
16 for (let i = 0; i < collection.length; i++) {
17 collection[i].order = i + 1;
18 if (hOP(collection[i], "columns")) {
19 reindex(collection[i].columns);
20 }
21 else if (hOP(collection[i], "controls")) {
22 reindex(collection[i].controls);
23 }
24 }
25}
26//# sourceMappingURL=funcs.js.map
\No newline at end of file