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

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.7.3",
3
+ "version": "1.8.0-beta.1",
4
4
  "main": "src/index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -52,13 +52,13 @@
52
52
  </template>
53
53
 
54
54
  <script>
55
- import Row from './../../Containers/Row/index.vue'
56
- import Column from './../../Containers/Column/index.vue'
57
- import SectionGroup from './../../Containers/SectionGroup/index.vue'
58
- import { debounce } from 'lodash-es'
55
+ import Row from "./../../Containers/Row/index.vue";
56
+ import Column from "./../../Containers/Column/index.vue";
57
+ import SectionGroup from "./../../Containers/SectionGroup/index.vue";
58
+ import { debounce } from "lodash-es";
59
59
 
60
60
  export default {
61
- name: 'CardGrid',
61
+ name: "CardGrid",
62
62
  components: { Row, Column, SectionGroup },
63
63
  props: {
64
64
  title: {
@@ -71,7 +71,7 @@ export default {
71
71
  },
72
72
  titleTag: {
73
73
  type: String,
74
- default: 'h2',
74
+ default: "h2",
75
75
  },
76
76
  cards: {
77
77
  type: Array,
@@ -99,9 +99,9 @@ export default {
99
99
  },
100
100
  size: {
101
101
  type: String,
102
- default: 'page',
102
+ default: "page",
103
103
  validator: (value) =>
104
- ['half-content', 'content', 'page', 'full'].indexOf(value) >= 0,
104
+ ["half-content", "content", "page", "full"].indexOf(value) >= 0,
105
105
  },
106
106
  isSelectable: {
107
107
  type: Boolean,
@@ -112,23 +112,17 @@ export default {
112
112
  },
113
113
  backgroundVariant: {
114
114
  type: String,
115
- default: 'none',
115
+ default: "none",
116
116
  validator: (value) =>
117
- [
118
- 'none',
119
- 'light',
120
- 'dark',
121
- 'grey',
122
- 'yellow',
123
- 'white',
124
- 'lightblue',
125
- ].indexOf(value) >= 0,
117
+ ["none", "light", "dark", "grey", "yellow", "white", "lightblue"].indexOf(
118
+ value
119
+ ) >= 0,
126
120
  },
127
121
  applyBackgroundOn: {
128
122
  type: String,
129
- default: 'section',
123
+ default: "section",
130
124
  validator: (value) =>
131
- ['content', 'block', 'container', 'section'].indexOf(value) >= 0,
125
+ ["content", "block", "container", "section"].indexOf(value) >= 0,
132
126
  },
133
127
  noPaddingTop: {
134
128
  type: Boolean,
@@ -138,8 +132,8 @@ export default {
138
132
  },
139
133
  rowSpacing: {
140
134
  type: String,
141
- default: 'large',
142
- validator: (value) => ['none', 'small', 'large'].indexOf(value) >= 0,
135
+ default: "large",
136
+ validator: (value) => ["none", "small", "large"].indexOf(value) >= 0,
143
137
  },
144
138
  rowClasses: {
145
139
  type: String,
@@ -147,12 +141,12 @@ export default {
147
141
  },
148
142
  columnSpacing: {
149
143
  type: String,
150
- default: 'default',
151
- validator: (value) => ['default', 'none'].indexOf(value) >= 0,
144
+ default: "default",
145
+ validator: (value) => ["default", "none"].indexOf(value) >= 0,
152
146
  },
153
147
  contentClass: {
154
148
  type: String,
155
- default: '',
149
+ default: "",
156
150
  },
157
151
  cardBrowseContent: {
158
152
  type: Boolean,
@@ -160,7 +154,7 @@ export default {
160
154
  },
161
155
  gridId: {
162
156
  type: String,
163
- default: 'default',
157
+ default: "default",
164
158
  },
165
159
  },
166
160
  data() {
@@ -168,89 +162,88 @@ export default {
168
162
  childCards: [],
169
163
  redrawCounter: 0,
170
164
  setColumnSizeDebounce: debounce(this.setColumnSize, 500),
171
- }
165
+ };
172
166
  },
173
167
  computed: {
174
168
  largeViewPort() {
175
169
  if (this.forceLgColumnsPerRow) {
176
- return 12 / this.forceLgColumnsPerRow
170
+ return 12 / this.forceLgColumnsPerRow;
177
171
  }
178
172
  return 12 / this.cards.length > 12 / (this.columnsPerRow || 3)
179
173
  ? 12 / this.cards.length
180
- : 12 / this.columnsPerRow
174
+ : 12 / this.columnsPerRow;
181
175
  },
182
176
  mediumViewPort() {
183
177
  if (this.forceMdColumnsPerRow) {
184
- return 12 / this.forceLgColumnsPerRow
178
+ return 12 / this.forceLgColumnsPerRow;
185
179
  }
186
180
  if (this.largeViewPort === 6) {
187
- return 6
181
+ return 6;
188
182
  }
189
- return 4
183
+ return 4;
190
184
  },
191
185
  smallViewPort() {
192
186
  if (this.forceSmColumnsPerRow) {
193
- return 12 / this.forceLgColumnsPerRow
187
+ return 12 / this.forceLgColumnsPerRow;
194
188
  }
195
- return 6
189
+ return 6;
196
190
  },
197
191
  },
198
192
  watch: {
199
193
  cards: {
200
194
  handler: function () {
201
- this.redrawCounter += 1
202
- this.setColumnSizeDebounce()
195
+ this.redrawCounter += 1;
196
+ this.setColumnSizeDebounce();
203
197
  },
204
198
  deep: true,
205
199
  },
206
200
  columnsPerRow: {
207
201
  handler: function () {
208
- this.setColumnSizeDebounce()
202
+ this.setColumnSizeDebounce();
209
203
  },
210
204
  },
211
205
  forceSmColumnsPerRow: {
212
206
  handler: function () {
213
- this.setColumnSizeDebounce()
207
+ this.setColumnSizeDebounce();
214
208
  },
215
209
  },
216
210
  forceMdColumnsPerRow: {
217
211
  handler: function () {
218
- this.setColumnSizeDebounce()
212
+ this.setColumnSizeDebounce();
219
213
  },
220
214
  },
221
215
  forceLgColumnsPerRow: {
222
216
  handler: function () {
223
- this.setColumnSizeDebounce()
217
+ this.setColumnSizeDebounce();
224
218
  },
225
219
  },
226
220
  },
227
221
  mounted() {
228
- window.addEventListener('resize', this.setColumnSizeDebounce)
229
- this.setColumnSizeDebounce()
222
+ window.addEventListener("resize", this.setColumnSizeDebounce);
223
+ this.setColumnSizeDebounce();
230
224
  },
231
225
  beforeDestroy() {
232
- window.removeEventListener('resize', this.setColumnSizeDebounce)
226
+ window.removeEventListener("resize", this.setColumnSizeDebounce);
233
227
  },
234
228
  methods: {
235
229
  cardTitleSelected(selectedCard, ev) {
236
- this.clearCards()
237
- selectedCard.selected = !!!selectedCard.selected
238
- const selectedCardModelIndex = this.getChildIndex(selectedCard)
230
+ this.clearCards();
231
+ selectedCard.selected = !!!selectedCard.selected;
232
+ const selectedCardModelIndex = this.getChildIndex(selectedCard);
239
233
 
240
- this.$emit('selected-title', {
241
- selectedCard: selectedCard.selected
242
- ? this.cards[selectedCardModelIndex]
243
- : null,
234
+ this.$emit("selected-title", {
235
+ selectedCard: selectedCard.selected ? this.cards[selectedCardModelIndex] : null,
244
236
  selectedCardModelIndex,
245
237
  ev,
246
- })
238
+ });
247
239
  },
248
240
  cardSelected(selectedCard, ev) {
249
- this.clearCards()
250
- selectedCard.selected = !!!selectedCard.selected
251
- const selectedCardModelIndex = this.getChildIndex(selectedCard)
241
+ debugger;
242
+ this.clearCards();
243
+ selectedCard.selected = !!!selectedCard.selected;
244
+ const selectedCardModelIndex = this.getChildIndex(selectedCard);
252
245
 
253
- this.$emit('selected', {
246
+ this.$emit("selected", {
254
247
  selectedCard: selectedCard.selected
255
248
  ? this.cardBrowseContent
256
249
  ? this.childCards[selectedCardModelIndex]
@@ -258,59 +251,59 @@ export default {
258
251
  : null,
259
252
  selectedCardModelIndex,
260
253
  ev,
261
- })
254
+ });
262
255
  },
263
256
  clearCards(selectedCard) {
264
257
  this.childCards.forEach((card) => {
265
- card.selected = false
258
+ card.selected = false;
266
259
  if (!selectedCard || selectedCard !== card) {
267
- card.selected = false
260
+ card.selected = false;
268
261
  }
269
- })
262
+ });
270
263
  },
271
264
  getChildIndex(selectedCard) {
272
- return this.childCards.findIndex((item) => item === selectedCard)
265
+ return this.childCards.findIndex((item) => item === selectedCard);
273
266
  },
274
267
  registerChild(child) {
275
- this.childCards.push(child)
276
- this.setColumnSizeDebounce()
268
+ this.childCards.push(child);
269
+ this.setColumnSizeDebounce();
277
270
  },
278
271
  deregisterChild(child) {
279
- const index = this.childCards.indexOf(child)
272
+ const index = this.childCards.indexOf(child);
280
273
  if (index > -1) {
281
- this.childCards.splice(index, 1)
274
+ this.childCards.splice(index, 1);
282
275
  }
283
276
  },
284
277
  setColumnSize() {
285
278
  setTimeout(() => {
286
- const columns = this.$refs.cardColumns
279
+ const columns = this.$refs.cardColumns;
287
280
  if (Array.isArray(columns) && columns.length > 0) {
288
- const row = this.$refs.cardRow
289
- const elementWidth = columns[0].$el.offsetWidth
290
- const parentWidth = row.$el.offsetWidth
291
- const gridColumnSize = parseInt(parentWidth / elementWidth)
292
- const isMobileView = parentWidth < 480
293
- const isTabletView = !isMobileView && parentWidth < 767
294
- this.$emit('isMobileView', isMobileView)
295
- this.$emit('isTabletView', isTabletView)
296
- this.$emit('isDesktopView', !isTabletView && !isMobileView)
297
- this.$emit('isMobileOrTabletView', isMobileView || isTabletView)
298
- this.$emit('gridColumnSize', gridColumnSize)
281
+ const row = this.$refs.cardRow;
282
+ const elementWidth = columns[0].$el.offsetWidth;
283
+ const parentWidth = row.$el.offsetWidth;
284
+ const gridColumnSize = parseInt(parentWidth / elementWidth);
285
+ const isMobileView = parentWidth < 480;
286
+ const isTabletView = !isMobileView && parentWidth < 767;
287
+ this.$emit("isMobileView", isMobileView);
288
+ this.$emit("isTabletView", isTabletView);
289
+ this.$emit("isDesktopView", !isTabletView && !isMobileView);
290
+ this.$emit("isMobileOrTabletView", isMobileView || isTabletView);
291
+ this.$emit("gridColumnSize", gridColumnSize);
299
292
  this.childCards.forEach((card) =>
300
- card.setGridMetaData(gridColumnSize, isMobileView, isTabletView),
301
- )
293
+ card.setGridMetaData(gridColumnSize, isMobileView, isTabletView)
294
+ );
302
295
  }
303
- })
296
+ });
304
297
  },
305
298
  handleFocus(ev) {
306
- this.$emit('focussed', ev)
299
+ this.$emit("focussed", ev);
307
300
  },
308
301
  },
309
- }
302
+ };
310
303
  </script>
311
304
 
312
305
  <style lang="scss" scoped>
313
- @import '../../../includes/scss/all';
306
+ @import "../../../includes/scss/all";
314
307
  .card-grid {
315
308
  &__column {
316
309
  &--default {
@@ -402,6 +402,8 @@ export default {
402
402
  },
403
403
  methods: {
404
404
  cardClicked(ev) {
405
+ debugger;
406
+ console.log("cardClicked this.isSelectable :- ", this.isSelectable);
405
407
  if (this.isSelectable) {
406
408
  this.parentGrid.cardSelected(this, ev);
407
409
  }
@@ -411,6 +413,7 @@ export default {
411
413
  }
412
414
  },
413
415
  cardTitleClicked(ev) {
416
+ debugger;
414
417
  if (this.isCardTitleSelectable) {
415
418
  this.parentGrid.cardTitleSelected(this, ev);
416
419
  }
@@ -13,6 +13,7 @@
13
13
  <label class="app-search__label font-weight-bold" for="app-search--search-input-box"
14
14
  >Search WorkSafe</label
15
15
  >
16
+ googleSearchFlag:- {{ googleSearchFlag }}
16
17
  <search
17
18
  ref="searchInputBox"
18
19
  :google-search-flag="googleSearchFlag"
@@ -10,7 +10,9 @@
10
10
  <img class="app-search__close-icon" width="22" height="18" :src="Close" />
11
11
  </button>
12
12
  <form @submit.prevent>
13
- <label class="app-search__label font-weight-bold" for="app-search--search-input-box"
13
+ <label
14
+ class="app-search__label font-weight-bold"
15
+ for="app-search--search-input-box"
14
16
  >Search WorkSafe</label
15
17
  >
16
18
  <search
@@ -30,40 +32,40 @@
30
32
  </template>
31
33
 
32
34
  <script>
33
- import Close from "../../../../assets/icons/close.svg?url";
34
- import Search from "../../../SubComponents/Search/index.vue";
35
+ import Close from '../../../../assets/icons/close.svg?url'
36
+ import Search from '../../../SubComponents/Search/index.vue'
35
37
 
36
38
  export default {
37
- name: "ModalSearch",
39
+ name: 'ModalSearch',
38
40
  components: { Search },
39
41
  props: {
40
42
  searchQuery: {
41
43
  type: String,
42
- default: "",
44
+ default: ''
43
45
  },
44
46
  contentParser: {
45
47
  type: Function,
46
- required: true,
48
+ required: true
47
49
  },
48
50
  googleSearchFlag: {
49
51
  type: String,
50
- default: "solar",
51
- },
52
+ default: 'googlerest'
53
+ }
52
54
  },
53
55
  data() {
54
56
  return {
55
57
  pageLimit: 20,
56
58
  pageNumber: 1,
57
59
  searchResults: null,
58
- Close,
59
- };
60
+ Close
61
+ }
60
62
  },
61
63
  mounted() {
62
- this.$refs.searchInputBox.$el.querySelector("input").focus();
63
- },
64
- };
64
+ this.$refs.searchInputBox.$el.querySelector('input').focus()
65
+ }
66
+ }
65
67
  </script>
66
68
 
67
69
  <style lang="scss" scoped>
68
- @import "./styles";
70
+ @import './styles';
69
71
  </style>
@@ -5,10 +5,7 @@
5
5
  v-if="!(isTypeahead && numFound > 0) && !isLoading"
6
6
  class="app-search-result__found"
7
7
  >
8
- <span
9
- >{{ numFound }} results found for
10
- {{ !suggestion ? query : suggestion }}</span
11
- >
8
+ <span>{{ numFound }} results found for {{ !suggestion ? query : suggestion }}</span>
12
9
  </p>
13
10
  <p
14
11
  v-if="results && results.length > 0 && suggestion"
@@ -21,7 +18,7 @@
21
18
  :force-lg-columns-per-row="1"
22
19
  :force-md-columns-per-row="1"
23
20
  :cards="results"
24
- :is-selectable="false"
21
+ :is-selectable="isSelectable"
25
22
  :size="'full'"
26
23
  :row-spacing="'none'"
27
24
  :no-padding-top="true"
@@ -82,14 +79,14 @@
82
79
  </template>
83
80
 
84
81
  <script>
85
- import CardGrid from '../../../Common/CardGrid/index.vue'
86
- import CardGridItem from '../../../Common/CardGridItem/index.vue'
87
- import { navigateToPath } from '../../../../../lib/utility'
88
- import Pagination from '../../Pagination/index.vue'
89
- import Column from '../../../Containers/Column/index.vue'
82
+ import CardGrid from "../../../Common/CardGrid/index.vue";
83
+ import CardGridItem from "../../../Common/CardGridItem/index.vue";
84
+ import { navigateToPath } from "../../../../../lib/utility";
85
+ import Pagination from "../../Pagination/index.vue";
86
+ import Column from "../../../Containers/Column/index.vue";
90
87
 
91
88
  export default {
92
- name: 'SearchListing',
89
+ name: "SearchListing",
93
90
  components: { CardGrid, CardGridItem, Pagination, Column },
94
91
  props: {
95
92
  isTypeahead: {
@@ -109,7 +106,7 @@ export default {
109
106
  query: {
110
107
  type: String,
111
108
  required: false,
112
- default: '',
109
+ default: "",
113
110
  },
114
111
  results: {
115
112
  type: Array,
@@ -132,49 +129,54 @@ export default {
132
129
  type: Boolean,
133
130
  default: false,
134
131
  },
132
+ isSelectable: {
133
+ type: Boolean,
134
+ default: true,
135
+ },
135
136
  },
136
137
  methods: {
137
138
  onClickItem(event, item, index) {
138
- this.$emit('select-item', event.target, item, index)
139
+ this.$emit("select-item", event.target, item, index);
139
140
  },
140
141
  truncate(value, limit) {
141
142
  if (value.length > limit) {
142
- value = value.substring(0, limit - 3) + '...'
143
+ value = value.substring(0, limit - 3) + "...";
143
144
  }
144
- return value
145
+ return value;
145
146
  },
146
147
  onSelectCardTitle(card) {
148
+ debugger;
147
149
  navigateToPath.call(
148
150
  this,
149
151
  card?.selectedCard?.link.match(/https?:\/\/[^\/]+(\/[^?#]*)/)[1], // open link in current environment
150
- card?.ev?.ctrlKey === true || card?.ev?.metaKey === true,
151
- )
152
- this.$nextTick(() => this.$emit('selected-title'))
152
+ card?.ev?.ctrlKey === true || card?.ev?.metaKey === true
153
+ );
154
+ this.$nextTick(() => this.$emit("selected-title"));
153
155
 
154
156
  if (this.$gtm) {
155
- this.fireGTM(card)
157
+ this.fireGTM(card);
156
158
  }
157
159
  },
158
160
  onSelectResult(card) {
159
161
  navigateToPath.call(
160
162
  this,
161
163
  card?.selectedCard?.link.match(/https?:\/\/[^\/]+(\/[^?#]*)/)[1], // title click is used for search result, but change also included here
162
- card?.ev?.ctrlKey === true || card?.ev?.metaKey === true,
163
- )
164
- this.$nextTick(() => this.$emit('selected'))
164
+ card?.ev?.ctrlKey === true || card?.ev?.metaKey === true
165
+ );
166
+ this.$nextTick(() => this.$emit("selected"));
165
167
 
166
168
  if (this.$gtm) {
167
- this.fireGTM(card)
169
+ this.fireGTM(card);
168
170
  }
169
171
  },
170
172
  fireGTM(card) {
171
173
  let attrs = {
172
174
  location:
173
- this.$route?.path === '/'
174
- ? 'Homepage'
175
- : this.$route?.path === '/search'
176
- ? 'Search Page'
177
- : this.$route?.path,
175
+ this.$route?.path === "/"
176
+ ? "Homepage"
177
+ : this.$route?.path === "/search"
178
+ ? "Search Page"
179
+ : this.$route?.path,
178
180
  label: this.query,
179
181
  results: this.results.length,
180
182
  clickText: card.selectedCard.title,
@@ -184,20 +186,20 @@ export default {
184
186
  industry: card?.selectedCard?.industry,
185
187
  topic: card?.selectedCard?.topic,
186
188
  language: card?.selectedCard?.language,
187
- }
188
- this.$gtm.push({ event: 'custom.search.site.result', ...attrs })
189
+ };
190
+ this.$gtm.push({ event: "custom.search.site.result", ...attrs });
189
191
  },
190
192
  showMoreResults() {
191
193
  if (this.$nuxt) {
192
- this.$router.push('/search?q=' + this.query)
194
+ this.$router.push("/search?q=" + this.query);
193
195
  }
194
196
  },
195
197
  },
196
- }
198
+ };
197
199
  </script>
198
200
 
199
201
  <style lang="scss" scoped>
200
- @import '../../../../includes/scss/all';
202
+ @import "../../../../includes/scss/all";
201
203
  .app-search-result {
202
204
  &__found,
203
205
  &__suggestion {
@@ -37,8 +37,8 @@ const DefaultSearch = (args) => ({
37
37
  setup () {
38
38
  return { args }
39
39
  },
40
- template: `<search
41
- v-bind="args"
40
+ template: `<search
41
+ v-bind="args"
42
42
  ref="solrsearch" />`
43
43
  })
44
44
 
@@ -6,10 +6,10 @@
6
6
  </div>
7
7
  </template>
8
8
  <template v-else>
9
+ ELSE :- searchType :- {{ searchType }}
9
10
  <b-input-group>
10
11
  <label class="visually-hidden" for="site-search"
11
- >Search by keyword (Typed keyword automatically filters below
12
- results)</label
12
+ >Search by keyword (Typed keyword automatically filters below results)</label
13
13
  >
14
14
  <b-form-input
15
15
  id="site-search"
@@ -19,7 +19,7 @@
19
19
  autocomplete="off"
20
20
  trim
21
21
  @update="searchType !== 'googlerest' ? onChange : () => {}"
22
- @keyup.enter="onChange"
22
+ @keyup.enter="searchType === 'googlerest' ? onChange : () => {}"
23
23
  ></b-form-input>
24
24
  <template #append>
25
25
  <b-button size="sm" class="search-button" @click="onSearch"
@@ -28,6 +28,7 @@
28
28
  /></b-button>
29
29
  </template>
30
30
  </b-input-group>
31
+ searchType:- {{ searchType }} <br />
31
32
  <search-listing
32
33
  v-if="loadSearchList && (searchResults || isLoading)"
33
34
  :class="{
@@ -43,6 +44,7 @@
43
44
  :offset="searchResults && searchResults.offset"
44
45
  :page-limit="pageLimit"
45
46
  :content-parser="contentParser"
47
+ :is-selectable="searchType === 'googlerest' ? false : true"
46
48
  :is-card-title-selectable="searchType === 'googlerest' ? true : false"
47
49
  @selected="$emit('selected')"
48
50
  @pageChanged="pageChanged"
@@ -52,11 +54,10 @@
52
54
  </template>
53
55
 
54
56
  <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
-
57
+ import axios from "axios";
58
+ import searchIcon from "../../../assets/icons/search.svg?url";
59
+ import SearchListing from "./SearchListing/index.vue";
60
+ import { BButton, BInputGroup, BFormInput } from "bootstrap-vue-next";
60
61
 
61
62
  export default {
62
63
  components: { SearchListing, BButton, BInputGroup, BFormInput },
@@ -75,11 +76,11 @@ export default {
75
76
  },
76
77
  initialSearchQuery: {
77
78
  type: String,
78
- default: '',
79
+ default: "",
79
80
  },
80
81
  googleSearchFlag: {
81
82
  type: String,
82
- default: 'solar',
83
+ default: "solar",
83
84
  },
84
85
  visibleSearchList: {
85
86
  type: Boolean,
@@ -89,39 +90,39 @@ export default {
89
90
  data() {
90
91
  return {
91
92
  searchIcon,
92
- searchQuery: '',
93
+ searchQuery: "",
93
94
  searchResults: null,
94
95
  isLoading: false,
95
- field_language: '8671',
96
+ field_language: "8671",
96
97
  searchType: this.googleSearchFlag,
97
98
  googleSearchScript: false,
98
99
  loadSearchList: this.visibleSearchList,
99
- }
100
+ };
100
101
  },
101
102
  computed: {
102
103
  searchClass() {
103
104
  return {
104
- 'wcl-search': true,
105
- 'wcl-search__google': this.searchType !== 'solar',
106
- }
105
+ "wcl-search": true,
106
+ "wcl-search__google": this.searchType !== "solar",
107
+ };
107
108
  },
108
109
  },
109
110
  mounted() {
110
- if (this.searchType === 'google') {
111
- this.setupGoogleStyle()
111
+ if (this.searchType === "google") {
112
+ this.setupGoogleStyle();
112
113
  } else {
113
114
  if (this.initialSearchQuery) {
114
- this.searchQuery = this.initialSearchQuery
115
- this.onSearch()
115
+ this.searchQuery = this.initialSearchQuery;
116
+ this.onSearch();
116
117
  }
117
118
  if (this.isTypeahead && window) {
118
- window.document.addEventListener('click', this.closeSearchResults)
119
+ window.document.addEventListener("click", this.closeSearchResults);
119
120
  }
120
121
  }
121
122
  },
122
123
  beforeDestroy() {
123
124
  if (this.isTypeahead && window && document) {
124
- window.document.removeEventListener('click', this.closeSearchResults)
125
+ window.document.removeEventListener("click", this.closeSearchResults);
125
126
  }
126
127
  },
127
128
  methods: {
@@ -136,54 +137,54 @@ export default {
136
137
  q: query,
137
138
  start: start,
138
139
  },
139
- },
140
- )
141
- return response
140
+ }
141
+ );
142
+ return response;
142
143
  } catch (error) {
143
- console.error('Error fetching search results:', error)
144
- return []
144
+ console.error("Error fetching search results:", error);
145
+ return [];
145
146
  }
146
147
  },
147
148
  async onGoogleSearch(pageNr = 1, searchQuery) {
148
- this.$emit('loading', true)
149
- this.isLoading = true
149
+ this.$emit("loading", true);
150
+ this.isLoading = true;
150
151
 
151
- const apiKey = 'AIzaSyD76GAmQQ6DuxKWf-aLXPZ9pwdz4nOvs2c'
152
- const searchEngineId = '53b1506aa03c64160'
152
+ const apiKey = "AIzaSyD76GAmQQ6DuxKWf-aLXPZ9pwdz4nOvs2c";
153
+ const searchEngineId = "53b1506aa03c64160";
153
154
 
154
- const start = (pageNr - 1) * this.pageLimit
155
+ const start = (pageNr - 1) * this.pageLimit;
155
156
  let response = await this.fetchSearchResults(
156
157
  apiKey,
157
158
  searchEngineId,
158
159
  searchQuery,
159
- start,
160
- )
161
- let items = []
162
- let suggest = response?.data?.spelling?.correctedQuery || ''
160
+ start
161
+ );
162
+ let items = [];
163
+ let suggest = response?.data?.spelling?.correctedQuery || "";
163
164
  if (response?.data?.spelling?.correctedQuery) {
164
165
  response = await this.fetchSearchResults(
165
166
  apiKey,
166
167
  searchEngineId,
167
168
  response?.data?.spelling?.correctedQuery,
168
- start,
169
- )
170
- items = response?.data?.items
169
+ start
170
+ );
171
+ items = response?.data?.items;
171
172
  } else if (response?.data?.items) {
172
- items = response?.data?.items
173
+ items = response?.data?.items;
173
174
  }
174
175
  if (items.length > 0) {
175
- const totalResults = response?.data?.searchInformation?.totalResults
176
+ const totalResults = response?.data?.searchInformation?.totalResults;
176
177
  // Loop through each item in the items array
177
178
  const modifiedResults = items.map((item) => {
178
179
  // Update the title using the handleSearchResultLinkTitle function
179
- const modifiedTitle = this.handleSearchResultLinkTitle(item.title)
180
+ const modifiedTitle = this.handleSearchResultLinkTitle(item.title);
180
181
 
181
182
  // Return the modified item with the updated title
182
183
  return {
183
184
  ...item,
184
185
  title: modifiedTitle,
185
- }
186
- })
186
+ };
187
+ });
187
188
 
188
189
  this.searchResults = {
189
190
  offset: Number(pageNr === 1 ? pageNr - 1 : pageNr),
@@ -191,19 +192,19 @@ export default {
191
192
  query: this.searchQuery,
192
193
  results: modifiedResults,
193
194
  suggestion: suggest,
194
- }
195
+ };
195
196
  } else {
196
197
  this.searchResults = {
197
198
  offset: 0,
198
199
  numFound: 0,
199
- query: this.searchQuery ?? '',
200
+ query: this.searchQuery ?? "",
200
201
  results: [],
201
202
  suggestion: suggest,
202
- }
203
+ };
203
204
  }
204
- this.$emit('loading', false)
205
- this.isLoading = false
206
- this.$emit('results', this.searchResults)
205
+ this.$emit("loading", false);
206
+ this.isLoading = false;
207
+ this.$emit("results", this.searchResults);
207
208
 
208
209
  // wait for the page title to be updated and then fire the search event
209
210
  setTimeout(() => {
@@ -211,87 +212,83 @@ export default {
211
212
  pageTitle: document.title,
212
213
  pageURL: this.$route?.fullPath,
213
214
  location:
214
- this.$route?.path === '/'
215
- ? 'Homepage'
216
- : this.$route?.path === '/search'
217
- ? 'Search Page'
218
- : this.$route?.path,
215
+ this.$route?.path === "/"
216
+ ? "Homepage"
217
+ : this.$route?.path === "/search"
218
+ ? "Search Page"
219
+ : this.$route?.path,
219
220
  label: this.searchQuery,
220
221
  results: this.searchResults.numFound,
221
- }
222
+ };
222
223
  if (this.$gtm) {
223
- this.$gtm.push({ event: 'custom.search.site.submit', ...attrs })
224
+ this.$gtm.push({ event: "custom.search.site.submit", ...attrs });
224
225
  }
225
- }, 300)
226
+ }, 300);
226
227
  },
227
228
  pageChanged(newPageNumber) {
228
- if (this.searchType === 'solar') {
229
+ if (this.searchType === "solar") {
229
230
  // Reset search results before fetching new results
230
- this.resetSearchResults()
231
- this.performSearch(newPageNumber, this.searchQuery, this.pageLimit)
231
+ this.resetSearchResults();
232
+ this.performSearch(newPageNumber, this.searchQuery, this.pageLimit);
232
233
  } else {
233
234
  // Fetch new search results with the updated page number
234
- this.onGoogleSearch(newPageNumber, this.searchQuery)
235
+ this.onGoogleSearch(newPageNumber, this.searchQuery);
235
236
  }
236
237
  },
237
238
  onSearch(e) {
238
- // debugger
239
- const { path } = this.$route || {}
239
+ debugger;
240
+ console.log("this.searchType:- ", this.searchType);
240
241
 
241
-
242
+ const { path } = this.$route || {};
242
243
 
243
244
  // Home page
244
245
  if (
245
- (e?.type === 'click' || e?.key == 'Enter') &&
246
+ (e?.type === "click" || e?.key == "Enter") &&
246
247
  this.searchQuery &&
247
248
  this.searchQuery.length > 2 &&
248
- path === '/'
249
+ path === "/"
249
250
  ) {
250
251
  // 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}`
252
+ const searchQuery = encodeURIComponent(this.searchQuery);
253
+ const origin = window.location.origin;
254
+ const hash = window.location.hash;
255
+ const pathname = "search";
256
+ const URL = `${origin}/${pathname}${hash}?q=${searchQuery}`;
256
257
 
257
258
  // Uncomment below commented code when goes live
258
- window.location.assign(URL)
259
+ window.location.assign(URL);
259
260
  } else {
260
- this.resetSearchResults()
261
- this.$emit('query', this.searchQuery)
261
+ this.resetSearchResults();
262
+ this.$emit("query", this.searchQuery);
262
263
 
263
- if (this.searchType === 'solar') {
264
- this.performSearch(1, this.searchQuery, this.pageLimit)
264
+ if (this.searchType === "solar") {
265
+ this.performSearch(1, this.searchQuery, this.pageLimit);
265
266
  } else {
266
- this.onGoogleSearch(1, this.searchQuery)
267
+ this.onGoogleSearch(1, this.searchQuery);
267
268
  }
268
269
  }
269
270
  },
270
271
  resetSearchResults() {
271
- this.searchResults = null
272
+ this.searchResults = null;
272
273
  },
273
274
  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)
275
+ if (this.isTypeahead && this.searchResults && ev?.target?.id !== "site-search") {
276
+ this.resetSearchResults();
277
+ this.searchQuery = null;
278
+ this.$emit("query", null);
282
279
  }
283
280
  },
284
281
  onChange(e) {
285
282
  //debugger
286
-
283
+
287
284
  if (this.searchQuery && this.searchQuery.length > 2) {
288
- this.onSearch(e)
285
+ this.onSearch(e);
289
286
  }
290
287
  },
291
288
  performSearch(pageNr = 1, searchQuery, pageLimit) {
292
289
  if (searchQuery) {
293
- this.$emit('loading', true)
294
- this.isLoading = true
290
+ this.$emit("loading", true);
291
+ this.isLoading = true;
295
292
  this.contentParser({
296
293
  query: searchQuery,
297
294
  start: pageNr > 1 ? (pageNr - 1) * pageLimit : 0,
@@ -305,100 +302,100 @@ export default {
305
302
  query: searchQuery,
306
303
  results: res.results,
307
304
  suggestion: null,
308
- }
305
+ };
309
306
  } else {
310
307
  this.searchResults = {
311
308
  offset: 0,
312
309
  numFound: 0,
313
- query: this.searchQuery ?? '',
310
+ query: this.searchQuery ?? "",
314
311
  results: [],
315
312
  suggestion: null,
316
- }
313
+ };
317
314
  }
318
- this.$emit('loading', false)
319
- this.isLoading = false
320
- this.$emit('results', this.searchResults)
315
+ this.$emit("loading", false);
316
+ this.isLoading = false;
317
+ this.$emit("results", this.searchResults);
321
318
  // wait for the page title to be updated and then fire the search event
322
319
  setTimeout(() => {
323
320
  const attrs = {
324
321
  pageTitle: document.title,
325
322
  pageURL: this.$route?.fullPath,
326
323
  location:
327
- this.$route?.path === '/'
328
- ? 'Homepage'
329
- : this.$route?.path === '/search'
330
- ? 'Search Page'
331
- : this.$route?.path,
324
+ this.$route?.path === "/"
325
+ ? "Homepage"
326
+ : this.$route?.path === "/search"
327
+ ? "Search Page"
328
+ : this.$route?.path,
332
329
  label: this.searchQuery,
333
330
  results: this.searchResults.numFound,
334
- }
331
+ };
335
332
  if (this.$gtm) {
336
- this.$gtm.push({ event: 'custom.search.site.submit', ...attrs })
333
+ this.$gtm.push({ event: "custom.search.site.submit", ...attrs });
337
334
  }
338
- }, 300)
339
- })
335
+ }, 300);
336
+ });
340
337
  }
341
338
  },
342
339
 
343
340
  // Method to customize google search style
344
341
  setupGoogleStyle() {
345
342
  if (this.googleSearchScript === false) {
346
- const script = document.createElement('script')
347
- script.async = true
343
+ const script = document.createElement("script");
344
+ script.async = true;
348
345
  script.src = this.$config
349
346
  ? this.$config.public.googleSearch
350
- : process.env.GOOGLE__URL
351
- document.head.appendChild(script)
352
- this.googleSearchScript = true
347
+ : process.env.GOOGLE__URL;
348
+ document.head.appendChild(script);
349
+ this.googleSearchScript = true;
353
350
 
354
351
  // Create a new style element
355
- const style = document.createElement('style')
356
- style.id = 'searchStyle' // Assign an ID to the style element
352
+ const style = document.createElement("style");
353
+ style.id = "searchStyle"; // Assign an ID to the style element
357
354
  // The CSS we are going to inject
358
- const cssVar = 'table.gssb_c {display: none !important;}'
355
+ const cssVar = "table.gssb_c {display: none !important;}";
359
356
  // Inject the style element into the head
360
- document.head.appendChild(style)
357
+ document.head.appendChild(style);
361
358
  // Set the text content of the style element to the CSS text
362
- style.textContent = cssVar
359
+ style.textContent = cssVar;
363
360
  }
364
361
  },
365
362
 
366
363
  // function to handle search result link titles
367
364
  handleSearchResultLinkTitle(title) {
368
365
  // Split the title by the '|' character
369
- const titleParts = title.split('|')
366
+ const titleParts = title.split("|");
370
367
 
371
368
  // Remove any leading or trailing whitespace from each part
372
- const cleanedTitleParts = titleParts.map((part) => part.trim())
369
+ const cleanedTitleParts = titleParts.map((part) => part.trim());
373
370
 
374
371
  // Join the cleaned title parts back together without the text after the '|' character
375
- const modifiedTitle = cleanedTitleParts[0] // Take only the first part before '|'
372
+ const modifiedTitle = cleanedTitleParts[0]; // Take only the first part before '|'
376
373
 
377
- return modifiedTitle
374
+ return modifiedTitle;
378
375
  },
379
376
 
380
377
  handleKeyUp(event) {
381
- if (event.key === 'Enter' || event.type === 'click') {
378
+ if (event.key === "Enter" || event.type === "click") {
382
379
  let keyword = event.key
383
380
  ? event.target.value
384
- : document.querySelector('input[name="search"]').value
381
+ : document.querySelector('input[name="search"]').value;
385
382
 
386
383
  // 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
384
+ if (keyword && !window.location.href.includes("/search")) {
385
+ let origin = window.location.origin;
386
+ let hash = window.location.hash;
387
+ let pathname = "search";
388
+ let URL = origin + "/" + pathname + hash;
392
389
  }
393
390
 
394
- this.setupPaginationEvent()
391
+ this.setupPaginationEvent();
395
392
  }
396
393
  },
397
394
  },
398
- }
395
+ };
399
396
  </script>
400
397
  <style lang="scss" scoped>
401
- @import '../../../includes/scss/all';
398
+ @import "../../../includes/scss/all";
402
399
 
403
400
  .wcl-search {
404
401
  position: relative;
@@ -456,7 +453,7 @@ export default {
456
453
  }
457
454
  }
458
455
 
459
- @include mq('xs') {
456
+ @include mq("xs") {
460
457
  .not-extra-small-screen {
461
458
  display: none;
462
459
  }
@@ -546,7 +543,7 @@ export default {
546
543
  padding-left: 32px;
547
544
 
548
545
  &:before {
549
- content: 'Search';
546
+ content: "Search";
550
547
  }
551
548
 
552
549
  @media screen and (max-width: 767px) {
@@ -626,7 +623,7 @@ export default {
626
623
  padding: 0;
627
624
 
628
625
  &::after {
629
- content: ' ';
626
+ content: " ";
630
627
  position: absolute;
631
628
  height: 16px;
632
629
  width: 11px;
@@ -733,7 +730,7 @@ export default {
733
730
  }
734
731
 
735
732
  /* search list end */
736
- @include mq('xs') {
733
+ @include mq("xs") {
737
734
  .not-extra-small-screen {
738
735
  display: none;
739
736
  }
@@ -746,4 +743,4 @@ export default {
746
743
  width: 85% !important;
747
744
  }
748
745
  }
749
- </style>
746
+ </style>