@worksafevictoria/wcl7.5 1.9.0-beta.18 → 1.9.0-beta.19

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.9.0-beta.18",
3
+ "version": "1.9.0-beta.19",
4
4
  "main": "src/index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,7 +14,10 @@
14
14
  :background-variant="background"
15
15
  @selected="selectedCard"
16
16
  >
17
- <template v-if="enableBundleFilter && bundle.length > 1" v-slot:gridHeaderRight>
17
+ <template
18
+ v-if="enableBundleFilter && bundle.length > 1"
19
+ v-slot:gridHeaderRight
20
+ >
18
21
  <switcher
19
22
  v-if="enableBundleFilter"
20
23
  :options="bundle"
@@ -45,7 +48,8 @@
45
48
  :class="{
46
49
  [`card_group__card--${card.colour}`]: card.pillText,
47
50
  [`card_group__card--none`]: !card.pillText,
48
- [`card_group__card--${cardResourseType}`]: 'card_group__card--resourse-group',
51
+ [`card_group__card--${cardResourseType}`]:
52
+ 'card_group__card--resourse-group',
49
53
  }"
50
54
  :card-header-title="card.title"
51
55
  :caret="getCaret(card)"
@@ -71,7 +75,10 @@
71
75
  </template>
72
76
 
73
77
  <!-- footer - download button -->
74
- <template v-if="cardResourseType === 'resource-group'" v-slot:cardFooter>
78
+ <template
79
+ v-if="cardResourseType === 'resource-group'"
80
+ v-slot:cardFooter
81
+ >
75
82
  <card-footer :card="card" :resource-type="cardResourseType" />
76
83
  </template>
77
84
  </card-grid-item>
@@ -113,20 +120,24 @@
113
120
  </template>
114
121
 
115
122
  <script>
116
- import Column from "./../../Containers/Column/index.vue";
117
- import CardGrid from "./../../Common/CardGrid/index.vue";
118
- import CardGridItem from "./../../Common/CardGridItem/index.vue";
119
- import CardTop from "./cardtop.vue";
120
- import CardBody from "./cardbody.vue";
121
- import CardFooter from "./cardfooter.vue";
122
- import CtaButton from "./../CtaButton/index.vue";
123
- import DirectoryFilters from "./../../Global/DirectoryFilters/index.vue";
124
- import Switcher from "./switcher.vue";
125
- import { isAbsoluteUrl, navigateToPath, isGovSite } from "./../../../../lib/utility";
126
- import { BSpinner } from "bootstrap-vue-next";
123
+ import Column from './../../Containers/Column/index.vue'
124
+ import CardGrid from './../../Common/CardGrid/index.vue'
125
+ import CardGridItem from './../../Common/CardGridItem/index.vue'
126
+ import CardTop from './cardtop.vue'
127
+ import CardBody from './cardbody.vue'
128
+ import CardFooter from './cardfooter.vue'
129
+ import CtaButton from './../CtaButton/index.vue'
130
+ import DirectoryFilters from './../../Global/DirectoryFilters/index.vue'
131
+ import Switcher from './switcher.vue'
132
+ import {
133
+ isAbsoluteUrl,
134
+ navigateToPath,
135
+ isGovSite,
136
+ } from './../../../../lib/utility'
137
+ import { BSpinner } from 'bootstrap-vue-next'
127
138
 
128
139
  export default {
129
- name: "ResourceGroup",
140
+ name: 'ResourceGroup',
130
141
  components: {
131
142
  Column,
132
143
  CardGrid,
@@ -142,15 +153,15 @@ export default {
142
153
  props: {
143
154
  background: {
144
155
  type: String,
145
- default: "white",
156
+ default: 'white',
146
157
  },
147
158
  title: {
148
159
  type: String,
149
- default: "",
160
+ default: '',
150
161
  },
151
162
  titleTag: {
152
163
  type: String,
153
- default: "h2",
164
+ default: 'h2',
154
165
  },
155
166
  rtl: {
156
167
  type: Boolean,
@@ -158,7 +169,7 @@ export default {
158
169
  },
159
170
  bundle: {
160
171
  type: Array,
161
- default: () => [""],
172
+ default: () => [''],
162
173
  },
163
174
  columns: {
164
175
  type: Number,
@@ -191,7 +202,7 @@ export default {
191
202
  },
192
203
  resourceType: {
193
204
  type: String,
194
- default: "resource-group",
205
+ default: 'resource-group',
195
206
  },
196
207
  showLoadMore: {
197
208
  type: Boolean,
@@ -199,7 +210,7 @@ export default {
199
210
  },
200
211
  emptyCardsText: {
201
212
  type: String,
202
- default: "No results returned",
213
+ default: 'No results returned',
203
214
  },
204
215
  loading: {
205
216
  type: Boolean,
@@ -209,11 +220,11 @@ export default {
209
220
  // Temp use of mounted to replace fetch
210
221
  async mounted() {
211
222
  if (this.displayedCards.length === 0) {
212
- console.log(
213
- "🚀 ~ mounted ~ this.displayedCards.length:",
214
- this.displayedCards.length
215
- );
216
- await this.loadFiltersAndContent();
223
+ // console.log(
224
+ // "🚀 ~ mounted ~ this.displayedCards.length:",
225
+ // this.displayedCards.length
226
+ // );
227
+ await this.loadFiltersAndContent()
217
228
  }
218
229
  },
219
230
  // TODO useAsyncData <script setup>
@@ -237,92 +248,97 @@ export default {
237
248
  selected: {},
238
249
  availableBundles: [],
239
250
  },
240
- };
251
+ }
241
252
  },
242
253
  computed: {
243
254
  allCardsRTL() {
244
255
  if (this.displayedCards.length === 0) {
245
- return this.rtl;
256
+ return this.rtl
246
257
  }
247
- return this.displayedCards.every((card) => this.rtl || card.rtl);
258
+ return this.displayedCards.every((card) => this.rtl || card.rtl)
248
259
  },
249
260
  },
250
261
  fetchOnServer: true,
251
- fetchKey: "wcl-card-group",
262
+ fetchKey: 'wcl-card-group',
252
263
  methods: {
253
264
  async loadFiltersAndContent() {
254
265
  await Promise.all([
255
266
  this.fetchFilters ? this.loadFilters() : Promise.resolve(),
256
267
  this.loadMoreCards(true),
257
- ]);
258
- console.log("🚀 ~ loadFiltersAndContent ~ this.fetchFilters:", this.fetchFilters);
268
+ ])
269
+ console.log(
270
+ '🚀 ~ loadFiltersAndContent ~ this.fetchFilters:',
271
+ this.fetchFilters,
272
+ )
259
273
  },
260
274
  init() {
261
275
  this.allCards = {
262
276
  total: 0,
263
277
  cards: [],
264
- };
265
- this.displayLimit = 0;
266
- this.hasMorePages = false;
267
- this.displayedCards = [];
268
- this.bundleCache = {};
278
+ }
279
+ this.displayLimit = 0
280
+ this.hasMorePages = false
281
+ this.displayedCards = []
282
+ this.bundleCache = {}
269
283
  },
270
284
  async fetchCards(currentDisplayedCards, allCards, addMoreBy, bundles) {
271
285
  const shouldMakeNewFetchCall =
272
- currentDisplayedCards.length + addMoreBy > allCards.cards.length;
286
+ currentDisplayedCards.length + addMoreBy > allCards.cards.length
273
287
 
274
288
  if (shouldMakeNewFetchCall) {
275
289
  const cardBundles = await Promise.all(
276
- bundles.map((bundle, index) => this.getBundle(bundle, addMoreBy, index))
277
- );
290
+ bundles.map((bundle, index) =>
291
+ this.getBundle(bundle, addMoreBy, index),
292
+ ),
293
+ )
278
294
 
279
- allCards = this.getShuffledCards(cardBundles);
295
+ allCards = this.getShuffledCards(cardBundles)
280
296
 
281
297
  if (
282
- this.type === "paragraph--cards_group_latest" ||
283
- this.type === "paragraph--browse_content" ||
284
- this.type === "paragraph--resource_group" ||
285
- this.type === "paragraph--resource_list"
298
+ this.type === 'paragraph--cards_group_latest' ||
299
+ this.type === 'paragraph--browse_content' ||
300
+ this.type === 'paragraph--resource_group' ||
301
+ this.type === 'paragraph--resource_list'
286
302
  ) {
287
303
  // allCards.cards = this.sortByDate(allCards.cards);
288
- allCards.cards = allCards.cards;
304
+ allCards.cards = allCards.cards
289
305
  }
290
306
  }
291
- return allCards;
307
+ return allCards
292
308
  },
293
309
  async loadMoreCards(init) {
294
310
  const attrs = {
295
311
  group: this.$pageStore?.content?.title,
296
312
  //group: this.$store?.state?.page?.content?.title,
297
- };
313
+ }
298
314
  if (this.$gtm && !init) {
299
- this.$gtm.push({ event: "custom.interaction.showmore.click", ...attrs });
315
+ this.$gtm.push({ event: 'custom.interaction.showmore.click', ...attrs })
300
316
  }
301
317
  if (init) {
302
- this.init();
318
+ this.init()
303
319
  }
304
- this.loader = true;
305
- const addMoreBy = this.initialDisplyLimit;
306
- this.displayLimit += addMoreBy;
320
+ this.loader = true
321
+ const addMoreBy = this.initialDisplyLimit
322
+ this.displayLimit += addMoreBy
307
323
  const bundles =
308
324
  this.filters.availableBundles.length > 0
309
325
  ? this.filters.availableBundles
310
- : this.bundle;
326
+ : this.bundle
311
327
  this.allCards = await this.fetchCards(
312
328
  this.displayedCards,
313
329
  this.allCards,
314
330
  addMoreBy,
315
- bundles
316
- );
331
+ bundles,
332
+ )
317
333
 
318
- this.hasMorePages = this.allCards.total > this.allCards.cards.length;
319
- this.displayedCards = this.allCards.cards.slice(0, this.displayLimit);
334
+ this.hasMorePages = this.allCards.total > this.allCards.cards.length
335
+ this.displayedCards = this.allCards.cards.slice(0, this.displayLimit)
320
336
 
321
- this.loader = false;
337
+ this.loader = false
322
338
  },
323
339
  getBundle(bundle, addMoreBy, index) {
324
- let start;
325
- const rows = addMoreBy;
340
+ let start
341
+ const rows = addMoreBy
326
342
  const cache = (this.bundleCache[bundle] = this.bundleCache[bundle] || {
327
343
  response: {
328
344
  results: [],
@@ -331,166 +347,177 @@ export default {
331
347
  qs: {
332
348
  start,
333
349
  },
334
- });
350
+ })
335
351
 
336
352
  if (cache.qs.start === undefined) {
337
- start = 0;
353
+ start = 0
338
354
  } else if (cache.response.numFound > cache.response.results.length) {
339
- start = cache.response.results.length;
355
+ start = cache.response.results.length
340
356
  } else {
341
- return Promise.resolve(cache.response);
357
+ return Promise.resolve(cache.response)
342
358
  }
343
359
 
344
360
  const qs = {
345
361
  bundle,
346
362
  rows,
347
363
  start,
348
- };
349
- return this.fetchContent(qs, this.filters.selected, index).then((response) => {
350
- cache.qs.start = qs.start;
351
- cache.response.numFound = response.numFound;
352
- cache.response.results.push(...response.results);
353
- return cache.response;
354
- });
364
+ }
365
+ return this.fetchContent(qs, this.filters.selected, index).then(
366
+ (response) => {
367
+ cache.qs.start = qs.start
368
+ cache.response.numFound = response.numFound
369
+ cache.response.results.push(...response.results)
370
+ return cache.response
371
+ },
372
+ )
355
373
  },
356
374
  getShuffledCards(cardBundles) {
357
- const shuffled = [];
375
+ const shuffled = []
358
376
  const bundleWithMostCards = cardBundles.reduce(
359
377
  (a, b) => (a.results.length > b.results.length ? a : b),
360
- { results: [] }
361
- ).results.length;
378
+ { results: [] },
379
+ ).results.length
362
380
 
363
381
  for (let i = 0; i < bundleWithMostCards; i++) {
364
382
  cardBundles.forEach((bundle) => {
365
383
  if (bundle.results[i]) {
366
- shuffled.push(bundle.results[i]);
384
+ shuffled.push(bundle.results[i])
367
385
  }
368
- });
386
+ })
369
387
  }
370
388
 
371
389
  const total = cardBundles.reduce((acc, bundle) => {
372
- return acc + bundle.numFound;
373
- }, 0);
390
+ return acc + bundle.numFound
391
+ }, 0)
374
392
 
375
- return { cards: shuffled, total };
393
+ return { cards: shuffled, total }
376
394
  },
377
395
  loadFilters() {
378
396
  return this.fetchFilters().then((taxonomies) => {
379
- console.log("🚀 ~ returnthis.fetchFilters ~ taxonomies:", taxonomies);
380
- this.filters.taxonomies = taxonomies;
381
- return Promise.resolve(taxonomies);
382
- });
397
+ console.log('🚀 ~ returnthis.fetchFilters ~ taxonomies:', taxonomies)
398
+ this.filters.taxonomies = taxonomies
399
+ return Promise.resolve(taxonomies)
400
+ })
383
401
  },
384
402
  onFilter(filters) {
385
- this.bundleCache = {};
403
+ this.bundleCache = {}
386
404
  Object.keys(filters).forEach((filter) => {
387
- this.filters.selected[filter] = filters[filter].map((obj) => obj.tid);
388
- });
389
- this.loadMoreCards(true);
405
+ this.filters.selected[filter] = filters[filter].map((obj) => obj.tid)
406
+ })
407
+ this.loadMoreCards(true)
390
408
  },
391
409
  onSwitcher(switchToBundle) {
392
- this.filters.selected = {};
393
- this.filters.availableBundles.length = 0;
410
+ this.filters.selected = {}
411
+ this.filters.availableBundles.length = 0
394
412
  if (switchToBundle) {
395
- this.filters.availableBundles.push(switchToBundle);
413
+ this.filters.availableBundles.push(switchToBundle)
396
414
  }
397
- this.loadMoreCards(true);
415
+ this.loadMoreCards(true)
398
416
  },
399
417
  async reset() {
400
- this.bundleCache = {};
401
- this.filters.selected = {};
402
- this.filters.availableBundles.length = 0;
403
- await this.loadMoreCards(true);
418
+ this.bundleCache = {}
419
+ this.filters.selected = {}
420
+ this.filters.availableBundles.length = 0
421
+ await this.loadMoreCards(true)
404
422
  },
405
423
  sortByDate(cards) {
406
424
  const sorted = cards.sort((a, b) => {
407
- return new Date(b.dateSort) - new Date(a.dateSort);
408
- });
409
- return sorted;
425
+ return new Date(b.dateSort) - new Date(a.dateSort)
426
+ })
427
+ return sorted
410
428
  },
411
429
  handleLoadMore() {
412
- this.loadMoreCards(false);
430
+ this.loadMoreCards(false)
413
431
  },
414
432
 
415
433
  getCaret(card) {
416
434
  if (card.link && isAbsoluteUrl(card.link)) {
417
- return "external";
435
+ return 'external'
418
436
  } else {
419
- return undefined;
437
+ return undefined
420
438
  }
421
439
  },
422
440
  selectedCard(card) {
423
441
  // Some custom logic for gov caretaker logic
424
442
  if (
425
- (this.$config ? this.$config.public.caretaker : process.env.CARETAKER) === "true"
443
+ (this.$config
444
+ ? this.$config.public.caretaker
445
+ : process.env.CARETAKER) === 'true'
426
446
  ) {
427
447
  if (!isGovSite(card?.selectedCard?.link)) {
428
448
  // this.$store.commit('page/SET_CARETAKER_REF', 'list-group')
429
449
  // this.$root.$emit('caretaker-open', card?.selectedCard?.link)
430
450
  if (this.$pageStore) {
431
- this.$pageStore.caretaker.referrer = "list-group";
451
+ this.$pageStore.caretaker.referrer = 'list-group'
432
452
  }
433
453
  if (this.$bus) {
434
- this.$bus.$emit("caretaker-open", card?.selectedCard?.link);
454
+ this.$bus.$emit('caretaker-open', card?.selectedCard?.link)
435
455
  }
436
456
  } else {
437
457
  navigateToPath.call(
438
458
  this,
439
459
  card?.selectedCard?.link,
440
- card?.ev?.ctrlKey === true || card?.ev?.metaKey === true
441
- );
460
+ card?.ev?.ctrlKey === true || card?.ev?.metaKey === true,
461
+ )
442
462
  }
443
463
  } else {
444
464
  navigateToPath.call(
445
465
  this,
446
466
  card?.selectedCard?.link,
447
- card?.ev?.ctrlKey === true || card?.ev?.metaKey === true
448
- );
467
+ card?.ev?.ctrlKey === true || card?.ev?.metaKey === true,
468
+ )
449
469
  }
450
470
  },
451
471
  focussed(ev) {
452
- const path = ev.path || (ev.composedPath && ev.composedPath());
453
- const theTabbedCards = path.find((el) => el["_prevClass"] === "tabbed-cards");
472
+ const path = ev.path || (ev.composedPath && ev.composedPath())
473
+ const theTabbedCards = path.find(
474
+ (el) => el['_prevClass'] === 'tabbed-cards',
475
+ )
454
476
  if (ev.shiftKey && theTabbedCards) {
455
- ev.preventDefault();
456
- let selectedTabbedCards = theTabbedCards.getElementsByClassName("isSelected");
457
- let selectedCard = selectedTabbedCards[0].getElementsByTagName("button");
458
- let thePrevLGItem = ev.target?.parentElement?.parentElement?.previousSibling?.getElementsByTagName(
459
- "button"
460
- );
477
+ ev.preventDefault()
478
+ let selectedTabbedCards =
479
+ theTabbedCards.getElementsByClassName('isSelected')
480
+ let selectedCard = selectedTabbedCards[0].getElementsByTagName('button')
481
+ let thePrevLGItem =
482
+ ev.target?.parentElement?.parentElement?.previousSibling?.getElementsByTagName(
483
+ 'button',
484
+ )
461
485
  if (thePrevLGItem) {
462
- thePrevLGItem[0].focus();
486
+ thePrevLGItem[0].focus()
463
487
  } else {
464
- selectedCard[0].focus();
488
+ selectedCard[0].focus()
465
489
  }
466
490
  } else if (!ev.shiftKey && theTabbedCards) {
467
- ev.preventDefault();
468
- let selectedTabbedCards = theTabbedCards.getElementsByClassName("isSelected");
469
- let nextTabbedCard = selectedTabbedCards[0]?.parentElement?.nextSibling?.getElementsByTagName(
470
- "button"
471
- );
472
- let theNextLGItem = ev.target?.parentElement?.parentElement?.nextSibling?.getElementsByTagName(
473
- "button"
474
- );
491
+ ev.preventDefault()
492
+ let selectedTabbedCards =
493
+ theTabbedCards.getElementsByClassName('isSelected')
494
+ let nextTabbedCard =
495
+ selectedTabbedCards[0]?.parentElement?.nextSibling?.getElementsByTagName(
496
+ 'button',
497
+ )
498
+ let theNextLGItem =
499
+ ev.target?.parentElement?.parentElement?.nextSibling?.getElementsByTagName(
500
+ 'button',
501
+ )
475
502
  if (theNextLGItem) {
476
- theNextLGItem[0].focus();
503
+ theNextLGItem[0].focus()
477
504
  } else if (nextTabbedCard) {
478
- nextTabbedCard[0].focus();
505
+ nextTabbedCard[0].focus()
479
506
  } else {
480
- let nextFocus = this.focusNextElement();
507
+ let nextFocus = this.focusNextElement()
481
508
  if (this.$bus) {
482
- this.$bus.$emit("last-focus-out");
509
+ this.$bus.$emit('last-focus-out')
483
510
  }
484
- nextFocus.focus();
511
+ nextFocus.focus()
485
512
  }
486
513
  } else {
487
- return true;
514
+ return true
488
515
  }
489
516
  },
490
517
  focusNextElement(reverse, activeElem) {
491
518
  /*check if an element is defined or use activeElement*/
492
519
  activeElem =
493
- activeElem instanceof HTMLElement ? activeElem : document.activeElement;
520
+ activeElem instanceof HTMLElement ? activeElem : document.activeElement
494
521
 
495
522
  let queryString = [
496
523
  'a:not([disabled]):not([tabindex="-1"])',
@@ -499,19 +526,23 @@ export default {
499
526
  'select:not([disabled]):not([tabindex="-1"])',
500
527
  '[tabindex]:not([disabled]):not([tabindex="-1"])',
501
528
  /* add custom queries here */
502
- ].join(","),
529
+ ].join(','),
503
530
  queryResult = Array.prototype.filter.call(
504
531
  document.querySelectorAll(queryString),
505
532
  (elem) => {
506
533
  /*check for visibility while always include the current activeElement*/
507
- return elem.offsetWidth > 0 || elem.offsetHeight > 0 || elem === activeElem;
508
- }
534
+ return (
535
+ elem.offsetWidth > 0 ||
536
+ elem.offsetHeight > 0 ||
537
+ elem === activeElem
538
+ )
539
+ },
509
540
  ),
510
541
  indexedList = queryResult
511
542
  .slice()
512
543
  .filter((elem) => {
513
544
  /* filter out all indexes not greater than 0 */
514
- return elem.tabIndex == 0 || elem.tabIndex == -1 ? false : true;
545
+ return elem.tabIndex == 0 || elem.tabIndex == -1 ? false : true
515
546
  })
516
547
  .sort((a, b) => {
517
548
  /* sort the array by index from smallest to largest */
@@ -519,33 +550,34 @@ export default {
519
550
  ? a.tabIndex < b.tabIndex
520
551
  ? -1
521
552
  : b.tabIndex < a.tabIndex
522
- ? 1
523
- : 0
553
+ ? 1
554
+ : 0
524
555
  : a.tabIndex != 0
525
- ? -1
526
- : b.tabIndex != 0
527
- ? 1
528
- : 0;
556
+ ? -1
557
+ : b.tabIndex != 0
558
+ ? 1
559
+ : 0
529
560
  }),
530
561
  focusable = [].concat(
531
562
  indexedList,
532
563
  queryResult.filter((elem) => {
533
564
  /* filter out all indexes above 0 */
534
- return elem.tabIndex == 0 || elem.tabIndex == -1 ? true : false;
535
- })
536
- );
565
+ return elem.tabIndex == 0 || elem.tabIndex == -1 ? true : false
566
+ }),
567
+ )
537
568
 
538
569
  /* if reverse is true return the previous focusable element
539
570
  if reverse is false return the next focusable element */
540
571
  return reverse
541
- ? focusable[focusable.indexOf(activeElem) - 1] || focusable[focusable.length - 1]
542
- : focusable[focusable.indexOf(activeElem) + 1] || focusable[0];
572
+ ? focusable[focusable.indexOf(activeElem) - 1] ||
573
+ focusable[focusable.length - 1]
574
+ : focusable[focusable.indexOf(activeElem) + 1] || focusable[0]
543
575
  },
544
576
  },
545
- };
577
+ }
546
578
  </script>
547
579
  <style lang="scss" scoped>
548
- @import "../../../includes/scss/all";
580
+ @import '../../../includes/scss/all';
549
581
  $cardTextPadding: 16px;
550
582
  $borderRadius: 8px;
551
583