Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

25376 fix mailing address form issue #721

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "business-filings-ui",
"version": "7.4.22",
"version": "7.4.23",
"private": true,
"appName": "Filings UI",
"sbcName": "SBC Common Components",
Expand Down
70 changes: 42 additions & 28 deletions src/components/common/Directors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@ export default class Directors extends Mixins(CommonMixin, DateMixin, DirectorMi
this.addAction(director, Actions.CEASED)
}
this.allDirectors.unshift(director)
this.cancelNewDirector()
}

/**
Expand Down Expand Up @@ -1153,7 +1154,6 @@ export default class Directors extends Mixins(CommonMixin, DateMixin, DirectorMi
this.directorEditInProgress = true
this.activeIndex = index
this.messageIndex = index
this.cancelNewDirector()
}

/**
Expand Down Expand Up @@ -1210,29 +1210,37 @@ export default class Directors extends Mixins(CommonMixin, DateMixin, DirectorMi
const director = this.allDirectors[index]

let mainFormIsValid = this.$refs.editDirectorForm[0].validate()
let addressFormIsValid = this.$refs.baseAddressEdit[0].$refs.addressForm.validate() as boolean
let addressFormIsValid = true // Default to true

// Only validate address forms if we're actually editing addresses
if (this.editFormShowHide.showAddress) {
addressFormIsValid = this.$refs.baseAddressEdit[0].$refs.addressForm.validate() as boolean

if (this.$refs.mailAddressEdit && this.$refs.mailAddressEdit[0]) {
let mailAddressFormIsValid = this.$refs.mailAddressEdit[0].$refs.addressForm.validate() as boolean
if (!mailAddressFormIsValid) {
addressFormIsValid = mailAddressFormIsValid
if (this.$refs.mailAddressEdit && this.$refs.mailAddressEdit[0]) {
const mailAddressFormIsValid = this.$refs.mailAddressEdit[0].$refs.addressForm.validate() as boolean
if (!mailAddressFormIsValid) {
addressFormIsValid = mailAddressFormIsValid
}
}
}

if (mainFormIsValid && addressFormIsValid) {
// save data from BaseAddress component
// - only save address if a change was made, ie there is an in-progress address from the component
if (!Object.values(this.inProgressDelivAddress).every(el => el === undefined)) {
director.deliveryAddress = this.inProgressDelivAddress
}

if (this.isBaseCompany) {
if (!Object.values(this.inProgressMailAddress).every(el => el === undefined)) {
director.mailingAddress = this.inProgressMailAddress
// Only update addresses if we're actually editing addresses
if (this.editFormShowHide.showAddress) {
// save data from BaseAddress component
// only save address if a change was made (there is an in-progress address from the component)
if (this.inProgressDelivAddress && !Object.values(this.inProgressDelivAddress).every(el => el === undefined)) {
director.deliveryAddress = this.inProgressDelivAddress
}

if (this.inheritDeliveryAddress) {
director.mailingAddress = director.deliveryAddress
if (this.isBaseCompany) {
if (this.inProgressMailAddress && !Object.values(this.inProgressMailAddress).every(el => el === undefined)) {
director.mailingAddress = this.inProgressMailAddress
}

if (this.inheritDeliveryAddress) {
director.mailingAddress = director.deliveryAddress
}
}
}

Expand All @@ -1245,19 +1253,25 @@ export default class Directors extends Mixins(CommonMixin, DateMixin, DirectorMi
// eslint-disable-next-line no-console
console.log('saveEditDirector() could not find original director with id =', id)
} else {
// check whether either address has changed
if (!isEqual(origDirector.deliveryAddress, director.deliveryAddress) ||
!isEqual(origDirector.mailingAddress, director.mailingAddress)) {
this.addAction(director, Actions.ADDRESSCHANGED)
} else {
this.removeAction(director, Actions.ADDRESSCHANGED)
// Only check for address changes if we're editing addresses
if (this.editFormShowHide.showAddress) {
// check whether either address has changed
if (!isEqual(origDirector.deliveryAddress, director.deliveryAddress) ||
!isEqual(origDirector.mailingAddress, director.mailingAddress)) {
this.addAction(director, Actions.ADDRESSCHANGED)
} else {
this.removeAction(director, Actions.ADDRESSCHANGED)
}
}

// check whether name has changed
if (!isEqual(origDirector.officer, director.officer)) {
this.addAction(director, Actions.NAMECHANGED)
} else {
this.removeAction(director, Actions.NAMECHANGED)
// Only check for name changes if we're editing names
if (this.editFormShowHide.showName) {
// check whether name has changed
if (!isEqual(origDirector.officer, director.officer)) {
this.addAction(director, Actions.NAMECHANGED)
} else {
this.removeAction(director, Actions.NAMECHANGED)
}
}
}
}
Expand Down
Loading