« get me outta code hell

data: Artwork: withAttachedArtwork & friends - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/things/artwork/withAttachedArtwork.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-04-23 14:40:15 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-04-23 14:40:24 -0300
commit0df2ba538cfced993ec6794a589512302a62373d (patch)
tree342d6cce5acd37555940a483b3c1aefb3222394a /src/data/composite/things/artwork/withAttachedArtwork.js
parentca8121c2225fe7dfa97c604ca08ae241e5fe84d7 (diff)
data: Artwork: withAttachedArtwork & friends
Diffstat (limited to 'src/data/composite/things/artwork/withAttachedArtwork.js')
-rw-r--r--src/data/composite/things/artwork/withAttachedArtwork.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/data/composite/things/artwork/withAttachedArtwork.js b/src/data/composite/things/artwork/withAttachedArtwork.js
new file mode 100644
index 00000000..d7c0d87b
--- /dev/null
+++ b/src/data/composite/things/artwork/withAttachedArtwork.js
@@ -0,0 +1,43 @@
+import {input, templateCompositeFrom} from '#composite';
+
+import {flipFilter, raiseOutputWithoutDependency}
+  from '#composite/control-flow';
+import {withNearbyItemFromList, withPropertyFromList} from '#composite/data';
+
+import withContainingArtworkList from './withContainingArtworkList.js';
+
+export default templateCompositeFrom({
+  annotaion: `withContribsFromMainArtwork`,
+
+  outputs: ['#attachedArtwork'],
+
+  steps: () => [
+    raiseOutputWithoutDependency({
+      dependency: 'attachAbove',
+      mode: input.value('falsy'),
+      output: input.value({'#attachedArtwork': null}),
+    }),
+
+    withContainingArtworkList(),
+
+    withPropertyFromList({
+      list: '#containingArtworkList',
+      property: input.value('attachAbove'),
+    }),
+
+    flipFilter({
+      filter: '#containingArtworkList.attachAbove',
+    }).outputs({
+      '#containingArtworkList.attachAbove': '#filterNotAttached',
+    }),
+
+    withNearbyItemFromList({
+      list: '#containingArtworkList',
+      item: input.myself(),
+      offset: input.value(-1),
+      filter: '#filterNotAttached',
+    }).outputs({
+      '#nearbyItem': '#attachedArtwork',
+    }),
+  ],
+});