From 99a3b9d4f4ce290cb04a0d940bf4f3e0fbb1c716 Mon Sep 17 00:00:00 2001
From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de>
Date: Tue, 10 Dec 2024 18:39:33 +0100
Subject: [PATCH] avoid displaying 01.01.1970 for `null` values, fixes #267

---
 controllers/api.php |  4 ++--
 js/test-block.js    | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/controllers/api.php b/controllers/api.php
index 2d9fa6f..59c74dc 100644
--- a/controllers/api.php
+++ b/controllers/api.php
@@ -29,7 +29,7 @@ class ApiController extends StudipController
                     'type'   => $assignment->type,
                     'icon'   => $assignment->getTypeIcon()->getShape(),
                     'start'  => date('d.m.Y, H:i', strtotime($assignment->start)),
-                    'end'    => date('d.m.Y, H:i', strtotime($assignment->end)),
+                    'end'    => $assignment->end ? date('d.m.Y, H:i', strtotime($assignment->end)) : null,
                     'active' => $assignment->active,
                     'block'  => $assignment->block_id ? $assignment->block->name : null
                 ];
@@ -67,7 +67,7 @@ class ApiController extends StudipController
             'type'           => $assignment->type,
             'icon'           => $assignment->getTypeIcon()->getShape(),
             'start'          => date('d.m.Y, H:i', strtotime($assignment->start)),
-            'end'            => date('d.m.Y, H:i', strtotime($assignment->end)),
+            'end'            => $assignment->end ? date('d.m.Y, H:i', strtotime($assignment->end)) : null,
             'active'         => $assignment->active,
             'block'          => $assignment->block_id ? $assignment->block->name : null,
             'reset_allowed'  => $assignment->isRunning($user_id) && $assignment->isResetAllowed(),
diff --git a/js/test-block.js b/js/test-block.js
index 25efc11..68758bf 100644
--- a/js/test-block.js
+++ b/js/test-block.js
@@ -77,19 +77,19 @@ const CoursewareTestBlock = {
                             class="cw-vs-select"
                         >
                             <template #open-indicator="selectAttributes">
-                                <studip-icon shape="arr_1down" size="10"/>
+                                <studip-icon shape="arr_1down" size="16"/>
                             </template>
                             <template #no-options="{}">
                                 <translate>Es steht keine Auswahl zur Verfügung</translate>
                             </template>
                             <template #selected-option="{title, icon, start, end}">
-                                <studip-icon :shape="icon" role="info"/>
-                                {{title}} ({{start}} - {{end}})
+                                <studip-icon v-if="icon" :shape="icon" role="info"/>
+                                {{title}} ({{start}}{{ end ? ' - ' + end : '' }})
                             </template>
                             <template #option="{title, icon, start, end, block}">
-                                <studip-icon :shape="icon" role="info"/>
+                                <studip-icon v-if="icon" :shape="icon" role="info"/>
                                 {{ block ? block + ' / ' + title : title }}<br>
-                                <small>{{start}} - {{end}}</small>
+                                <small>{{start}}{{ end ? ' - ' + end : '' }}</small>
                             </template>
                         </studip-select>
                     </label>
-- 
GitLab