-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace datetimepicker #526
Conversation
Note that the datetimepicker is not really accessible right now. Hopefully, there will be some improvement related to this soon. See here: Eonasdan/tempus-dominus#2390
(keyboard events & focus)
Codecov Report
@@ Coverage Diff @@
## mampf-next #526 +/- ##
===========================================
Coverage 66.48% 66.48%
===========================================
Files 311 311
Lines 9417 9417
===========================================
Hits 6261 6261
Misses 3156 3156 |
Also close the datetimepicker when a date was selected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I played around with it and it seems to work very nicely! I noticed the following things:
-
The new datetimepicker does not yet seem to be idempotent (possibly because of the use of
$(document).ready
instead of the turbolinks load event. You can see this by clicking the back and forward button. Playing around in this way, you can produce dead datetimepickers in the middle of the window:
-
Creating absurd inputs sometimes results in a javascript exception as in here:
-
If several error messages appear, they are appended after each other, but not separated in some way:
|
I can produce this message by using the datetimepicker for an existing homework: I modify the date like 2022-08-01 07:07 by removing a dash to 202208-01 07:07 and then click on the "Save" button. Playing around with this I discovered another small issue: If two homeworks are edited at the same time and such an error is created for one them, hitting the save button for this one will lead to errors being displayed for the other one as well (in the example in the screenshot I hit the save button in the third row, but error messages probably destined for the third row were being displayed in the first row) |
Oh, good that you do such thorough testing here ;)
This is actually not related to this PR, you found an already existing bug. Note that other components are affected by this as well, e.g. try to select a wrong deletion date. The reason is in Also note that there are code lines that cannot work right now, e.g. this line in $('#assignment_title').removeClass('is-invalid') There is no |
I agree, this is a separate PR. |
As this is perfectly describing our use case, I've replaced it with |
It'd be great if you could also check the checkboxes in my first comment of this page (hope that you can access these checkboxes and check/uncheck them, even if you're not the person that posted the comment). |
The previously used JQuery datetimepicker was imported like this
This dirty fix to direct webpack to the node modules folder has already caused too much pain since this was of course very fragile and thus failed often and seemingly in an undeterministic way. A quick fix was to change the import path, load the page again, then change the path back, so that webpack(er) picks up the changes. This has to find an end.
Therefore, this PR replaces the previously used JQuery datetimepicker with the Tempus Dominus Datetimepicker.
What to look for in reviews
/lectures/:id/edit
endpoint under the "Homework" section/media/:id/edit
endpoint inside the publish modal. Note that when you create an exercise, there are actually two datetimepickers in this modal! check both: only one datetimepicker (when trying to publish something different than an exercise) and both datetimepickers (when publishing an exercise)Further notes
Moment.js
as library for formatting datetime strings. No frontend datetimeformatting is done anymore. The backend formatting is not affected by this.javascript/packs/application.sass
file is now an empty file. We cannot delete it right now as that would also mean we'd have to change the webpacker configuration which is done in another PR addressing Webpacker has been retired / Upgrade frontend bundling #454.