@bcrs-shared-components/staff-payment 1.0.35 → 1.1.0

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 (2) hide show
  1. package/StaffPayment.vue +70 -38
  2. package/package.json +3 -3
package/StaffPayment.vue CHANGED
@@ -4,8 +4,9 @@
4
4
  <v-col cols="3" class="pl-5" v-if="displaySideLabel">
5
5
  <label class="side-label" :class="{'error-text': invalidSection}">Payment</label>
6
6
  </v-col>
7
+
7
8
  <v-col :cols="displaySideLabel ? 9 : 12" class="pl-2">
8
- <v-radio-group class="payment-group" v-model="paymentOption">
9
+ <v-radio-group class="payment-group" v-model="paymentOption" hide-details>
9
10
  <!-- Cash or Cheque radio button and form -->
10
11
  <v-radio id="fas-radio" label="Cash or Cheque" :value="StaffPaymentOptions.FAS" />
11
12
  <v-form class="ml-8" ref="fasForm" v-model="fasFormValid">
@@ -14,7 +15,7 @@
14
15
  id="routing-slip-number-textfield"
15
16
  label="Routing Slip Number"
16
17
  :value="staffPaymentData.routingSlipNumber"
17
- :rules="routingSlipNumberRules"
18
+ :rules="validate ? routingSlipNumberRules : []"
18
19
  :disabled="paymentOption === StaffPaymentOptions.BCOL || paymentOption === StaffPaymentOptions.NO_FEE"
19
20
  @focus="paymentOption = StaffPaymentOptions.FAS"
20
21
  @input="emitStaffPaymentData({ option: StaffPaymentOptions.FAS, routingSlipNumber: $event })"
@@ -29,7 +30,7 @@
29
30
  id="bcol-account-number-textfield"
30
31
  label="BC Online Account Number"
31
32
  :value="staffPaymentData.bcolAccountNumber"
32
- :rules="bcolAccountNumberRules"
33
+ :rules="validate ? bcolAccountNumberRules : []"
33
34
  :disabled="paymentOption === StaffPaymentOptions.FAS || paymentOption === StaffPaymentOptions.NO_FEE"
34
35
  @focus="paymentOption = StaffPaymentOptions.BCOL"
35
36
  @input="emitStaffPaymentData({ option: StaffPaymentOptions.BCOL, bcolAccountNumber: $event })"
@@ -39,7 +40,7 @@
39
40
  id="dat-number-textfield"
40
41
  label="DAT Number"
41
42
  :value="staffPaymentData.datNumber"
42
- :rules="datNumberRules"
43
+ :rules="validate ? datNumberRules : []"
43
44
  :disabled="paymentOption === StaffPaymentOptions.FAS || paymentOption === StaffPaymentOptions.NO_FEE"
44
45
  @focus="paymentOption = StaffPaymentOptions.BCOL"
45
46
  @input="emitStaffPaymentData({ option: StaffPaymentOptions.BCOL, datNumber: $event })"
@@ -49,7 +50,8 @@
49
50
  :folioNumber="staffPaymentData.folioNumber"
50
51
  :disabled="paymentOption === StaffPaymentOptions.FAS || paymentOption === StaffPaymentOptions.NO_FEE"
51
52
  @focus="paymentOption = StaffPaymentOptions.BCOL"
52
- @emitFolioNumber="emitStaffPaymentData({ option: StaffPaymentOptions.BCOL, folioNumber: $event })"
53
+ @emitFolioNumber="paymentOption === StaffPaymentOptions.BCOL &&
54
+ emitStaffPaymentData({ option: StaffPaymentOptions.BCOL, folioNumber: $event })"
53
55
  validate="true"
54
56
  />
55
57
  </v-form>
@@ -65,6 +67,7 @@
65
67
  class="mt-2"
66
68
  id="priority-checkbox"
67
69
  label="Priority (add $100.00)"
70
+ hide-details
68
71
  :input-value="staffPaymentData.isPriority"
69
72
  :disabled="paymentOption === StaffPaymentOptions.NO_FEE"
70
73
  @change="emitStaffPaymentData({ isPriority: !!$event })"
@@ -110,7 +113,7 @@ export default class StaffPayment extends Vue {
110
113
  @Prop({ default: false })
111
114
  private validate: boolean
112
115
 
113
- /** Whether to show invalid section styling. */
116
+ /** Whether to show invalid section styling (label only). */
114
117
  @Prop({ default: false })
115
118
  private invalidSection: boolean
116
119
 
@@ -160,17 +163,9 @@ export default class StaffPayment extends Vue {
160
163
  ]
161
164
 
162
165
  /** Called when this component is mounted. */
163
- private mounted (): void {
164
- this.$nextTick(() => { this.isMounted = true })
165
- }
166
-
167
- /** Prompt the field validations. */
168
- @Watch('validate')
169
- private validateFields (val: boolean): void {
170
- if (val) {
171
- if (this.paymentOption === StaffPaymentOptions.FAS) this.$refs.fasForm.validate()
172
- if (this.paymentOption === StaffPaymentOptions.BCOL) this.$refs.bcolForm.validate()
173
- }
166
+ private async mounted (): Promise<void> {
167
+ await this.$nextTick()
168
+ this.isMounted = true
174
169
  }
175
170
 
176
171
  /** Called when payment option (radio group item) has changed. */
@@ -178,27 +173,36 @@ export default class StaffPayment extends Vue {
178
173
  private onPaymentOptionChanged (val: number): void {
179
174
  switch (val) {
180
175
  case StaffPaymentOptions.FAS:
181
- // reset other form and update data
176
+ // reset other form
182
177
  this.$refs.bcolForm.resetValidation()
183
178
  this.$refs.folioNumberInputRef.resetFolioNumberValidation()
179
+ // enable validation for this form
180
+ this.$refs.fasForm.validate()
181
+ // update data
184
182
  this.emitStaffPaymentData({ option: StaffPaymentOptions.FAS })
185
183
  break
184
+
186
185
  case StaffPaymentOptions.BCOL:
187
- // reset other form and update data
186
+ // reset other form
188
187
  this.$refs.fasForm.resetValidation()
188
+ // enable validation for this form
189
+ this.$refs.bcolForm.validate()
190
+ // update data
189
191
  this.emitStaffPaymentData({ option: StaffPaymentOptions.BCOL })
190
192
  break
193
+
191
194
  case StaffPaymentOptions.NO_FEE:
192
- // reset forms and update data
195
+ // reset other forms
193
196
  this.$refs.fasForm.resetValidation()
194
197
  this.$refs.bcolForm.resetValidation()
195
198
  this.$refs.folioNumberInputRef.resetFolioNumberValidation()
199
+ // update data
196
200
  this.emitStaffPaymentData({ option: StaffPaymentOptions.NO_FEE, isPriority: false })
197
201
  break
198
202
  }
199
203
  }
200
204
 
201
- /** Watched for change to FAS form validity. */
205
+ /** Watches for change to FAS form validity. */
202
206
  @Watch('fasFormValid')
203
207
  private onFasFormValid (val: boolean) {
204
208
  // ignore initial condition
@@ -216,34 +220,49 @@ export default class StaffPayment extends Vue {
216
220
 
217
221
  /** Watches for changes to Staff Payment Data prop. */
218
222
  @Watch('staffPaymentData', { deep: true, immediate: true })
219
- private onStaffPaymentDataChanged (val: StaffPaymentIF): void {
223
+ private async onStaffPaymentDataChanged (val: StaffPaymentIF): Promise<void> {
220
224
  this.paymentOption = val.option
221
- this.$nextTick(() => this.emitValid())
225
+ await this.$nextTick()
226
+ this.emitValid()
222
227
  }
223
228
 
224
229
  /** Emits an event to update the Staff Payment Data prop. */
225
230
  @Emit('update:staffPaymentData')
226
231
  private emitStaffPaymentData ({
227
232
  option = this.staffPaymentData.option,
228
- routingSlipNumber = this.staffPaymentData.routingSlipNumber,
229
- bcolAccountNumber = this.staffPaymentData.bcolAccountNumber,
230
- datNumber = this.staffPaymentData.datNumber,
231
- folioNumber = this.staffPaymentData.folioNumber,
232
- isPriority = this.staffPaymentData.isPriority
233
+ routingSlipNumber = this.staffPaymentData.routingSlipNumber || '',
234
+ bcolAccountNumber = this.staffPaymentData.bcolAccountNumber || '',
235
+ datNumber = this.staffPaymentData.datNumber || '',
236
+ folioNumber = this.staffPaymentData.folioNumber || '',
237
+ isPriority = this.staffPaymentData.isPriority || false
233
238
  }): StaffPaymentIF {
234
- return { option, routingSlipNumber, bcolAccountNumber, datNumber, folioNumber, isPriority }
239
+ // return only the appropriate fields for each option
240
+ switch (option) {
241
+ case StaffPaymentOptions.FAS:
242
+ return { option, routingSlipNumber, isPriority } as StaffPaymentIF
243
+
244
+ case StaffPaymentOptions.BCOL:
245
+ return { option, bcolAccountNumber, datNumber, folioNumber, isPriority } as StaffPaymentIF
246
+
247
+ case StaffPaymentOptions.NO_FEE:
248
+ return { option } as StaffPaymentIF
249
+ }
235
250
  }
236
251
 
237
252
  /** Emits an event indicating whether or not this component is valid. */
238
253
  @Emit('valid')
239
254
  private emitValid (): boolean {
240
- return (this.fasFormValid || (this.bcolFormValid && this.$refs.folioNumberInputRef.validateFolioNumber()) ||
241
- (this.staffPaymentData.option === StaffPaymentOptions.NO_FEE))
255
+ return (this.fasFormValid ||
256
+ (this.bcolFormValid && this.$refs.folioNumberInputRef.validateFolioNumber()) ||
257
+ (this.staffPaymentData.option === StaffPaymentOptions.NO_FEE)
258
+ )
242
259
  }
243
260
  }
244
261
  </script>
245
262
 
246
263
  <style lang="scss" scoped>
264
+ @import '@/assets/styles/theme.scss';
265
+
247
266
  #staff-payment-container {
248
267
  margin-top: 1rem;
249
268
  padding-bottom: 0.5rem;
@@ -252,16 +271,29 @@ export default class StaffPayment extends Vue {
252
271
  font-size: 1rem;
253
272
  }
254
273
 
255
- .payment-container {
256
- > label:first-child {
257
- font-weight: 700;
258
- margin-bottom: 2rem;
259
- }
260
- }
261
-
262
274
  .payment-group {
263
275
  margin-top: 0;
264
276
  padding-top: 0;
265
277
  width: 100%;
266
278
  }
279
+
280
+ // radio buttons
281
+ ::v-deep .v-input--selection-controls__input >.v-icon {
282
+ color: $gray7 !important;
283
+ }
284
+
285
+ // radio labels and checkbox labels
286
+ ::v-deep .v-input--selection-controls__input + .v-label {
287
+ color: $gray7 !important;
288
+ }
289
+
290
+ // text field labels
291
+ ::v-deep .v-text-field__slot .theme--light.v-label {
292
+ color: $gray7 !important;
293
+ }
294
+
295
+ // text input
296
+ ::v-deep .v-text-field__slot input {
297
+ color: $gray9 !important;
298
+ }
267
299
  </style>
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@bcrs-shared-components/staff-payment",
3
- "version": "1.0.35",
3
+ "version": "1.1.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
7
  "dependencies": {
8
8
  "@bcrs-shared-components/enums": "^1.0.14",
9
- "@bcrs-shared-components/folio-number-input": "^1.0.9",
9
+ "@bcrs-shared-components/folio-number-input": "^1.0.10",
10
10
  "@bcrs-shared-components/interfaces": "^1.0.28",
11
11
  "vue-property-decorator": "^8.4.0"
12
12
  },
13
- "gitHead": "985898aed4bf45fbb548f06fed55f7041e18575a"
13
+ "gitHead": "51815e18847d2dc71fd3673c847e96f49e8460f4"
14
14
  }