@worksafevictoria/wcl7.5 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/.storybook/preview.js +20 -13
  2. package/bin/deploy.sh +1 -1
  3. package/lib/utility.js +10 -8
  4. package/package.json +4 -4
  5. package/src/assets/icons/AppFooter/x-ws-footer.svg +10 -0
  6. package/src/assets/icons/AppFooter/x-ww-footer.svg +28 -0
  7. package/src/assets/icons/SocialShare/x-icon-white.svg +28 -0
  8. package/src/assets/styles/modal.scss +51 -0
  9. package/src/components/Common/CardGrid/index.vue +56 -51
  10. package/src/components/Common/CardGridItem/card-grid-item-caret.vue +7 -4
  11. package/src/components/Common/CardGridItem/index.vue +77 -63
  12. package/src/components/Containers/Carousel/index.vue +14 -7
  13. package/src/components/Containers/HomepageHeader/index.stories.js +60 -36
  14. package/src/components/Containers/HomepageHeader/index.vue +2 -26
  15. package/src/components/Containers/HomepageHeaderNew/index.stories.js +15 -15
  16. package/src/components/Containers/HomepageHeaderNew/index.vue +97 -68
  17. package/src/components/Containers/SectionGroup/index.vue +1 -1
  18. package/src/components/Containers/Subheader/index.vue +5 -1
  19. package/src/components/Global/AppFooter/FooterSocialShare/index.vue +1 -1
  20. package/src/components/Global/AppFooter/index.vue +14 -7
  21. package/src/components/Global/AppHeaderNew/styles.scss +10 -15
  22. package/src/components/Global/BackToTop/index.vue +8 -8
  23. package/src/components/Global/Cookies/index.stories.js +16 -10
  24. package/src/components/Global/Cookies/index.vue +280 -243
  25. package/src/components/Global/Cookies/styles.scss +54 -54
  26. package/src/components/Global/DirectoryFilters/SingleTaxonomy/index.vue +50 -133
  27. package/src/components/Global/GlobalNotice/index.vue +79 -100
  28. package/src/components/Global/SocialShare/index.vue +1 -1
  29. package/src/components/Global/Strip/index.vue +1 -1
  30. package/src/components/Paragraphs/Accordion/AccordionItem/index.vue +8 -4
  31. package/src/components/Paragraphs/Accordion/StepperItem/index.vue +23 -23
  32. package/src/components/Paragraphs/Accordion/index.stories.js +21 -18
  33. package/src/components/Paragraphs/Accordion/index.vue +52 -48
  34. package/src/components/Paragraphs/BrowseContent/index.vue +1 -1
  35. package/src/components/Paragraphs/BrowseContent/setup.vue +284 -0
  36. package/src/components/Paragraphs/Chart/Constants.js +485 -485
  37. package/src/components/Paragraphs/Chart/index.vue +232 -241
  38. package/src/components/Paragraphs/Directory/Records/HSCP/index.stories.js +33 -0
  39. package/src/components/Paragraphs/Directory/Records/HSCP/index.vue +334 -0
  40. package/src/components/Paragraphs/Directory/Records/index.vue +63 -27
  41. package/src/components/Paragraphs/Directory/Records/styles.scss +1 -0
  42. package/src/components/Paragraphs/Directory/constants.js +23 -5
  43. package/src/components/Paragraphs/Directory/index.vue +14 -14
  44. package/src/components/Paragraphs/ListGroup/index.vue +5 -1
  45. package/src/components/Paragraphs/ScrollSpy/index.vue +23 -14
  46. package/src/components/Paragraphs/SelectableCards/index.vue +15 -12
  47. package/src/components/Paragraphs/TabbedCards/index.vue +13 -14
  48. package/src/components/Paragraphs/Tabs/index.vue +19 -17
  49. package/src/components/Paragraphs/TextMedia/MediaTypes/Video/index.vue +9 -9
  50. package/src/components/Paragraphs/TextMedia/index.vue +20 -16
  51. package/src/components/Paragraphs/VideoGrid/index.stories.js +43 -19
  52. package/src/components/Paragraphs/VideoGrid/index.vue +13 -13
  53. package/src/components/Paragraphs/Webform/index.stories.js +82 -69
  54. package/src/components/SubComponents/CardGroup/index.vue +5 -1
  55. package/src/components/SubComponents/FormAddressPostcode/index.vue +35 -37
  56. package/src/components/SubComponents/FormInstance/components/handler/index.vue +25 -29
  57. package/src/components/SubComponents/FormInstance/components/renderer/index.vue +63 -28
  58. package/src/components/SubComponents/FormInstance/models/overrides/file.js +33 -40
  59. package/src/components/SubComponents/FormInstance/services/form-submit-parser.js +22 -15
  60. package/src/components/SubComponents/FormInstance/services/registry-factory.js +1 -1
  61. package/src/components/SubComponents/FormInstance/stories/fileupload.stories.js +57 -0
  62. package/src/components/SubComponents/FormInstance/stories/mocks/fileupload.json +25 -0
  63. package/src/components/SubComponents/FormInstance/style.scss +2 -2
  64. package/src/components/SubComponents/FormInstance/tests/address.test.js +4 -4
  65. package/src/components/SubComponents/FormInstance/tests/checkboxes.test.js +7 -7
  66. package/src/components/SubComponents/FormInstance/tests/customcomposite.test.js +15 -15
  67. package/src/components/SubComponents/FormInstance/tests/date.test.js +8 -8
  68. package/src/components/SubComponents/FormInstance/tests/form-test-utils.js +9 -9
  69. package/src/components/SubComponents/FormInstance/tests/multiple.test.js +13 -13
  70. package/src/components/SubComponents/FormInstance/tests/rule-visible.test.js +120 -120
  71. package/src/components/SubComponents/FormInstance/tests/scale.test.js +6 -6
  72. package/src/components/SubComponents/FormInstance/tests/url.test.js +13 -10
  73. package/src/components/SubComponents/Pagination/index.vue +19 -18
  74. package/src/components/SubComponents/ResourceGroup/index.vue +5 -1
  75. package/src/components/SubComponents/Search/SearchListing/index.vue +20 -20
  76. package/src/components/SubComponents/Search/index.vue +35 -33
  77. package/src/components/SubComponents/VideoThumbnail/index.vue +48 -133
  78. package/src/includes/scss/vars/src/colors.module.scss +28 -1
  79. package/src/index.js +21 -3
  80. package/src/main.js +2 -10
  81. package/src/mock/carousel-items.js +71 -46
@@ -5,15 +5,15 @@
5
5
  v-if="title"
6
6
  class="accordion-stepper"
7
7
  :class="{
8
- rtl: rtl
8
+ rtl: rtl,
9
9
  }"
10
10
  >
11
11
  <div>
12
12
  <button
13
- :id="'accordion' + _uid ? _uid : ''"
13
+ :id="'accordion' + itemid"
14
14
  :aria-expanded="showAccordion ? 'true' : 'false'"
15
15
  class="accordion-stepper__title"
16
- :aria-controls="'sect' + _uid ? _uid : ''"
16
+ :aria-controls="'sect' + itemid"
17
17
  @click="toggleAccordion"
18
18
  >
19
19
  <div
@@ -25,13 +25,9 @@
25
25
  </div>
26
26
 
27
27
  <div class="accordion-stepper__titleText">
28
- <rich-text
29
- :tag="'h3'"
30
- :tag-class="'card-title'"
31
- :content="title"
32
- />
28
+ <rich-text :tag="'h3'" :tag-class="'card-title'" :content="title" />
33
29
  </div>
34
-
30
+
35
31
  <div class="stepper-icon__wrapper">
36
32
  <icon
37
33
  v-show="showAccordion && content"
@@ -54,10 +50,10 @@
54
50
  <b-card-body v-if="content">
55
51
  <div
56
52
  v-show="showAccordion"
57
- :id="'sect' + _uid ? _uid : ''"
53
+ :id="'sect' + itemid"
58
54
  class="accordion-stepper__content"
59
55
  role="region"
60
- :aria-labelledby="'accordion' + _uid ? _uid : ''"
56
+ :aria-labelledby="'accordion' + itemid"
61
57
  >
62
58
  <rich-text :content="content" />
63
59
  </div>
@@ -80,42 +76,46 @@ export default {
80
76
  RichText,
81
77
  Icon,
82
78
  BCard,
83
- BCardBody
79
+ BCardBody,
84
80
  },
85
81
  props: {
86
82
  title: {
87
83
  type: String,
88
- default: 'Item'
84
+ default: 'Item',
89
85
  },
90
86
  content: {
91
87
  type: String,
92
- default: null
88
+ default: null,
93
89
  },
94
90
  rtl: {
95
91
  type: Boolean,
96
- default: false
92
+ default: false,
97
93
  },
98
94
  open: {
99
95
  type: Boolean,
100
- default: false
96
+ default: false,
101
97
  },
102
98
  showPreHeading: {
103
99
  type: Boolean,
104
- default: false
100
+ default: false,
105
101
  },
106
102
  number: {
107
103
  type: Number,
108
- default: null
104
+ default: null,
109
105
  },
110
106
  isWorkWell: {
111
107
  type: Boolean,
112
- default: false
113
- }
108
+ default: false,
109
+ },
110
+ itemid: {
111
+ type: String,
112
+ default: 'Item',
113
+ },
114
114
  },
115
115
  data: () => ({
116
116
  showAccordion: false,
117
117
  CaretDown,
118
- CaretUp
118
+ CaretUp,
119
119
  }),
120
120
  mounted() {
121
121
  this.$nextTick(() => {
@@ -125,8 +125,8 @@ export default {
125
125
  methods: {
126
126
  toggleAccordion() {
127
127
  this.showAccordion = !this.showAccordion
128
- }
129
- }
128
+ },
129
+ },
130
130
  }
131
131
  </script>
132
132
 
@@ -6,25 +6,28 @@ const mockAccordionItems = [
6
6
  field_pre_heading: 'preheading text',
7
7
  field_rich_text: {
8
8
  value:
9
- '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>'
10
- }
9
+ '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>',
10
+ },
11
+ id: 'id-1',
11
12
  },
12
13
  {
13
14
  field_title: 'Item two',
14
15
  field_pre_heading: 'preheading text',
15
16
  field_rich_text: {
16
17
  value:
17
- '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>'
18
- }
18
+ '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>',
19
+ },
20
+ id: 'id-2',
19
21
  },
20
22
  {
21
23
  field_title: 'Item three',
22
24
  field_pre_heading: 'preheading text',
23
25
  field_rich_text: {
24
26
  value:
25
- '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>'
26
- }
27
- }
27
+ '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>',
28
+ },
29
+ id: 'id-3',
30
+ },
28
31
  ]
29
32
 
30
33
  export default {
@@ -34,26 +37,26 @@ export default {
34
37
  argTypes: {
35
38
  titleTag: {
36
39
  control: 'select',
37
- options: ['h2', 'h3', 'h4']
40
+ options: ['h2', 'h3', 'h4'],
38
41
  },
39
42
  isStepper: {
40
43
  control: 'boolean',
41
- table: { disable: true }
44
+ table: { disable: true },
42
45
  },
43
46
 
44
47
  showPreHeading: {
45
48
  control: 'boolean',
46
- table: { disable: true }
49
+ table: { disable: true },
47
50
  },
48
51
  option: {
49
52
  control: 'select',
50
- options: ['open-all', 'close-all', 'open-first']
53
+ options: ['open-all', 'close-all', 'open-first'],
51
54
  },
52
55
  size: {
53
56
  control: 'text',
54
- table: { disable: true }
55
- }
56
- }
57
+ table: { disable: true },
58
+ },
59
+ },
57
60
  }
58
61
 
59
62
  export const Standard = {
@@ -66,8 +69,8 @@ export const Standard = {
66
69
  rtl: false,
67
70
  option: 'open-first',
68
71
  accordionList: mockAccordionItems,
69
- size: 'content'
70
- }
72
+ size: 'content',
73
+ },
71
74
  }
72
75
 
73
76
  export const Stepper = {
@@ -80,6 +83,6 @@ export const Stepper = {
80
83
  rtl: false,
81
84
  option: 'open-first',
82
85
  accordionList: mockAccordionItems,
83
- size: 'content'
84
- }
86
+ size: 'content',
87
+ },
85
88
  }
@@ -7,40 +7,44 @@
7
7
  class="paragraph--accordion"
8
8
  :no-padding-bottom="isStepper"
9
9
  >
10
- <ol class="accordion-list">
11
- <li
12
- v-for="(item, index) in accordionList"
13
- :key="_uid ? _uid : '' + index"
14
- :class="{
15
- workwell: isWorkwell,
16
- rtl: rtl || item.field_rtl,
17
- stepper: isStepper
18
- }"
19
- class="accordion"
20
- >
21
- <stepper-item
22
- v-if="isStepper"
23
- :content="hasContent(item) ? item.field_rich_text.value : ''"
24
- :title="item.field_title"
25
- class="accordion__item stepper"
26
- :rtl="rtl || item.field_rtl"
27
- :open="isAccordionOpen(index)"
28
- :number="index + 1"
29
- :is-work-well="isWorkwell"
30
- />
31
- <accordion-item
32
- v-if="!isStepper"
33
- :content="hasContent(item) ? item.field_rich_text.value : ''"
34
- :title="item.field_title"
35
- class="accordion__item"
36
- :rtl="rtl || item.field_rtl"
37
- :show-pre-heading="showPreHeading"
38
- :pre-heading="item.field_pre_heading || ''"
39
- :open="isAccordionOpen(index)"
40
- :meta="Array.isArray(item.meta) ? item.meta : []"
41
- />
42
- </li>
43
- </ol>
10
+ <div>
11
+ <ol class="accordion-list">
12
+ <li
13
+ v-for="(item, index) in accordionList"
14
+ :key="item.id ? item.id : '' + index"
15
+ :class="{
16
+ workwell: isWorkwell,
17
+ rtl: rtl || item.field_rtl,
18
+ stepper: isStepper,
19
+ }"
20
+ class="accordion"
21
+ >
22
+ <stepper-item
23
+ v-if="isStepper"
24
+ :itemid="item.id ? item.id : '' + index"
25
+ :content="hasContent(item) ? item.field_rich_text.value : ''"
26
+ :title="item.field_title"
27
+ class="accordion__item stepper"
28
+ :rtl="rtl || item.field_rtl"
29
+ :open="isAccordionOpen(index)"
30
+ :number="index + 1"
31
+ :is-work-well="isWorkwell"
32
+ />
33
+ <accordion-item
34
+ v-if="!isStepper"
35
+ :itemid="item.id ? item.id : '' + index"
36
+ :content="hasContent(item) ? item.field_rich_text.value : ''"
37
+ :title="item.field_title"
38
+ class="accordion__item"
39
+ :rtl="rtl || item.field_rtl"
40
+ :show-pre-heading="showPreHeading"
41
+ :pre-heading="item.field_pre_heading || ''"
42
+ :open="isAccordionOpen(index)"
43
+ :meta="Array.isArray(item.meta) ? item.meta : []"
44
+ />
45
+ </li>
46
+ </ol>
47
+ </div>
44
48
  </section-group>
45
49
  </template>
46
50
 
@@ -55,51 +59,51 @@ export default {
55
59
  props: {
56
60
  titleTag: {
57
61
  type: String,
58
- default: 'h2'
62
+ default: 'h2',
59
63
  },
60
64
  title: {
61
65
  type: String,
62
- default: null
66
+ default: null,
63
67
  },
64
68
  isStepper: {
65
69
  type: Boolean,
66
- default: false
70
+ default: false,
67
71
  },
68
72
  showPreHeading: {
69
73
  type: Boolean,
70
- default: false
74
+ default: false,
71
75
  },
72
76
  isWorkwell: {
73
77
  type: Boolean,
74
- default: false
78
+ default: false,
75
79
  },
76
80
  accordionList: {
77
81
  type: Array,
78
- default: null
82
+ default: null,
79
83
  },
80
84
  rtl: {
81
85
  type: Boolean,
82
- default: false
86
+ default: false,
83
87
  },
84
88
  size: {
85
89
  type: String,
86
- default: 'content'
90
+ default: 'content',
87
91
  },
88
92
  option: {
89
93
  type: String,
90
- default: 'open-first'
91
- }
94
+ default: 'open-first',
95
+ },
92
96
  },
93
97
  data: () => ({
94
98
  OPEN_ALL: 'open-all',
95
99
  CLOSE_ALL: 'close-all',
96
100
  OPEN_FIRST: 'open-first',
97
- accordionOption: null
101
+ accordionOption: null,
98
102
  }),
99
103
  computed: {
100
104
  isPDF() {
101
105
  return typeof this.$isPDF === 'function' ? this.$isPDF() : false
102
- }
106
+ },
103
107
  },
104
108
  mounted() {
105
109
  if (this.option) {
@@ -121,8 +125,8 @@ export default {
121
125
  },
122
126
  hasContent(item) {
123
127
  return item?.field_rich_text?.value
124
- }
125
- }
128
+ },
129
+ },
126
130
  }
127
131
  </script>
128
132
 
@@ -8,6 +8,7 @@
8
8
  :columns="columns"
9
9
  :show-load-more="showMore && hasMorePages"
10
10
  :class="`wcl-browse-content card_group__card--col-${columns}`"
11
+ :card-browse-content="true"
11
12
  @loadMore="() => loadMoreCards(false)"
12
13
  >
13
14
  <template
@@ -126,7 +127,6 @@ export default {
126
127
  },
127
128
  }
128
129
  },
129
- fetchOnServer: true,
130
130
  fetchKey: 'ws-browscontent',
131
131
  methods: {
132
132
  async loadFiltersAndContent() {
@@ -0,0 +1,284 @@
1
+ <template>
2
+ <card-group
3
+ :title="title"
4
+ :title-tag="titleTag"
5
+ :background="background"
6
+ :cards="displayedCards"
7
+ :loading="loading"
8
+ :columns="columns"
9
+ :show-load-more="showMore && hasMorePages"
10
+ :class="`wcl-browse-content card_group__card--col-${columns}`"
11
+ :card-browse-content="true"
12
+ @loadMore="() => loadMoreCards(false)"
13
+ >
14
+ <template
15
+ v-if="enableBundleFilter && bundle.length > 1"
16
+ v-slot:cardGroupFilter
17
+ >
18
+ <switcher
19
+ v-if="enableBundleFilter"
20
+ :options="bundle"
21
+ class="wcl-browse-content__switcher"
22
+ :get-option-alias="getBundleAlias"
23
+ @switched="onSwitcher"
24
+ @reset="onSwitcher"
25
+ />
26
+ </template>
27
+
28
+ <template v-if="filters.taxonomies.length > 0" v-slot:cardGroupPreContent>
29
+ <directory-filters
30
+ class="wcl-browse-content__filter"
31
+ :filters="filters"
32
+ :results="allCards.total"
33
+ :is-filtering="loading"
34
+ @onFilter="onFilter"
35
+ @onReset="reset"
36
+ />
37
+ </template>
38
+ </card-group>
39
+ </template>
40
+
41
+ <script setup>
42
+ import CardGroup from '../../SubComponents/CardGroup/index.vue'
43
+ import DirectoryFilters from '../../Global/DirectoryFilters/index.vue'
44
+ import Switcher from './switcher.vue'
45
+
46
+ const nuxtApp = useNuxtApp()
47
+
48
+ const hasMorePages = ref(false)
49
+ const displayedCards = ref([])
50
+ const loading = ref(true)
51
+ const bundleCache = ref({})
52
+ const displayLimit = ref(0)
53
+ const allCards = ref(undefined)
54
+ const filters = ref({
55
+ taxonomies: [],
56
+ selected: {},
57
+ availableBundles: [],
58
+ })
59
+ const props = defineProps({
60
+ background: {
61
+ type: String,
62
+ default: 'grey',
63
+ },
64
+ title: {
65
+ type: String,
66
+ default: '',
67
+ },
68
+ titleTag: {
69
+ type: String,
70
+ default: 'h2',
71
+ },
72
+ bundle: {
73
+ type: Array,
74
+ default: () => [''],
75
+ },
76
+ columns: {
77
+ type: Number,
78
+ default: 0,
79
+ },
80
+ initialDisplyLimit: {
81
+ type: Number,
82
+ default: 0,
83
+ },
84
+ fetchContent: {
85
+ type: Function,
86
+ required: true,
87
+ },
88
+ fetchFilters: {
89
+ type: Function,
90
+ required: false,
91
+ default: null,
92
+ },
93
+ enableBundleFilter: {
94
+ type: Boolean,
95
+ },
96
+ getBundleAlias: {
97
+ type: Function,
98
+ required: false,
99
+ default: null,
100
+ },
101
+ showMore: {
102
+ type: Boolean,
103
+ },
104
+ type: {
105
+ type: String,
106
+ required: true,
107
+ },
108
+ })
109
+
110
+ await useAsyncData('fetchData', async () => {
111
+ try {
112
+ await Promise.all([
113
+ props.fetchFilters ? loadFilters() : Promise.resolve(),
114
+ loadMoreCards(true),
115
+ ])
116
+ } catch (err) {
117
+ console.log('🚀 ~ err:', err)
118
+ }
119
+ })
120
+
121
+ function initial() {
122
+ allCards.value = {
123
+ total: 0,
124
+ cards: [],
125
+ }
126
+ displayLimit.value = 0
127
+ hasMorePages.value = false
128
+ displayedCards.value = []
129
+ bundleCache.value = {}
130
+ }
131
+ async function fetchCards(currentDisplayedCards, allCards, addMoreBy, bundles) {
132
+ const shouldMakeNewFetchCall =
133
+ currentDisplayedCards.length + addMoreBy > allCards.cards.length
134
+ if (shouldMakeNewFetchCall) {
135
+ const cardBundles = await Promise.all(
136
+ bundles.map((bundle, index) => getBundle(bundle, addMoreBy, index)),
137
+ )
138
+ allCards = getShuffledCards(cardBundles)
139
+
140
+ if (
141
+ props.type === 'paragraph--cards_group_latest' ||
142
+ props.type === 'paragraph--browse_content'
143
+ ) {
144
+ allCards.cards = sortByDate(allCards.cards)
145
+ }
146
+ }
147
+ return allCards
148
+ }
149
+
150
+ async function loadMoreCards(init) {
151
+ const attrs = {
152
+ group: nuxtApp.$pageStore?.content?.title,
153
+ }
154
+ if (nuxtApp.$gtm && !init) {
155
+ nuxtApp.$gtm.push({ event: 'custom.interaction.showmore.click', ...attrs })
156
+ }
157
+ if (init) {
158
+ initial()
159
+ }
160
+ loading.value = true
161
+ const addMoreBy = props.initialDisplyLimit
162
+ displayLimit.value += addMoreBy
163
+ const bundles =
164
+ filters.value.availableBundles.length > 0
165
+ ? filters.value.availableBundles
166
+ : props.bundle
167
+ allCards.value = await fetchCards(
168
+ displayedCards.value,
169
+ allCards.value,
170
+ addMoreBy,
171
+ bundles,
172
+ )
173
+ hasMorePages.value = allCards.value.total > allCards.value.cards.length
174
+ displayedCards.value = allCards.value.cards.slice(0, displayLimit.value)
175
+ loading.value = false
176
+ }
177
+ async function getBundle(bundle, addMoreBy, index) {
178
+ let start
179
+ const rows = addMoreBy
180
+ const cache = (bundleCache.value[bundle] = bundleCache.value[bundle] || {
181
+ response: {
182
+ results: [],
183
+ numFound: 0,
184
+ },
185
+ qs: {
186
+ start,
187
+ },
188
+ })
189
+ if (cache.qs.start === undefined) {
190
+ start = 0
191
+ } else if (cache.response.numFound > cache.response.results.length) {
192
+ start = cache.response.results.length
193
+ } else {
194
+ return Promise.resolve(cache.response)
195
+ }
196
+ const qs = {
197
+ bundle,
198
+ rows,
199
+ start,
200
+ }
201
+ let response = await props.fetchContent(qs, filters.value.selected)
202
+ cache.qs.start = qs.start
203
+ cache.response.numFound = response.numFound
204
+ cache.response.results.push(...response.results)
205
+ return cache.response
206
+ }
207
+ function getShuffledCards(cardBundles) {
208
+ const shuffled = []
209
+ const bundleWithMostCards = cardBundles.reduce(
210
+ (a, b) => (a.results.length > b.results.length ? a : b),
211
+ { results: [] },
212
+ ).results.length
213
+
214
+ for (let i = 0; i < bundleWithMostCards; i++) {
215
+ cardBundles.forEach((bundle) => {
216
+ if (bundle.results[i]) {
217
+ shuffled.push(bundle.results[i])
218
+ }
219
+ })
220
+ }
221
+
222
+ const total = cardBundles.reduce((acc, bundle) => {
223
+ return acc + bundle.numFound
224
+ }, 0)
225
+
226
+ return { cards: shuffled, total }
227
+ }
228
+ function loadFilters() {
229
+ return props.fetchFilters().then((taxonomies) => {
230
+ filters.value.taxonomies = taxonomies
231
+
232
+ return Promise.resolve(taxonomies)
233
+ })
234
+ }
235
+ const onFilter = (fltrs) => {
236
+ bundleCache.value = {}
237
+ Object.keys(fltrs).forEach((filter) => {
238
+ filters.values.selected[filter] = fltrs[filter].map((obj) => obj.tid)
239
+ })
240
+ loadMoreCards(true)
241
+ }
242
+ const onSwitcher = (switchToBundle) => {
243
+ filters.value.selected = {}
244
+ filters.value.availableBundles.length = 0
245
+ if (switchToBundle) {
246
+ filters.value.availableBundles.push(switchToBundle)
247
+ }
248
+ loadMoreCards(true)
249
+ }
250
+ const reset = async () => {
251
+ bundleCache.value = {}
252
+ filters.value.selected = {}
253
+ filters.value.availableBundles.length = 0
254
+ await loadMoreCards(true)
255
+ }
256
+ function sortByDate(cards) {
257
+ const sorted = cards.sort((a, b) => {
258
+ return new Date(b.dateSort) - new Date(a.dateSort)
259
+ })
260
+ return sorted
261
+ }
262
+ </script>
263
+ <style lang="scss" scoped>
264
+ .wcl-browse-content {
265
+ &__filter {
266
+ align-items: flex-end;
267
+ place-content: flex-end;
268
+ }
269
+
270
+ &.card_group__card--col-4 {
271
+ :deep(.card-grid__column .card-grid-item__description) {
272
+ display: none;
273
+ }
274
+ }
275
+
276
+ :deep(.card_group__card--blue .card_item__desc p) {
277
+ margin-top: 12px;
278
+ }
279
+
280
+ :deep(.card_group__card--red .card_item__desc p) {
281
+ margin-top: 12px;
282
+ }
283
+ }
284
+ </style>