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

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

Issue 2453773003: Alerting the user when the provided date for credit card is passed, not save the card, and not clos… (Closed)
Patch Set: Make the UI look like mocks again. Created 4 years, 1 month 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 b3ff3fb37ce31ce64f546ee2322215e7d9c107d5..32a7dd3fe91c241ac72294a689a149ff1f1fcf10 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
@@ -55,6 +55,17 @@ Polymer({
I18nBehavior,
],
+ /**
+ * @return {boolean} True iff the provided expiration date is passed.
+ * @private
+ */
+ checkIfCardExpired_: function(expirationMonth_, expirationYear_) {
+ var now = new Date();
+ return (expirationYear_ < now.getFullYear() ||
+ (expirationYear_ == now.getFullYear() &&
+ expirationMonth_ <= now.getMonth()));
+ },
+
/** @override */
attached: function() {
this.title_ = this.i18n(
@@ -108,10 +119,15 @@ Polymer({
* @private
*/
onSaveButtonTap_: function() {
- this.creditCard.expirationYear = this.expirationYear_;
- this.creditCard.expirationMonth = this.expirationMonth_;
- this.fire('save-credit-card', this.creditCard);
- this.close();
+ // 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_,
+ this.expirationYear_)) {
+ this.creditCard.expirationYear = this.expirationYear_;
+ this.creditCard.expirationMonth = this.expirationMonth_;
+ this.fire('save-credit-card', this.creditCard);
+ this.close();
+ }
},
/** @private */

Powered by Google App Engine
This is Rietveld 408576698