@worksafevictoria/wcl7.5 1.7.3 → 1.8.0-beta.10

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 (24) hide show
  1. package/lib/utility.js +2 -0
  2. package/package.json +1 -1
  3. package/src/components/Common/CardGrid/index.vue +77 -82
  4. package/src/components/Common/CardGridItem/index.vue +6 -2
  5. package/src/components/Global/AppHeader/ModalSearch/index.vue +1 -0
  6. package/src/components/Global/AppHeader/index.vue +194 -284
  7. package/src/components/Global/AppHeaderNew/ModalSearch/index.vue +16 -14
  8. package/src/components/Paragraphs/Directory/Asbestos/Records/SingleRecord/index.stories.js +30 -0
  9. package/src/components/Paragraphs/Directory/Asbestos/Records/SingleRecord/index.vue +182 -0
  10. package/src/components/Paragraphs/Directory/Asbestos/Records/index.stories.js +19 -0
  11. package/src/components/Paragraphs/Directory/Asbestos/Records/index.vue +254 -0
  12. package/src/components/Paragraphs/Directory/HSCP/Records/SingleRecord/index.vue +38 -152
  13. package/src/components/Paragraphs/Directory/HSCP/Records/SingleRecord/styles.scss +127 -0
  14. package/src/components/Paragraphs/Directory/HSCP/Records/index.vue +41 -87
  15. package/src/components/Paragraphs/Directory/HSCP/styles.scss +68 -0
  16. package/src/components/Paragraphs/Directory/Records/PRS/index.stories.js +2 -2
  17. package/src/components/Paragraphs/Directory/styles.scss +2 -0
  18. package/src/components/SubComponents/FormInstance/models/overrides/file.js +2 -1
  19. package/src/components/SubComponents/Search/SearchListing/index.vue +51 -45
  20. package/src/components/SubComponents/Search/index.stories.js +4 -3
  21. package/src/components/SubComponents/Search/index.vue +130 -138
  22. package/src/index.js +2 -0
  23. package/src/mock/asbestos-removalists.js +226 -0
  24. package/src/mock/course-provider.js +33 -19
@@ -8,8 +8,7 @@
8
8
  <template v-else>
9
9
  <b-input-group>
10
10
  <label class="visually-hidden" for="site-search"
11
- >Search by keyword (Typed keyword automatically filters below
12
- results)</label
11
+ >Search by keyword (Typed keyword automatically filters below results)</label
13
12
  >
14
13
  <b-form-input
15
14
  id="site-search"
@@ -18,7 +17,7 @@
18
17
  aria-label="searchbar"
19
18
  autocomplete="off"
20
19
  trim
21
- @update="searchType !== 'googlerest' ? onChange : () => {}"
20
+ @update="onChange"
22
21
  @keyup.enter="onChange"
23
22
  ></b-form-input>
24
23
  <template #append>
@@ -43,20 +42,20 @@
43
42
  :offset="searchResults && searchResults.offset"
44
43
  :page-limit="pageLimit"
45
44
  :content-parser="contentParser"
46
- :is-card-title-selectable="searchType === 'googlerest' ? true : false"
45
+ :google-search-flag="searchType"
46
+ :is-selectable="searchType === 'solar'"
47
+ :is-card-title-selectable="searchType !== 'solar'"
47
48
  @selected="$emit('selected')"
48
49
  @pageChanged="pageChanged"
49
50
  />
50
51
  </template>
51
52
  </div>
52
53
  </template>
53
-
54
54
  <script>
55
- import axios from 'axios'
56
- import searchIcon from '../../../assets/icons/search.svg?url'
57
- import SearchListing from './SearchListing/index.vue'
58
- import { BButton, BInputGroup, BFormInput } from 'bootstrap-vue-next'
59
-
55
+ import axios from "axios";
56
+ import searchIcon from "../../../assets/icons/search.svg?url";
57
+ import SearchListing from "./SearchListing/index.vue";
58
+ import { BButton, BInputGroup, BFormInput } from "bootstrap-vue-next";
60
59
 
61
60
  export default {
62
61
  components: { SearchListing, BButton, BInputGroup, BFormInput },
@@ -75,11 +74,11 @@ export default {
75
74
  },
76
75
  initialSearchQuery: {
77
76
  type: String,
78
- default: '',
77
+ default: "",
79
78
  },
80
79
  googleSearchFlag: {
81
80
  type: String,
82
- default: 'solar',
81
+ default: "solar",
83
82
  },
84
83
  visibleSearchList: {
85
84
  type: Boolean,
@@ -89,39 +88,39 @@ export default {
89
88
  data() {
90
89
  return {
91
90
  searchIcon,
92
- searchQuery: '',
91
+ searchQuery: "",
93
92
  searchResults: null,
94
93
  isLoading: false,
95
- field_language: '8671',
94
+ field_language: "8671",
96
95
  searchType: this.googleSearchFlag,
97
96
  googleSearchScript: false,
98
97
  loadSearchList: this.visibleSearchList,
99
- }
98
+ };
100
99
  },
101
100
  computed: {
102
101
  searchClass() {
103
102
  return {
104
- 'wcl-search': true,
105
- 'wcl-search__google': this.searchType !== 'solar',
106
- }
103
+ "wcl-search": true,
104
+ "wcl-search__google": this.searchType !== "solar",
105
+ };
107
106
  },
108
107
  },
109
108
  mounted() {
110
- if (this.searchType === 'google') {
111
- this.setupGoogleStyle()
109
+ if (this.searchType === "google") {
110
+ this.setupGoogleStyle();
112
111
  } else {
113
112
  if (this.initialSearchQuery) {
114
- this.searchQuery = this.initialSearchQuery
115
- this.onSearch()
113
+ this.searchQuery = this.initialSearchQuery;
114
+ this.onSearch();
116
115
  }
117
116
  if (this.isTypeahead && window) {
118
- window.document.addEventListener('click', this.closeSearchResults)
117
+ window.document.addEventListener("click", this.closeSearchResults);
119
118
  }
120
119
  }
121
120
  },
122
121
  beforeDestroy() {
123
122
  if (this.isTypeahead && window && document) {
124
- window.document.removeEventListener('click', this.closeSearchResults)
123
+ window.document.removeEventListener("click", this.closeSearchResults);
125
124
  }
126
125
  },
127
126
  methods: {
@@ -136,54 +135,54 @@ export default {
136
135
  q: query,
137
136
  start: start,
138
137
  },
139
- },
140
- )
141
- return response
138
+ }
139
+ );
140
+ return response;
142
141
  } catch (error) {
143
- console.error('Error fetching search results:', error)
144
- return []
142
+ console.error("Error fetching search results:", error);
143
+ return [];
145
144
  }
146
145
  },
147
146
  async onGoogleSearch(pageNr = 1, searchQuery) {
148
- this.$emit('loading', true)
149
- this.isLoading = true
147
+ this.$emit("loading", true);
148
+ this.isLoading = true;
150
149
 
151
- const apiKey = 'AIzaSyD76GAmQQ6DuxKWf-aLXPZ9pwdz4nOvs2c'
152
- const searchEngineId = '53b1506aa03c64160'
150
+ const apiKey = "AIzaSyD76GAmQQ6DuxKWf-aLXPZ9pwdz4nOvs2c";
151
+ const searchEngineId = "53b1506aa03c64160";
153
152
 
154
- const start = (pageNr - 1) * this.pageLimit
153
+ const start = (pageNr - 1) * this.pageLimit;
155
154
  let response = await this.fetchSearchResults(
156
155
  apiKey,
157
156
  searchEngineId,
158
157
  searchQuery,
159
- start,
160
- )
161
- let items = []
162
- let suggest = response?.data?.spelling?.correctedQuery || ''
158
+ start
159
+ );
160
+ let items = [];
161
+ let suggest = response?.data?.spelling?.correctedQuery || "";
163
162
  if (response?.data?.spelling?.correctedQuery) {
164
163
  response = await this.fetchSearchResults(
165
164
  apiKey,
166
165
  searchEngineId,
167
166
  response?.data?.spelling?.correctedQuery,
168
- start,
169
- )
170
- items = response?.data?.items
167
+ start
168
+ );
169
+ items = response?.data?.items;
171
170
  } else if (response?.data?.items) {
172
- items = response?.data?.items
171
+ items = response?.data?.items;
173
172
  }
174
173
  if (items.length > 0) {
175
- const totalResults = response?.data?.searchInformation?.totalResults
174
+ const totalResults = response?.data?.searchInformation?.totalResults;
176
175
  // Loop through each item in the items array
177
176
  const modifiedResults = items.map((item) => {
178
177
  // Update the title using the handleSearchResultLinkTitle function
179
- const modifiedTitle = this.handleSearchResultLinkTitle(item.title)
178
+ const modifiedTitle = this.handleSearchResultLinkTitle(item.title);
180
179
 
181
180
  // Return the modified item with the updated title
182
181
  return {
183
182
  ...item,
184
183
  title: modifiedTitle,
185
- }
186
- })
184
+ };
185
+ });
187
186
 
188
187
  this.searchResults = {
189
188
  offset: Number(pageNr === 1 ? pageNr - 1 : pageNr),
@@ -191,19 +190,19 @@ export default {
191
190
  query: this.searchQuery,
192
191
  results: modifiedResults,
193
192
  suggestion: suggest,
194
- }
193
+ };
195
194
  } else {
196
195
  this.searchResults = {
197
196
  offset: 0,
198
197
  numFound: 0,
199
- query: this.searchQuery ?? '',
198
+ query: this.searchQuery ?? "",
200
199
  results: [],
201
200
  suggestion: suggest,
202
- }
201
+ };
203
202
  }
204
- this.$emit('loading', false)
205
- this.isLoading = false
206
- this.$emit('results', this.searchResults)
203
+ this.$emit("loading", false);
204
+ this.isLoading = false;
205
+ this.$emit("results", this.searchResults);
207
206
 
208
207
  // wait for the page title to be updated and then fire the search event
209
208
  setTimeout(() => {
@@ -211,87 +210,80 @@ export default {
211
210
  pageTitle: document.title,
212
211
  pageURL: this.$route?.fullPath,
213
212
  location:
214
- this.$route?.path === '/'
215
- ? 'Homepage'
216
- : this.$route?.path === '/search'
217
- ? 'Search Page'
218
- : this.$route?.path,
213
+ this.$route?.path === "/"
214
+ ? "Homepage"
215
+ : this.$route?.path === "/search"
216
+ ? "Search Page"
217
+ : this.$route?.path,
219
218
  label: this.searchQuery,
220
219
  results: this.searchResults.numFound,
221
- }
220
+ };
222
221
  if (this.$gtm) {
223
- this.$gtm.push({ event: 'custom.search.site.submit', ...attrs })
222
+ this.$gtm.push({ event: "custom.search.site.submit", ...attrs });
224
223
  }
225
- }, 300)
224
+ }, 300);
226
225
  },
227
226
  pageChanged(newPageNumber) {
228
- if (this.searchType === 'solar') {
227
+ if (this.searchType === "solar") {
229
228
  // Reset search results before fetching new results
230
- this.resetSearchResults()
231
- this.performSearch(newPageNumber, this.searchQuery, this.pageLimit)
229
+ this.resetSearchResults();
230
+ this.performSearch(newPageNumber, this.searchQuery, this.pageLimit);
232
231
  } else {
233
232
  // Fetch new search results with the updated page number
234
- this.onGoogleSearch(newPageNumber, this.searchQuery)
233
+ this.onGoogleSearch(newPageNumber, this.searchQuery);
235
234
  }
236
235
  },
237
236
  onSearch(e) {
238
- // debugger
239
- const { path } = this.$route || {}
240
-
241
-
237
+ const { path } = this.$route || {};
242
238
 
243
239
  // Home page
244
240
  if (
245
- (e?.type === 'click' || e?.key == 'Enter') &&
241
+ (e?.type === "click" || e?.key == "Enter") &&
246
242
  this.searchQuery &&
247
243
  this.searchQuery.length > 2 &&
248
- path === '/'
244
+ path === "/"
249
245
  ) {
250
246
  // Search page
251
- const searchQuery = encodeURIComponent(this.searchQuery)
252
- const origin = window.location.origin
253
- const hash = window.location.hash
254
- const pathname = 'search'
255
- const URL = `${origin}/${pathname}${hash}?q=${searchQuery}`
247
+ const searchQuery = encodeURIComponent(this.searchQuery);
248
+ const origin = window.location.origin;
249
+ const hash = window.location.hash;
250
+ const pathname = "search";
251
+ const URL = `${origin}/${pathname}${hash}?q=${searchQuery}`;
256
252
 
257
253
  // Uncomment below commented code when goes live
258
- window.location.assign(URL)
254
+ window.location.assign(URL);
259
255
  } else {
260
- this.resetSearchResults()
261
- this.$emit('query', this.searchQuery)
256
+ this.resetSearchResults();
257
+ this.$emit("query", this.searchQuery);
262
258
 
263
- if (this.searchType === 'solar') {
264
- this.performSearch(1, this.searchQuery, this.pageLimit)
259
+ if (this.searchType === "solar") {
260
+ this.performSearch(1, this.searchQuery, this.pageLimit);
265
261
  } else {
266
- this.onGoogleSearch(1, this.searchQuery)
262
+ this.onGoogleSearch(1, this.searchQuery);
267
263
  }
268
264
  }
269
265
  },
270
266
  resetSearchResults() {
271
- this.searchResults = null
267
+ this.searchResults = null;
272
268
  },
273
269
  closeSearchResults(ev) {
274
- if (
275
- this.isTypeahead &&
276
- this.searchResults &&
277
- ev?.target?.id !== 'site-search'
278
- ) {
279
- this.resetSearchResults()
280
- this.searchQuery = null
281
- this.$emit('query', null)
270
+ if (this.isTypeahead && this.searchResults && ev?.target?.id !== "site-search") {
271
+ this.resetSearchResults();
272
+ this.searchQuery = null;
273
+ this.$emit("query", null);
282
274
  }
283
275
  },
284
276
  onChange(e) {
285
277
  //debugger
286
-
278
+
287
279
  if (this.searchQuery && this.searchQuery.length > 2) {
288
- this.onSearch(e)
280
+ this.onSearch(e);
289
281
  }
290
282
  },
291
283
  performSearch(pageNr = 1, searchQuery, pageLimit) {
292
284
  if (searchQuery) {
293
- this.$emit('loading', true)
294
- this.isLoading = true
285
+ this.$emit("loading", true);
286
+ this.isLoading = true;
295
287
  this.contentParser({
296
288
  query: searchQuery,
297
289
  start: pageNr > 1 ? (pageNr - 1) * pageLimit : 0,
@@ -305,100 +297,100 @@ export default {
305
297
  query: searchQuery,
306
298
  results: res.results,
307
299
  suggestion: null,
308
- }
300
+ };
309
301
  } else {
310
302
  this.searchResults = {
311
303
  offset: 0,
312
304
  numFound: 0,
313
- query: this.searchQuery ?? '',
305
+ query: this.searchQuery ?? "",
314
306
  results: [],
315
307
  suggestion: null,
316
- }
308
+ };
317
309
  }
318
- this.$emit('loading', false)
319
- this.isLoading = false
320
- this.$emit('results', this.searchResults)
310
+ this.$emit("loading", false);
311
+ this.isLoading = false;
312
+ this.$emit("results", this.searchResults);
321
313
  // wait for the page title to be updated and then fire the search event
322
314
  setTimeout(() => {
323
315
  const attrs = {
324
316
  pageTitle: document.title,
325
317
  pageURL: this.$route?.fullPath,
326
318
  location:
327
- this.$route?.path === '/'
328
- ? 'Homepage'
329
- : this.$route?.path === '/search'
330
- ? 'Search Page'
331
- : this.$route?.path,
319
+ this.$route?.path === "/"
320
+ ? "Homepage"
321
+ : this.$route?.path === "/search"
322
+ ? "Search Page"
323
+ : this.$route?.path,
332
324
  label: this.searchQuery,
333
325
  results: this.searchResults.numFound,
334
- }
326
+ };
335
327
  if (this.$gtm) {
336
- this.$gtm.push({ event: 'custom.search.site.submit', ...attrs })
328
+ this.$gtm.push({ event: "custom.search.site.submit", ...attrs });
337
329
  }
338
- }, 300)
339
- })
330
+ }, 300);
331
+ });
340
332
  }
341
333
  },
342
334
 
343
335
  // Method to customize google search style
344
336
  setupGoogleStyle() {
345
337
  if (this.googleSearchScript === false) {
346
- const script = document.createElement('script')
347
- script.async = true
338
+ const script = document.createElement("script");
339
+ script.async = true;
348
340
  script.src = this.$config
349
341
  ? this.$config.public.googleSearch
350
- : process.env.GOOGLE__URL
351
- document.head.appendChild(script)
352
- this.googleSearchScript = true
342
+ : process.env.GOOGLE__URL;
343
+ document.head.appendChild(script);
344
+ this.googleSearchScript = true;
353
345
 
354
346
  // Create a new style element
355
- const style = document.createElement('style')
356
- style.id = 'searchStyle' // Assign an ID to the style element
347
+ const style = document.createElement("style");
348
+ style.id = "searchStyle"; // Assign an ID to the style element
357
349
  // The CSS we are going to inject
358
- const cssVar = 'table.gssb_c {display: none !important;}'
350
+ const cssVar = "table.gssb_c {display: none !important;}";
359
351
  // Inject the style element into the head
360
- document.head.appendChild(style)
352
+ document.head.appendChild(style);
361
353
  // Set the text content of the style element to the CSS text
362
- style.textContent = cssVar
354
+ style.textContent = cssVar;
363
355
  }
364
356
  },
365
357
 
366
358
  // function to handle search result link titles
367
359
  handleSearchResultLinkTitle(title) {
368
360
  // Split the title by the '|' character
369
- const titleParts = title.split('|')
361
+ const titleParts = title.split("|");
370
362
 
371
363
  // Remove any leading or trailing whitespace from each part
372
- const cleanedTitleParts = titleParts.map((part) => part.trim())
364
+ const cleanedTitleParts = titleParts.map((part) => part.trim());
373
365
 
374
366
  // Join the cleaned title parts back together without the text after the '|' character
375
- const modifiedTitle = cleanedTitleParts[0] // Take only the first part before '|'
367
+ const modifiedTitle = cleanedTitleParts[0]; // Take only the first part before '|'
376
368
 
377
- return modifiedTitle
369
+ return modifiedTitle;
378
370
  },
379
371
 
380
372
  handleKeyUp(event) {
381
- if (event.key === 'Enter' || event.type === 'click') {
373
+ if (event.key === "Enter" || event.type === "click") {
382
374
  let keyword = event.key
383
375
  ? event.target.value
384
- : document.querySelector('input[name="search"]').value
376
+ : document.querySelector('input[name="search"]').value;
385
377
 
386
378
  // Check if the URL does not contain "/search"
387
- if (keyword && !window.location.href.includes('/search')) {
388
- let origin = window.location.origin
389
- let hash = window.location.hash
390
- let pathname = 'search'
391
- let URL = origin + '/' + pathname + hash
379
+ if (keyword && !window.location.href.includes("/search")) {
380
+ let origin = window.location.origin;
381
+ let hash = window.location.hash;
382
+ let pathname = "search";
383
+ let URL = origin + "/" + pathname + hash;
392
384
  }
393
385
 
394
- this.setupPaginationEvent()
386
+ this.setupPaginationEvent();
395
387
  }
396
388
  },
397
389
  },
398
- }
390
+ };
399
391
  </script>
400
392
  <style lang="scss" scoped>
401
- @import '../../../includes/scss/all';
393
+ @import "../../../includes/scss/all";
402
394
 
403
395
  .wcl-search {
404
396
  position: relative;
@@ -456,7 +448,7 @@ export default {
456
448
  }
457
449
  }
458
450
 
459
- @include mq('xs') {
451
+ @include mq("xs") {
460
452
  .not-extra-small-screen {
461
453
  display: none;
462
454
  }
@@ -546,7 +538,7 @@ export default {
546
538
  padding-left: 32px;
547
539
 
548
540
  &:before {
549
- content: 'Search';
541
+ content: "Search";
550
542
  }
551
543
 
552
544
  @media screen and (max-width: 767px) {
@@ -626,7 +618,7 @@ export default {
626
618
  padding: 0;
627
619
 
628
620
  &::after {
629
- content: ' ';
621
+ content: " ";
630
622
  position: absolute;
631
623
  height: 16px;
632
624
  width: 11px;
@@ -733,7 +725,7 @@ export default {
733
725
  }
734
726
 
735
727
  /* search list end */
736
- @include mq('xs') {
728
+ @include mq("xs") {
737
729
  .not-extra-small-screen {
738
730
  display: none;
739
731
  }
@@ -746,4 +738,4 @@ export default {
746
738
  width: 85% !important;
747
739
  }
748
740
  }
749
- </style>
741
+ </style>
package/src/index.js CHANGED
@@ -31,6 +31,7 @@ import ListGroup from './components/Paragraphs/ListGroup/index.vue'
31
31
  import ScrollSpy from './components/Paragraphs/ScrollSpy/index.vue'
32
32
  import Directory from './components/Paragraphs/Directory/index.vue'
33
33
  import HscpDirectory from './components/Paragraphs/Directory/HSCP/Records/index.vue'
34
+ import ArDirectory from './components/Paragraphs/Directory/Asbestos/Records/index.vue'
34
35
  import SelectableCards from './components/Paragraphs/SelectableCards/index.vue'
35
36
  import VideoMedia from './components/Paragraphs/VideoPlayer/index.vue'
36
37
  import VideoGrid from './components/Paragraphs/VideoGrid/index.vue'
@@ -99,6 +100,7 @@ export {
99
100
  ScrollSpy,
100
101
  Directory,
101
102
  HscpDirectory,
103
+ ArDirectory,
102
104
  SelectableCards,
103
105
  Statistics,
104
106
  ProofPoints,