@bcrs-shared-components/staff-payment 3.0.1 → 3.0.2

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.
@@ -1,4 +1,4 @@
1
- import type { Meta } from '@storybook/vue'
1
+ import type { Meta } from '@storybook/vue3'
2
2
  import { StaffPayment } from './index'
3
3
  import { StaffPaymentOptions } from '@bcrs-shared-components/enums'
4
4
  import { StaffPaymentIF } from '@bcrs-shared-components/interfaces'
@@ -8,10 +8,12 @@ const meta: Meta<typeof StaffPayment> = {
8
8
  }
9
9
  export default meta
10
10
 
11
- const Template = (args, { argTypes }) => ({
12
- props: Object.keys(argTypes),
11
+ const Template = (args) => ({
13
12
  components: { StaffPayment },
14
- template: '<staff-payment v-bind="$props" />' // $props comes from args below
13
+ setup () {
14
+ return { args }
15
+ },
16
+ template: '<staff-payment v-bind="args" />'
15
17
  })
16
18
 
17
19
  const staffPaymentData: StaffPaymentIF = {
@@ -25,5 +27,7 @@ const staffPaymentData: StaffPaymentIF = {
25
27
 
26
28
  export const Default = Template.bind({})
27
29
  Default['args'] = {
28
- staffPaymentData: staffPaymentData
30
+ staffPaymentData: staffPaymentData,
31
+ validate: false,
32
+ invalidSection: false
29
33
  }
package/StaffPayment.vue CHANGED
@@ -18,7 +18,7 @@
18
18
  :sm="displaySideLabel ? 9 : 12"
19
19
  >
20
20
  <v-radio-group
21
- v-model="paymentOption"
21
+ v-model="staffPaymentData.option"
22
22
  class="payment-group"
23
23
  >
24
24
  <!-- Cash or Cheque radio button and form -->
@@ -26,6 +26,7 @@
26
26
  id="fas-radio"
27
27
  class="mb-0"
28
28
  label="Cash or Cheque"
29
+ color="primary"
29
30
  :value="StaffPaymentOptions.FAS"
30
31
  />
31
32
  <v-form
@@ -35,14 +36,13 @@
35
36
  >
36
37
  <v-text-field
37
38
  id="routing-slip-number-textfield"
38
- filled
39
+ v-model="staffPaymentData.routingSlipNumber"
40
+ variant="filled"
39
41
  label="Routing Slip Number"
40
- :value="staffPaymentData.routingSlipNumber"
41
42
  :rules="validate ? routingSlipNumberRules : []"
42
- :disabled="paymentOption === StaffPaymentOptions.BCOL || paymentOption === StaffPaymentOptions.NO_FEE"
43
+ :disabled="fasFormInputDisabled"
43
44
  @keyup="staffPaymentData.routingSlipNumber = staffPaymentData.routingSlipNumber.trim()"
44
- @focus="paymentOption = StaffPaymentOptions.FAS"
45
- @input="emitStaffPaymentData({ option: StaffPaymentOptions.FAS, routingSlipNumber: $event })"
45
+ @focus="staffPaymentData.option = StaffPaymentOptions.FAS"
46
46
  />
47
47
  </v-form>
48
48
 
@@ -51,6 +51,7 @@
51
51
  id="bcol-radio"
52
52
  class="mb-0 pt-2"
53
53
  label="BC Online"
54
+ color="primary"
54
55
  :value="StaffPaymentOptions.BCOL"
55
56
  />
56
57
  <v-form
@@ -60,34 +61,31 @@
60
61
  >
61
62
  <v-text-field
62
63
  id="bcol-account-number-textfield"
63
- filled
64
+ v-model="staffPaymentData.bcolAccountNumber"
65
+ variant="filled"
64
66
  label="BC Online Account Number"
65
- :value="staffPaymentData.bcolAccountNumber"
66
67
  :rules="validate ? bcolAccountNumberRules : []"
67
- :disabled="paymentOption === StaffPaymentOptions.FAS || paymentOption === StaffPaymentOptions.NO_FEE"
68
+ :disabled="bcolFormInputDisabled"
68
69
  @keyup="staffPaymentData.bcolAccountNumber = staffPaymentData.bcolAccountNumber.trim()"
69
- @focus="paymentOption = StaffPaymentOptions.BCOL"
70
- @input="emitStaffPaymentData({ option: StaffPaymentOptions.BCOL, bcolAccountNumber: $event })"
70
+ @focus="staffPaymentData.option = StaffPaymentOptions.BCOL"
71
71
  />
72
72
  <v-text-field
73
73
  id="dat-number-textfield"
74
- filled
74
+ v-model="staffPaymentData.datNumber"
75
+ variant="filled"
75
76
  label="DAT Number"
76
- :value="staffPaymentData.datNumber"
77
77
  :rules="validate ? datNumberRules : []"
78
- :disabled="paymentOption === StaffPaymentOptions.FAS || paymentOption === StaffPaymentOptions.NO_FEE"
78
+ :disabled="bcolFormInputDisabled"
79
79
  @keyup="staffPaymentData.datNumber = staffPaymentData.datNumber.trim()"
80
- @focus="paymentOption = StaffPaymentOptions.BCOL"
81
- @input="emitStaffPaymentData({ option: StaffPaymentOptions.BCOL, datNumber: $event })"
80
+ @focus="staffPaymentData.option = StaffPaymentOptions.BCOL"
82
81
  />
83
82
  <FolioNumberInput
84
83
  ref="folioNumberInputRef"
85
84
  :folioNumber="staffPaymentData.folioNumber"
86
- :disabled="paymentOption === StaffPaymentOptions.FAS || paymentOption === StaffPaymentOptions.NO_FEE"
85
+ :disabled="bcolFormInputDisabled"
87
86
  validate="true"
88
- @focus="paymentOption = StaffPaymentOptions.BCOL"
89
- @emitFolioNumber="paymentOption === StaffPaymentOptions.BCOL &&
90
- emitStaffPaymentData({ option: StaffPaymentOptions.BCOL, folioNumber: $event })"
87
+ @focus="staffPaymentData.option = StaffPaymentOptions.BCOL"
88
+ @emitFolioNumber="staffPaymentData.folioNumber = $event"
91
89
  />
92
90
  </v-form>
93
91
 
@@ -96,24 +94,24 @@
96
94
  id="no-fee-radio"
97
95
  class="mb-0 pt-2"
98
96
  label="No Fee"
97
+ color="primary"
99
98
  :value="StaffPaymentOptions.NO_FEE"
100
99
  />
101
-
102
- <template v-if="displayPriorityCheckbox">
103
- <v-divider class="mt-6" />
104
-
105
- <!-- Priority checkbox -->
106
- <v-checkbox
107
- id="priority-checkbox"
108
- class="priority-checkbox mt-6 pt-0"
109
- label="Priority (add $100.00)"
110
- hide-details
111
- :input-value="staffPaymentData.isPriority"
112
- :disabled="paymentOption === StaffPaymentOptions.NO_FEE"
113
- @change="emitStaffPaymentData({ isPriority: !!$event })"
114
- />
115
- </template>
116
100
  </v-radio-group>
101
+ <template v-if="displayPriorityCheckbox">
102
+ <v-divider class="mt-6" />
103
+
104
+ <!-- Priority checkbox -->
105
+ <v-checkbox
106
+ id="priority-checkbox"
107
+ v-model="staffPaymentData.isPriority"
108
+ class="priority-checkbox mt-6 pt-0"
109
+ label="Priority (add $100.00)"
110
+ color="primary"
111
+ hide-details
112
+ :disabled="staffPaymentData.option === StaffPaymentOptions.NO_FEE"
113
+ />
114
+ </template>
117
115
  </v-col>
118
116
  </v-row>
119
117
  </div>
@@ -168,8 +166,8 @@ export default class StaffPayment extends Vue {
168
166
  })
169
167
  readonly staffPaymentData!: StaffPaymentIF
170
168
 
171
- /** Radio group model property. */
172
- private paymentOption = StaffPaymentOptions.NONE
169
+ /** Whether this component has been mounted. */
170
+ private isMounted = false
173
171
 
174
172
  /** FAS form model property. */
175
173
  private fasFormValid = false
@@ -177,8 +175,17 @@ export default class StaffPayment extends Vue {
177
175
  /** BCOL form model property. */
178
176
  private bcolFormValid = false
179
177
 
180
- /** Whether this component has been mounted. */
181
- private isMounted = false
178
+ /** If FAS form inputs are disabled. */
179
+ get fasFormInputDisabled (): boolean {
180
+ return this.staffPaymentData.option === StaffPaymentOptions.BCOL ||
181
+ this.staffPaymentData.option === StaffPaymentOptions.NO_FEE
182
+ }
183
+
184
+ /** If BCOL form inputs are disabled. */
185
+ get bcolFormInputDisabled (): boolean {
186
+ return this.staffPaymentData.option === StaffPaymentOptions.FAS ||
187
+ this.staffPaymentData.option === StaffPaymentOptions.NO_FEE
188
+ }
182
189
 
183
190
  /** Validation rules for Routing Slip Number. */
184
191
  readonly routingSlipNumberRules: Array<(v) => boolean | string> = [
@@ -204,8 +211,8 @@ export default class StaffPayment extends Vue {
204
211
  this.isMounted = true
205
212
  }
206
213
 
207
- /** Called when payment option (radio group item) has changed. */
208
- @Watch('paymentOption')
214
+ /** Called when staff payment data option (radio group item) has changed. */
215
+ @Watch('staffPaymentData.option')
209
216
  private onPaymentOptionChanged (val: number): void {
210
217
  switch (val) {
211
218
  case StaffPaymentOptions.FAS:
@@ -214,8 +221,6 @@ export default class StaffPayment extends Vue {
214
221
  this.$refs.folioNumberInputRef.resetFolioNumberValidation()
215
222
  // enable validation for this form
216
223
  this.$refs.fasForm.validate()
217
- // update data
218
- this.emitStaffPaymentData({ option: StaffPaymentOptions.FAS })
219
224
  break
220
225
 
221
226
  case StaffPaymentOptions.BCOL:
@@ -223,8 +228,6 @@ export default class StaffPayment extends Vue {
223
228
  this.$refs.fasForm.resetValidation()
224
229
  // enable validation for this form
225
230
  this.$refs.bcolForm.validate()
226
- // update data
227
- this.emitStaffPaymentData({ option: StaffPaymentOptions.BCOL })
228
231
  break
229
232
 
230
233
  case StaffPaymentOptions.NO_FEE:
@@ -233,46 +236,27 @@ export default class StaffPayment extends Vue {
233
236
  this.$refs.bcolForm.resetValidation()
234
237
  this.$refs.folioNumberInputRef.resetFolioNumberValidation()
235
238
  // update data
236
- this.emitStaffPaymentData({ option: StaffPaymentOptions.NO_FEE, isPriority: false })
239
+ this.staffPaymentData.isPriority = false
237
240
  break
238
241
  }
239
242
  }
240
243
 
241
- /** Watches for change to FAS form validity. */
242
- @Watch('fasFormValid')
243
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
244
- private onFasFormValid (val: boolean) {
245
- // ignore initial condition
246
- if (!this.isMounted) return
247
- this.emitValid()
248
- }
249
-
250
- /** Watches for change to BCOL form validity. */
251
- @Watch('bcolFormValid')
252
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
253
- private onBcolFormValid (val: boolean) {
254
- // ignore initial condition
255
- if (!this.isMounted) return
256
- this.emitValid()
257
- }
258
-
259
244
  /** Watches for changes to Staff Payment Data prop. */
260
245
  @Watch('staffPaymentData', { deep: true, immediate: true })
261
246
  private async onStaffPaymentDataChanged (val: StaffPaymentIF): Promise<void> {
262
- this.paymentOption = val.option
263
- await this.$nextTick()
247
+ this.emitStaffPaymentData({ ...this.staffPaymentData })
264
248
  this.emitValid()
265
249
  }
266
250
 
267
251
  /** Emits an event to update the Staff Payment Data prop. */
268
252
  @Emit('update:staffPaymentData')
269
253
  private emitStaffPaymentData ({
270
- option = this.staffPaymentData.option,
271
- routingSlipNumber = this.staffPaymentData.routingSlipNumber || '',
272
- bcolAccountNumber = this.staffPaymentData.bcolAccountNumber || '',
273
- datNumber = this.staffPaymentData.datNumber || '',
274
- folioNumber = this.staffPaymentData.folioNumber || '',
275
- isPriority = this.staffPaymentData.isPriority || false
254
+ option = StaffPaymentOptions.NONE,
255
+ routingSlipNumber = '',
256
+ bcolAccountNumber = '',
257
+ datNumber = '',
258
+ folioNumber = '',
259
+ isPriority = false
276
260
  }): StaffPaymentIF {
277
261
  // return only the appropriate fields for each option
278
262
  switch (option) {
@@ -287,6 +271,24 @@ export default class StaffPayment extends Vue {
287
271
  }
288
272
  }
289
273
 
274
+ /** Watches for change to FAS form validity. */
275
+ @Watch('fasFormValid')
276
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
277
+ private onFasFormValid () {
278
+ // ignore initial condition
279
+ if (!this.isMounted) return
280
+ this.emitValid()
281
+ }
282
+
283
+ /** Watches for change to BCOL form validity. */
284
+ @Watch('bcolFormValid')
285
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
286
+ private onBcolFormValid () {
287
+ // ignore initial condition
288
+ if (!this.isMounted) return
289
+ this.emitValid()
290
+ }
291
+
290
292
  /** Emits an event indicating whether or not this component is valid. */
291
293
  @Emit('valid')
292
294
  private emitValid (): boolean {
package/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
2
  "name": "@bcrs-shared-components/staff-payment",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
7
  "dependencies": {
8
8
  "@bcrs-shared-components/enums": "^2.0.0",
9
- "@bcrs-shared-components/folio-number-input": "^2.0.1",
10
- "@bcrs-shared-components/interfaces": "^2.0.0",
11
- "vue": "^2.7.14"
9
+ "@bcrs-shared-components/folio-number-input": "^2.0.2",
10
+ "@bcrs-shared-components/interfaces": "^2.0.0"
12
11
  },
13
12
  "devDependencies": {
14
- "vue-property-decorator": "^9.1.2"
13
+ "vue-facing-decorator": "^3.0.3"
15
14
  },
16
- "gitHead": "41e6bc79f9e564618ac9a53db02303f1e15558bf"
15
+ "gitHead": "5f3b43cd73175662b749d8831ed3b207b3fe44fa"
17
16
  }