diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2022-12-22 22:33:24 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2022-12-22 22:33:24 -0400 |
commit | 215aa2577d9d2e0812a8c42c90bd1d7ba83d2028 (patch) | |
tree | bf7d2b36ec9f1fbb2dcea0fcfaf165d367b7fa92 /src/data | |
parent | e6f233025c0e511bb472bb75540d50381b58db48 (diff) |
many homepage carousel shenanigans
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', |