diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/content/dependencies/generateArtistInfoPageTracksChunkItem.js | 9 | ||||
-rw-r--r-- | src/data/composite/things/contribution/index.js | 2 | ||||
-rw-r--r-- | src/data/composite/things/contribution/thingPropertyMatches.js | 33 | ||||
-rw-r--r-- | src/data/composite/things/contribution/thingReferenceTypeMatches.js | 39 | ||||
-rw-r--r-- | src/data/things/contribution.js | 34 | ||||
-rw-r--r-- | src/util/wiki-data.js | 12 |
6 files changed, 112 insertions, 17 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageTracksChunkItem.js b/src/content/dependencies/generateArtistInfoPageTracksChunkItem.js index 9674eb4f..d7460c80 100644 --- a/src/content/dependencies/generateArtistInfoPageTracksChunkItem.js +++ b/src/content/dependencies/generateArtistInfoPageTracksChunkItem.js @@ -1,5 +1,4 @@ import {empty} from '#sugar'; -import {isArtistContribution, isContributorContribution} from '#wiki-data'; export default { contentDependencies: [ @@ -20,11 +19,11 @@ export default { const creditedAsArtist = contribs - .some(isArtistContribution); + .some(contrib => contrib.isArtistContribution); const creditedAsContributor = contribs - .some(isContributorContribution); + .some(contrib => contrib.isContributorContribution); const annotatedContribs = contribs @@ -32,11 +31,11 @@ export default { const annotatedArtistContribs = annotatedContribs - .filter(isArtistContribution); + .filter(contrib => contrib.isArtistContribution); const annotatedContributorContribs = annotatedContribs - .filter(isContributorContribution); + .filter(contrib => contrib.isContributorContribution); // Don't display annotations associated with crediting in the // Contributors field if the artist is also credited as an Artist diff --git a/src/data/composite/things/contribution/index.js b/src/data/composite/things/contribution/index.js index 2cc69254..2c812644 100644 --- a/src/data/composite/things/contribution/index.js +++ b/src/data/composite/things/contribution/index.js @@ -1,4 +1,6 @@ export {default as inheritFromContributionPresets} from './inheritFromContributionPresets.js'; +export {default as thingPropertyMatches} from './thingPropertyMatches.js'; +export {default as thingReferenceTypeMatches} from './thingReferenceTypeMatches.js'; export {default as withContributionArtist} from './withContributionArtist.js'; export {default as withContributionContext} from './withContributionContext.js'; export {default as withMatchingContributionPresets} from './withMatchingContributionPresets.js'; diff --git a/src/data/composite/things/contribution/thingPropertyMatches.js b/src/data/composite/things/contribution/thingPropertyMatches.js new file mode 100644 index 00000000..4a37f2cf --- /dev/null +++ b/src/data/composite/things/contribution/thingPropertyMatches.js @@ -0,0 +1,33 @@ +import {input, templateCompositeFrom} from '#composite'; + +import {exitWithoutDependency} from '#composite/control-flow'; + +export default templateCompositeFrom({ + annotation: `thingPropertyMatches`, + + compose: false, + + inputs: { + value: input({type: 'string'}), + }, + + steps: () => [ + exitWithoutDependency({ + dependency: 'thingProperty', + value: input.value(false), + }), + + { + dependencies: [ + 'thingProperty', + input('value'), + ], + + compute: ({ + ['thingProperty']: thingProperty, + [input('value')]: value, + }) => + thingProperty === value, + }, + ], +}); diff --git a/src/data/composite/things/contribution/thingReferenceTypeMatches.js b/src/data/composite/things/contribution/thingReferenceTypeMatches.js new file mode 100644 index 00000000..2ee811af --- /dev/null +++ b/src/data/composite/things/contribution/thingReferenceTypeMatches.js @@ -0,0 +1,39 @@ +import {input, templateCompositeFrom} from '#composite'; + +import {exitWithoutDependency} from '#composite/control-flow'; +import {withPropertyFromObject} from '#composite/data'; + +export default templateCompositeFrom({ + annotation: `thingReferenceTypeMatches`, + + compose: false, + + inputs: { + value: input({type: 'string'}), + }, + + steps: () => [ + exitWithoutDependency({ + dependency: 'thing', + value: input.value(false), + }), + + withPropertyFromObject({ + object: 'thing', + property: input.value('constructor'), + }), + + { + dependencies: [ + '#thing.constructor', + input('value'), + ], + + compute: ({ + ['#thing.constructor']: constructor, + [input('value')]: value, + }) => + constructor[Symbol.for('Thing.referenceType')] === value, + }, + ], +}); diff --git a/src/data/things/contribution.js b/src/data/things/contribution.js index 7b1518ab..9d6a9711 100644 --- a/src/data/things/contribution.js +++ b/src/data/things/contribution.js @@ -14,6 +14,8 @@ import {flag, simpleDate} from '#composite/wiki-properties'; import { inheritFromContributionPresets, + thingPropertyMatches, + thingReferenceTypeMatches, withContributionArtist, withContributionContext, withMatchingContributionPresets, @@ -121,6 +123,38 @@ export class Contribution extends Thing { dependency: '#value', }), ], + + isArtistContribution: thingPropertyMatches({ + value: input.value('artistContribs'), + }), + + isContributorContribution: thingPropertyMatches({ + value: input.value('contributorContribs'), + }), + + isCoverArtistContribution: thingPropertyMatches({ + value: input.value('coverArtistContribs'), + }), + + isBannerArtistContribution: thingPropertyMatches({ + value: input.value('bannerArtistContribs'), + }), + + isWallpaperArtistContribution: thingPropertyMatches({ + value: input.value('wallpaperArtistContribs'), + }), + + isForTrack: thingReferenceTypeMatches({ + value: input.value('track'), + }), + + isForAlbum: thingReferenceTypeMatches({ + value: input.value('album'), + }), + + isForFlash: thingReferenceTypeMatches({ + value: input.value('flash'), + }), }); [inspect.custom](depth, options, inspect) { diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js index 8a2c44cd..f8ab3ef3 100644 --- a/src/util/wiki-data.js +++ b/src/util/wiki-data.js @@ -271,18 +271,6 @@ export function getNewReleases(numReleases, {albumData}) { .slice(0, numReleases); } -export function isArtistContribution(contrib) { - return contrib.thingProperty === 'artistContribs'; -} - -export function isContributorContribution(contrib) { - return contrib.thingProperty === 'contributorContribs'; -} - -export function isCoverArtistContribution(contrib) { - return contrib.thingProperty === 'coverArtistContribs'; -} - // Carousel layout and utilities // Layout constants: |