diff options
Diffstat (limited to 'src/data/composite/wiki-properties')
-rw-r--r-- | src/data/composite/wiki-properties/directory.js | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/src/data/composite/wiki-properties/directory.js b/src/data/composite/wiki-properties/directory.js index 0b2181c9..41ce4b27 100644 --- a/src/data/composite/wiki-properties/directory.js +++ b/src/data/composite/wiki-properties/directory.js @@ -2,22 +2,32 @@ // almost any data object. Also corresponds to a part of the URL which pages of // such objects are visited at. -import {isDirectory} from '#validators'; -import {getKebabCase} from '#wiki-data'; - -// TODO: Not templateCompositeFrom. - -export default function() { - return { - flags: {update: true, expose: true}, - update: {validate: isDirectory}, - expose: { - dependencies: ['name'], - transform(directory, {name}) { - if (directory === null && name === null) return null; - else if (directory === null) return getKebabCase(name); - else return directory; - }, - }, - }; -} +import {input, templateCompositeFrom} from '#composite'; + +import {isDirectory, isName} from '#validators'; + +import {exposeDependency} from '#composite/control-flow'; +import {withDirectory} from '#composite/wiki-data'; + +export default templateCompositeFrom({ + annotation: `directory`, + + compose: false, + + inputs: { + name: input({ + validate: isName, + defaultDependency: 'name', + }), + }, + + steps: () => [ + withDirectory({ + directory: input.updateValue({validate: isDirectory}), + }), + + exposeDependency({ + dependency: '#directory', + }), + ], +}); |