Skip to content

Commit

Permalink
fixup! Move footer buttons from children into user-match-modal
Browse files Browse the repository at this point in the history
  • Loading branch information
canac committed Jan 29, 2025
1 parent 3948601 commit b071863
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ export default angular
templateUrl: template,
bindings: {
contacts: '<',
// Set to true from the parent to cause the form to submit and call onSubmit if it is valid
// Set to true from the parent to cause the form to submit and call onSubmit
submitted: '<',
// Called with a `success` boolean to indicate whether the selection was valid
// If the form was valid, it is also called with `contact` set to the selected contact
onSubmit: '&'
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@ describe('userMatchIdentity', function () {
})

describe('$onChanges', () => {
it('submits the form', () => {
it('submits the form when submitted changes to true', () => {
$ctrl.$onChanges({
submitted: { currentValue: true }
})

expect($ctrl.onSubmit).toHaveBeenCalled()
})

it('does nothing when the when submitted changes to false', () => {
$ctrl.$onChanges({
submitted: { currentValue: false }
})

expect($ctrl.onSubmit).not.toHaveBeenCalled()
})
})

describe('selectContact()', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class UserMatchModalController {
}

onSelectContact (success, contact) {
// If the user-match-identity selection was invalid, success will be false, but we still need to
// reset identitySubmitted so that we can set it to true later when the user tries to submit again
this.identitySubmitted = false
if (!success) {
return
Expand Down Expand Up @@ -155,6 +157,8 @@ class UserMatchModalController {

// Request that the user-match-identity component submit the form because the user clicked next
requestIdentitySubmit () {
// Changing this will trigger $onChanges in user-match-identity, which will ultimately call
// onSelectContact in this controller
this.identitySubmitted = true
}

Expand Down

0 comments on commit b071863

Please sign in to comment.