From 5a5bed0db999d90ee00cd7eedee74fd825bdb67a Mon Sep 17 00:00:00 2001
From: Hangzhi <hangzhi@protonmail.com>
Date: Wed, 10 Apr 2019 14:39:03 +0200
Subject: [PATCH] display five individual timetables for every day instead of
 one timetable for every day on mobile devices

---
 .../templates/timetable/datepicker.html       |  2 +-
 .../chronos/templates/timetable/lesson.html   |  4 ++
 .../chronos/templates/timetable/plan.html     | 47 ++++++++++++++++++-
 biscuit/apps/chronos/views.py                 |  1 -
 4 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/biscuit/apps/chronos/templates/timetable/datepicker.html b/biscuit/apps/chronos/templates/timetable/datepicker.html
index b30a0aa9..6b0de340 100644
--- a/biscuit/apps/chronos/templates/timetable/datepicker.html
+++ b/biscuit/apps/chronos/templates/timetable/datepicker.html
@@ -57,7 +57,7 @@
 </script>
 
 
-<div class="col s2">
+<div class="col s2" style="display: initial;">
     <a class="waves-effect waves-teal btn-flat btn-flat-medium left" id="date-before">
         <i class="material-icons center">navigate_before</i>
     </a>
diff --git a/biscuit/apps/chronos/templates/timetable/lesson.html b/biscuit/apps/chronos/templates/timetable/lesson.html
index aa4f59a8..1eda3c99 100644
--- a/biscuit/apps/chronos/templates/timetable/lesson.html
+++ b/biscuit/apps/chronos/templates/timetable/lesson.html
@@ -25,10 +25,12 @@
 
                             {# Class or room > Display teacher #}
                             {% if type == 2 or type == 1 %}
+                                {% if element_container.element.teacher %}
                                 <span data-position="bottom" class="tooltipped"
                                       data-tooltip="{{ element_container.element.teacher }}"><a
                                         href="{% url "timetable_smart_plan" "teacher" element_container.element.teacher.id %}">{{ element_container.element.teacher.shortcode }}</a></span>
                                 <br>
+                                {% endif %}
                             {% endif %}
 
                             {# Badge #}
@@ -81,12 +83,14 @@
 
                         {# Class or room > Display teacher #}
                         {% if type == 2 or type == 1 %}
+                            {% if element_container.element.teacher %}
                             <span data-position="bottom" class="tooltipped"
                                   data-tooltip="{{ element_container.element.teacher }}">
                                 <a href="{% url "timetable_smart_plan" "teacher" element_container.element.teacher.id %}">
                                     {{ element_container.element.teacher.shortcode }}
                                 </a>
                             </span>
+                            {% endif %}
                         {% endif %}
 
                         {# Display subject #}
diff --git a/biscuit/apps/chronos/templates/timetable/plan.html b/biscuit/apps/chronos/templates/timetable/plan.html
index 9d4073da..f5e6d8e2 100755
--- a/biscuit/apps/chronos/templates/timetable/plan.html
+++ b/biscuit/apps/chronos/templates/timetable/plan.html
@@ -118,7 +118,8 @@
             </a>
         {% endif %}
     </div>
-    <div class="timetable-plan">
+    {# show full timetable on tablets, laptops and pcs #}
+    <div class="timetable-plan hide-on-small-and-down">
 
         {#  Week days #}
         <div class="row">
@@ -143,7 +144,7 @@
                     <div class="card timetable-title-card">
                         <div class="card-content">
                     <span class="card-title">
-                        {{ long_week_day }}
+                        {{ long_week_day.0 }}
                     </span>
                         </div>
                     </div>
@@ -181,6 +182,48 @@
             </div>
         {% endfor %}
     </div>
+    {# show 5 seperate ones on mobiles #}
+    <div class="timetable-plan hide-on-med-and-up">
+        {% for long_week_day in long_week_days %}
+            <div class="card timetable-mobile-title-card">
+                <div class="card-content">
+                    <span class="card-title">
+                        {{ long_week_day.0 }}
+                    </span>
+                </div>
+            </div>
+            {% for row, time in plan %}
+                <div class="row">
+                    <div class="col s4">
+                        <div class="card timetable-title-card">
+                            <div class="card-content">
+
+                                {# Lesson number #}
+                                <span class="card-title left">
+                                {{ time.number_format }}
+                             </span>
+
+                                {# Time dimension of lesson #}
+                                <div class="right timetable-time grey-text text-darken-2">
+                                    <span>{{ time.start|date:"H:i" }}</span><br>
+                                    <span>{{ time.end|date:"H:i" }}</span>
+                                </div>
+                            </div>
+                        </div>
+
+                    </div>
+                    {% for col in row %}
+                        {% if forloop.counter0 == long_week_day.1 %}
+                            <div class="col s8">
+                                {# A lesson #}
+                                {% include "timetable/lesson.html" %}
+                            </div>
+                        {% endif %}
+                    {% endfor %}
+                </div>
+            {% endfor %}
+        {% endfor %}
+    </div>
 </main>
 
 {% include 'partials/footer.html' %}
diff --git a/biscuit/apps/chronos/views.py b/biscuit/apps/chronos/views.py
index 57c4c092..8166392f 100755
--- a/biscuit/apps/chronos/views.py
+++ b/biscuit/apps/chronos/views.py
@@ -166,7 +166,6 @@ def my_plan(request, year=None, day=None, month=None):
         "el": el,
         "times": parse_lesson_times(),
         "week_day": date.isoweekday() - 1,
-        "week_days": WEEK_DAYS,
         "date": date,
         "date_js": int(date.timestamp()) * 1000,
         "display_date_only": True
-- 
GitLab