Skip to content

Commit

Permalink
Merge pull request #538 from MaMpf-HD/mampf-next
Browse files Browse the repository at this point in the history
Continuous Release 1.8.0
  • Loading branch information
Splines authored Oct 16, 2023
2 parents de82635 + 5b28b04 commit 2ad8445
Show file tree
Hide file tree
Showing 70 changed files with 501 additions and 356 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ gem "activerecord-nulldb-adapter"
# Use sqlite3 as the database for Active Record
gem "sqlite3", "~> 1.4"
# Use Puma as the app server
gem "puma", "~> 4.1"
gem "puma", "< 7"
# Use SCSS for stylesheets
gem "sass-rails", ">= 6"
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
Expand Down
44 changes: 23 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/rails/sprockets-rails
revision: 73e7351abff3506f6dca6b2da8abedfd5c7c0d77
revision: 065cbe83989c44019eca7161782ed4fdb6473517
branch: master
specs:
sprockets-rails (3.4.2)
Expand Down Expand Up @@ -142,9 +142,9 @@ GEM
bindex (0.8.1)
bootsnap (1.16.0)
msgpack (~> 1.2)
bootstrap (5.2.1)
bootstrap (5.3.1)
autoprefixer-rails (>= 9.1.0)
popper_js (>= 2.11.6, < 3)
popper_js (>= 2.11.8, < 3)
sassc-rails (>= 2.0.0)
bootstrap_form (5.1.0)
actionpack (>= 5.2)
Expand Down Expand Up @@ -278,7 +278,7 @@ GEM
http-accept (1.7.0)
http-cookie (1.0.5)
domain_name (~> 0.5)
i18n (1.12.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5)
Expand Down Expand Up @@ -329,9 +329,9 @@ GEM
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
loofah (2.19.1)
loofah (2.21.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
nokogiri (>= 1.12.0)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
Expand All @@ -344,7 +344,7 @@ GEM
mime-types-data (3.2023.0218.1)
mini_magick (4.12.0)
mini_mime (1.1.2)
minitest (5.18.0)
minitest (5.19.0)
msgpack (1.7.0)
multi_json (1.15.0)
multipart-post (2.3.0)
Expand All @@ -360,7 +360,7 @@ GEM
net-protocol
netrc (0.11.0)
nio4r (2.5.8)
nokogiri (1.14.3-x86_64-linux)
nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4)
onebox (2.2.19)
addressable (~> 2.8.0)
Expand All @@ -383,7 +383,7 @@ GEM
ttfunk
pg (1.4.6)
pgreset (0.3)
popper_js (2.11.6)
popper_js (2.11.8)
pr_geohash (1.0.0)
premailer (1.21.0)
addressable
Expand All @@ -399,13 +399,13 @@ GEM
prometheus_exporter (2.0.8)
webrick
public_suffix (5.0.1)
puma (4.3.12)
puma (6.3.1)
nio4r (~> 2.0)
pundit (2.3.0)
activesupport (>= 3.0.0)
raabro (1.4.0)
racc (1.6.2)
rack (2.2.7)
racc (1.7.1)
rack (2.2.8)
rack-proxy (0.7.6)
rack
rack-test (2.1.0)
Expand All @@ -424,16 +424,18 @@ GEM
activesupport (= 7.0.4.3)
bundler (>= 1.15.0)
railties (= 7.0.4.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-erd (1.7.2)
activerecord (>= 4.2)
activesupport (>= 4.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.5.0)
loofah (~> 2.19, >= 2.19.1)
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
rails-i18n (7.0.6)
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 8)
Expand Down Expand Up @@ -587,7 +589,7 @@ GEM
tins (~> 1.0)
terser (1.1.14)
execjs (>= 0.3.0, < 3)
thor (1.2.1)
thor (1.2.2)
thredded (1.1.0)
active_record_union (>= 1.3.0)
autoprefixer-rails
Expand All @@ -609,7 +611,7 @@ GEM
sassc-rails (>= 2.0.0)
sprockets-es6
timeago_js (>= 3.0.2.2)
tilt (2.1.0)
tilt (2.2.0)
timeago_js (3.0.2.2)
timeout (0.3.2)
tins (1.32.1)
Expand Down Expand Up @@ -648,7 +650,7 @@ GEM
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
will_paginate (3.3.1)
zeitwerk (2.6.7)
zeitwerk (2.6.11)

PLATFORMS
x86_64-linux
Expand Down Expand Up @@ -705,7 +707,7 @@ DEPENDENCIES
premailer-rails
progress_bar
prometheus_exporter
puma (~> 4.1)
puma (< 7)
rack
rails (~> 7.0.4.3)
rails-erd
Expand Down Expand Up @@ -734,7 +736,7 @@ DEPENDENCIES
sunspot_rails!
sunspot_solr
terser
thredded!
thredded
thredded-markdown_katex!
trix-rails
turbolinks (~> 5)
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
//= require announcements
//= require answers
//= require bootstrap_modal_turbolinks_fix
//= require bootstrap_popovers
//= require chapters
//= require clickers
//= require courses
Expand Down
24 changes: 0 additions & 24 deletions app/assets/javascripts/bootstrap_modal_turbolinks_fix.coffee

This file was deleted.

16 changes: 16 additions & 0 deletions app/assets/javascripts/bootstrap_modal_turbolinks_fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$(document).on('turbolinks:load', function () {
// show all active modals
$('.activeModal').modal('show');
// remove active status (this needs to be reestablished before caching)
$('.activeModal').removeClass('activeModal');
});

$(document).on('turbolinks:before-cache', function () {
// if some modal is open
if ($('body').hasClass('modal-open')) {
$('.modal.show').addClass('activeModal');
$('.modal.show').modal('hide');
// remove the greyed out background
$('.modal-backdrop').remove();
}
});
18 changes: 18 additions & 0 deletions app/assets/javascripts/bootstrap_popovers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
$(document).on('turbolinks:load', function () {
initBootstrapPopovers();
});

/**
* Initializes all Bootstrap popovers on the page.
*
* This function might be used for the first initialization of popovers as well
* as for reinitialization on page changes.
*
* See: https://getbootstrap.com/docs/5.3/components/popovers/#enable-popovers
*/
function initBootstrapPopovers() {
const popoverHtmlElements = document.querySelectorAll('[data-bs-toggle="popover"]');
for (const element of popoverHtmlElements) {
new bootstrap.Popover(element);
}
}
126 changes: 126 additions & 0 deletions app/assets/javascripts/datetimepicker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// Initialize on page load (when js file is dynamically loaded)
$(document).ready(startInitialization);

// On page change (e.g. go back and forth in browser)
$(document).on('turbolinks:before-cache', () => {
// Remove stale datetimepickers
$('.tempus-dominus-widget').remove();
});

function startInitialization() {
const pickerElements = $('.td-picker');
if (pickerElements.length == 0) {
console.error('No datetimepicker element found on page, although requested.');
return;
}

pickerElements.each((i, element) => {
element = $(element);
const datetimePicker = initDatetimePicker(element);
registerErrorHandlers(datetimePicker, element);
registerFocusHandlers(datetimePicker, element);
});
}

function getDateTimePickerIcons() {
// At the moment: continue to use FontAwesome 5 icons
// see https://getdatepicker.com/6/plugins/fa5.html
// see https://github.com/Eonasdan/tempus-dominus/blob/master/dist/plugins/fa-five.js
return {
type: 'icons',
time: 'fas fa-clock',
date: 'fas fa-calendar',
up: 'fas fa-arrow-up',
down: 'fas fa-arrow-down',
previous: 'fas fa-chevron-left',
next: 'fas fa-chevron-right',
today: 'fas fa-calendar-check',
clear: 'fas fa-trash',
close: 'fas fa-times',
}
}

function initDatetimePicker(element) {
// see https://getdatepicker.com
return new tempusDominus.TempusDominus(
element.get(0),
{
display: {
sideBySide: true, // clock to the right of the calendar
icons: getDateTimePickerIcons(),
},
localization: {
startOfTheWeek: 1,
// choose format to be compliant with backend time format
format: 'yyyy-MM-dd HH:mm',
hourCycle: 'h23',
}
}
);
}

function registerErrorHandlers(datetimePicker, element) {
// Catch Tempus Dominus error when user types in invalid date
// this is rather hacky at the moment, see this discussion:
// https://github.com/Eonasdan/tempus-dominus/discussions/2656
datetimePicker.dates.oldParseInput = datetimePicker.dates.parseInput;
datetimePicker.dates.parseInput = (input) => {
try {
return datetimePicker.dates.oldParseInput(input);
} catch (err) {
const errorMsg = element.find('.td-error').data('td-invalid-date');
element.find('.td-error').text(errorMsg).show();
datetimePicker.dates.clear();
}
};

datetimePicker.subscribe(tempusDominus.Namespace.events.change, (e) => {
// see https://getdatepicker.com/6/namespace/events.html#change

// Clear error message
if (e.isValid && !e.isClear) {
element.find('.td-error').empty();
}

// If date was selected, close datetimepicker.
// However: leave the datetimepicker open if user only changed time
if (e.oldDate && e.date && !hasUserChangedDate(e.oldDate, e.date)) {
datetimePicker.hide();
}
});
}

function hasUserChangedDate(oldDate, newDate) {
return oldDate.getHours() != newDate.getHours()
|| oldDate.getMinutes() != newDate.getMinutes();
}

function registerFocusHandlers(datetimePicker, element) {
// Show datetimepicker when user clicks in text field next to button
// or when input field receives focus
var isButtonInvokingFocus = false;

element.find('.td-input').on('click focusin', (e) => {
try {
if (!isButtonInvokingFocus) {
datetimePicker.show();
}
}
finally {
isButtonInvokingFocus = false;
}
});

element.find('.td-picker-button').on('click', () => {
isButtonInvokingFocus = true;
element.find('.td-input').focus();
});

// Hide datetimepicker when input field loses focus
element.find('.td-input').blur((e) => {
if (!e.relatedTarget) {
return;
}
datetimePicker.hide();
});
}
10 changes: 6 additions & 4 deletions app/assets/javascripts/lectures.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ disableExceptOrganizational = ->
return

$(document).on 'turbolinks:load', ->

# activate all popovers
$('[data-bs-toggle="popover"]').popover()

initBootstrapPopovers()
# if any input is given to the lecture form (for people in lecture),
# disable other input
$('#lecture-form :input').on 'change', ->
Expand Down Expand Up @@ -82,6 +79,11 @@ $(document).on 'turbolinks:load', ->
location.reload(true)
return

# reload current page if lecture comments editing is cancelled
$('#cancel-lecture-comments').on 'click', ->
location.reload(true)
return

# reload current page if lecture preferences editing is cancelled
$('#cancel-lecture-organizational').on 'click', ->
location.reload(true)
Expand Down
Loading

0 comments on commit 2ad8445

Please sign in to comment.