From ebd725b0d34de8f98709105d38765a0b87f498d4 Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Sat, 29 Aug 2020 21:27:38 +0200 Subject: [PATCH] feat(PublicPage): add schedule parts system for page with a lot of schedule (dense schedule) --- assets/development/styles/organization.css | 18 +++++ src/controllers/PublicController.ts | 11 +++ views/organization.twig | 92 +++++++++++----------- 3 files changed, 77 insertions(+), 44 deletions(-) diff --git a/assets/development/styles/organization.css b/assets/development/styles/organization.css index ac388dd..773b051 100644 --- a/assets/development/styles/organization.css +++ b/assets/development/styles/organization.css @@ -478,6 +478,17 @@ section { ********************************************************************************/ +.schedule.dense { + display: grid; + grid-template-columns: repeat(2, 1fr); + width: 100%; + column-gap: 1em; +} + +.schedule.dense .schedule-category-days-container { + margin-right: 7em; +} + .schedule-category { margin-bottom: 1em; } @@ -952,6 +963,13 @@ RESPONSIVE width: 80%; } + /** + Schedule + **/ + .schedule.dense { + grid-template-columns: 1fr; + } + .schedule-category-header { padding-left: 1em; padding-right: 1em; diff --git a/src/controllers/PublicController.ts b/src/controllers/PublicController.ts index 2c5eeac..1f96a9f 100644 --- a/src/controllers/PublicController.ts +++ b/src/controllers/PublicController.ts @@ -237,6 +237,17 @@ export default class PublicController { }) } + if (version.schedule.length > 8) { + let isFirst = true; + version.scheduleParts = [[], []] + version.schedule.forEach((schedule: any) => { + version.scheduleParts[isFirst ? 0 : 1].push(schedule) + isFirst = !isFirst + }) + } else { + version.scheduleParts = [version.schedule] + } + version.cutDescription = Utils.isStrUsable(version, 'descriptionLong') && version.descriptionLong.length > 800 // if (version.cutDescription) { diff --git a/views/organization.twig b/views/organization.twig index d43d99a..fad5c83 100644 --- a/views/organization.twig +++ b/views/organization.twig @@ -149,54 +149,58 @@

Crénaux

-
- {% for item in data.schedule %} - {% if item.when|length > 0 %} -
-
-
- {{ item.name|e }} - {% if item.description is not empty %} - - {{ item.description|e }} - {% endif %} +
+ {% for schedules in data.scheduleParts %} +
+ {% for item in schedules %} + {% if item.when|length > 0 %} +
+
+
+ {{ item.name|e }} + {% if item.description is not empty %} + - {{ item.description|e }} + {% endif %} +
+
+ +
-
- -
-
-
-
- {# {% for when in item.when %} -
-
- {{ when.day }} -
-
- {{ when.from }} - {{ when.to }} -
-
- {% endfor %} #} - {% for when in item.when %} -
-
- {{ when.day|e }} -
-
- {% for i in when.hours %} - - {{ i.from|e }} - {{ i.to|e }}{% if not loop.last %},{% endif %} - - {% endfor %} -
-
- {% endfor %} +
+
+ {# {% for when in item.when %} +
+
+ {{ when.day }} +
+
+ {{ when.from }} - {{ when.to }} +
+
+ {% endfor %} #} + {% for when in item.when %} +
+
+ {{ when.day|e }} +
+
+ {% for i in when.hours %} + + {{ i.from|e }} - {{ i.to|e }}{% if not loop.last %},{% endif %} + + {% endfor %} +
+
+ {% endfor %} +
+ {% endif %} + {% endfor %}
- {% endif %} {% endfor %}