Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Severin Beauvais committed Oct 23, 2024
1 parent 23c8362 commit 4849960
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 156 deletions.
4 changes: 2 additions & 2 deletions src/components/ContinuationIn/AuthorizationInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@

<!-- Unlimited Liability Corporation Information -->
<v-row
v-if="getExistingBusinessInfo.affidavitFileName"
v-if="getExistingBusinessInfo.affidavitFile"
no-gutters
>
<v-col
Expand Down Expand Up @@ -163,7 +163,7 @@
</v-row>

<v-divider
v-if="getExistingBusinessInfo.affidavitFileName"
v-if="getExistingBusinessInfo.affidavitFile"
class="my-6"
/>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<template>
<div id="unlimited-liability-corporation-information">
<div
v-if="getExistingBusinessInfo"
id="unlimited-liability-corporation-information"
>
<!-- Upload Files -->
<v-card
flat
class="py-8 px-6"
:class="{ 'invalid-section': getShowErrors && !affidavitFileValid }"
:class="{ 'invalid-section': getShowErrors && !componentValid }"
>
<!-- Upload File -->
<v-row no-gutters>
Expand All @@ -21,7 +24,7 @@
sm="9"
class="pt-4 pt-sm-0"
>
<p :class="{ 'error-text': getShowErrors && !affidavitFileValid }">
<p :class="{ 'error-text': getShowErrors && !componentValid }">
You are required to provide either a <strong>Director's Affidavit</strong> or a
<strong>Court Order</strong>. This will be reviewed by BC Registries.
</p>
Expand All @@ -36,7 +39,7 @@
outlined
color="primary"
class="btn-outlined-primary mt-4"
:disabled="affidavitFileValid"
:disabled="componentValid"
:loading="isDocumentLoading"
@click="onClickAddDocumentButton()"
>
Expand All @@ -62,13 +65,13 @@
/>

<div
v-if="affidavitFileValid"
v-if="getExistingBusinessInfo.affidavitFile"
class="dk-gray-background rounded d-flex justify-space-between align-center mt-5 px-2 py-2"
>
<v-icon>mdi-paperclip</v-icon>
<div class="document-details mr-auto pl-2">
{{ business.affidavitFile.name }}
<span class="pl-2">({{ friendlyFileSize(business.affidavitFile) }})</span>
{{ getExistingBusinessInfo.affidavitFile.name }}
<span class="pl-2">({{ friendlyFileSize(getExistingBusinessInfo.affidavitFile) }})</span>
</div>
<v-btn
class="remove-document-button"
Expand Down Expand Up @@ -121,21 +124,14 @@ export default class UnlimitedLiabilityCorporationInformation extends Mixins(Dat
@Action(useStore) setHaveChanges!: (x: boolean) => void
// Local properties
business = {} as ExistingBusinessInfoIF
customErrorMessage = ''
fileValidity = false
isDocumentLoading = false
/** Called when this component is mounted. */
mounted (): void {
// point business variable to Existing Business Info object from the store, if it exists
if (this.getExistingBusinessInfo) this.business = this.getExistingBusinessInfo
}
/** Whether the affidavit file is valid. */
get affidavitFileValid (): boolean {
/** Whether this component is valid. */
get componentValid (): boolean {
// assume valid if file object is present
return !!this.business.affidavitFile
return !!this.getExistingBusinessInfo.affidavitFile
}
/** When user has clicked the Add button, opens the file selection dialog. */
Expand Down Expand Up @@ -187,40 +183,44 @@ export default class UnlimitedLiabilityCorporationInformation extends Mixins(Dat
}
// add properties reactively to business object
// (it is the same object the parent is working with)
this.$set(this.business, 'affidavitFile', {
this.$set(this.getExistingBusinessInfo, 'affidavitFile', {
name: file.name,
lastModified: file.lastModified,
size: file.size
} as File)
this.$set(this.business, 'affidavitFileKey', psu.key)
this.$set(this.business, 'affidavitFileName', file.name)
this.$set(this.getExistingBusinessInfo, 'affidavitFileKey', psu.key)
this.$set(this.getExistingBusinessInfo, 'affidavitFileName', file.name)
// user has changed something
this.setHaveChanges(true)
}
}
/** Called when user clicks a Remove button. */
/**
* Called when user clicks Remove button.
* May also be called by parent component to remove the file info.
*/
onRemoveClicked (): void {
// delete file from Minio, not waiting for response and ignoring errors
this.deleteDocument(this.business.affidavitFileKey).catch(() => null)
this.deleteDocument(this.getExistingBusinessInfo.affidavitFileKey).catch(() => null)
// delete properties reactively
this.$delete(this.business, 'affidavitFile')
this.$delete(this.business, 'affidavitFileKey')
this.$delete(this.business, 'affidavitFileName')
this.$delete(this.getExistingBusinessInfo, 'affidavitFile')
this.$delete(this.getExistingBusinessInfo, 'affidavitFileKey')
this.$delete(this.getExistingBusinessInfo, 'affidavitFileName')
// clear any existing error message
this.customErrorMessage = ''
// user has changed something
this.setHaveChanges(true)
}
/** Emits form validity. */
@Watch('business', { deep: true })
@Watch('getShowErrors')
@Watch('affidavitFileValid')
/** Watches for changes to affidavit file object and emits form validity. */
@Watch('getExistingBusinessInfo.affidavitFile', { deep: true, immediate: true })
@Emit('valid')
private onComponentValid (): boolean {
// if we're here it's because the user has changed something
this.setHaveChanges(true)
// this component is valid if we have the affidavit file
return (this.getShowErrors && this.affidavitFileValid)
return this.componentValid
}
}
</script>
Expand Down
88 changes: 52 additions & 36 deletions src/views/ContinuationIn/ContinuationInAuthorization.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<template>
<!-- *** TODO: should I check for existence of some object, like "business"? -->
<div id="continuation-in-authorization">
<!-- Name -->
<section
Expand Down Expand Up @@ -107,36 +106,36 @@
/>
</section>

<!-- *** TODO: wrap this in a transition -->
<!-- Unlimited Liability Corporation Information -->
<section
v-if="isContinuationInAffidavitRequired"
id="ulc-information-section"
class="mt-10"
>
<header>
<h2>Unlimited Liability Corporation Information</h2>
<p>
Additional information is required for an Unlimited Liability Corporation from Alberta.
</p>
</header>

<ExpandableHelp
class="mt-4"
helpLabel="Help with Unlimited Liability Corporation Information"
<v-expand-transition>
<section
v-if="isUlcInfoRequired"
id="ulc-information-section"
class="mt-10"
>
<template #content>
<UnlimitedLiabilityCorporationHelp />
</template>
</ExpandableHelp>
<header>
<h2>Unlimited Liability Corporation Information</h2>
<p>
Additional information is required for an Unlimited Liability Corporation from Alberta.
</p>
</header>

<!-- *** TODO: should I pass "business" to this component? -->
<!-- *** what does Authorization Proof do? -->
<UnlimitedLiabilityCorporationInformation
class="mt-6"
@valid="ulcInformationValid = $event"
/>
</section>
<ExpandableHelp
class="mt-4"
helpLabel="Help with Unlimited Liability Corporation Information"
>
<template #content>
<UnlimitedLiabilityCorporationHelp />
</template>
</ExpandableHelp>

<UnlimitedLiabilityCorporationInformation
ref="ulcInformation"
class="mt-6"
@valid="ulcInformationValid = $event"
/>
</section>
</v-expand-transition>
</div>
</template>

Expand Down Expand Up @@ -173,6 +172,11 @@ import UnlimitedLiabilityCorporationHelp from '@/components/ContinuationIn/Unlim
}
})
export default class ContinuationInAuthorization extends Mixins(CommonMixin, NameRequestMixin) {
// Refs
$refs!: {
ulcInformation: UnlimitedLiabilityCorporationInformation
}
@Getter(useStore) getBusinessContact!: ContactPointIF
@Getter(useStore) getExistingBusinessInfo!: ExistingBusinessInfoIF
@Getter(useStore) getNameRequestNumber!: string
Expand Down Expand Up @@ -218,10 +222,10 @@ export default class ContinuationInAuthorization extends Mixins(CommonMixin, Nam
}
/**
* Whether a Continuation In Director's Affidavit or Court Order is required.
* Whether additional ULC information is required.
* Is true if the business is a Continued In ULC from Alberta.
*/
get isContinuationInAffidavitRequired (): boolean {
get isUlcInfoRequired (): boolean {
const previousJurisdiction = this.getExistingBusinessInfo?.previousJurisdiction
return (
this.isEntityUlcContinueIn &&
Expand All @@ -246,19 +250,31 @@ export default class ContinuationInAuthorization extends Mixins(CommonMixin, Nam
})
}
/** Watch all components on this page and set validity in store accordingly. */
/** When ULC Info is no longer required, remove existing file info. */
@Watch('isUlcInfoRequired')
private onUlcInfoRequiredChanged (val: boolean): void {
if (!val) {
this.$refs.ulcInformation.onRemoveClicked()
}
}
/**
* Watch all components on this page and set validity in the store accordingly.
* Note: Only need 1 immediate watcher for initial update.
*/
@Watch('getNameTranslationsValid', { immediate: true })
@Watch('existingBusinessInformationValid', { immediate: true })
@Watch('businessContactInfoValid', { immediate: true })
@Watch('authorizationProofValid', { immediate: true })
@Watch('ulcInformationValid', { immediate: true })
@Watch('existingBusinessInformationValid')
@Watch('businessContactInfoValid')
@Watch('authorizationProofValid')
@Watch('isUlcInfoRequired')
@Watch('ulcInformationValid')
private onComponentValidityChanged () {
this.setContinuationAuthorizationPageValid(
this.getNameTranslationsValid &&
this.existingBusinessInformationValid &&
this.businessContactInfoValid &&
this.authorizationProofValid &&
(!this.isContinuationInAffidavitRequired || this.ulcInformationValid)
(!this.isUlcInfoRequired || this.ulcInformationValid)
)
}
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/AuthorizationInformation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ describe('Authorization Information component', () => {
const wrapper = wrapperFactory(
AuthorizationInformation,
null,
null,
{ continuationIn: { existingBusinessInfo: { affidavitFile: {} } } },
null,
null,
// declare computed property to override computed property:
{
isExpro: () => true
}
{ isExpro: () => true }
)
await Vue.nextTick()

Expand Down
19 changes: 18 additions & 1 deletion tests/unit/ContinuationInAuthorization.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@ import BusinessContactInfo from '@/components/common/BusinessContactInfo.vue'
import AuthorizationProof from '@/components/ContinuationIn/AuthorizationProof.vue'
import NameRequestInfo from '@/components/common/NameRequestInfo.vue'
import NameTranslations from '@/components/common/NameTranslations.vue'
import { ExpandableHelp } from '@bcrs-shared-components/expandable-help'
import UnlimitedLiabilityCorporationInformation
from '@/components/ContinuationIn/UnlimitedLiabilityCorporationInformation.vue'

describe('Continuation In Authorization component', () => {
it('renders the component correctly', async () => {
const wrapper = wrapperFactory(ContinuationInAuthorization)
const wrapper = wrapperFactory(
ContinuationInAuthorization,
null,
null,
null,
null,
{ isUlcInfoRequired: () => true }
)
await Vue.nextTick()

// verify main component exists
Expand Down Expand Up @@ -41,6 +51,13 @@ describe('Continuation In Authorization component', () => {
expect(fourthSection.find('header p').text()).toContain('You must provide proof')
expect(fourthSection.findComponent(AuthorizationProof).exists()).toBe(true)

const fifthSection = wrapper.findAll('section').at(4)
expect(fifthSection.find('header').exists()).toBe(true)
expect(fifthSection.find('header h2').text()).toBe('Unlimited Liability Corporation Information')
expect(fifthSection.find('header p').text()).toContain('Additional information is')
expect(fifthSection.findComponent(ExpandableHelp).exists()).toBe(true)
expect(fifthSection.findComponent(UnlimitedLiabilityCorporationInformation).exists()).toBe(true)

wrapper.destroy()
})
})
54 changes: 0 additions & 54 deletions tests/unit/ContinuationInUploadAffidavit.spec.ts

This file was deleted.

Loading

0 comments on commit 4849960

Please sign in to comment.