« get me outta code hell

GroupCategory.js « group « things « data « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/group/GroupCategory.js
blob: daf31868964d9255392f64b1dc8a5663bfef2e9c (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
import {input, V} from '#composite';
import Thing from '#thing';

import {exposeConstant} from '#composite/control-flow';

import {color, directory, flag, name, referenceList, soupyFind}
  from '#composite/wiki-properties';

export class GroupCategory extends Thing {
  static [Thing.referenceType] = 'group-category';
  static [Thing.friendlyName] = `Group Category`;
  static [Thing.wikiData] = 'groupCategoryData';

  static [Thing.getPropertyDescriptors] = ({Group}) => ({
    // Update & expose

    name: name(V('Unnamed Group Category')),
    directory: directory(),

    excludeGroupsFromGalleryTabs: flag(V(false)),

    color: color(),

    groups: referenceList({
      class: input.value(Group),
      find: soupyFind.input('group'),
    }),

    // Update only

    find: soupyFind(),

    // Expose only

    isGroupCategory: exposeConstant(V(true)),
  });

  static [Thing.reverseSpecs] = {
    groupCategoriesWhichInclude: {
      bindTo: 'groupCategoryData',

      referencing: groupCategory => [groupCategory],
      referenced: groupCategory => groupCategory.groups,
    },
  };

  static [Thing.yamlDocumentSpec] = {
    fields: {
      'Category': {property: 'name'},

      'Color': {property: 'color'},

      'Exclude Groups From Gallery Tabs': {
        property: 'excludeGroupsFromGalleryTabs',
      },
    },
  };
}