From 0fb2784f7b7d02df3c25db49ec43d2b178035bbe Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 15 Aug 2024 12:01:23 -0300 Subject: data: Contribution.associatedContributions: segregate wiki edits --- src/data/things/contribution.js | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'src/data/things/contribution.js') diff --git a/src/data/things/contribution.js b/src/data/things/contribution.js index 79acf1e1..82ec1db3 100644 --- a/src/data/things/contribution.js +++ b/src/data/things/contribution.js @@ -8,10 +8,16 @@ import Thing from '#thing'; import {isStringNonEmpty, isThing, validateReference} from '#validators'; import {exitWithoutDependency, exposeDependency} from '#composite/control-flow'; -import {withNearbyItemFromList, withPropertyFromObject} from '#composite/data'; import {withResolvedReference} from '#composite/wiki-data'; import {flag, simpleDate} from '#composite/wiki-properties'; +import { + withFilteredList, + withNearbyItemFromList, + withPropertyFromList, + withPropertyFromObject, +} from '#composite/data'; + import { inheritFromContributionPresets, thingPropertyMatches, @@ -123,10 +129,38 @@ export class Contribution extends Thing { withPropertyFromObject({ object: 'thing', property: 'thingProperty', + }).outputs({ + '#value': '#contributions', + }), + + withPropertyFromList({ + list: '#contributions', + property: input.value('annotation'), + }), + + { + dependencies: ['#contributions.annotation', 'annotation'], + compute: (continuation, { + ['#contributions.annotation']: contributionAnnotations, + ['annotation']: annotation, + }) => continuation({ + ['#likeContributionsFilter']: + contributionAnnotations.map(mappingAnnotation => + (annotation === 'edits for wiki' + ? mappingAnnotation === annotation + : mappingAnnotation !== 'edits for wiki')), + }), + }, + + withFilteredList({ + list: '#contributions', + filter: '#likeContributionsFilter', + }).outputs({ + '#filteredList': '#contributions', }), exposeDependency({ - dependency: '#value', + dependency: '#contributions', }), ], -- cgit 1.3.0-6-gf8a5