@worksafevictoria/wcl7.5 1.1.0-beta.74 → 1.1.0-beta.76

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/bin/deploy.sh CHANGED
@@ -22,4 +22,4 @@ cd storybook-static
22
22
 
23
23
  # Deploy to GH-Pages
24
24
  cd ..
25
- node node_modules/gh-pages/bin/gh-pages.js -d storybook-static -t true
25
+ node node_modules/gh-pages/bin/gh-pages.js -d storybook-static
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worksafevictoria/wcl7.5",
3
- "version": "1.1.0-beta.74",
3
+ "version": "1.1.0-beta.76",
4
4
  "main": "src/index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -10,3 +10,54 @@
10
10
  border: none !important;
11
11
  }
12
12
  }
13
+
14
+ .modal-dialog {
15
+ .modal-content {
16
+ .modal-body {
17
+ .section-group__block {
18
+ max-width: 100%;
19
+ }
20
+ }
21
+ border-radius: 8px;
22
+ }
23
+ .modal-body {
24
+ padding: 32px;
25
+ fieldset {
26
+ display: flex;
27
+ flex-direction: row;
28
+ flex-wrap: wrap;
29
+ legend {
30
+ font-size: 28px;
31
+ font-weight: 700;
32
+ line-height: 32px;
33
+ letter-spacing: 0px;
34
+ margin-bottom: 32px;
35
+ }
36
+ .option {
37
+ margin-bottom: 32px;
38
+ flex-basis: 50%;
39
+ display: flex;
40
+ @media screen and (max-width: 600px) {
41
+ flex-basis: 100%;
42
+ }
43
+ input[type='checkbox'] {
44
+ height: 24px;
45
+ border: 1px solid #bababa;
46
+ width: 24px;
47
+ cursor: pointer;
48
+ }
49
+ label {
50
+ margin: 0px;
51
+ width: 80%;
52
+ position: relative;
53
+ left: 16px;
54
+ cursor: pointer;
55
+ }
56
+ }
57
+ }
58
+ }
59
+ .modal-footer,
60
+ .modal-header {
61
+ border: none;
62
+ }
63
+ }
@@ -33,8 +33,8 @@
33
33
  [`card-grid-item__control-radio`]:
34
34
  isSelectable && buttonRole === 'radio',
35
35
  [`card-grid-item__selected-radio`]:
36
- selected && buttonRole === 'radio'
37
- }
36
+ selected && buttonRole === 'radio',
37
+ },
38
38
  ]"
39
39
  >
40
40
  <slot name="cardTop"></slot>
@@ -52,7 +52,7 @@
52
52
  :icon-is-bordered="iconIsBordered"
53
53
  :class="{
54
54
  [`text-left`]: iconPosition === 'top-left',
55
- rtl: rtl
55
+ rtl: rtl,
56
56
  }"
57
57
  >
58
58
  </card-grid-item-icon>
@@ -63,8 +63,8 @@
63
63
  {
64
64
  rtl: rtl,
65
65
  [`card-grid-item__caretContainer__control-radio`]:
66
- isSelectable && buttonRole === 'radio'
67
- }
66
+ isSelectable && buttonRole === 'radio',
67
+ },
68
68
  ]"
69
69
  >
70
70
  <b-card-title
@@ -74,7 +74,7 @@
74
74
  :class="{
75
75
  [`card-grid-item__header--${headerSize}`]: true,
76
76
  [`card-grid-item__header--align-${headerTextAlign}`]: true,
77
- 'card-grid-item__header--cursor': isCardTitleSelectable
77
+ 'card-grid-item__header--cursor': isCardTitleSelectable,
78
78
  }"
79
79
  @click="cardTitleClicked($event)"
80
80
  >
@@ -122,7 +122,7 @@
122
122
  class="d-inline card-grid-item-icon--top-right"
123
123
  :class="{
124
124
  [`text-right`]: iconPosition === 'top-right',
125
- rtl: rtl
125
+ rtl: rtl,
126
126
  }"
127
127
  :rtl="rtl"
128
128
  >
@@ -134,7 +134,7 @@
134
134
  text-tag="div"
135
135
  class="card-grid-item__body"
136
136
  :class="{
137
- rtl: rtl
137
+ rtl: rtl,
138
138
  }"
139
139
  >
140
140
  <div
@@ -142,7 +142,7 @@
142
142
  :class="{
143
143
  [descriptionClass]: !!descriptionClass,
144
144
  [`card-grid-item__description--withIcon`]:
145
- iconPosition === 'before-description'
145
+ iconPosition === 'before-description',
146
146
  }"
147
147
  >
148
148
  <card-grid-item-icon
@@ -181,7 +181,7 @@
181
181
  v-if="caretPosition === 'bottom'"
182
182
  class="card-grid-item__caretContainer card-grid-item__caretContainer--bottom"
183
183
  :class="{
184
- rtl: !rtl
184
+ rtl: !rtl,
185
185
  }"
186
186
  >
187
187
  <card-grid-item-caret :caret="caret" :rtl="rtl" />
@@ -196,52 +196,60 @@
196
196
  import CardGridItemIcon from './card-grid-item-icon.vue'
197
197
  import CardGridItemCaret from './card-grid-item-caret.vue'
198
198
  import RichText from '../../Paragraphs/RichText/index.vue'
199
- import parseISO from 'date-fns/parseISO'
199
+ import { parseISO } from 'date-fns'
200
200
  import { isAbsoluteUrl, isGovSite } from '../../../../lib/utility'
201
201
  import { BCard, BCardBody, BCardTitle, BCardText } from 'bootstrap-vue-next'
202
202
 
203
203
  export default {
204
204
  name: 'CardGridItem',
205
- components: {CardGridItemIcon, CardGridItemCaret, RichText, BCard, BCardBody, BCardTitle, BCardText },
205
+ components: {
206
+ CardGridItemIcon,
207
+ CardGridItemCaret,
208
+ RichText,
209
+ BCard,
210
+ BCardBody,
211
+ BCardTitle,
212
+ BCardText,
213
+ },
206
214
  props: {
207
215
  backgroundVariant: {
208
216
  type: String,
209
217
  default: 'white',
210
218
  validator: (value) =>
211
- ['white', 'transparent', 'light'].indexOf(value) >= 0
219
+ ['white', 'transparent', 'light'].indexOf(value) >= 0,
212
220
  },
213
221
  imageSrc: {
214
222
  type: String,
215
- default: null
223
+ default: null,
216
224
  },
217
225
  imageAlt: {
218
226
  type: String,
219
- default: null
227
+ default: null,
220
228
  },
221
229
  description: {
222
230
  type: String,
223
- default: null
231
+ default: null,
224
232
  },
225
233
  stripDescriptionHtml: {
226
- type: Boolean
234
+ type: Boolean,
227
235
  },
228
236
  descriptionClass: {
229
237
  type: String,
230
- default: ''
238
+ default: '',
231
239
  },
232
240
  glyphSrc: {
233
241
  type: [Object, String],
234
- default: null
242
+ default: null,
235
243
  },
236
244
  glyphIconComponent: {
237
245
  type: String,
238
- default: null
246
+ default: null,
239
247
  },
240
248
  iconSize: {
241
249
  type: String,
242
250
  default: 'small',
243
251
  validator: (value) =>
244
- ['xsmall', 'small', 'medium', 'large'].indexOf(value) >= 0
252
+ ['xsmall', 'small', 'medium', 'large'].indexOf(value) >= 0,
245
253
  },
246
254
  iconPosition: {
247
255
  type: String,
@@ -252,112 +260,113 @@ export default {
252
260
  'top-left',
253
261
  'top-right',
254
262
  'after-title',
255
- 'before-description'
256
- ].indexOf(value) >= 0
263
+ 'before-description',
264
+ ].indexOf(value) >= 0,
257
265
  },
258
266
  iconIsBordered: {
259
267
  type: Boolean,
260
- default: true
268
+ default: true,
261
269
  },
262
270
  showDivider: {
263
- type: Boolean
271
+ type: Boolean,
264
272
  },
265
273
  cardHeaderTitle: {
266
274
  type: String,
267
- default: null
275
+ default: null,
268
276
  },
269
277
  invertOnSelectBackground: {
270
278
  type: String,
271
279
  default: 'none',
272
- validator: (value) => ['none', 'yellow', 'black'].indexOf(value) >= 0
280
+ validator: (value) => ['none', 'yellow', 'black'].indexOf(value) >= 0,
273
281
  },
274
282
  borderOnSelectBackground: {
275
283
  type: String,
276
284
  default: 'none',
277
285
  validator: (value) =>
278
- ['none', 'yellow', 'black', 'blue'].indexOf(value) >= 0
286
+ ['none', 'yellow', 'black', 'blue'].indexOf(value) >= 0,
279
287
  },
280
288
  rtl: {
281
289
  type: Boolean,
282
- default: false
290
+ default: false,
283
291
  },
284
292
  headerSize: {
285
293
  type: String,
286
294
  default: 'custom',
287
295
  validator: (value) =>
288
296
  ['medium', 'large', 'extra-large', 'extra-2x-large', 'custom'].indexOf(
289
- value
290
- ) >= 0
297
+ value,
298
+ ) >= 0,
291
299
  },
292
300
  headerTextAlign: {
293
301
  type: String,
294
302
  default: 'left',
295
- validator: (value) => ['left', 'center', 'right'].indexOf(value) >= 0
303
+ validator: (value) => ['left', 'center', 'right'].indexOf(value) >= 0,
296
304
  },
297
305
  headerTag: {
298
306
  type: String,
299
307
  required: false,
300
- default: 'h3'
308
+ default: 'h3',
301
309
  },
302
310
  caret: {
303
311
  type: String,
304
312
  default: undefined,
305
313
  validator: (value) =>
306
- ['down', 'up', 'right', 'left', 'external'].indexOf(value) >= 0
314
+ ['down', 'up', 'right', 'left', 'external'].indexOf(value) >= 0,
307
315
  },
308
316
  caretPosition: {
309
317
  type: String,
310
318
  default: 'top',
311
- validator: (value) => ['top', 'bottom', 'after-title'].indexOf(value) >= 0
319
+ validator: (value) =>
320
+ ['top', 'bottom', 'after-title'].indexOf(value) >= 0,
312
321
  },
313
322
  cardPadding: {
314
323
  type: String,
315
324
  default: 'none',
316
325
  validator: (value) =>
317
- ['none', 'xsmall', 'small', 'medium', 'large'].indexOf(value) >= 0
326
+ ['none', 'xsmall', 'small', 'medium', 'large'].indexOf(value) >= 0,
318
327
  },
319
328
  borderType: {
320
329
  type: String,
321
330
  default: 'none',
322
331
  validator: (value) =>
323
- ['none', 'thin', 'shadow', 'thick', 'dark'].indexOf(value) >= 0
332
+ ['none', 'thin', 'shadow', 'thick', 'dark'].indexOf(value) >= 0,
324
333
  },
325
334
  cardTextAlign: {
326
335
  type: String,
327
- default: 'left'
336
+ default: 'left',
328
337
  },
329
338
  disableSelect: {
330
339
  type: Boolean,
331
- default: false
340
+ default: false,
332
341
  },
333
342
  pillText: {
334
343
  type: String,
335
- default: ''
344
+ default: '',
336
345
  },
337
346
  buttonRole: {
338
347
  type: String,
339
- default: 'link'
348
+ default: 'link',
340
349
  },
341
350
  isSelected: {
342
351
  type: Boolean,
343
- default: false
352
+ default: false,
344
353
  },
345
354
  isExpandable: {
346
355
  type: Boolean,
347
- default: false
356
+ default: false,
348
357
  },
349
358
  link: {
350
359
  type: [String, Boolean],
351
- default: false
360
+ default: false,
352
361
  },
353
362
  taxonomies: {
354
363
  type: Object,
355
- default: () => {}
364
+ default: () => {},
356
365
  },
357
366
  isCardTitleSelectable: {
358
367
  type: Boolean,
359
- default: false
360
- }
368
+ default: false,
369
+ },
361
370
  },
362
371
  data: () => ({
363
372
  isSelectable: false,
@@ -367,7 +376,7 @@ export default {
367
376
  isMobileView: false,
368
377
  isTabletView: false,
369
378
  selected: false,
370
- isAbsoluteUrl
379
+ isAbsoluteUrl,
371
380
  }),
372
381
  computed: {
373
382
  cardClass() {
@@ -394,12 +403,12 @@ export default {
394
403
  [`card-grid-item__card--border-${this.borderType}`]: true,
395
404
  [`card-grid-item__card--bg-${this.backgroundVariant}`]: true,
396
405
  [`card-grid-item__card--select-${this.buttonRole}`]: true,
397
- [`card-grid-item__card--align-${this.cardTextAlign}`]: true
406
+ [`card-grid-item__card--align-${this.cardTextAlign}`]: true,
398
407
  }
399
408
  },
400
409
  urlHostname() {
401
410
  return window.location.protocol + '//' + window.location.host
402
- }
411
+ },
403
412
  },
404
413
  mounted() {
405
414
  this.selected = this.isSelected
@@ -468,8 +477,8 @@ export default {
468
477
  if (theEl && theEl.length > 0) {
469
478
  var content = {
470
479
  content: this.$diffInDays(
471
- parseISO(theEl[0]?.componentOptions?.propsData?.card?.created)
472
- )
480
+ parseISO(theEl[0]?.componentOptions?.propsData?.card?.created),
481
+ ),
473
482
  }
474
483
  }
475
484
  if (this.$gtm) {
@@ -484,33 +493,33 @@ export default {
484
493
  label: this.cardHeaderTitle,
485
494
  data: linkURL,
486
495
  ...content,
487
- ...this.taxonomies
496
+ ...this.taxonomies,
488
497
  }
489
498
  // fire the default event
490
499
  this.$gtm.push({
491
500
  event: 'custom.interaction.tile.click',
492
501
  group: this?.parentGrid?.title,
493
- ...attrs
502
+ ...attrs,
494
503
  })
495
504
  if (this.pillText === 'News') {
496
505
  this.$gtm.push({
497
506
  event: 'custom.interaction.news.click',
498
507
  group: 'News',
499
- ...attrs
508
+ ...attrs,
500
509
  })
501
510
  }
502
511
  if (this.pillText === 'Event') {
503
512
  this.$gtm.push({
504
513
  event: 'custom.interaction.event.click',
505
514
  group: 'Event',
506
- ...attrs
515
+ ...attrs,
507
516
  })
508
517
  }
509
518
  if (this.pillText === 'Safety alert') {
510
519
  this.$gtm.push({
511
520
  event: 'custom.interaction.safety.click',
512
521
  group: 'Safety alert',
513
- ...attrs
522
+ ...attrs,
514
523
  })
515
524
  }
516
525
  if (
@@ -520,7 +529,7 @@ export default {
520
529
  this.$gtm.push({
521
530
  event: 'custom.interaction.outboundlink',
522
531
  category: this.cardHeaderTitle,
523
- label: this.link
532
+ label: this.link,
524
533
  })
525
534
  }
526
535
  }
@@ -534,11 +543,11 @@ export default {
534
543
  this.$gtm.push({
535
544
  event: 'custom.interaction.outboundlink',
536
545
  category: this.cardHeaderTitle,
537
- label: this.link
546
+ label: this.link,
538
547
  })
539
548
  }
540
- }
541
- }
549
+ },
550
+ },
542
551
  }
543
552
  </script>
544
553
 
@@ -203,65 +203,65 @@ h3.cookie-header {
203
203
  }
204
204
  }
205
205
 
206
- .modal-content {
207
- border: none !important;
208
- fieldset {
209
- .option {
210
- margin-bottom: 24px;
211
- display: flex;
212
- margin-right: 0px;
213
- padding-left: 24px;
214
- float: right;
206
+ // .modal-content {
207
+ // border: none !important;
208
+ // fieldset {
209
+ // .option {
210
+ // margin-bottom: 24px;
211
+ // display: flex;
212
+ // margin-right: 0px;
213
+ // padding-left: 24px;
214
+ // float: right;
215
215
 
216
- @media screen and (max-width: 600px) {
217
- flex-basis: 100%;
218
- }
216
+ // @media screen and (max-width: 600px) {
217
+ // flex-basis: 100%;
218
+ // }
219
219
 
220
- input[type='checkbox'] {
221
- height: 24px;
222
- border: 1px solid $gray;
223
- width: 24px;
224
- margin-left: 16px;
225
- margin-right: 16px;
226
- border-radius: 4px;
227
- }
220
+ // input[type='checkbox'] {
221
+ // height: 24px;
222
+ // border: 1px solid $gray;
223
+ // width: 24px;
224
+ // margin-left: 16px;
225
+ // margin-right: 16px;
226
+ // border-radius: 4px;
227
+ // }
228
228
 
229
- label {
230
- font-size: 16px;
231
- font-weight: 400;
232
- vertical-align: middle;
233
- position: relative;
234
- margin-left: 24px;
235
- }
236
- }
229
+ // label {
230
+ // font-size: 16px;
231
+ // font-weight: 400;
232
+ // vertical-align: middle;
233
+ // position: relative;
234
+ // margin-left: 24px;
235
+ // }
236
+ // }
237
237
 
238
- .modal-description {
239
- margin-right: 100px;
240
- }
241
- }
242
- }
238
+ // .modal-description {
239
+ // margin-right: 100px;
240
+ // }
241
+ // }
242
+ // }
243
243
 
244
- .modal-content h5 {
245
- font-weight: 700;
246
- font-size: 20px;
247
- line-height: 24px;
248
- font-style: normal;
249
- color: $black;
250
- }
244
+ // .modal-content h5 {
245
+ // font-weight: 700;
246
+ // font-size: 20px;
247
+ // line-height: 24px;
248
+ // font-style: normal;
249
+ // color: $black;
250
+ // }
251
251
 
252
- .modal {
253
- background: rgba(0,0,0,0.5)
254
- }
252
+ // .modal {
253
+ // background: rgba(0,0,0,0.5)
254
+ // }
255
255
 
256
- .modal-backdrop {
257
- display: none;
258
- }
256
+ // .modal-backdrop {
257
+ // display: none;
258
+ // }
259
259
 
260
- .modal-heading-text {
261
- font-size: 26px;
262
- font-weight: 700;
263
- line-height: 32px;
264
- letter-spacing: 0px;
265
- margin-bottom: 0px;
266
- margin-top: 0px;
267
- }
260
+ // .modal-heading-text {
261
+ // font-size: 26px;
262
+ // font-weight: 700;
263
+ // line-height: 32px;
264
+ // letter-spacing: 0px;
265
+ // margin-bottom: 0px;
266
+ // margin-top: 0px;
267
+ // }
@@ -118,57 +118,3 @@ export default {
118
118
  },
119
119
  }
120
120
  </script>
121
- <style lang="scss">
122
- // Putting all modal styling in one place
123
- // Not working from modal.scss
124
- .modal-dialog {
125
- .modal-content {
126
- .modal-body {
127
- .section-group__block {
128
- max-width: 100%;
129
- }
130
- }
131
- border-radius: 8px;
132
- }
133
- .modal-body {
134
- padding: 32px;
135
- fieldset {
136
- display: flex;
137
- flex-direction: row;
138
- flex-wrap: wrap;
139
- legend {
140
- font-size: 28px;
141
- font-weight: 700;
142
- line-height: 32px;
143
- letter-spacing: 0px;
144
- margin-bottom: 32px;
145
- }
146
- .option {
147
- margin-bottom: 32px;
148
- flex-basis: 50%;
149
- display: flex;
150
- @media screen and (max-width: 600px) {
151
- flex-basis: 100%;
152
- }
153
- input[type='checkbox'] {
154
- height: 24px;
155
- border: 1px solid #bababa;
156
- width: 24px;
157
- cursor: pointer;
158
- }
159
- label {
160
- margin: 0px;
161
- width: 80%;
162
- position: relative;
163
- left: 16px;
164
- cursor: pointer;
165
- }
166
- }
167
- }
168
- }
169
- .modal-footer,
170
- .modal-header {
171
- border: none;
172
- }
173
- }
174
- </style>
@@ -5,7 +5,7 @@
5
5
  <single-taxonomy
6
6
  v-for="(t, i) in computedPropFilters"
7
7
  :key="i"
8
- :ref="`${t.record_id}`"
8
+ :ref="elRef[`${t.record_id}`]"
9
9
  :data="t"
10
10
  :results="filteredList.length"
11
11
  :loading="isFiltering"
@@ -42,8 +42,8 @@
42
42
  ? chart.filter === 'primary'
43
43
  ? by_primary()
44
44
  : chart.filter === 'months'
45
- ? by_months()
46
- : compare()
45
+ ? by_months()
46
+ : compare()
47
47
  : noData()
48
48
  "
49
49
  :options="chart.options"
@@ -54,264 +54,252 @@
54
54
  </container>
55
55
  </template>
56
56
 
57
- <script>
57
+ <script setup>
58
58
  import { GChart } from 'vue-google-charts'
59
- import Container from '../../Containers/Container/index.vue'
59
+ import Container from '../../Containers/Container/index.vue'
60
60
  import Column from '../../Containers/Column/index.vue'
61
61
  import Row from '../../Containers/Row/index.vue'
62
62
  import FilterButton from '../../Common/FilterButton/index.vue' // Reset
63
63
  import SingleTaxonomy from '../../Global/DirectoryFilters/SingleTaxonomy/index.vue'
64
64
  import { BFormGroup, BFormSelect } from 'bootstrap-vue-next'
65
+ import { defineProps, computed, toRefs, ref } from 'vue'
65
66
 
66
- export default {
67
- name: 'Chart',
68
- components: {
69
- Row,
70
- Column,
71
- Container,
72
- GChart,
73
- FilterButton,
74
- SingleTaxonomy,
75
- BFormGroup,
76
- BFormSelect
77
- },
78
- props: {
79
- statsData: { type: Array, default: () => [] },
80
- filterFields: { type: Array, default: () => [] },
81
- chart: { type: Object, default: () => {} }
82
- },
83
- data() {
67
+ const props = defineProps({
68
+ statsData: { type: Array, default: () => [] },
69
+ filterFields: { type: Array, default: () => [] },
70
+ chart: { type: Object, default: () => {} },
71
+ })
72
+
73
+ const { statsData, filterFields, chart } = toRefs(props)
74
+
75
+ const hideReset = ref(true)
76
+ const isFiltering = ref(false)
77
+ const filters = ref({
78
+ taxonomies: [],
79
+ selected: {},
80
+ availableBundles: [],
81
+ })
82
+ const graphSelected = ref(null)
83
+ const chartHeight = ref(
84
+ chart.value.options.height ? chart.value.options.height : 600,
85
+ )
86
+ const elRef = ref({})
87
+
88
+ const graphOptions = computed(() => {
89
+ return filterFields.value.slice(1).map((field) => {
90
+ if (!graphSelected.value) {
91
+ graphSelected.value = field.record_id
92
+ }
93
+ return { value: field.record_id, text: field.name }
94
+ })
95
+ })
96
+
97
+ const computedPropFilters = computed(() => {
98
+ let fields = filterFields.value.map((field) => {
99
+ let terms = null
100
+ if (field.date) {
101
+ terms = statsData.value
102
+ .map((item) => item[field.record_id].split('/')[2]) // Date field get year
103
+ .filter((value, index, self) => self.indexOf(value) === index)
104
+ .map((value) => {
105
+ return { tid: value, name: value, preselected: false }
106
+ })
107
+ .sort((a, b) => a.name.localeCompare(b.name))
108
+ } else {
109
+ terms = statsData.value
110
+ .map((item) => item[field.record_id])
111
+ .filter((value, index, self) => self.indexOf(value) === index)
112
+ .map((value) => {
113
+ return { tid: value, name: value, preselected: false }
114
+ })
115
+ .sort((a, b) => a.name.localeCompare(b.name))
116
+ }
84
117
  return {
85
- hideReset: true,
86
- isFiltering: false,
87
- filters: {
88
- taxonomies: [],
89
- selected: {},
90
- availableBundles: []
91
- },
92
- graphSelected: null,
93
- chartHeight: this.chart.options.height ? this.chart.options.height : 600
118
+ name: field.name,
119
+ record_id: field.record_id,
120
+ terms,
94
121
  }
95
- },
96
- computed: {
97
- graphOptions: function() {
98
- return this.filterFields.slice(1).map((field) => {
99
- if (!this.graphSelected) {
100
- this.graphSelected = field.record_id
101
- }
102
- return { value: field.record_id, text: field.name }
103
- })
104
- },
105
- computedPropFilters: function() {
106
- let fields = this.filterFields.map((field) => {
107
- let terms = null
108
- if (field.date) {
109
- terms = this.statsData
110
- .map((item) => item[field.record_id].split('/')[2]) // Date field get year
111
- .filter((value, index, self) => self.indexOf(value) === index)
112
- .map((value) => {
113
- return { tid: value, name: value, preselected: false }
114
- })
115
- .sort((a, b) => a.name.localeCompare(b.name))
122
+ })
123
+ return fields
124
+ })
125
+
126
+ const filteredList = computed(() => {
127
+ let filterKeys = Object.keys(filters.value.selected).map((key) => key)
128
+ let list = statsData.value.filter((element) => {
129
+ let include = true
130
+ for (var i = 0, n = filterKeys.length; i < n; ++i) {
131
+ if (filters.value.selected[filterKeys[i]].length > 0) {
132
+ let filterType = filterFields.value.find(
133
+ (item) => item.record_id === filterKeys[i],
134
+ )
135
+ if (filterType.date) {
136
+ // Filter by year
137
+ if (
138
+ filters.value.selected[filterKeys[i]].indexOf(
139
+ element[filterKeys[i]].split('/')[2],
140
+ ) === -1
141
+ ) {
142
+ include = false
143
+ }
116
144
  } else {
117
- terms = this.statsData
118
- .map((item) => item[field.record_id])
119
- .filter((value, index, self) => self.indexOf(value) === index)
120
- .map((value) => {
121
- return { tid: value, name: value, preselected: false }
122
- })
123
- .sort((a, b) => a.name.localeCompare(b.name))
124
- }
125
- return {
126
- name: field.name,
127
- record_id: field.record_id,
128
- terms
129
- }
130
- })
131
- return fields
132
- },
133
- filteredList: function() {
134
- let filterKeys = Object.keys(this.filters.selected).map((key) => key)
135
- let list = this.statsData.filter((element) => {
136
- let include = true
137
- for (var i = 0, n = filterKeys.length; i < n; ++i) {
138
- if (this.filters.selected[filterKeys[i]].length > 0) {
139
- let filterType = this.filterFields.find(
140
- (item) => item.record_id === filterKeys[i]
141
- )
142
- if (filterType.date) {
143
- // Filter by year
144
- if (
145
- this.filters.selected[filterKeys[i]].indexOf(
146
- element[filterKeys[i]].split('/')[2]
147
- ) === -1
148
- ) {
149
- include = false
150
- }
151
- } else {
152
- if (
153
- this.filters.selected[filterKeys[i]].indexOf(
154
- element[filterKeys[i]]
155
- ) === -1
156
- ) {
157
- include = false
158
- }
159
- }
145
+ if (
146
+ filters.value.selected[filterKeys[i]].indexOf(
147
+ element[filterKeys[i]],
148
+ ) === -1
149
+ ) {
150
+ include = false
160
151
  }
161
152
  }
162
- if (include) {
163
- return element
164
- }
165
- })
166
- return list
167
- }
168
- },
169
- methods: {
170
- onFilter(filters) {
171
- this.hideReset = false
172
- const allFiltersUnselected = Object.values(this.$refs).every(
173
- (taxonomy) => {
174
- return Object.values(taxonomy[0].selectedFilters).every(
175
- (filter) => filter.filter((item) => !item.preselected).length === 0
176
- )
177
- }
178
- )
179
- if (allFiltersUnselected) {
180
- this.hideReset = true
181
153
  }
182
- Object.keys(filters).forEach((filter) => {
183
- this.filters.selected[filter] = filters[filter].map((obj) => obj.tid)
184
- })
185
- },
186
- reset() {
187
- this.hideReset = true
188
- Object.keys(this.$refs).forEach((key) => {
189
- this.$refs[key][0].reset()
190
- })
191
- this.filters.selected = {}
192
- },
193
- by_primary() {
194
- let primaryFilter = this.filterFields[0]
195
- let data = [[primaryFilter.name, this.chart.header]]
196
- let keys = {}
154
+ }
155
+ if (include) {
156
+ return element
157
+ }
158
+ })
159
+ return list
160
+ })
197
161
 
198
- this.filteredList.forEach((element) => {
199
- // Work off primary field
200
- let group = null
201
- if (primaryFilter.date) {
202
- group = `${element[primaryFilter.record_id].split('/')[2]} `
203
- } else {
204
- group = element[primaryFilter.record_id]
205
- }
162
+ const onFilter = (filterParam) => {
163
+ hideReset.value = false
164
+ const allFiltersUnselected = Object.values(elRef.value).every((taxonomy) => {
165
+ return Object.values(taxonomy[0].selectedFilters).every(
166
+ (filter) => filter.filter((item) => !item.preselected).length === 0,
167
+ )
168
+ })
169
+ if (allFiltersUnselected) {
170
+ hideReset.value = true
171
+ }
172
+ Object.keys(filterParam).forEach((filter) => {
173
+ filters.value.selected[filter] = filterParam[filter].map((obj) => obj.tid)
174
+ })
175
+ }
176
+ const reset = () => {
177
+ hideReset.value = true
178
+ Object.keys(elRef).forEach((key) => {
179
+ elRef[key][0].reset()
180
+ })
181
+ filters.value.selected = {}
182
+ }
183
+ const by_primary = () => {
184
+ let primaryFilter = filterFields.value[0]
185
+ let data = [[primaryFilter.name, chart.value.header]]
186
+ let keys = {}
206
187
 
207
- if (group in keys) {
208
- keys[group]++
209
- } else {
210
- keys[group] = 1
211
- }
212
- })
213
- Object.keys(keys).forEach((item) => {
214
- data.push([item, keys[item]])
215
- })
216
- if (this.chart.type === 'BarChart') {
217
- this.chart.options.height = data[0].length * 200
218
- } else {
219
- this.chart.options.height = this.chartHeight
220
- }
221
- return data
222
- },
223
- by_months() {
224
- let primaryFilter = this.filterFields[0]
225
- if (!primaryFilter.date) {
226
- return ['Requires date in primary field']
227
- }
228
- let data = [
229
- ['Month'],
230
- ['Jan'],
231
- ['Feb'],
232
- ['Mar'],
233
- ['Apr'],
234
- ['May'],
235
- ['Jun'],
236
- ['Jul'],
237
- ['Aug'],
238
- ['Sep'],
239
- ['Oct'],
240
- ['Nov'],
241
- ['Dec']
242
- ]
243
- let years = this.filteredList
244
- .map((item) => item[primaryFilter.record_id].split('/')[2])
245
- .filter((value, index, self) => self.indexOf(value) === index)
246
- data[0].push(...years)
247
- for (var i = 1, n = data.length; i < n; ++i) {
248
- for (var j = 0, m = years.length; j < m; ++j) {
249
- data[i].push(0)
250
- }
251
- }
252
- this.filteredList.forEach((element) => {
253
- let year = element[primaryFilter.record_id].split('/')[2]
254
- let month = element[primaryFilter.record_id].split('/')[1]
255
- data[month][data[0].indexOf(year)]++
256
- })
257
- for (var i = 2; i < data.length; i++) {
258
- for (var j = 1; j < data[i].length; j++) {
259
- data[i][j] = data[i][j] + data[i - 1][j]
260
- }
261
- }
262
- if (this.chart.type === 'BarChart') {
263
- this.chart.options.height = data[0].length * 200
264
- } else {
265
- this.chart.options.height = this.chartHeight
266
- }
267
- return data
268
- },
269
- compare() {
270
- let primaryFilter = this.filterFields[0]
271
- let comparison = this.filteredList
272
- .map((item) => item[this.graphSelected])
273
- .filter((value, index, self) => self.indexOf(value) === index)
274
- .sort((a, b) => a.localeCompare(b))
275
- let data = [['Year', ...comparison]]
276
- let keys = {}
277
- this.filteredList.forEach((element) => {
278
- let group = null
279
- if (primaryFilter.date) {
280
- group = `${element[primaryFilter.record_id].split('/')[2]} `
281
- } else {
282
- group = element[primaryFilter.record_id]
283
- }
284
- if (group in keys) {
285
- } else {
286
- keys[group] = {}
287
- comparison.forEach((co) => {
288
- keys[group][co] = 0
289
- })
290
- }
291
- keys[group][element[this.graphSelected]]++
292
- })
293
- Object.keys(keys).forEach((key) => {
294
- data.push([key, ...Object.entries(keys[key]).map(([k, v]) => v)])
188
+ filteredList.value.forEach((element) => {
189
+ // Work off primary field
190
+ let group = null
191
+ if (primaryFilter.date) {
192
+ group = `${element[primaryFilter.record_id].split('/')[2]} `
193
+ } else {
194
+ group = element[primaryFilter.record_id]
195
+ }
196
+
197
+ if (group in keys) {
198
+ keys[group]++
199
+ } else {
200
+ keys[group] = 1
201
+ }
202
+ })
203
+ Object.keys(keys).forEach((item) => {
204
+ data.push([item, keys[item]])
205
+ })
206
+ if (chart.value.type === 'BarChart') {
207
+ chart.value.options.height = data[0].length * 200
208
+ } else {
209
+ chart.value.options.height = chartHeight.value
210
+ }
211
+ return data
212
+ }
213
+ const by_months = () => {
214
+ let primaryFilter = filterFields.value[0]
215
+ if (!primaryFilter.date) {
216
+ return ['Requires date in primary field']
217
+ }
218
+ let data = [
219
+ ['Month'],
220
+ ['Jan'],
221
+ ['Feb'],
222
+ ['Mar'],
223
+ ['Apr'],
224
+ ['May'],
225
+ ['Jun'],
226
+ ['Jul'],
227
+ ['Aug'],
228
+ ['Sep'],
229
+ ['Oct'],
230
+ ['Nov'],
231
+ ['Dec'],
232
+ ]
233
+ let years = filteredList.value
234
+ .map((item) => item[primaryFilter.record_id].split('/')[2])
235
+ .filter((value, index, self) => self.indexOf(value) === index)
236
+ data[0].push(...years)
237
+ for (var i = 1, n = data.length; i < n; ++i) {
238
+ for (var j = 0, m = years.length; j < m; ++j) {
239
+ data[i].push(0)
240
+ }
241
+ }
242
+ filteredList.value.forEach((element) => {
243
+ let year = element[primaryFilter.record_id].split('/')[2]
244
+ let month = element[primaryFilter.record_id].split('/')[1]
245
+ data[month][data[0].indexOf(year)]++
246
+ })
247
+ for (var i = 2; i < data.length; i++) {
248
+ for (var j = 1; j < data[i].length; j++) {
249
+ data[i][j] = data[i][j] + data[i - 1][j]
250
+ }
251
+ }
252
+ if (chart.value.type === 'BarChart') {
253
+ chart.value.options.height = data[0].length * 200
254
+ } else {
255
+ chart.value.options.height = chartHeight.value
256
+ }
257
+ return data
258
+ }
259
+ const compare = () => {
260
+ let primaryFilter = filterFields.value[0]
261
+ let comparison = filteredList.value
262
+ .map((item) => item[graphSelected.value])
263
+ .filter((value, index, self) => self.indexOf(value) === index)
264
+ .sort((a, b) => a.localeCompare(b))
265
+ let data = [['Year', ...comparison]]
266
+ let keys = {}
267
+ filteredList.value.forEach((element) => {
268
+ let group = null
269
+ if (primaryFilter.date) {
270
+ group = `${element[primaryFilter.record_id].split('/')[2]} `
271
+ } else {
272
+ group = element[primaryFilter.record_id]
273
+ }
274
+ if (group in keys) {
275
+ } else {
276
+ keys[group] = {}
277
+ comparison.forEach((co) => {
278
+ keys[group][co] = 0
295
279
  })
296
- if (this.chart.type === 'BarChart') {
297
- this.chart.options.height = data[0].length * 200
298
- } else {
299
- this.chart.options.height = this.chartHeight
300
- }
301
- return data
302
- },
303
- noData() {
304
- return [
305
- [
306
- { label: 'Results', type: 'string' },
307
- { label: 'Results', type: 'number' },
308
- { role: 'style', type: 'string' },
309
- { role: 'annotation', type: 'string' }
310
- ],
311
- ['', 0, null, 'No results found']
312
- ]
313
280
  }
281
+ keys[group][element[graphSelected.value]]++
282
+ })
283
+ Object.keys(keys).forEach((key) => {
284
+ data.push([key, ...Object.entries(keys[key]).map(([k, v]) => v)])
285
+ })
286
+ if (chart.value.type === 'BarChart') {
287
+ chart.value.options.height = data[0].length * 200
288
+ } else {
289
+ chart.value.options.height = chartHeight.value
314
290
  }
291
+ return data
292
+ }
293
+ const noData = () => {
294
+ return [
295
+ [
296
+ { label: 'Results', type: 'string' },
297
+ { label: 'Results', type: 'number' },
298
+ { role: 'style', type: 'string' },
299
+ { role: 'annotation', type: 'string' },
300
+ ],
301
+ ['', 0, null, 'No results found'],
302
+ ]
315
303
  }
316
304
  </script>
317
305