From 305c2e4eca49754db3b51881a21f81c2c51e0324 Mon Sep 17 00:00:00 2001 From: Moritz Strohm <strohm@data-quest.de> Date: Tue, 29 Oct 2024 13:01:17 +0000 Subject: [PATCH] fixed functionality issues in TIC 4421, re #4421 Merge request studip/studip!3556 --- app/controllers/calendar/schedule.php | 51 ++++++--- app/views/calendar/schedule/course_info.php | 18 +++- app/views/calendar/schedule/index.php | 9 ++ lib/classes/calendar/Helper.php | 7 +- lib/navigation/StartNavigation.php | 2 +- resources/assets/stylesheets/print.scss | 110 ++------------------ 6 files changed, 74 insertions(+), 123 deletions(-) diff --git a/app/controllers/calendar/schedule.php b/app/controllers/calendar/schedule.php index c1652f7e6b7..0a99314a4f9 100644 --- a/app/controllers/calendar/schedule.php +++ b/app/controllers/calendar/schedule.php @@ -35,6 +35,26 @@ class Calendar_ScheduleController extends AuthenticatedController $show_hidden = Request::bool('show_hidden', false); + //Handle the selected semester and create a Fullcalendar instance. + + $this->semester = null; + if (Request::submitted('semester_id')) { + $this->semester = Semester::find(Request::option('semester_id')); + if ($this->semester) { + //Store the new semester-ID in the session: + $_SESSION['schedule_semester_id'] = $this->semester->id; + } + } + if (!$this->semester) { + //Load the semester from the session: + $semester_id = $_SESSION['schedule_semester_id'] ?? ''; + if ($semester_id) { + $this->semester = Semester::find($semester_id); + } else { + $this->semester = Semester::findCurrent(); + } + } + //Build the sidebar: $sidebar = Sidebar::get(); @@ -43,6 +63,7 @@ class Calendar_ScheduleController extends AuthenticatedController $semester_widget = new SemesterSelectorWidget( $this->indexURL(['show_hidden' => $show_hidden ?: null]) ); + $semester_widget->setSelection($semester->id ?? ''); $sidebar->addWidget($semester_widget); //Then add the actions for the action widget: @@ -84,16 +105,6 @@ class Calendar_ScheduleController extends AuthenticatedController ); $sidebar->addWidget($actions); - //Handle the selected semester and create a Fullcalendar instance. - - $semester = null; - if (Request::submitted('semester_id')) { - $semester = Semester::find(Request::option('semester_id')); - } - if (!$semester) { - $semester = Semester::findCurrent(); - } - $fullcalendar = \Studip\Calendar\Helper::getScheduleFullcalendar( $semester->id ?? '', Request::bool('show_hidden', false) @@ -190,7 +201,7 @@ class Calendar_ScheduleController extends AuthenticatedController ] ); - $event_classes = []; + $event_classes = ['schedule']; $event_title = $cycle_date->course->getFullName(); if ($course_membership) { $event_classes[] = sprintf('course-color-%u', $course_membership->gruppe); @@ -262,9 +273,21 @@ class Calendar_ScheduleController extends AuthenticatedController $this->entry->user_id = $GLOBALS['user']->id; if (!Request::submitted('save')) { //Provide good default values: - $this->entry->dow = Request::int('dow', date('N')); - $this->entry->setFormattedStart(Request::get('start', date('H:00', strtotime('+1 hour')))); - $this->entry->setFormattedEnd(Request::get('end', date('H:00', strtotime('+2 hours')))); + if (Request::submitted('start')) { + //String format + $this->entry->dow = Request::int('dow', date('N')); + $this->entry->setFormattedStart(Request::get('start', date('H:00', strtotime('+1 hour')))); + $this->entry->setFormattedEnd(Request::get('end', date('H:00', strtotime('+2 hours')))); + } elseif (Request::submitted('begin')) { + //Fullcalendar: Timestamps + $begin = Request::get('begin'); + $end = Request::get('end'); + if ($begin && $end) { + $this->entry->dow = date('N', $begin); + $this->entry->setFormattedStart(date('H:i', $begin)); + $this->entry->setFormattedEnd(date('H:i', $end)); + } + } } PageLayout::setTitle(_('Neuer Termin')); } else { diff --git a/app/views/calendar/schedule/course_info.php b/app/views/calendar/schedule/course_info.php index b8135926a3c..7cfaeae9c10 100644 --- a/app/views/calendar/schedule/course_info.php +++ b/app/views/calendar/schedule/course_info.php @@ -68,10 +68,20 @@ ['formaction' => $controller->url_for('calendar/schedule/hide_course/' . $course->id)] ) ?> <? endif ?> - <?= \Studip\LinkButton::create( - _('Direkt zur Veranstaltung'), - URLHelper::getURL('dispatch.php/course/overview', ['cid' => $course->id]) - ) ?> + <?php + $enrolment_info = $course->getEnrolmentInformation($GLOBALS['user']->id); + ?> + <? if ($enrolment_info->isEnrolmentAllowed()) : ?> + <?= \Studip\LinkButton::create( + _('Direkt zur Veranstaltung'), + URLHelper::getURL('dispatch.php/course/overview', ['cid' => $course->id]) + ) ?> + <? else : ?> + <?= \Studip\LinkButton::create( + _('Direkt zur Veranstaltung'), + URLHelper::getURL('dispatch.php/course/details', ['sem_id' => $course->id]) + ) ?> + <? endif ?> </div> </form> <? endif ?> diff --git a/app/views/calendar/schedule/index.php b/app/views/calendar/schedule/index.php index 390a0161ec1..d18ddbf3418 100644 --- a/app/views/calendar/schedule/index.php +++ b/app/views/calendar/schedule/index.php @@ -1,6 +1,15 @@ <?php /** + * @var ?Semester $semester The selected semester. * @var \Studip\Fullcalendar $fullcalendar The fullcalendar instance to be rendered. */ ?> +<? if ($semester) : ?> + <h2> + <?= studip_interpolate( + _('Mein Stundenplan im %{semester}'), + ['semester' => $semester->name] + ) ?> + </h2> +<? endif ?> <?= $fullcalendar ?> diff --git a/lib/classes/calendar/Helper.php b/lib/classes/calendar/Helper.php index dd860070982..004e2f5047b 100644 --- a/lib/classes/calendar/Helper.php +++ b/lib/classes/calendar/Helper.php @@ -133,8 +133,8 @@ class Helper return new \Studip\Fullcalendar( _('Stundenplan'), [ - 'editable' => false, - 'selectable' => false, + 'editable' => true, + 'selectable' => true, 'dialog_size' => 'auto', 'minTime' => sprintf('%02u:00', $calendar_settings['start'] ?? 8), 'maxTime' => sprintf('%02u:00', $calendar_settings['end'] ?? 20), @@ -165,6 +165,9 @@ class Helper 'full_semester_time_range' => false ] ] + ], + 'studip_urls' => [ + 'add' => \URLHelper::getURL('dispatch.php/calendar/schedule/entry/add') ] ] ); diff --git a/lib/navigation/StartNavigation.php b/lib/navigation/StartNavigation.php index 94881c8dc19..0bc9125ad51 100644 --- a/lib/navigation/StartNavigation.php +++ b/lib/navigation/StartNavigation.php @@ -273,7 +273,7 @@ class StartNavigation extends Navigation $this->addSubNavigation('profile', $navigation); - $navigation = new Navigation(_('Kalender')); + $navigation = new Navigation(_('Stundenplan')); if (Config::get()->CALENDAR_ENABLE) { $navigation->addSubNavigation('calendar', new Navigation(_('Kalender'), 'dispatch.php/calendar/calendar')); diff --git a/resources/assets/stylesheets/print.scss b/resources/assets/stylesheets/print.scss index 7f6c0434600..72044e0a6ee 100644 --- a/resources/assets/stylesheets/print.scss +++ b/resources/assets/stylesheets/print.scss @@ -125,108 +125,14 @@ td.rahmen_table_row_odd { } } -/* --- print-style for calendar api------------------------------------------ */ -#schedule { - width: 100%; - height: 100%; - - #schedule_headings { - margin-left: 41pt; - background: none; - } - - #schedule_data { - width: 100%; - table-layout: fixed; - - thead td { - text-align: center; - } - - th:first-child, td:first-child { - width: 40px; - } - - td { - vertical-align: top; - } - } - - div.schedule_entry { - position: absolute; - margin: 0; - padding: 0; - font-size: 11pt; - color: var(--black); - - dl { - height: 100%; - margin: 0; - color: var(--black) ! important; - background-color: var(--white); - border: 1px solid var(--light-gray-color-60); - overflow: hidden; - - dd { - margin: 0; - overflow: hidden; - word-wrap: break-word; - } - - dt { - background-color: transparent ! important; - } - - a:hover { - text-decoration: underline; - } - } - } - - div.schedule_day { - border-left: 1pt solid var(--black); - position: relative; - } - - div.schedule_hours { - border-top: 1px solid #ddd; - padding-bottom: 1px; - } - - div.snatch { - position: absolute; - bottom: 4pt; - text-align: center; - width: 100%; - cursor: ns-resize; - padding-bottom: 2pt; - } - - #new_entry { - position: absolute; - border: 2pt solid #E0E0F0; - width: 400pt; - height: 230pt; - background-color: #E8EEF7; - font-size: 12pt; - } - - div.new_entry { - position: absolute; - left: 50%; - top: 180pt; - margin-left: -25%; - height: 320pt; - width: 50%; - font-size: 12pt; - background-color: #E8EEF7; - border: 2pt solid #E0E0F0; - } - - div.schedule_marker { - border-bottom: 1px dotted #ddd; - border-top: 1px solid #ddd; - padding: 0; +/* course date entries in the schedule need to be styled for print view: */ +.fc-event.schedule { + &.course-color-1, &.course-color-2, &.course-color-3, &.course-color-4, + &.course-color-5, &.course-color-6, &.course-color-7, &.course-color-8, + &.course-color-9 { + color: $black; + background-color: $white; + border-color: $black; } } -- GitLab