1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
import {empty} from '#sugar';
export default {
contentDependencies: [
'generateAbsoluteDatetimestamp',
'generateArtistCredit',
'generateColorStyleAttribute',
'linkAlbum',
'linkGroup',
],
extraDependencies: ['html', 'language'],
query: (album, group) => {
const otherCategory =
album.groups
.map(group => group.category)
.find(category => category !== group.category);
const otherGroups =
album.groups
.filter(group => group.category === otherCategory);
return {otherGroups};
},
relations: (relation, query, album, _group) => ({
colorStyle:
relation('generateColorStyleAttribute', album.color),
albumLink:
relation('linkAlbum', album),
datetimestamp:
(album.date
? relation('generateAbsoluteDatetimestamp', album.date)
: null),
artistCredit:
relation('generateArtistCredit', album.artistContribs, []),
otherGroupLinks:
query.otherGroups
.map(group => relation('linkGroup', group)),
}),
data: (_query, album, group) => ({
groupName:
group.name,
notFromThisGroup:
!group.albums.includes(album),
}),
slots: {
accentMode: {
validate: v => v.is('groups', 'artists'),
},
},
generate: (data, relations, slots, {html, language}) =>
html.tag('li',
relations.colorStyle,
language.encapsulate('groupInfoPage.albumList.item', itemCapsule =>
language.encapsulate(itemCapsule, workingCapsule => {
const workingOptions = {};
workingOptions.album =
relations.albumLink.slot('color', false);
const yearCapsule = language.encapsulate(itemCapsule, 'withYear');
if (relations.datetimestamp) {
workingCapsule += '.withYear';
workingOptions.yearAccent =
language.$(yearCapsule, 'accent', {
year:
relations.datetimestamp.slots({style: 'year', tooltip: true}),
});
}
const otherGroupCapsule = language.encapsulate(itemCapsule, 'withOtherGroup');
if (
(slots.accentMode === 'groups' ||
slots.accentMode === null) &&
data.notFromThisGroup
) {
workingCapsule += '.withOtherGroup';
workingOptions.otherGroupAccent =
html.tag('span', {class: 'other-group-accent'},
language.$(otherGroupCapsule, 'notFromThisGroup', {
group:
data.groupName,
}));
} else if (
slots.accentMode === 'groups' &&
!empty(relations.otherGroupLinks)
) {
workingCapsule += '.withOtherGroup';
workingOptions.otherGroupAccent =
html.tag('span', {class: 'other-group-accent'},
language.$(otherGroupCapsule, 'accent', {
groups:
language.formatConjunctionList(
relations.otherGroupLinks.map(groupLink =>
groupLink.slot('color', false))),
}));
}
const artistCapsule = language.encapsulate(itemCapsule, 'withArtists');
const {artistCredit} = relations;
artistCredit.setSlots({
normalStringKey:
artistCapsule + '.by',
featuringStringKey:
artistCapsule + '.featuring',
normalFeaturingStringKey:
artistCapsule + '.by.featuring',
});
if (slots.accentMode === 'artists' && !html.isBlank(artistCredit)) {
workingCapsule += '.withArtists';
workingOptions.by =
html.tag('span', {class: 'by'},
html.metatag('chunkwrap', {split: ','},
html.resolve(artistCredit)));
}
return language.$(workingCapsule, workingOptions);
}))),
};
|