« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/flash/FlashAct.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/things/flash/FlashAct.js')
-rw-r--r--src/data/things/flash/FlashAct.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/data/things/flash/FlashAct.js b/src/data/things/flash/FlashAct.js
new file mode 100644
index 00000000..66d4ee1b
--- /dev/null
+++ b/src/data/things/flash/FlashAct.js
@@ -0,0 +1,74 @@
+
+import {input, V} from '#composite';
+import Thing from '#thing';
+import {isContentString} from '#validators';
+
+import {withPropertyFromObject} from '#composite/data';
+import {exposeConstant, exposeDependency, exposeUpdateValueOrContinue}
+  from '#composite/control-flow';
+import {color, directory, name, soupyFind, soupyReverse, thing, thingList}
+  from '#composite/wiki-properties';
+
+export class FlashAct extends Thing {
+  static [Thing.referenceType] = 'flash-act';
+  static [Thing.friendlyName] = `Flash Act`;
+  static [Thing.wikiData] = 'flashActData';
+
+  static [Thing.getPropertyDescriptors] = ({Flash, FlashSide}) => ({
+    // Update & expose
+
+    side: thing(V(FlashSide)),
+
+    name: name(V('Unnamed Flash Act')),
+    directory: directory(),
+    color: color(),
+
+    listTerminology: [
+      exposeUpdateValueOrContinue({
+        validate: input.value(isContentString),
+      }),
+
+      withPropertyFromObject('side', V('listTerminology')),
+      exposeDependency('#side.listTerminology'),
+    ],
+
+    flashes: thingList(V(Flash)),
+
+    // Update only
+
+    find: soupyFind(),
+    reverse: soupyReverse(),
+
+    // Expose only
+
+    isFlashAct: exposeConstant(V(true)),
+  });
+
+  static [Thing.findSpecs] = {
+    flashAct: {
+      referenceTypes: ['flash-act'],
+      bindTo: 'flashActData',
+    },
+  };
+
+  static [Thing.reverseSpecs] = {
+    flashActsWhoseFlashesInclude: {
+      bindTo: 'flashActData',
+
+      referencing: flashAct => [flashAct],
+      referenced: flashAct => flashAct.flashes,
+    },
+  };
+
+  static [Thing.yamlDocumentSpec] = {
+    fields: {
+      'Act': {property: 'name'},
+      'Directory': {property: 'directory'},
+
+      'Color': {property: 'color'},
+      'List Terminology': {property: 'listTerminology'},
+
+      'Review Points': {ignore: true},
+    },
+  };
+}