« get me outta code hell

generateGroupInfoPageAlbumsSection.js « dependencies « content « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateGroupInfoPageAlbumsSection.js
blob: 0b678e9d84af2a9c5b171ea37802c8e4e364915e (plain)
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
export default {
  contentDependencies: [
    'generateContentHeading',
    'generateGroupInfoPageAlbumsListByDate',
    'generateGroupInfoPageAlbumsListBySeries',
    'generateIntrapageDotSwitcher',
    'linkGroupGallery',
  ],

  extraDependencies: ['html', 'language'],

  relations: (relation, group) => ({
    contentHeading:
      relation('generateContentHeading'),

    galleryLink:
      relation('linkGroupGallery', group),

    albumsListByDate:
      relation('generateGroupInfoPageAlbumsListByDate', group),

    albumsListBySeries:
      relation('generateGroupInfoPageAlbumsListBySeries', group),

    viewSwitcher:
      relation('generateIntrapageDotSwitcher'),
  }),

  generate: (relations, {html, language}) =>
    language.encapsulate('groupInfoPage', pageCapsule =>
      language.encapsulate(pageCapsule, 'albumList', listCapsule =>
        html.tags([
          relations.contentHeading
            .slots({
              tag: 'h2',
              title: language.$(listCapsule, 'title'),
            }),

          html.tag('p',
            {[html.onlyIfSiblings]: true},

            language.encapsulate(pageCapsule, 'viewAlbumGallery', viewAlbumGalleryCapsule =>
              language.encapsulate(viewAlbumGalleryCapsule, workingCapsule => {
                const workingOptions = {};

                workingOptions.link =
                  relations.galleryLink
                    .slot('content',
                      language.$(viewAlbumGalleryCapsule, 'link'));

                if (
                  !html.isBlank(relations.albumsListByDate) &&
                  !html.isBlank(relations.albumsListBySeries)
                ) {
                  workingCapsule += '.withViewSwitcher';
                  workingOptions.viewSwitcher =
                    html.tag('span', {class: 'group-view-switcher'},
                      language.encapsulate(pageCapsule, 'viewSwitcher', switcherCapsule =>
                        language.$(switcherCapsule, {
                          options:
                            relations.viewSwitcher.slots({
                              initialOptionIndex: 0,

                              titles: [
                                language.$(switcherCapsule, 'bySeries'),
                                language.$(switcherCapsule, 'byDate'),
                              ],

                              targetIDs: [
                                'group-album-list-by-series',
                                'group-album-list-by-date',
                              ],
                            }),
                        })));
                }

                return language.$(workingCapsule, workingOptions);
              }))),

          ((!html.isBlank(relations.albumsListByDate) &&
            !html.isBlank(relations.albumsListBySeries))

            ? [
                relations.albumsListBySeries,
                relations.albumsListByDate.slot('hidden', true),
              ]

            : [
                relations.albumsListBySeries,
                relations.albumsListByDate,
              ]),
        ]))),
};