« get me outta code hell

contribsPresent.js « wiki-properties « composite « data « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/wiki-properties/contribsPresent.js
blob: 24f302a5af9a526ed9f39eccb0002e24f40da240 (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
// Nice 'n simple shorthand for an exposed-only flag which is true when any
// contributions are present in the specified property.

import {input, templateCompositeFrom} from '#composite';
import {isContributionList} from '#validators';

import {exposeDependency, withResultOfAvailabilityCheck}
  from '#composite/control-flow';

export default templateCompositeFrom({
  annotation: `contribsPresent`,

  compose: false,

  inputs: {
    contribs: input.staticDependency({
      validate: isContributionList,
      acceptsNull: true,
    }),
  },

  steps: () => [
    withResultOfAvailabilityCheck({
      from: input('contribs'),
      mode: input.value('empty'),
    }),

    exposeDependency({dependency: '#availability'}),
  ],
});