Closed Bug 1470196 Opened 6 years ago Closed 6 years ago

Show the month name after the month number in the cc-exp-month dropdown

Categories

(Firefox :: WebPayments UI, enhancement, P1)

enhancement

Tracking

()

VERIFIED FIXED
Firefox 65
Tracking Status
firefox65 --- verified

People

(Reporter: epang, Assigned: dpino)

Details

(Whiteboard: [webpayments-reserve])

Attachments

(2 files, 4 obsolete files)

Change format of month is expiry dropdown
Status: NEW → ASSIGNED
Priority: P3 → P1
Attached image Expiry.png
Format month of expiry as number then text.
ex. '01 January' 

Also can be found here:
https://mozilla.invisionapp.com/d/main#/console/13422080/304878922/preview
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Assignee: epang → nobody
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Whiteboard: [webpayments] [ux] → [webpayments-reserve]
Priority: P1 → P3
Status: REOPENED → NEW
Summary: Switch order of month name and number → Show the month name after the month number in the cc-exp-month dropdown
We can use `new Intl.DateTimeFormat(locale, { month: "long" })`
Attachment #9026622 - Flags: review?(MattN+bmo)
Attachment #9026622 - Attachment is obsolete: true
Attachment #9026622 - Flags: review?(MattN+bmo)
Attachment #9026629 - Flags: review?(MattN+bmo)
Assignee: nobody → dpino
Status: NEW → ASSIGNED
Priority: P3 → P1
Comment on attachment 9026629 [details] [diff] [review]
Bug-1470196-Show-the-month-name-after-the-month-numb.patch

Review of attachment 9026629 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks Diego. Can you also make sure that the Payment Request and autofill tests pass with this change:

./mach test browser/components/payments/
./mach mochitest browser/extensions/formautofill/

::: browser/components/payments/res/containers/basic-card-form.js
@@ +264,5 @@
>      // billingAddressSelect is updated after loadRecord.
>      this.formHandler.updatePopulatedState(billingAddressSelect.popupBox);
>  
> +    // Fill up cc-expire-month options. Format: "month number - month name".
> +    let dateFormat = new Intl.DateTimeFormat(navigator.language, {month: 'long'}).format;

Sorry, I should have been more explicit that you should do this in https://searchfox.org/mozilla-central/rev/8f89901f2d69d9783f946a7458a6d7ee70635a94/browser/extensions/formautofill/content/autofillEditForms.js#342,348,372 so it also affects the preferences dialog. You can add a helper like `generateYears` which gets called from the constructor (not loadRecord since you're only changing the label).

@@ +269,5 @@
> +    let ccExpMonthOptions = document.querySelectorAll('#cc-exp-month > option');
> +    for (let option of ccExpMonthOptions) {
> +      if (option.value.length > 0) {
> +        let value = Number.parseInt(option.value);
> +        let monthName = dateFormat(new Date(Date.UTC(1970, value-1, 1)));

Nit: spaces around operators like '-'
Attachment #9026629 - Flags: review?(MattN+bmo) → feedback+
I reworked the code to make it more similar to `generateYears` (now `generateMonths` creates the options and appends them to the list), so they can be placed at the same level.
Attachment #9026629 - Attachment is obsolete: true
Attachment #9026910 - Flags: review?(MattN+bmo)
Comment on attachment 9026910 [details] [diff] [review]
Bug-1470196-Show-the-month-name-after-the-month-numb.patch

Review of attachment 9026910 [details] [diff] [review]:
-----------------------------------------------------------------

This looks good with some small changes assuming the tests all pass.

::: browser/extensions/formautofill/content/autofillEditForms.js
@@ +380,5 @@
> +    // Empty month option
> +    this._elements.month.appendChild(new Option());
> +
> +    // Populate cc-expire-month list. Format: "month number - month name"
> +    let dateFormat = new Intl.DateTimeFormat(navigator.language, {month: 'long'}).format;

Nit: use double-quotes for Mozilla JS style

@@ +387,5 @@
> +        let monthName = dateFormat(new Date(Date.UTC(1970, i, 1)));
> +        let option = new Option();
> +        option.value = monthNumber;
> +        monthNumber = monthNumber < 10 ? "0" + monthNumber : monthNumber.toString();
> +        option.textContent = `${monthNumber} - ${monthName}`;

It's a bit unusual to change the type of monthNumber from a Number to a String. Can you avoid that please? You can also use padStart:

let monthNumber = (i + 1).toString();
option.value = monthNumber;
option.textContent = `${monthNumber.padStart(2, "0")} - ${monthName}`;

@@ +388,5 @@
> +        let option = new Option();
> +        option.value = monthNumber;
> +        monthNumber = monthNumber < 10 ? "0" + monthNumber : monthNumber.toString();
> +        option.textContent = `${monthNumber} - ${monthName}`;
> +        this._elements.month.appendChild(option);

We also should be localizing the hyphen and doing substitution so a locale can re-order the string but that is quite annoying until we have bug 1446164 so I've just noted that issue there. Can you add a comment:
// XXX: Bug 1446164 - Localize this string.
Attachment #9026910 - Flags: review?(MattN+bmo) → review+
Addressed comments from latest review.
Attachment #9026910 - Attachment is obsolete: true
Attachment #9026997 - Flags: review?(MattN+bmo)
Fixed error in previous patch (months were only generated until November).
Attachment #9026997 - Attachment is obsolete: true
Attachment #9026997 - Flags: review?(MattN+bmo)
Attachment #9027107 - Flags: review?(MattN+bmo)
Comment on attachment 9027107 [details] [diff] [review]
Bug-1470196-Show-the-month-name-after-the-month-numb.patch

Review of attachment 9027107 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks
Attachment #9027107 - Flags: review?(MattN+bmo) → review+
Keywords: checkin-needed
Pushed by dvarga@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/bfdd8cc5f88a
Show the month name after the month number in the cc-exp-month dropdown r=MattN
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/bfdd8cc5f88a
Status: ASSIGNED → RESOLVED
Closed: 6 years ago6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 65
Flags: qe-verify+
QA Contact: hani.yacoub
Verified as fixed on Firefox Nightly 65.0a1 (2018-12-03) on Windows 10 x 64, Windows 7 x32, Mac OS X 10.13 and on Ubuntu 16.04 x64.
Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: