« get me outta code hell

FlashAct.js « flash « things « data « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/flash/FlashAct.js
blob: 66d4ee1b39a9f5bb14e1ce14b9d38126c9b82e59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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},
    },
  };
}