@pnp/sp
Version:
pnp - provides a fluent api for working with SharePoint REST
26 lines • 847 B
JavaScript
import { hOP } from "@pnp/core";
/**
* Gets the next order value 1 based for the provided collection
*
* @param collection Collection of orderable things
*/
export function getNextOrder(collection) {
return collection.length < 1 ? 1 : (Math.max.apply(null, collection.map(i => i.order)) + 1);
}
/**
* Normalizes the order value for all the sections, columns, and controls to be 1 based and stepped (1, 2, 3...)
*
* @param collection The collection to normalize
*/
export function reindex(collection) {
for (let i = 0; i < collection.length; i++) {
collection[i].order = i + 1;
if (hOP(collection[i], "columns")) {
reindex(collection[i].columns);
}
else if (hOP(collection[i], "controls")) {
reindex(collection[i].controls);
}
}
}
//# sourceMappingURL=funcs.js.map