diff options
Diffstat (limited to 'src/data')
-rw-r--r-- | src/data/things/homepage-layout.js | 14 | ||||
-rw-r--r-- | src/data/things/validators.js | 10 | ||||
-rw-r--r-- | src/data/yaml.js | 1 |
3 files changed, 25 insertions, 0 deletions
diff --git a/src/data/things/homepage-layout.js b/src/data/things/homepage-layout.js index 5948ff46..32b8cf2a 100644 --- a/src/data/things/homepage-layout.js +++ b/src/data/things/homepage-layout.js @@ -65,6 +65,7 @@ export class HomepageLayoutAlbumsRow extends HomepageLayoutRow { isCountingNumber, isString, validateArrayItems, + validateFromConstants, }, } = opts) => ({ ...HomepageLayoutRow[Thing.getPropertyDescriptors](opts), @@ -84,6 +85,19 @@ export class HomepageLayoutAlbumsRow extends HomepageLayoutRow { }, }, + displayStyle: { + flags: {update: true, expose: true}, + + update: { + validate: validateFromConstants('grid', 'montage'), + }, + + expose: { + transform: (displayStyle) => + displayStyle ?? 'grid', + }, + }, + sourceGroupByRef: Thing.common.singleReference(Group), sourceAlbumsByRef: Thing.common.referenceList(Album), diff --git a/src/data/things/validators.js b/src/data/things/validators.js index cc603d48..a0d473ba 100644 --- a/src/data/things/validators.js +++ b/src/data/things/validators.js @@ -162,6 +162,16 @@ export function validateInstanceOf(constructor) { return (object) => isInstance(object, constructor); } +export function validateFromConstants(...values) { + return (value) => { + if (!values.includes(value)) { + throw new TypeError(`Expected one of ${values.join(', ')}`); + } + + return true; + }; +} + // Wiki data (primitives & non-primitives) export function isColor(color) { diff --git a/src/data/yaml.js b/src/data/yaml.js index ae160d59..f967cee3 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -421,6 +421,7 @@ export function makeProcessHomepageLayoutRowDocument(rowClass, spec) { export const homepageLayoutRowTypeProcessMapping = { albums: makeProcessHomepageLayoutRowDocument(T.HomepageLayoutAlbumsRow, { propertyFieldMapping: { + displayStyle: 'Display Style', sourceGroupByRef: 'Group', countAlbumsFromGroup: 'Count', sourceAlbumsByRef: 'Albums', |