Closed Bug 1512941 Opened 7 years ago Closed 7 years ago

[de-xbl] Migrate timepicker-grids to custom element.

Categories

(Calendar :: Lightning Only, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: arshad, Assigned: arshad)

References

Details

Attachments

(1 file, 17 obsolete files)

63.48 KB, patch
mkmelin
: review+
arshad
: feedback+
Details | Diff | Splinter Review
No description provided.
Assignee: nobody → arshdkhn1
Status: NEW → ASSIGNED
Depends on: 1512943, 1512942
No longer depends on: 1512942
Depends on: 1512942
Attached patch timepicker-grids_WIP.patch (obsolete) β€” β€” Splinter Review
still trying to figure out the errors that I get..
Attached patch timepicker-grids.patch (obsolete) β€” β€” Splinter Review
Attachment #9031055 - Attachment is obsolete: true
Attachment #9031874 - Flags: feedback?(mkmelin+mozilla)
Attached patch timepicker-grids-combined.patch (obsolete) β€” β€” Splinter Review
This patch has code for timepicker-minute, timepicker-hour and timepicker-grids, so just test this out for checking those bindings as well.
Attachment #9031874 - Attachment is obsolete: true
Attachment #9031874 - Flags: feedback?(mkmelin+mozilla)
Attachment #9031885 - Flags: feedback?(mkmelin+mozilla)
Attached patch timepicker-grids-combined.patch (obsolete) β€” β€” Splinter Review
patch for timepicker-minute, timepicker-hour and timepicker-grids.
Attachment #9031885 - Attachment is obsolete: true
Attachment #9031885 - Flags: feedback?(mkmelin+mozilla)
Attachment #9031888 - Flags: feedback?(mkmelin+mozilla)
Comment on attachment 9031888 [details] [diff] [review] timepicker-grids-combined.patch Review of attachment 9031888 [details] [diff] [review]: ----------------------------------------------------------------- > applying timepicker-grids-combined.patch > patch failed, unable to continue (try -v) > patch failed, rejects left in working directory > errors during apply, please fix and qrefresh timepicker-grids-combined.patch ::: calendar/resources/content/datetimepickers/datetimepickers.js @@ +79,5 @@ > + this._updateAttributes(); > + } > + > + attributeChangedCallback() { > + this._updateAttributes(); add if (!this.isConnectedAndReady) { return; } per https://searchfox.org/comm-central/rev/85923675941e2dad376a1ecfdb26e3cf824ea7fc/mozilla/toolkit/content/customElements.js#95 @@ +85,5 @@ > + > + _updateAttributes() { > + if (!this.label) { > + return; > + } shouldn't need this @@ +101,5 @@ > + } > + } > + } > + > + customElements.define("timepicker-minute", MozTimepickerMinute); same thing as above for these ::: mail/base/content/customElements.js @@ +10,5 @@ > "chrome://messenger/content/mailWidgets.js", > "chrome://messenger/content/generalBindings.js", > "chrome://messenger/content/statuspanel.js", > "chrome://messenger/content/foldersummary.js", > + // "chrome://calendar/content/datetimepickers/datetimepickers.js", remove
Comment on attachment 9031888 [details] [diff] [review] timepicker-grids-combined.patch Review of attachment 9031888 [details] [diff] [review]: ----------------------------------------------------------------- for MozTimepickerGrids - why is the hasChildrenAppended needed? ::: calendar/resources/content/datetimepickers/datetimepickers.js @@ +95,5 @@ > + } > + > + if (this.hasAttribute("selected")) { > + this.label.setAttribute("selected", this.getAttribute("selected")); > + } else { https://searchfox.org/comm-central/rev/85923675941e2dad376a1ecfdb26e3cf824ea7fc/mozilla/toolkit/content/customElements.js#95 ::: calendar/resources/content/datetimepickers/datetimepickers.xml @@ +686,5 @@ > event.preventDefault(); > ]]></handler> > </handlers> > </binding> > Don't understand what this was meant to work aound, but we should find a proper fix.
Attachment #9031888 - Flags: feedback?(mkmelin+mozilla)
Attached patch timepicker-grids-combined.patch (obsolete) β€” β€” Splinter Review
Attachment #9031888 - Attachment is obsolete: true
Attachment #9032788 - Flags: review?(mkmelin+mozilla)
Comment on attachment 9032788 [details] [diff] [review] timepicker-grids-combined.patch Review of attachment 9032788 [details] [diff] [review]: ----------------------------------------------------------------- Still something wrong with the patch. Can't apply it hg qpush -v applying timepicker-grids-combined.patch patching file calendar/base/content/dialogs/calendar-event-dialog-attendees.xul patching file calendar/base/content/dialogs/calendar-event-dialog-recurrence.xul patching file calendar/base/content/dialogs/calendar-event-dialog-reminder.xul patching file calendar/base/content/dialogs/calendar-event-dialog-timezone.xul patching file calendar/base/content/dialogs/calendar-print-dialog.xul patching file calendar/base/content/dialogs/calendar-summary-dialog.xul patching file calendar/lightning/content/lightning-item-iframe.xul patching file calendar/lightning/content/messenger-overlay-sidebar.xul patching file calendar/lightning/jar.mn patching file calendar/resources/content/datetimepickers/datetimepickers.css patching file calendar/resources/content/datetimepickers/datetimepickers.js patching file calendar/resources/content/datetimepickers/datetimepickers.xml patching file mail/base/content/customElements.js patching file calendar/resources/content/datetimepickers/datetimepickers.css patching file calendar/resources/content/datetimepickers/datetimepickers.js adding calendar/resources/content/datetimepickers/datetimepickers.js cannot patch calendar/resources/content/datetimepickers/datetimepickers.js: file is not tracked committing files: calendar/base/content/dialogs/calendar-event-dialog-attendees.xul calendar/base/content/dialogs/calendar-event-dialog-recurrence.xul calendar/base/content/dialogs/calendar-event-dialog-reminder.xul calendar/base/content/dialogs/calendar-event-dialog-timezone.xul calendar/base/content/dialogs/calendar-print-dialog.xul calendar/base/content/dialogs/calendar-summary-dialog.xul calendar/lightning/content/lightning-item-iframe.xul calendar/lightning/content/messenger-overlay-sidebar.xul calendar/lightning/jar.mn calendar/resources/content/datetimepickers/datetimepickers.css calendar/resources/content/datetimepickers/datetimepickers.js calendar/resources/content/datetimepickers/datetimepickers.xml mail/base/content/customElements.js committing manifest committing changelog patch failed, rejects left in working directory errors during apply, please fix and qrefresh timepicker-grids-combined.patch
Attachment #9032788 - Flags: review?(mkmelin+mozilla)
Attached patch timepicker-grids-combined.patch (obsolete) β€” β€” Splinter Review
Attachment #9032788 - Attachment is obsolete: true
Attachment #9032791 - Flags: feedback?(mkmelin+mozilla)
Comment on attachment 9032791 [details] [diff] [review] timepicker-grids-combined.patch Review of attachment 9032791 [details] [diff] [review]: ----------------------------------------------------------------- Still get JavaScript error: chrome://calendar/content/datetimepickers/datetimepickers.js, line 62: ReferenceError: clickMinute is not defined ... just by trying to add an event, and choose time (minutes) ::: calendar/resources/content/datetimepickers/datetimepickers.js @@ +64,5 @@ > + spacer.setAttribute("flex", "1"); > + > + const minutebox = document.createElement("vbox"); > + minutebox.addEventListener("click", () => { > + this.clickMinute(this, this.getAttribute("value")); perhaps from here, looks like minutebox is a just a vbox, so woudln't hva a clickMinute method
Attachment #9032791 - Flags: feedback?(mkmelin+mozilla) → feedback-
(In reply to Magnus Melin [:mkmelin] from comment #10) > Comment on attachment 9032791 [details] [diff] [review] > timepicker-grids-combined.patch > > Review of attachment 9032791 [details] [diff] [review]: > ----------------------------------------------------------------- > > Still get > JavaScript error: > chrome://calendar/content/datetimepickers/datetimepickers.js, line 62: > ReferenceError: clickMinute is not defined > > ... just by trying to add an event, and choose time (minutes) > > ::: calendar/resources/content/datetimepickers/datetimepickers.js > @@ +64,5 @@ > > + spacer.setAttribute("flex", "1"); > > + > > + const minutebox = document.createElement("vbox"); > > + minutebox.addEventListener("click", () => { > > + this.clickMinute(this, this.getAttribute("value")); > > perhaps from here, looks like minutebox is a just a vbox, so woudln't hva a > clickMinute method Not sure what you meant. I can't reproduce it.
Attached patch timepicker-grids-combined.patch (obsolete) β€” β€” Splinter Review
Attachment #9032791 - Attachment is obsolete: true
Comment on attachment 9033389 [details] [diff] [review] timepicker-grids-combined.patch Review of attachment 9033389 [details] [diff] [review]: ----------------------------------------------------------------- updated the patch, but I dont think it has any changes. I can't reproduce the errors that you were getting. :/
Attachment #9033389 - Flags: feedback?(mkmelin+mozilla)
can you try one more time?
Comment on attachment 9033389 [details] [diff] [review] timepicker-grids-combined.patch Review of attachment 9033389 [details] [diff] [review]: ----------------------------------------------------------------- ::: calendar/resources/content/datetimepickers/datetimepickers.js @@ +85,5 @@ > + this._updateAttributes(); > + } > + > + attributeChangedCallback() { > + this._updateAttributes(); what about the this.isConnectedAndReady() check here @@ +91,5 @@ > + > + _updateAttributes() { > + if (!this.label) { > + return; > + } instead of this? Same thing for the other elements
(In reply to Magnus Melin [:mkmelin] from comment #15) > Comment on attachment 9033389 [details] [diff] [review] > timepicker-grids-combined.patch > > Review of attachment 9033389 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: calendar/resources/content/datetimepickers/datetimepickers.js > @@ +85,5 @@ > > + this._updateAttributes(); > > + } > > + > > + attributeChangedCallback() { > > + this._updateAttributes(); > > what about the this.isConnectedAndReady() check here > > @@ +91,5 @@ > > + > > + _updateAttributes() { > > + if (!this.label) { > > + return; > > + } > > instead of this? > > Same thing for the other elements i felt there is not point in checking anything other than label element, if there is no label then we can't set anny attr on it. No point in checking isConnectedReady and using delayconnectedcaloback here..
But you *are* using delayConnectedCallback already, and per the documentation then you should use isConnectedReady in combination
(In reply to Magnus Melin [:mkmelin] from comment #17) > But you *are* using delayConnectedCallback already, and per the > documentation then you should use isConnectedReady in combination Yes, I should remove that. Sorry, my bad.
Attached patch timepicker-grids-combined.patch (obsolete) β€” β€” Splinter Review
Attachment #9033389 - Attachment is obsolete: true
Attachment #9033389 - Flags: feedback?(mkmelin+mozilla)
Attached patch timepicker-grids-combined.patch (obsolete) β€” β€” Splinter Review
Attachment #9033397 - Attachment is obsolete: true
Attached patch timepicker-grids-combined.patch (obsolete) β€” β€” Splinter Review
Attachment #9033398 - Attachment is obsolete: true
Attachment #9033400 - Flags: feedback?(mkmelin+mozilla)
Comment on attachment 9033400 [details] [diff] [review] timepicker-grids-combined.patch Review of attachment 9033400 [details] [diff] [review]: ----------------------------------------------------------------- Seems to work fine. f+ with the below addressed ::: calendar/resources/content/datetimepickers/datetimepickers.xml @@ +566,5 @@ > + if(timepickerGrid.changeTo12HoursFormat) { > + timepickerGrid.changeTo12HoursFormat(amLabel, pmLabel); > + clearInterval(tgInterval); > + } > + }, 100); Instead of this hack, I think you should do window.customElements.upgrade(timepickerGrid); timepickerGrid.changeTo12HoursFormat(amLabel, pmLabel);
Attachment #9033400 - Flags: feedback?(mkmelin+mozilla) → feedback+
Attached patch timepicker-grids-combined.patch (obsolete) β€” β€” Splinter Review
Attachment #9033400 - Attachment is obsolete: true
Attachment #9033534 - Flags: review?(philipp)
Attachment #9033534 - Flags: feedback+
Comment on attachment 9033534 [details] [diff] [review] timepicker-grids-combined.patch Review of attachment 9033534 [details] [diff] [review]: ----------------------------------------------------------------- Looks ok to me. There are a lot more comments I could do, but they were also issues before. We should rewrite some of these bindings someday (tm). ::: calendar/resources/content/datetimepickers/datetimepickers.js @@ +421,5 @@ > + this.kMINUTE_VIEW_ONE = 1; > + } > + > + /** > + * Set up the picker, called when the popup pops I'd appreciate if we could fill in the docs for this and other functions, e.g. full description, use of @param and @returns.
Attachment #9033534 - Flags: review?(philipp) → review+
Please don't land any changes involving datetimepickers.xml until we have finally landed bug sorted out bug 1503731.
Oh another thing. Instead of the scoped block, can we use a <script type="module"> instead?
Depends on: 1503731
Attached patch timepicker-grids-combinedWIP.patch (obsolete) β€” β€” Splinter Review
Attachment #9033534 - Attachment is obsolete: true

(In reply to Philipp Kewisch [:Fallen] [:πŸ“†] from comment #26)

Oh another thing. Instead of the scoped block, can we use a <script
type="module"> instead?
modules dont load synchronously and can't be loaded dynamically(atleast at the time when script[type="module"] landed)

Do the modules need to be loaded synchronously? It seems to me this is something we should avoid requiring. Dynamic loading is indeed not possible, but iiuc we wouldn't need to?

It's pretty unclear to me how type=module would/could/should work for calendar, given it's all used through the overlaying hack :/

Philipp, could you please help me out with proper comments for the methods? I am not good at writing comments plus I dont have much knowledge how they work?

Flags: needinfo?(philipp)
Attached patch timepicker-grids-combined.patch (obsolete) β€” β€” Splinter Review

Need to just rebase this patch after my build finishes. Right now I am on an old commit and for me the datetimepicker popup is not openin when I click on arrow buttons.

Attachment #9036967 - Attachment is obsolete: true
Flags: needinfo?(philipp)
Comment on attachment 9045962 [details] [diff] [review] timepicker-grids-combined.patch Review of attachment 9045962 [details] [diff] [review]: ----------------------------------------------------------------- Hey could you please take a look at the comments and just lemme know better ones if any?
Attachment #9045962 - Flags: feedback?(philipp)
Comment on attachment 9045962 [details] [diff] [review] timepicker-grids-combined.patch Review of attachment 9045962 [details] [diff] [review]: ----------------------------------------------------------------- Hey Arshad, some feedback here: ::: calendar/resources/content/datetimepickers/datetimepickers.js @@ +8,5 @@ > +// leaking to window scope. > +{ > + /* global MozXULElement */ > + > + class MozTimepickerMinute extends MozXULElement { Would it make sense to not make minute/hour separate bindings but just use normal elements and then do any necessary processing in the timepicker element? I don't think we need to translate this 1:1 here from XBL. @@ +421,5 @@ > + this.kMINUTE_VIEW_ONE = 1; > + } > + > + /** > + * Set up the picker, called when the popup pops. We usually leave an empty line after the description and before the arguments. @@ +469,5 @@ > + } > + } > + > + /** > + * Called when the more tab is clicked, and possibly at startup. Focus on what the method does, not when or how it is called. When it is called may potentially change and we may miss updating all comments where it is referenced. This is the same for the method name. Maybe it would make more sense to call it selectMinuteBox and then describe it accordingly. @@ +483,5 @@ > + this.selectMinuteItem(oneMinuteItem); > + } > + > + /** > + * Called when the less tab is clicked, and possibly at startup. Same here, you should focus on what this method does instead. @@ +650,5 @@ > + } > + > + /** > + * Helper function to move hours. > + * @param {number} number - value by which hours should be moved. The other calendar files don't use a - to split number, but instead align to a tab stop so that all param descriptions start in the same column. Objects such as String, Number should be with an uppercase first letter. @@ +679,5 @@ > + } > + > + /** > + * Helper function to calulate the nearest even five minutes. > + * @param {calDateTime object} time - time near to which new time will be calculated. Check the jsdoc documentation on how to specify objects. This should probably just be {calDateTime}. Just a note in case you come across this in the docs: we don't create extra comments to define how calDateTime is structured. You are not doing this, but it is mentioned in the jsdoc docs.
Attachment #9045962 - Flags: feedback?(philipp) → feedback+
Attached patch timepicker-grids-combined.patch (obsolete) β€” β€” Splinter Review
Attachment #9045962 - Attachment is obsolete: true
Attached patch timepicker-grids.patch (obsolete) β€” β€” Splinter Review
Attachment #9047945 - Attachment is obsolete: true
Attachment #9048036 - Flags: review+
Attachment #9048036 - Flags: feedback?(mkmelin+mozilla)

This is the same for the method name. Maybe it would make more sense to call
it selectMinuteBox and then describe it accordingly.

Not sure what you meant by this ^?

Attached patch timepicker-grids.patch (obsolete) β€” β€” Splinter Review
Attachment #9048036 - Attachment is obsolete: true
Attachment #9048036 - Flags: feedback?(mkmelin+mozilla)
Attachment #9048059 - Flags: review+
Attachment #9048059 - Flags: feedback?(mkmelin+mozilla)
Attached patch timepicker-grids.patch (obsolete) β€” β€” Splinter Review
Attachment #9048059 - Attachment is obsolete: true
Attachment #9048059 - Flags: feedback?(mkmelin+mozilla)
Attachment #9048060 - Flags: review+
Attachment #9048060 - Flags: feedback?(mkmelin+mozilla)
Comment on attachment 9048060 [details] [diff] [review] timepicker-grids.patch Review of attachment 9048060 [details] [diff] [review]: ----------------------------------------------------------------- Seems to be working, but please fix some nits as per below ::: calendar/resources/content/datetimepickers/datetimepickers.js @@ +206,5 @@ > this.label.removeAttribute("selected"); > } > } > } > /** * The MozTimepickerGrids widget displays he grid of times to select, e.g. * for an event. Typically it represents the popup content that let's the * user select a time, in a <timepicker> widget. * @extends MozXULElement */ @@ +457,5 @@ > + onPopupShowing() { > + // select the hour item > + let hours24 = this.mSelectedTime.getHours(); > + let hourItemId = `.time-picker-hour-box-class[value="${hours24}"]`; > + let hourItem = this.querySelector(hourItemId); would inline hourItemId and not declare it for a one time usage @@ +480,5 @@ > + this.switchMinuteView(this.kMINUTE_VIEW_ONE); > + > + // select minute box corresponding to the time > + let minutes = this.mSelectedTime.getMinutes(); > + let oneMinuteItemId = `.time-picker-one-minute-class[value="${minutes}"]`; here too @@ +498,5 @@ > + // BUT leave the selected time at what may NOT be an even five minutes > + // So that If they click more again the proper non-even-five minute > + // box will be selected > + let minutesByFive = this.calcNearestFiveMinutes(this.mSelectedTime); > + let fiveMinuteItemId = `.time-picker-five-minute-class[value="${minutesByFive}"]`; and here @@ +570,5 @@ > + > + /** > + * Selects an hour item. > + * > + * @param {object} hourItem Hour item node to be selected these should be @param {Node} @@ +587,5 @@ > + /** > + * Selects a minute item. > + * > + * @param {object} minuteItem Minute item node to be selected > + */ {Node}
Attachment #9048060 - Flags: feedback?(mkmelin+mozilla) → feedback+

need to fix one test and this patch will be ready to land

(In reply to Arshad Khan [:arshad] from comment #43)

need to fix one test and this patch will be ready to land

testalarmDialog.js test is only failign for linux. I have pulled latest changesets for my linux machine and will test out the patch as soon as my build finishes.

There ll be sometimes error like mPicker is null which I am not handling here. See https://bugzilla.mozilla.org/show_bug.cgi?id=1524456#c28 and https://bugzilla.mozilla.org/show_bug.cgi?id=1524456#c29 .

Attached patch timepicker-grids.patch β€” β€” Splinter Review
Attachment #9048060 - Attachment is obsolete: true
Attachment #9049481 - Flags: review+
Attachment #9049481 - Flags: feedback+

Just ran the testAlarmDialog.js test on ubuntu and the failed try tesst passed. Not sure wther the test failure was intermittent or not, so I have pushed another try - https://treeherder.mozilla.org/#/jobs?repo=try-comm-central&revision=7829aa18efdd4071a4eb1864c4407518e29353bd&selectedJob=232640559 . Lets see what happens now. Certainly there will be some testFailures due to recent issues.

Keywords: checkin-needed

See the try - https://bugzilla.mozilla.org/show_bug.cgi?id=1512941#c41 . The one test that's failing didn't fail again that's why I am adding checkin-needed keyword.

Looking at the history here, there was never an r+, only f+ from Magnus and Philipp. Am I too strict?

Flags: needinfo?(mkmelin+mozilla)
Attachment #9049481 - Flags: review+ → review?(philipp)

Yeah I don't see a review yet.

Flags: needinfo?(mkmelin+mozilla)
Keywords: checkin-needed

(In reply to Jorg K (GMT+1) from comment #49)

Looking at the history here, there was never an r+, only f+ from Magnus and Philipp. Am I too strict?

https://bugzilla.mozilla.org/show_bug.cgi?id=1512941#c24

Very confusing, so an earlier version had r+ and a later f+? Maybe Philipp or even Magnus can just take another look.

Comment on attachment 9049481 [details] [diff] [review] timepicker-grids.patch Oh yes it was from that review. For future reference, please don't move patches and reviews between bugs. Way too confusing
Attachment #9049481 - Flags: review?(philipp) → review+

Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/4a9f709716ad
Migrate timepicker-grids binding to custom element. r=philipp

Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → 6.9
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: