Skip to content
Snippets Groups Projects
Commit a0dd66e7 authored by Moritz Strohm's avatar Moritz Strohm
Browse files

set defaultDate on changed calendar dates in sidebar widgets, fixes #3924

Closes #3924

Merge request studip/studip!3046
parent 0efc3059
No related branches found
No related tags found
No related merge requests found
...@@ -111,6 +111,8 @@ class Calendar_CalendarController extends AuthenticatedController ...@@ -111,6 +111,8 @@ class Calendar_CalendarController extends AuthenticatedController
{ {
PageLayout::setTitle(_('Kalender')); PageLayout::setTitle(_('Kalender'));
$default_date = \Studip\Calendar\Helper::getDefaultCalendarDate();
if (Request::isPost()) { if (Request::isPost()) {
//In case the checkbox of the options widget is clicked, the resulting //In case the checkbox of the options widget is clicked, the resulting
//POST request must be catched here and result in a redirect. //POST request must be catched here and result in a redirect.
...@@ -203,6 +205,7 @@ class Calendar_CalendarController extends AuthenticatedController ...@@ -203,6 +205,7 @@ class Calendar_CalendarController extends AuthenticatedController
if ($calendar_owner && $calendar_owner->id === User::findCurrent()->id) { if ($calendar_owner && $calendar_owner->id === User::findCurrent()->id) {
//The user is viewing their own calendar. //The user is viewing their own calendar.
$options = new OptionsWidget(); $options = new OptionsWidget();
$options->addLayoutCSSClass('calendar-action');
$options->addCheckbox( $options->addCheckbox(
_('Abgelehnte Termine anzeigen'), _('Abgelehnte Termine anzeigen'),
Request::bool('show_declined'), Request::bool('show_declined'),
...@@ -237,6 +240,7 @@ class Calendar_CalendarController extends AuthenticatedController ...@@ -237,6 +240,7 @@ class Calendar_CalendarController extends AuthenticatedController
$this->url_for('calendar/calendar/index', ['view' => 'group']), $this->url_for('calendar/calendar/index', ['view' => 'group']),
'group_id' 'group_id'
); );
$group_select->addLayoutCSSClass('calendar-action');
$options = [ $options = [
'' => _('(bitte wählen)') '' => _('(bitte wählen)')
]; ];
...@@ -263,6 +267,7 @@ class Calendar_CalendarController extends AuthenticatedController ...@@ -263,6 +267,7 @@ class Calendar_CalendarController extends AuthenticatedController
$this->url_for('calendar/calendar'), $this->url_for('calendar/calendar'),
'user_id' 'user_id'
); );
$calendar_select->addLayoutCSSClass('calendar-action');
$select_options = [ $select_options = [
'' => _('(bitte wählen)'), '' => _('(bitte wählen)'),
User::findCurrent()->id => _('Eigener Kalender') User::findCurrent()->id => _('Eigener Kalender')
...@@ -335,7 +340,6 @@ class Calendar_CalendarController extends AuthenticatedController ...@@ -335,7 +340,6 @@ class Calendar_CalendarController extends AuthenticatedController
$slot_durations = $this->getUserCalendarSlotSettings(); $slot_durations = $this->getUserCalendarSlotSettings();
//Create the fullcalendar object: //Create the fullcalendar object:
$default_date = \Studip\Calendar\Helper::getDefaultCalendarDate();
$data_url_params = []; $data_url_params = [];
if (Request::bool('show_declined')) { if (Request::bool('show_declined')) {
......
...@@ -737,6 +737,25 @@ class Fullcalendar ...@@ -737,6 +737,25 @@ class Fullcalendar
url.searchParams.set('defaultDate', changed_date) url.searchParams.set('defaultDate', changed_date)
this.href = url.toString(); this.href = url.toString();
}); });
jQuery('.sidebar-widget.calendar-action').each(function() {
//Each sidebar widget is different. The placement of the defaultDate URL parameter
//has to reflect that.
jQuery(this).find('button[formaction]').each(function() {
//Modify the formaction attribute:
let url = new URL(jQuery(this).attr('formaction'));
url.searchParams.set('defaultDate', changed_date);
jQuery(this).attr('formaction', url.toString());
});
jQuery(this).find('form[action]').each(function() {
//Add a hidden input with the defaultDate:
let hidden_input = jQuery(this).find('input[name="defaultDate"]')[0];
if (!hidden_input) {
hidden_input = jQuery('<input type="hidden" name="defaultDate">');
jQuery(this).append(hidden_input);
}
jQuery(hidden_input).val(changed_date);
});
});
// Now change the URL of the window. // Now change the URL of the window.
const url = new URL(window.location.href); const url = new URL(window.location.href);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment