@worksafevictoria/wcl7.5 1.13.0-beta.16 → 1.13.0-beta.17

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worksafevictoria/wcl7.5",
3
- "version": "1.13.0-beta.16",
3
+ "version": "1.13.0-beta.17",
4
4
  "main": "src/index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -25,7 +25,7 @@
25
25
  />
26
26
  </template>
27
27
 
28
- <template v-if="filters.taxonomies.length > 0" v-slot:cardGroupPreContent>
28
+ <template v-if="filters?.taxonomies?.length > 0" v-slot:cardGroupPreContent>
29
29
  <directory-filters
30
30
  class="wcl-browse-content__filter"
31
31
  :filters="filters"
@@ -38,250 +38,245 @@
38
38
  </card-group>
39
39
  </template>
40
40
 
41
- <script>
42
- import CardGroup from '../../SubComponents/CardGroup/index.vue'
43
- import DirectoryFilters from '../../Global/DirectoryFilters/index.vue'
44
- import Switcher from './switcher.vue'
41
+ <script setup>
42
+ // import { CardGroup, DirectoryFilters, Switcher } from '@worksafevictoria/wcl7.5'
45
43
 
46
- export default {
47
- name: 'BrowseContent',
48
- components: {
49
- CardGroup,
50
- DirectoryFilters,
51
- Switcher,
44
+ const nuxtApp = useNuxtApp()
45
+ const hasMorePages = ref(false)
46
+ const displayedCards = ref([])
47
+ const loading = ref(false)
48
+ const bundleCache = ref({})
49
+ const displayLimit = ref(0)
50
+ const allCards = ref(undefined)
51
+ const props = defineProps({
52
+ background: {
53
+ type: String,
54
+ default: 'grey',
52
55
  },
53
- props: {
54
- background: {
55
- type: String,
56
- default: 'grey',
57
- },
58
- title: {
59
- type: String,
60
- default: '',
61
- },
62
- titleTag: {
63
- type: String,
64
- default: 'h2',
65
- },
66
- bundle: {
67
- type: Array,
68
- default: () => [''],
69
- },
70
- columns: {
71
- type: Number,
72
- default: 0,
73
- },
74
- initialDisplyLimit: {
75
- type: Number,
76
- default: 0,
77
- },
78
- fetchContent: {
79
- type: Function,
80
- required: true,
81
- },
82
- fetchFilters: {
83
- type: Function,
84
- required: false,
85
- default: null,
86
- },
87
- enableBundleFilter: {
88
- type: Boolean,
89
- },
90
- getBundleAlias: {
91
- type: Function,
92
- required: false,
93
- default: null,
94
- },
95
- showMore: {
96
- type: Boolean,
97
- },
98
- type: {
99
- type: String,
100
- required: true,
101
- },
56
+ title: {
57
+ type: String,
58
+ default: '',
102
59
  },
103
- // Temp use of mounted to replace fetch
104
- async mounted() {
105
- if (this.displayedCards.length === 0) {
106
- await this.loadFiltersAndContent()
107
- }
60
+ titleTag: {
61
+ type: String,
62
+ default: 'h2',
108
63
  },
109
- // TODO useAsyncData <script setup>
110
- // async fetch() {
111
- // if (this.displayedCards.length === 0) {
112
- // await this.loadFiltersAndContent()
113
- // }
114
- // },
115
- data() {
116
- return {
117
- hasMorePages: false,
118
- displayedCards: [],
119
- loading: true,
120
- bundleCache: {},
121
- displayLimit: 0,
122
- allCards: undefined,
123
- filters: {
124
- taxonomies: [],
125
- selected: {},
126
- availableBundles: [],
127
- },
128
- }
64
+ bundle: {
65
+ type: Array,
66
+ default: () => [''],
129
67
  },
130
- fetchKey: 'ws-browscontent',
131
- methods: {
132
- async loadFiltersAndContent() {
133
- await Promise.all([
134
- this.fetchFilters ? this.loadFilters() : Promise.resolve(),
135
- this.loadMoreCards(true),
136
- ])
137
- },
138
- init() {
139
- this.allCards = {
140
- total: 0,
141
- cards: [],
142
- }
143
- this.displayLimit = 0
144
- this.hasMorePages = false
145
- this.displayedCards = []
146
- this.bundleCache = {}
147
- },
148
- async fetchCards(currentDisplayedCards, allCards, addMoreBy, bundles) {
149
- const shouldMakeNewFetchCall =
150
- currentDisplayedCards.length + addMoreBy > allCards.cards.length
151
- if (shouldMakeNewFetchCall) {
152
- const cardBundles = await Promise.all(
153
- bundles.map((bundle, index) =>
154
- this.getBundle(bundle, addMoreBy, index),
155
- ),
156
- )
157
- allCards = this.getShuffledCards(cardBundles)
68
+ columns: {
69
+ type: Number,
70
+ default: 0,
71
+ },
72
+ initialDisplyLimit: {
73
+ type: Number,
74
+ default: 0,
75
+ },
76
+ fetchContent: {
77
+ type: Function,
78
+ required: true,
79
+ },
80
+ fetchFilters: {
81
+ type: Function,
82
+ required: false,
83
+ default: null,
84
+ },
85
+ enableBundleFilter: {
86
+ type: Boolean,
87
+ },
88
+ getBundleAlias: {
89
+ type: Function,
90
+ required: false,
91
+ default: null,
92
+ },
93
+ showMore: {
94
+ type: Boolean,
95
+ },
96
+ type: {
97
+ type: String,
98
+ required: true,
99
+ },
100
+ id: {
101
+ type: String,
102
+ required: true,
103
+ },
104
+ })
158
105
 
159
- if (
160
- this.type === 'paragraph--cards_group_latest' ||
161
- this.type === 'paragraph--browse_content'
162
- ) {
163
- allCards.cards = this.sortByDate(allCards.cards)
164
- }
165
- }
166
- return allCards
167
- },
168
- async loadMoreCards(init) {
169
- const attrs = {
170
- group: this.$pageStore?.content?.title,
171
- }
172
- if (this.$gtm && !init) {
173
- this.$gtm.push({ event: 'custom.interaction.showmore.click', ...attrs })
174
- }
175
- if (init) {
176
- this.init()
177
- }
178
- this.loading = true
179
- const addMoreBy = this.initialDisplyLimit
180
- this.displayLimit += addMoreBy
181
- const bundles =
182
- this.filters.availableBundles.length > 0
183
- ? this.filters.availableBundles
184
- : this.bundle
185
- this.allCards = await this.fetchCards(
186
- this.displayedCards,
187
- this.allCards,
188
- addMoreBy,
189
- bundles,
190
- )
191
- this.hasMorePages = this.allCards.total > this.allCards.cards.length
192
- this.displayedCards = this.allCards.cards.slice(0, this.displayLimit)
193
- this.loading = false
194
- },
195
- getBundle(bundle, addMoreBy, index) {
196
- let start
197
- const rows = addMoreBy
198
- const cache = (this.bundleCache[bundle] = this.bundleCache[bundle] || {
199
- response: {
200
- results: [],
201
- numFound: 0,
202
- },
203
- qs: {
204
- start,
205
- },
106
+ const filterKey = computed(() => `filters-${props.id}`)
107
+ const { data: filters } = await useAsyncData(filterKey, async () => {
108
+ try {
109
+ const filters = {
110
+ taxonomies: [],
111
+ selected: {},
112
+ availableBundles: [],
113
+ }
114
+ if (props.fetchFilters) {
115
+ await props.fetchFilters().then((taxonomies) => {
116
+ filters.taxonomies = taxonomies
206
117
  })
118
+ }
119
+ return filters
120
+ } catch (err) {
121
+ console.log('🚀 ~ err:', err)
122
+ }
123
+ })
207
124
 
208
- if (cache.qs.start === undefined) {
209
- start = 0
210
- } else if (cache.response.numFound > cache.response.results.length) {
211
- start = cache.response.results.length
212
- } else {
213
- return Promise.resolve(cache.response)
214
- }
215
-
216
- const qs = {
217
- bundle,
218
- rows,
219
- start,
220
- }
221
- return this.fetchContent(qs, this.filters.selected, index).then(
222
- (response) => {
223
- cache.qs.start = qs.start
224
- cache.response.numFound = response.numFound
225
- cache.response.results.push(...response.results)
226
- return cache.response
227
- },
228
- )
229
- },
230
- getShuffledCards(cardBundles) {
231
- const shuffled = []
232
- const bundleWithMostCards = cardBundles.reduce(
233
- (a, b) => (a.results.length > b.results.length ? a : b),
234
- { results: [] },
235
- ).results.length
125
+ const cardsKey = computed(() => `cards-${props.id}`)
126
+ const { data: savedCards } = await useAsyncData(cardsKey, async () => {
127
+ await loadMoreCards(true)
128
+ return {
129
+ cards: JSON.parse(JSON.stringify(allCards.value)),
130
+ bundle: JSON.parse(JSON.stringify(bundleCache.value)),
131
+ }
132
+ })
236
133
 
237
- for (let i = 0; i < bundleWithMostCards; i++) {
238
- cardBundles.forEach((bundle) => {
239
- if (bundle.results[i]) {
240
- shuffled.push(bundle.results[i])
241
- }
242
- })
243
- }
134
+ watch(
135
+ () => savedCards.value,
136
+ (newVal, oldVal) => {
137
+ if (newVal && allCards.value === undefined) {
138
+ allCards.value = JSON.parse(JSON.stringify(savedCards.value.cards))
139
+ bundleCache.value = JSON.parse(JSON.stringify(savedCards.value.bundle))
140
+ displayLimit.value += props.initialDisplyLimit
141
+ hasMorePages.value = allCards.value.total > allCards.value.cards.length
142
+ displayedCards.value = allCards.value.cards.slice(0, displayLimit.value)
143
+ }
144
+ },
145
+ { immediate: true },
146
+ )
244
147
 
245
- const total = cardBundles.reduce((acc, bundle) => {
246
- return acc + bundle.numFound
247
- }, 0)
148
+ function initial() {
149
+ allCards.value = {
150
+ total: 0,
151
+ cards: [],
152
+ }
153
+ displayLimit.value = 0
154
+ hasMorePages.value = false
155
+ displayedCards.value = []
156
+ bundleCache.value = {}
157
+ }
158
+ async function fetchCards(currentDisplayedCards, allCards, addMoreBy, bundles) {
159
+ const shouldMakeNewFetchCall =
160
+ currentDisplayedCards.length + addMoreBy > allCards.cards.length
161
+ if (shouldMakeNewFetchCall) {
162
+ const cardBundles = await Promise.all(
163
+ bundles.map((bundle, index) => getBundle(bundle, addMoreBy, index)),
164
+ )
165
+ allCards = getShuffledCards(cardBundles)
248
166
 
249
- return { cards: shuffled, total }
250
- },
251
- loadFilters() {
252
- return this.fetchFilters().then((taxonomies) => {
253
- this.filters.taxonomies = taxonomies
254
- return Promise.resolve(taxonomies)
255
- })
167
+ if (
168
+ props.type === 'paragraph--cards_group_latest' ||
169
+ props.type === 'paragraph--browse_content'
170
+ ) {
171
+ allCards.cards = sortByDate(allCards.cards)
172
+ }
173
+ }
174
+ return allCards
175
+ }
176
+ async function loadMoreCards(init) {
177
+ const attrs = {
178
+ group: nuxtApp.$pageStore?.content?.title,
179
+ }
180
+ if (nuxtApp.$gtm && !init) {
181
+ nuxtApp.$gtm.push({ event: 'custom.interaction.showmore.click', ...attrs })
182
+ }
183
+ if (init) {
184
+ initial()
185
+ }
186
+ loading.value = true
187
+ // const addMoreBy = props.initialDisplyLimit
188
+ displayLimit.value += props.initialDisplyLimit
189
+ const bundles =
190
+ filters.value.availableBundles.length > 0
191
+ ? filters.value.availableBundles
192
+ : props.bundle
193
+ allCards.value = await fetchCards(
194
+ displayedCards.value,
195
+ allCards.value,
196
+ props.initialDisplyLimit, //addMoreBy,
197
+ bundles,
198
+ )
199
+ hasMorePages.value = allCards.value.total > allCards.value.cards.length
200
+ displayedCards.value = allCards.value.cards.slice(0, displayLimit.value)
201
+ loading.value = false
202
+ }
203
+ async function getBundle(bundle, addMoreBy, index) {
204
+ let start
205
+ const rows = addMoreBy
206
+ const cache = (bundleCache.value[bundle] = bundleCache.value[bundle] || {
207
+ response: {
208
+ results: [],
209
+ numFound: 0,
256
210
  },
257
- onFilter(filters) {
258
- this.bundleCache = {}
259
- Object.keys(filters).forEach((filter) => {
260
- this.filters.selected[filter] = filters[filter].map((obj) => obj.tid)
261
- })
262
- this.loadMoreCards(true)
211
+ qs: {
212
+ start,
263
213
  },
264
- onSwitcher(switchToBundle) {
265
- this.filters.selected = {}
266
- this.filters.availableBundles.length = 0
267
- if (switchToBundle) {
268
- this.filters.availableBundles.push(switchToBundle)
214
+ })
215
+ if (cache.qs.start === undefined) {
216
+ start = 0
217
+ } else if (cache.response.numFound > cache.response.results.length) {
218
+ start = cache.response.results.length
219
+ } else {
220
+ return Promise.resolve(cache.response)
221
+ }
222
+ const qs = {
223
+ bundle,
224
+ rows,
225
+ start,
226
+ }
227
+ let response = await props.fetchContent(qs, filters.value.selected)
228
+ cache.qs.start = qs.start
229
+ cache.response.numFound = response.numFound
230
+ cache.response.results.push(...response.results)
231
+ return cache.response
232
+ }
233
+ function getShuffledCards(cardBundles) {
234
+ const shuffled = []
235
+ const bundleWithMostCards = cardBundles.reduce(
236
+ (a, b) => (a.results.length > b.results.length ? a : b),
237
+ { results: [] },
238
+ ).results.length
239
+
240
+ for (let i = 0; i < bundleWithMostCards; i++) {
241
+ cardBundles.forEach((bundle) => {
242
+ if (bundle.results[i]) {
243
+ shuffled.push(bundle.results[i])
269
244
  }
270
- this.loadMoreCards(true)
271
- },
272
- async reset() {
273
- this.bundleCache = {}
274
- this.filters.selected = {}
275
- this.filters.availableBundles.length = 0
276
- await this.loadMoreCards(true)
277
- },
278
- sortByDate(cards) {
279
- const sorted = cards.sort((a, b) => {
280
- return new Date(b.dateSort) - new Date(a.dateSort)
281
- })
282
- return sorted
283
- },
284
- },
245
+ })
246
+ }
247
+
248
+ const total = cardBundles.reduce((acc, bundle) => {
249
+ return acc + bundle.numFound
250
+ }, 0)
251
+
252
+ return { cards: shuffled, total }
253
+ }
254
+ const onFilter = (fltrs) => {
255
+ bundleCache.value = {}
256
+ Object.keys(fltrs).forEach((filter) => {
257
+ filters.value.selected[filter] = fltrs[filter].map((obj) => obj.tid)
258
+ })
259
+ loadMoreCards(true)
260
+ }
261
+ const onSwitcher = (switchToBundle) => {
262
+ filters.value.selected = {}
263
+ filters.value.availableBundles.length = 0
264
+ if (switchToBundle) {
265
+ filters.value.availableBundles.push(switchToBundle)
266
+ }
267
+ loadMoreCards(true)
268
+ }
269
+ const reset = async () => {
270
+ bundleCache.value = {}
271
+ filters.value.selected = {}
272
+ filters.value.availableBundles.length = 0
273
+ await loadMoreCards(true)
274
+ }
275
+ function sortByDate(cards) {
276
+ const sorted = cards.sort((a, b) => {
277
+ return new Date(b.dateSort) - new Date(a.dateSort)
278
+ })
279
+ return sorted
285
280
  }
286
281
  </script>
287
282
  <style lang="scss" scoped>
@@ -17,6 +17,7 @@
17
17
  $multiplier: calc(($max - $min) / ($end - $start) * 100);
18
18
  $adder: calc(($min * $end - $max * $start) / ($end - $start));
19
19
  $formula: calc(#{$multiplier + 0vw} + #{$adder + 0px});
20
+ #{$property}: $formula;
20
21
  @if $clip and $clipAtStart {
21
22
  @media (max-width: #{$start + 0px}) {
22
23
  #{$property}: $min + 0px;
@@ -27,5 +28,4 @@
27
28
  #{$property}: $max + 0px;
28
29
  }
29
30
  }
30
- #{$property}: $formula;
31
31
  }
package/src/index.js CHANGED
@@ -59,9 +59,6 @@ import Search from './components/SubComponents/Search/index.vue'
59
59
  import VideoThumbnail from './components/SubComponents/VideoThumbnail/index.vue'
60
60
  import ResourceGroup from './components/SubComponents/ResourceGroup/index.vue'
61
61
 
62
- // Temp Components for testing
63
- import BrowseContent2 from './components/Paragraphs/BrowseContent/setup.vue'
64
-
65
62
  // Export Global Components
66
63
  export {
67
64
  Container,
@@ -128,15 +125,8 @@ export {
128
125
  ResourceGroup,
129
126
  }
130
127
 
131
- // Export for BrowseContent
128
+ // DEPRECATED - to be removed in future
132
129
  import DirectoryFilters from './components/Global/DirectoryFilters/index.vue'
133
130
  import Switcher from './components/Paragraphs/BrowseContent/switcher.vue'
134
131
 
135
- export {
136
- // CardGroup, already imported
137
- DirectoryFilters,
138
- Switcher,
139
- }
140
-
141
- // Temp Components for testing
142
- export { BrowseContent2 }
132
+ export { DirectoryFilters, Switcher }
@@ -1,284 +0,0 @@
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>