Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #4875 from darkdh/4855
Browse files Browse the repository at this point in the history
Disable save button when no detail present
  • Loading branch information
bbondy authored Oct 18, 2016
2 parents 4a7f1ac + aaf88ca commit e92ac92
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
13 changes: 12 additions & 1 deletion js/components/autofillAddressPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ class AutofillAddressPanel extends ImmutableComponent {
onClick (e) {
e.stopPropagation()
}
get disableSaveButton () {
let currentDetail = this.props.currentDetail
if (!currentDetail.size) return true
if (!currentDetail.get('name') && !currentDetail.get('organization') &&
!currentDetail.get('streetAddress') && !currentDetail.get('city') &&
!currentDetail.get('state') && !currentDetail.get('country') &&
!currentDetail.get('phone') && !currentDetail.get('email')) return true
return false
}

render () {
return <Dialog onHide={this.props.onHide} className='manageAutofillDataPanel autofillAddressPanel' isClickDismiss>
<div className='genericForm manageAutofillData' onClick={this.onClick}>
Expand Down Expand Up @@ -141,7 +151,8 @@ class AutofillAddressPanel extends ImmutableComponent {
</div>
<div className='formRow manageAutofillDataButtons'>
<Button l10nId='cancel' className='secondaryAltButton' onClick={this.props.onHide} />
<Button l10nId='save' className='primaryButton saveAddressButton' onClick={this.onSave} />
<Button l10nId='save' className='primaryButton saveAddressButton' onClick={this.onSave}
disabled={this.disableSaveButton} />
</div>
</div>
</div>
Expand Down
9 changes: 8 additions & 1 deletion js/components/autofillCreditCardPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ class AutofillCreditCardPanel extends ImmutableComponent {
onClick (e) {
e.stopPropagation()
}
get disableSaveButton () {
let currentDetail = this.props.currentDetail
if (!currentDetail.size) return true
if (!currentDetail.get('name') && !currentDetail.get('card')) return true
return false
}
render () {
var ExpMonth = []
for (let i = 1; i <= 12; ++i) {
Expand Down Expand Up @@ -98,7 +104,8 @@ class AutofillCreditCardPanel extends ImmutableComponent {
</div>
<div className='formRow manageAutofillDataButtons'>
<Button l10nId='cancel' className='secondaryAltButton' onClick={this.props.onHide} />
<Button l10nId='save' className='primaryButton saveCreditCardButton' onClick={this.onSave} />
<Button l10nId='save' className='primaryButton saveCreditCardButton' onClick={this.onSave}
disabled={this.disableSaveButton} />
</div>
</div>
</div>
Expand Down

0 comments on commit e92ac92

Please sign in to comment.