Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3628)

Unified Diff: chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js

Issue 2654553004: MD Settings: Update Autofill Credit Card Dialog to accept Enter Key (Closed)
Patch Set: update tests Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js
diff --git a/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js b/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js
index 32a7dd3fe91c241ac72294a689a149ff1f1fcf10..9ee7c53ef69d1f86b069d0e418b9b0045d4db233 100644
--- a/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js
+++ b/chrome/browser/resources/settings/passwords_and_forms_page/credit_card_edit_dialog.js
@@ -71,6 +71,9 @@ Polymer({
this.title_ = this.i18n(
this.creditCard.guid ? 'editCreditCardTitle' : 'addCreditCardTitle');
+ // Needed to initialize the disabled state of the Save button.
+ this.onCreditCardNameOrNumberChanged_();
+
// Add a leading '0' if a month is 1 char.
if (this.creditCard.expirationMonth.length == 1)
this.creditCard.expirationMonth = '0' + this.creditCard.expirationMonth;
@@ -119,6 +122,9 @@ Polymer({
* @private
*/
onSaveButtonTap_: function() {
+ if (!this.saveEnabled_())
+ return;
+
// If the card is expired, reflect the error to the user.
// Otherwise, update the card, save and close the dialog.
if (!this.checkIfCardExpired_(this.expirationMonth_,
@@ -139,5 +145,16 @@ Polymer({
onYearChange_: function() {
this.expirationYear_ = this.yearList_[this.$.year.selectedIndex];
},
+
+ /** @private */
+ onCreditCardNameOrNumberChanged_: function() {
+ this.$.saveButton.disabled = !this.saveEnabled_();
+ },
+
+ /** @private */
+ saveEnabled_: function() {
+ return (this.creditCard.name && this.creditCard.name.trim()) ||
+ (this.creditCard.cardNumber && this.creditCard.cardNumber.trim());
+ },
});
})();

Powered by Google App Engine
This is Rietveld 408576698