Skip to content

Commit

Permalink
add the Ref Number component
Browse files Browse the repository at this point in the history
Signed-off-by: Qin <[email protected]>
  • Loading branch information
ArwenQin committed Dec 6, 2024
1 parent 625165f commit 95e7b3a
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/components/NoticeOfWithdraw/PlanOfArrangement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class PlanOfArrangement extends Vue {
@Prop({ default: false }) readonly hasDraftPlanOfArrangement!: boolean
/** Draft come into effect. */
@Prop({ default: false }) readonly hasComeIntoEffect!: boolean
@Prop({ default: false }) readonly hasDraftComeIntoEffect!: boolean
/** Prompt Error. */
@Prop({ default: false }) readonly invalidSection!: boolean
Expand All @@ -74,7 +74,7 @@ export default class PlanOfArrangement extends Vue {
mounted (): void {
// Set default draft values if they exist
if (this.hasDraftPlanOfArrangement) this.planOfArrangement = this.hasDraftPlanOfArrangement
if (this.hasComeIntoEffect) this.comeIntoEffect = this.hasComeIntoEffect
if (this.hasDraftComeIntoEffect) this.comeIntoEffect = this.hasDraftComeIntoEffect
}
@Watch('planOfArrangement')
Expand Down Expand Up @@ -110,7 +110,6 @@ export default class PlanOfArrangement extends Vue {
<style lang="scss" scoped>
@import '@/assets/styles/theme.scss';
#court-order-label,
#poa-label {
font-size: $px-16;
font-weight: bold;
Expand Down
127 changes: 127 additions & 0 deletions src/components/NoticeOfWithdraw/ReferenceNumber.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<template>
<div id="reference-number-section">
<v-row no-gutters>
<v-col
cols="12"
sm="3"
class="pr-4"
>
<label
id="reference-number-label"
:class="{'error-text': invalidSection}"
>Folio or Reference Number</label>
</v-col>
<v-col
cols="12"
:sm="9"
>
<v-form
id="reference-num-form"
ref="refNumRef"
v-model="valid"
>
<v-text-field
id="reference-number-input"
v-model="referenceNumber"
label="Folio or Reference Number (Optional)"
:rules="referenceNumRules"
filled
/>
</v-form>
</v-col>
</v-row>
</div>
</template>

<script lang="ts">
import Vue from 'vue'
import { Component, Emit, Prop, Watch } from 'vue-property-decorator'
import { FormIF } from '@bcrs-shared-components/interfaces'
@Component({})
export default class ReferenceNumber extends Vue {
// Refs
$refs!: Vue['$refs'] & {
refNumRef: FormIF
}
/** Prompt the validations. Used for global validations. */
@Prop({ default: false }) readonly autoValidation!: boolean
/** Draft court order number. */
@Prop({ default: '' }) readonly draftReferenceNumber!: string
// Local properties
private referenceNumber = ''
private referenceNumRules = []
private valid = false
/** Called when component is mounted. */
mounted (): void {
// Set default draft values if they exist
if (this.draftReferenceNumber) this.referenceNumber = this.draftReferenceNumber
}
/** Clear rules and reset validations. */
private clearValidations (): void {
this.referenceNumRules = []
this.$refs.refNumRef.resetValidation()
}
/** Triggers the form validation. */
public validate (): boolean {
return this.$refs.refNumRef.validate()
}
@Watch('autoValidation')
@Watch('referenceNumber')
validateReferenceNum (): void {
if (this.autoValidation) {
// Apply TextField rules
this.referenceNumRules = [
(v: string) => (!v || !/^\s/g.test(v)) || 'Invalid spaces', // leading spaces
(v: string) => (!v || !/\s$/g.test(v)) || 'Invalid spaces', // trailing spaces
(v: string) => (!v || !(v.length > 20)) || 'Folio or Reference number is invalid' // too long
]
this.$refs.refNumRef.validate()
} else this.clearValidations()
}
/** Emit reference number. */
@Watch('referenceNumber')
@Emit('emitReferenceNumber')
private emitReferenceNumber (): string { return this.referenceNumber }
@Watch('valid')
@Emit('emitValid')
private emitValid (): boolean {
return this.valid
}
}
</script>

<style lang="scss" scoped>
@import '@/assets/styles/theme.scss';
#reference-number-label {
font-size: $px-16;
font-weight: bold;
color: $gray9;
}
:deep() {
.v-card__actions {
justify-content: flex-end;
}
.v-input .v-label {
font-weight: normal;
color: $gray7;
}
.theme--light.v-input input {
font-weight: normal;
color: $gray7;
}
}
</style>
32 changes: 31 additions & 1 deletion src/views/NoticeOfWithdrawal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,38 @@
:autoValidation="showErrors"
:hasDraftPlanOfArrangement="hasPlanOfArrangement"
:hasDraftComeIntoEffect="hasComeIntoEffect"
:hasComeIntoEffect="hasComeIntoEffect"
@emitPoa="hasPlanOfArrangement=$event"
@emitEffect="hasComeIntoEffect=$event"
/>
</v-card>
</div>
</section>

<!-- Folio or Reference Number -->
<section>
<header>
<h2>Folio or Reference Number</h2>
<p class="grey-text">
You can add a folio or reference number for your own tracking purposes.
The number will appear on your withdrawal documents and receipt.
</p>
</header>
<div
id="reference-number-section"
:class="{ 'invalid-section': showErrors }"
>
<v-card
flat
class="py-8 px-5"
>
<ReferenceNumber
:autoValidation="showErrors"
:draftReferenceNumber="referenceNumber"
@emitReferenceNumber="referenceNumber=$event"
/>
</v-card>
</div>
</section>
</article>
</v-col>

Expand Down Expand Up @@ -271,6 +296,7 @@ import { EffectOfOrderTypes, FilingStatus, SaveErrorReasons } from '@/enums'
import { FilingCodes, FilingTypes, StaffPaymentOptions } from '@bcrs-shared-components/enums'
import { ConfirmDialogType, StaffPaymentIF } from '@/interfaces'
import PlanOfArrangement from '@/components/NoticeOfWithdraw/PlanOfArrangement.vue'
import ReferenceNumber from '@/components/NoticeOfWithdraw/ReferenceNumber.vue'
import { DocumentDelivery } from '@bcrs-shared-components/document-delivery'
import { useBusinessStore, useConfigurationStore, useRootStore } from '@/stores'
Expand All @@ -284,6 +310,7 @@ import { useBusinessStore, useConfigurationStore, useRootStore } from '@/stores'
PaymentErrorDialog,
ResumeErrorDialog,
RecordToBeWithdrawn,
ReferenceNumber,
SaveErrorDialog,
SbcFeeSummary,
StaffPaymentDialog
Expand Down Expand Up @@ -316,6 +343,9 @@ export default class NoticeOfWithdrawal extends Mixins(CommonMixin, DateMixin, F
hasPlanOfArrangement = false
hasComeIntoEffect = false
// variable for Reference Number component
referenceNumber = ''
// variables for Document Delivery component
documentDeliveryValid = true
documentOptionalEmail = ''
Expand Down

0 comments on commit 95e7b3a

Please sign in to comment.