« get me outta code hell

data: HomepageLayout: make 'type' expose-only - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-02-11 10:44:34 -0400
committer(quasar) nebula <qznebula@protonmail.com>2025-02-12 07:43:59 -0400
commitea4cd3278454f6ff4bd869de1fd44eef42f0476b (patch)
tree673465d271c5ab38e26ff7c2bae022e90d936cd1 /src
parent26c9f3a8feb3803322a14f6f980f96ab62676b35 (diff)
data: HomepageLayout: make 'type' expose-only
Diffstat (limited to 'src')
-rw-r--r--src/data/things/homepage-layout.js45
1 files changed, 18 insertions, 27 deletions
diff --git a/src/data/things/homepage-layout.js b/src/data/things/homepage-layout.js
index 97e481f8..3287d6f0 100644
--- a/src/data/things/homepage-layout.js
+++ b/src/data/things/homepage-layout.js
@@ -164,16 +164,6 @@ export class HomepageLayoutRow extends Thing {
   static [Thing.getPropertyDescriptors] = ({HomepageLayoutSection}) => ({
     // Update & expose
 
-    type: {
-      flags: {update: true, expose: true},
-
-      update: {
-        validate() {
-          throw new Error(`'type' property validator must be overridden`);
-        },
-      },
-    },
-
     section: thing({
       class: input.value(HomepageLayoutSection),
     }),
@@ -181,11 +171,23 @@ export class HomepageLayoutRow extends Thing {
     // Update only
 
     find: soupyFind(),
+
+    // Expose only
+
+    type: {
+      flags: {expose: true},
+
+      expose: {
+        compute() {
+          throw new Error(`'type' property validator must be overridden`);
+        },
+      },
+    },
   });
 
   static [Thing.yamlDocumentSpec] = {
     fields: {
-      'Row': {property: 'type'},
+      'Row': {ignore: true},
     },
   };
 
@@ -216,19 +218,6 @@ export class HomepageLayoutAlbumsRow extends HomepageLayoutRow {
 
     // Update & expose
 
-    type: {
-      flags: {update: true, expose: true},
-      update: {
-        validate(value) {
-          if (value !== 'albums') {
-            throw new TypeError(`Expected 'albums'`);
-          }
-
-          return true;
-        },
-      },
-    },
-
     displayStyle: {
       flags: {update: true, expose: true},
 
@@ -279,9 +268,11 @@ export class HomepageLayoutAlbumsRow extends HomepageLayoutRow {
       update: {validate: isCountingNumber},
     },
 
-    actionLinks: {
-      flags: {update: true, expose: true},
-      update: {validate: validateArrayItems(isString)},
+    // Expose only
+
+    type: {
+      flags: {expose: true},
+      expose: {compute: () => 'albums'},
     },
   });