/
ServiceSelection.vue
282 lines (266 loc) · 8.76 KB
/
ServiceSelection.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<template>
<div :class="{'service-selection-mobile': $vuetify.breakpoint.xs}">
<v-card-text>
<v-row justify="center">
<v-col cols="12" sm="6" class="text-center">
<v-combobox
:items="serviceList"
:item-text="'external_service_name'"
:filter="serviceSearchFilter"
label="Select Service"
outlined
color="primary"
class="service-selection"
v-model="selectedService"
name="service-select"
@change="serviceSelection"
@input="clickSelection"
@keyup="setKeyPressed"
hide-details
>
<template v-slot:selection="data">
{{ data.item.external_service_name }}
<span v-if="checkDisabled(data.item)" class="ml-1 caption">(Unavailable)</span>
</template>
<template v-slot:item="data">
<div
v-bind:class="{'disabled-selection': checkDisabled(data.item)}"
class="service-selection-options"
>
<div>{{ data.item.external_service_name }}</div>
<div v-if="data.item.online_link" class="service-link" :class="{'service-link-mobile': $vuetify.breakpoint.xs}" @click="goToServiceLink(data.item.online_link)">
Online Option <v-icon small>mdi-open-in-new</v-icon>
</div>
</div>
</template>
</v-combobox>
<!-- <v-btn
v-if="selectedService && selectedService.online_link"
text
link
color="primary"
target="_blank"
:href="selectedService.online_link"
>
Click here for more options
<v-icon small class="ml-1">mdi-open-in-new</v-icon>
</v-btn> -->
</v-col>
</v-row>
<!-- <v-row>-->
<!-- {{myMessage}}-->
<!-- </v-row>-->
<v-row justify="center">
<v-col cols="12" sm="6">
<v-textarea
:maxlength="maxChars"
:label=this.textCharsLeft
class="mt-3"
outlined
name="additional-options"
v-model="additionalOptions"
@change="changeAdditionalOptions"
@keyup="setCharsLeft"
></v-textarea>
</v-col>
</v-row>
<template v-if="selectedService && !keyPressed">
<p class="text-center mb-6">Do you want to book an appointment with <strong>{{currentOffice.office_name}}</strong> for <strong>{{selectedService.external_service_name}}</strong> service?</p>
<div class="d-flex justify-center mb-6">
<!-- <v-btn
large
outlined
color="primary"
class="mr-3"
@click="otherBookingOptionModel = true"
>No, Book With Another Option</v-btn> -->
<v-btn
large
@click="proceedBooking"
color="primary"
>
Yes, Book With The Service BC Centre
<v-icon right small class="ml-1">mdi-arrow-right</v-icon>
</v-btn>
</div>
<p class="text-center body-2">
Information is collected under the authority of
<a href="http://www.bclaws.ca/civix/document/id/complete/statreg/96165_03#d2e3154" target="_blank">Sections 26(c)</a>
of the Freedom of Information and Protection of Privacy Act to help us assess and respond to your enquiry. Questions about the collection of information can be directed to the Director, Provincial Operations, PO BOX 9412 STN PROV GOVT, Victoria, BC, V8W 9V1, 1 800 663-7867.
</p>
</template>
</v-card-text>
<!-- Other Booking Option Model Popup -->
<v-dialog
v-model="otherBookingOptionModel"
max-width="600"
>
<v-card>
<v-toolbar flat color="grey lighten-3">
<v-toolbar-title>Other Booking Options for BC Services Card</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon @click="otherBookingOptionModel = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-toolbar>
<v-card-text>
<p class="mt-4 mb-6">Please use one of the below methods to book your appointment</p>
<p>
<strong>Phone: </strong> (250)-387-6121
</p>
<p>
<strong>Email: </strong> info@gov.bc.ca
</p>
<p>
<strong>Fax: </strong> (250)-952-4124
</p>
</v-card-text>
</v-card>
</v-dialog>
</div>
</template>
<script lang="ts">
import { Component, Mixins, Prop, Vue } from 'vue-property-decorator'
import { mapActions, mapMutations, mapState } from 'vuex'
import { Office } from '@/models/office'
import { Service } from '@/models/service'
import { ServiceAvailability } from '@/utils/constants'
import StepperMixin from '@/mixins/StepperMixin.vue'
@Component({
computed: {
...mapState('office', [
'currentOffice',
'currentService',
'additionalNotes',
'serviceList'
])
},
methods: {
...mapMutations('office', [
'setCurrentService',
'setAdditionalNotes'
]),
...mapActions('office', [
'getServiceByOffice'
])
}
})
export default class ServiceSelection extends Mixins(StepperMixin) {
private readonly serviceList!: Service[]
private readonly currentOffice!: Office
private readonly currentService!: Service
private readonly additionalNotes!: string
private readonly setCurrentService!: (service: Service) => void
private readonly setAdditionalNotes!: (notes: string) => void
private readonly getServiceByOffice!: (officeId: number) => Promise<Service[]>
private selectedService: Service = null
private selectedServiceType = typeof this.selectedService
private additionalOptions = ''
private maxChars = 255
private charsLeft = this.maxChars
private textCharsPrefix = 'Additional information? (Optional - '
private textCharsSuffix = ' characters left)'
private textCharsLeft = this.textCharsPrefix + this.charsLeft + this.textCharsSuffix
private keyPressed = true
private myMessage = ''
private otherBookingOptionModel = false
private async mounted () {
if (this.isOnCurrentStep) {
if (this.currentOffice?.office_id) {
await this.getServiceByOffice(this.currentOffice.office_id)
}
this.selectedService = (!this.checkDisabled(this.currentService)) ? this.currentService : null
this.additionalOptions = this.additionalNotes || ''
}
}
private serviceSelection (value) {
// this.mylog('-> serviceSelection')
this.keyPressed = false
this.setCurrentService(value)
}
private mylog (myText) {
this.myMessage = this.myMessage + '\r\n' + myText
}
private setKeyPressed (e) {
// this.mylog('-> setKeyPressed')
if (e.key !== 'Enter') {
this.keyPressed = true
}
}
private clickSelection (value) {
if (!value?.service_name) {
this.selectedService = null
this.setCurrentService(undefined)
} else {
if (this.checkDisabled(value)) {
this.selectedService = null
this.setCurrentService(undefined)
} else {
this.setCurrentService(value)
}
}
}
private changeAdditionalOptions () {
this.setCharsLeft()
this.setAdditionalNotes(this.additionalOptions)
}
private proceedBooking () {
this.stepNext()
}
private setCharsLeft () {
if (this.additionalOptions.length <= this.maxChars) {
this.charsLeft = this.maxChars - this.additionalOptions.length
} else {
this.charsLeft = 0
this.additionalOptions = this.additionalOptions.substring(0, this.maxChars)
}
this.textCharsLeft = this.textCharsPrefix + this.charsLeft + this.textCharsSuffix
}
private checkDisabled (value) {
return (value?.online_availability === ServiceAvailability.DISABLE)
}
private goToServiceLink (url) {
window.open(url, '_blank')
}
private serviceSearchFilter (item, queryText, itemText) {
return `${item?.external_service_name || ''} ${item?.service_desc || ''}`.toLowerCase().indexOf((queryText || '').toLowerCase()) > -1
}
}
</script>
<style lang="scss" scoped>
@import "@/assets/scss/theme.scss";
.v-list-item {
border-bottom: 1px solid $gray6;
}
.service-message {
font-size: 10px;
font-style: italic;
margin-bottom: 8px;
max-width: 450px;
}
.disabled-selection {
color: rgba(0, 0, 0, 0.38);
}
.service-selection-options {
width: 100%;
border-bottom: 1px solid $gray2;
padding-bottom: 6px;
padding-top: 4px;
.service-link {
font-weight: 600;
font-size: .85rem;
display: block;
float: right;
padding: 8px;
padding-right: 4px;
padding-left: 14px;
margin-top: -10px;
color: $BCgovBlue8;
word-break: normal;
}
}
.service-link-mobile {
margin-top: 0 !important;
margin-bottom: -4px;
}
</style>