diff options
Diffstat (limited to 'src/content/dependencies')
-rw-r--r-- | src/content/dependencies/generateReleaseInfoContributionsLine.js | 74 | ||||
-rw-r--r-- | src/content/dependencies/generateReleaseInfoContributionsLineWikiEditsPart.js | 52 |
2 files changed, 103 insertions, 23 deletions
diff --git a/src/content/dependencies/generateReleaseInfoContributionsLine.js b/src/content/dependencies/generateReleaseInfoContributionsLine.js index 3e96ed44..ee817f08 100644 --- a/src/content/dependencies/generateReleaseInfoContributionsLine.js +++ b/src/content/dependencies/generateReleaseInfoContributionsLine.js @@ -1,20 +1,37 @@ import {empty} from '#sugar'; export default { - contentDependencies: ['linkContribution'], + contentDependencies: [ + 'generateReleaseInfoContributionsLineWikiEditsPart', + 'linkContribution', + ], + extraDependencies: ['html', 'language'], - relations(relation, contributions) { - if (empty(contributions)) { - return {}; - } + query: (contributions) => ({ + normalContributions: + contributions + .filter(contrib => contrib.annotation !== 'edits for wiki'), - return { - contributionLinks: - contributions - .map(contrib => relation('linkContribution', contrib)), - }; - }, + wikiEditContributions: + contributions + .filter(contrib => contrib.annotation === 'edits for wiki'), + }), + + relations: (relation, query, _contributions) => ({ + contributionLinks: + query.normalContributions + .map(contrib => relation('linkContribution', contrib)), + + wikiEditsPart: + relation('generateReleaseInfoContributionsLineWikiEditsPart', + query.wikiEditContributions), + }), + + data: (query, _contributions) => ({ + hasWikiEdits: + !empty(query.wikiEditContributions), + }), slots: { showContribution: {type: 'boolean', default: true}, @@ -25,21 +42,32 @@ export default { chronologyKind: {type: 'string'}, }, - generate(relations, slots, {html, language}) { - if (!relations.contributionLinks) { - return html.blank(); - } + generate(data, relations, slots, {language}) { + const contributionsList = + language.formatConjunctionList( + relations.contributionLinks.map(link => + link.slots({ + showContribution: slots.showContribution, + showExternalLinks: slots.showExternalLinks, + showChronology: slots.showChronology, + chronologyKind: slots.chronologyKind, + }))); return language.$(slots.stringKey, { + [language.onlyIfOptions]: ['artists'], + artists: - language.formatConjunctionList( - relations.contributionLinks.map(link => - link.slots({ - showContribution: slots.showContribution, - showExternalLinks: slots.showExternalLinks, - showChronology: slots.showChronology, - chronologyKind: slots.chronologyKind, - }))), + (data.hasWikiEdits + ? language.encapsulate('misc.artistLink.withEditsForWiki', capsule => + language.$(capsule, { + // It's nonsense to display "+ edits" without + // having any regular contributions, also. + [language.onlyIfOptions]: ['artists'], + + artists: contributionsList, + edits: relations.wikiEditsPart, + })) + : contributionsList), }); }, }; diff --git a/src/content/dependencies/generateReleaseInfoContributionsLineWikiEditsPart.js b/src/content/dependencies/generateReleaseInfoContributionsLineWikiEditsPart.js new file mode 100644 index 00000000..37f29b1c --- /dev/null +++ b/src/content/dependencies/generateReleaseInfoContributionsLineWikiEditsPart.js @@ -0,0 +1,52 @@ +export default { + contentDependencies: [ + 'generateTextWithTooltip', + 'generateTooltip', + 'linkContribution', + ], + + extraDependencies: ['html', 'language'], + + relations: (relation, contributions) => ({ + textWithTooltip: + relation('generateTextWithTooltip'), + + tooltip: + relation('generateTooltip'), + + contributionLinks: + contributions + .map(contrib => relation('linkContribution', contrib)), + }), + + generate: (relations, {html, language}) => + language.encapsulate('misc.artistLink.withEditsForWiki', capsule => + relations.textWithTooltip.slots({ + attributes: + {class: 'wiki-edits'}, + + text: + language.$(capsule, 'edits'), + + tooltip: + relations.tooltip.slots({ + attributes: + {class: 'wiki-edits-tooltip'}, + + content: + html.tags( + relations.contributionLinks.map(link => + language.$(capsule, 'editsLine', { + artist: + link.slots({ + showContribution: false, + showExternalLinks: false, + showChronology: false, + preventTooltip: true, + }), + })), + + {[html.joinChildren]: html.tag('br')}), + }), + })), +}; |