@worksafevictoria/wcl7.5 1.1.0 → 1.1.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/.storybook/main.js +2 -1
- package/package.json +1 -1
- package/src/components/SubComponents/FormInstance/index.vue +3 -1
- package/src/components/SubComponents/Search/GoogleREST/index.stories.js +50 -0
- package/src/components/SubComponents/Search/GoogleSearch/index.stories.js +23 -0
- package/src/components/SubComponents/Search/SearchListing/index.vue +69 -9
- package/src/components/SubComponents/Search/index.stories.js +19 -16
- package/src/components/SubComponents/Search/index.vue +563 -59
- package/src/components/SubComponents/GoogleSearch/index.stories.js +0 -8
- package/src/components/SubComponents/GoogleSearch/index.vue +0 -405
package/.storybook/main.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<div>
|
|
3
|
+
<h1>Form Instance</h1>
|
|
3
4
|
<p>
|
|
4
5
|
The .vue and .stories.js files for SubComponents/FormInstance (displayed in Storybook under Form) must be copied from current Storybook 6 branch when time to upgrade them. They are causing errors preventing Storybook from being rendered and therefore tested.
|
|
5
6
|
</p>
|
|
7
|
+
</div>
|
|
6
8
|
</template>
|
|
7
9
|
|
|
8
10
|
<script>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import Search from './../index.vue'
|
|
2
|
+
|
|
3
|
+
const contentParser = () => {
|
|
4
|
+
return Promise.resolve({
|
|
5
|
+
results: [
|
|
6
|
+
{
|
|
7
|
+
title: 'Content title 1',
|
|
8
|
+
description: 'Content description 2'
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
offset: 0,
|
|
12
|
+
numFound: 1000
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
title: 'SubComponents/Search',
|
|
18
|
+
component: { Search },
|
|
19
|
+
tags: ['autodocs'],
|
|
20
|
+
argTypes: {
|
|
21
|
+
contentParser: {
|
|
22
|
+
table: { disable: true }
|
|
23
|
+
},
|
|
24
|
+
googleSearchFlag: {
|
|
25
|
+
table: { disable: true }
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
args: {
|
|
29
|
+
pageLimit: 10,
|
|
30
|
+
contentParser: contentParser,
|
|
31
|
+
isTypeahead: false,
|
|
32
|
+
initialSearchQuery: 'Mental Health',
|
|
33
|
+
googleSearchFlag: 'googlerest',
|
|
34
|
+
visibleSearchList: true
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const DefaultSearch = (args) => ({
|
|
40
|
+
components: { Search },
|
|
41
|
+
setup () {
|
|
42
|
+
return { args }
|
|
43
|
+
},
|
|
44
|
+
template: `<search
|
|
45
|
+
v-bind="args"
|
|
46
|
+
:search-type="googleSearchFlag"
|
|
47
|
+
ref="googlerest" />`
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
export const GoogleREST = DefaultSearch.bind({})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Search from './../index.vue'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'SubComponents/Search',
|
|
5
|
+
component: { Search },
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
args: {
|
|
8
|
+
googleSearchFlag: 'google'
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const DefaultSearch = (args) => ({
|
|
13
|
+
components: { Search },
|
|
14
|
+
setup () {
|
|
15
|
+
return { args }
|
|
16
|
+
},
|
|
17
|
+
template: `<search
|
|
18
|
+
v-bind="args"
|
|
19
|
+
:google-search-flag="googleSearchFlag"
|
|
20
|
+
ref="googlerest" />`
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
export const GoogleSearch = DefaultSearch.bind({})
|
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="app-search-result">
|
|
3
|
-
<div v-if="isLoading" class="app-search-result__loader"
|
|
3
|
+
<div v-if="isLoading" class="app-search-result__loader"></div>
|
|
4
4
|
<p
|
|
5
5
|
v-if="!(isTypeahead && numFound > 0) && !isLoading"
|
|
6
6
|
class="app-search-result__found"
|
|
7
7
|
>
|
|
8
|
-
<span
|
|
8
|
+
<span
|
|
9
|
+
>{{ numFound }} results found for
|
|
10
|
+
{{ !suggestion ? query : suggestion }}</span
|
|
11
|
+
>
|
|
12
|
+
</p>
|
|
13
|
+
<p
|
|
14
|
+
v-if="results && results.length > 0 && suggestion"
|
|
15
|
+
class="app-search-result__suggestion"
|
|
16
|
+
>
|
|
17
|
+
Showing results for <span class="suggestion">{{ suggestion }}</span>
|
|
9
18
|
</p>
|
|
10
19
|
<card-grid
|
|
11
20
|
v-if="results && results.length > 0 && !isLoading"
|
|
12
21
|
:force-lg-columns-per-row="1"
|
|
13
22
|
:force-md-columns-per-row="1"
|
|
14
23
|
:cards="results"
|
|
15
|
-
:is-selectable="
|
|
24
|
+
:is-selectable="false"
|
|
16
25
|
:size="'full'"
|
|
17
26
|
:row-spacing="'none'"
|
|
18
27
|
:no-padding-top="true"
|
|
19
28
|
@selected="onSelectResult"
|
|
29
|
+
@selected-title="onSelectCardTitle"
|
|
20
30
|
>
|
|
21
31
|
<template v-slot:cardItem="{ card }">
|
|
22
32
|
<card-grid-item
|
|
@@ -29,7 +39,7 @@
|
|
|
29
39
|
:description="
|
|
30
40
|
!isTypeahead && card.description
|
|
31
41
|
? truncate(card.description, 144)
|
|
32
|
-
: ''
|
|
42
|
+
: card.htmlSnippet || ''
|
|
33
43
|
"
|
|
34
44
|
:strip-description-html="true"
|
|
35
45
|
:taxonomies="{
|
|
@@ -37,6 +47,7 @@
|
|
|
37
47
|
topic: card.topic,
|
|
38
48
|
language: card.language
|
|
39
49
|
}"
|
|
50
|
+
:is-card-title-selectable="isCardTitleSelectable"
|
|
40
51
|
/>
|
|
41
52
|
</template>
|
|
42
53
|
<template
|
|
@@ -58,7 +69,6 @@
|
|
|
58
69
|
:aria-label="'search result pagination'"
|
|
59
70
|
:rows="pageLimit"
|
|
60
71
|
:offset="offset"
|
|
61
|
-
:max-pages="4"
|
|
62
72
|
:total="numFound"
|
|
63
73
|
:align="'start'"
|
|
64
74
|
@prev="(pg) => $emit('pageChanged', pg.currentPage)"
|
|
@@ -113,6 +123,14 @@ export default {
|
|
|
113
123
|
isLoading: {
|
|
114
124
|
type: Boolean,
|
|
115
125
|
required: false
|
|
126
|
+
},
|
|
127
|
+
suggestion: {
|
|
128
|
+
type: String,
|
|
129
|
+
default: null
|
|
130
|
+
},
|
|
131
|
+
isCardTitleSelectable: {
|
|
132
|
+
type: Boolean,
|
|
133
|
+
default: false
|
|
116
134
|
}
|
|
117
135
|
},
|
|
118
136
|
methods: {
|
|
@@ -125,6 +143,18 @@ export default {
|
|
|
125
143
|
}
|
|
126
144
|
return value
|
|
127
145
|
},
|
|
146
|
+
onSelectCardTitle(card) {
|
|
147
|
+
navigateToPath.call(
|
|
148
|
+
this,
|
|
149
|
+
card?.selectedCard?.link,
|
|
150
|
+
card?.ev?.ctrlKey === true || card?.ev?.metaKey === true
|
|
151
|
+
)
|
|
152
|
+
this.$nextTick(() => this.$emit('selected-title'))
|
|
153
|
+
|
|
154
|
+
if (this.$gtm) {
|
|
155
|
+
this.fireGTM(card)
|
|
156
|
+
}
|
|
157
|
+
},
|
|
128
158
|
onSelectResult(card) {
|
|
129
159
|
navigateToPath.call(
|
|
130
160
|
this,
|
|
@@ -132,6 +162,12 @@ export default {
|
|
|
132
162
|
card?.ev?.ctrlKey === true || card?.ev?.metaKey === true
|
|
133
163
|
)
|
|
134
164
|
this.$nextTick(() => this.$emit('selected'))
|
|
165
|
+
|
|
166
|
+
if (this.$gtm) {
|
|
167
|
+
this.fireGTM(card)
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
fireGTM(card) {
|
|
135
171
|
let attrs = {
|
|
136
172
|
location:
|
|
137
173
|
this.$route?.path === '/'
|
|
@@ -149,9 +185,7 @@ export default {
|
|
|
149
185
|
topic: card?.selectedCard?.topic,
|
|
150
186
|
language: card?.selectedCard?.language
|
|
151
187
|
}
|
|
152
|
-
|
|
153
|
-
this.$gtm.push({ event: 'custom.search.site.result', ...attrs })
|
|
154
|
-
}
|
|
188
|
+
this.$gtm.push({ event: 'custom.search.site.result', ...attrs })
|
|
155
189
|
},
|
|
156
190
|
showMoreResults() {
|
|
157
191
|
if (this.$nuxt) {
|
|
@@ -165,8 +199,13 @@ export default {
|
|
|
165
199
|
<style lang="scss" scoped>
|
|
166
200
|
@import '../../../../includes/scss/all';
|
|
167
201
|
.app-search-result {
|
|
168
|
-
&__found
|
|
202
|
+
&__found,
|
|
203
|
+
&__suggestion {
|
|
169
204
|
margin: 40px 16px;
|
|
205
|
+
.suggestion {
|
|
206
|
+
font-weight: bold;
|
|
207
|
+
color: #006bff;
|
|
208
|
+
}
|
|
170
209
|
}
|
|
171
210
|
|
|
172
211
|
:deep(.card-grid-item__card) {
|
|
@@ -214,4 +253,25 @@ export default {
|
|
|
214
253
|
}
|
|
215
254
|
}
|
|
216
255
|
}
|
|
256
|
+
|
|
257
|
+
.wcl-search__google {
|
|
258
|
+
.app-search-result {
|
|
259
|
+
:deep(.card-grid-item__card) {
|
|
260
|
+
border-radius: 0 !important;
|
|
261
|
+
border-bottom: solid $gray-alt 1px;
|
|
262
|
+
&:hover {
|
|
263
|
+
background-color: transparent !important;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
:deep(.card-title) {
|
|
267
|
+
text-decoration: underline;
|
|
268
|
+
border: 3px solid transparent;
|
|
269
|
+
width: auto;
|
|
270
|
+
&:hover {
|
|
271
|
+
border: 3px solid #da47ff;
|
|
272
|
+
color: #006bff !important;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
217
277
|
</style>
|
|
@@ -15,29 +15,32 @@ const contentParser = () => {
|
|
|
15
15
|
|
|
16
16
|
export default {
|
|
17
17
|
title: 'SubComponents/Search',
|
|
18
|
-
component: Search,
|
|
18
|
+
component: { Search },
|
|
19
|
+
tags: ['autodocs'],
|
|
19
20
|
argTypes: {
|
|
20
|
-
pageLimit: {
|
|
21
|
-
control: 'number'
|
|
22
|
-
},
|
|
23
21
|
contentParser: {
|
|
24
|
-
control: 'function',
|
|
25
22
|
table: { disable: true }
|
|
26
|
-
},
|
|
27
|
-
isTypeahead: {
|
|
28
|
-
control: 'boolean'
|
|
29
|
-
},
|
|
30
|
-
initialSearchQuery: {
|
|
31
|
-
control: 'text'
|
|
32
23
|
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const Default = {
|
|
24
|
+
},
|
|
37
25
|
args: {
|
|
38
26
|
pageLimit: 5,
|
|
39
27
|
contentParser: contentParser,
|
|
40
28
|
isTypeahead: false,
|
|
41
|
-
initialSearchQuery: 'Metal'
|
|
29
|
+
initialSearchQuery: 'Metal',
|
|
30
|
+
googleSearchFlag: 'solar',
|
|
31
|
+
visibleSearchList: true
|
|
42
32
|
}
|
|
43
33
|
}
|
|
34
|
+
|
|
35
|
+
const DefaultSearch = (args) => ({
|
|
36
|
+
components: { Search },
|
|
37
|
+
setup () {
|
|
38
|
+
return { args }
|
|
39
|
+
},
|
|
40
|
+
template: `<search
|
|
41
|
+
v-bind="args"
|
|
42
|
+
ref="solrsearch" />`
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
export const Default = DefaultSearch.bind({})
|
|
46
|
+
|