From 478218e26c9c43178674ee183988a7284908fed8 Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 4 Jul 2023 21:08:18 +0200 Subject: [PATCH 01/25] Uninstall old Datetimepicker --- package.json | 1 - yarn.lock | 24 ------------------------ 2 files changed, 25 deletions(-) diff --git a/package.json b/package.json index 9641db02d..6f080f1ab 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "css-loader": "^5.2.7", "friendly-challenge": "^0.9.12", "imports-loader": "^1.2.0", - "jquery-datetimepicker": "^2.5.21", "moment": "^2.29.4", "regenerator-runtime": "^0.13.11", "sass": "^1.63.4", diff --git a/yarn.lock b/yarn.lock index 90dd51384..5bfce2f6f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4232,25 +4232,6 @@ jest-worker@^26.5.0: merge-stream "^2.0.0" supports-color "^7.0.0" -jquery-datetimepicker@^2.5.21: - version "2.5.21" - resolved "https://registry.yarnpkg.com/jquery-datetimepicker/-/jquery-datetimepicker-2.5.21.tgz#00c388a78df2732fedfdb5c6529b6e84d53e0235" - integrity sha512-wDTpZ4f1PWd1XGaIIE0n6jLynlm+akBJ7/NjaB1bk2UJSS593CHJPZ3+FNEXoyvNVUeBlBC0oX6WTfCyfUhX/w== - dependencies: - jquery ">= 1.7.2" - jquery-mousewheel ">= 3.1.13" - php-date-formatter "^1.3.4" - -"jquery-mousewheel@>= 3.1.13": - version "3.1.13" - resolved "https://registry.yarnpkg.com/jquery-mousewheel/-/jquery-mousewheel-3.1.13.tgz#06f0335f16e353a695e7206bf50503cb523a6ee5" - integrity sha512-GXhSjfOPyDemM005YCEHvzrEALhKDIswtxSHSR2e4K/suHVJKJxxRCGz3skPjNxjJjQa9AVSGGlYjv1M3VLIPg== - -"jquery@>= 1.7.2": - version "3.7.0" - resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.7.0.tgz#fe2c01a05da500709006d8790fe21c8a39d75612" - integrity sha512-umpJ0/k8X0MvD1ds0P9SfowREz2LenHsQaxSohMZ5OMNEU2r0tf8pdeEFTHMFxWVxKNyU9rTtK3CWzUCTKJUeQ== - js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -5170,11 +5151,6 @@ pbkdf2@^3.0.3: safe-buffer "^5.0.1" sha.js "^2.4.8" -php-date-formatter@^1.3.4: - version "1.3.6" - resolved "https://registry.yarnpkg.com/php-date-formatter/-/php-date-formatter-1.3.6.tgz#6d67359da890c742005fa89d20be3ded31cc1d2a" - integrity sha512-/CKsZYmAwXeNh8KpD/CF9hcJDZNhdb2ICN8+qgqOt5sUu9liZIxZ1R284TNj5MtPt8RjG5X0xn6WSqL0kcKMBg== - picocolors@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-0.2.1.tgz#570670f793646851d1ba135996962abad587859f" From 6b93a134c61c4ad0c9aabc1dffbb9983df161afd Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 4 Jul 2023 21:08:54 +0200 Subject: [PATCH 02/25] Remove old import hack for Datetimepicker --- app/javascript/packs/application.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 82d42fcd6..5c9da133f 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -15,23 +15,10 @@ // const images = require.context('../images', true) // const imagePath = (name) => images(name, true) -// JQuery Datetimepicker fix -// import '...' does not work, random names for the import don't work either -// we use "css" and "myLib" imports although these strings do not show up anywhere -// in our codebase. This is just a hack to make the imports-loader work. Maybe it has -// to do with how webpacker resolves the imports or how jquery-datetimepicker exports -// its module. -import css from 'jquery-datetimepicker/build/jquery.datetimepicker.min.css' -import myLib from 'imports-loader?imports=default%20jquery%20$!./../../../node_modules/jquery-datetimepicker/build/jquery.datetimepicker.full.min.js' - -import moment from "moment"; // require -window.moment = moment; import { WidgetInstance } from "friendly-challenge"; var friendlyChallengeWidgetInstance = WidgetInstance -$.datetimepicker.setLocale('de'); - document.addEventListener("turbolinks:load", function () { var doneCallback, element, options, widget; From 2e8bdcb52c9e46ab359c1e55d42d93cb261ef351 Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 4 Jul 2023 21:09:45 +0200 Subject: [PATCH 03/25] Try out Tempus Dominus datetimepicker on assignments --- app/assets/javascripts/datetimepicker.js | 12 ++++++++++ app/views/assignments/_form.html.erb | 28 ++++++++++++++++++++---- app/views/layouts/_head.html.erb | 27 +++++++++++++++++++++++ 3 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 app/assets/javascripts/datetimepicker.js diff --git a/app/assets/javascripts/datetimepicker.js b/app/assets/javascripts/datetimepicker.js new file mode 100644 index 000000000..4ff5cc6a9 --- /dev/null +++ b/app/assets/javascripts/datetimepicker.js @@ -0,0 +1,12 @@ +// see https://getdatepicker.com +console.log('trying to import datetimepicker'); +$('#assignment-picker').tempusDominus({ + display: { + sideBySide: true + }, + localization: { + startOfTheWeek: 1, + format: 'yyyy-MM-dd HH:mm', + hourCycle: 'h23' + } +}); diff --git a/app/views/assignments/_form.html.erb b/app/views/assignments/_form.html.erb index 8377dc5f0..f8ded9f8f 100644 --- a/app/views/assignments/_form.html.erb +++ b/app/views/assignments/_form.html.erb @@ -1,3 +1,5 @@ +<%= javascript_include_tag 'datetimepicker' %> +
<%= form_with model: assignment do |f| %> @@ -10,15 +12,33 @@ id="assignment-title-error">
+
- <%= f.text_field :deadline, - class: 'form-control', - autocomplete: 'off', - id: "assignment_deadline_#{assignment.id}" %> +
+
+ <%= f.text_field :deadline, + id: 'assignment-picker-input', + class: 'form-control', + 'data-td-target': '#assignment-picker' %> + + + +
+
+
+ +
<%= f.select :medium_id, options_for_select(Medium.where(teachable: assignment.lecture, diff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erb index 64336b5d0..d1147a46d 100644 --- a/app/views/layouts/_head.html.erb +++ b/app/views/layouts/_head.html.erb @@ -34,6 +34,31 @@ integrity="sha256-rADF2WO6GbkNb5O9gqHdjQ/XhrfnXDtPdHdRe5KQmek=" crossorigin="anonymous"> + + + + + + + + + + + + + + +<%# Datetimepicker (Tempus Dominus) %> + +<%# + + + + %> + - + + - - - - - - + - - -<%# Datetimepicker (Tempus Dominus) %> - -<%# - - - - %> + href="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.7.10/dist/css/tempus-dominus.css">