fix: schedule hours merging

This commit is contained in:
Matthieu Bessat 2020-08-04 12:24:58 +02:00
parent 4817bc216d
commit 9c403260b7
2 changed files with 25 additions and 30 deletions

View file

@ -142,27 +142,22 @@ export default class PublicController {
// TODO: Rassembler les horaires qui sont dans le même jour, uniquement pour le front
// version.schedule = version.schedule.map((s: any) => {
// let newWhens: any = []
// console.log(s)
// // s.when.foreach((w: any) => {
// // // if there is already a when with the same day add it
// // let scheduleObject: any = { from: w.from, to: w.to }
// // if (newWhens.filter((_n: any) => _n.day === w.day).length > 0) {
// // newWhens.map((newWhen: any) => {
// // if (newWhen.day === w.day) {
// // newWhen.hours.push(scheduleObject)
// // }
// // return newWhen
// // })
// // } else {
// // w.hours = [scheduleObject]
// // newWhens.push(w)
// // }
// // })
// // s.when = newWhens
// return s
// })
version.schedule = version.schedule.map((s: any) => {
let days = [...new Set(s.when.map((w: any) => w.day))]
return {
when: days.map((day: any) => {
return {
day,
wow: 'wow',
hours: s.when
.filter((w: any) => w.day === day)
.map((hour: any) => { return { from: hour.from, to: hour.to } })
}
}),
name: s.name,
description: s.description
}
})
// if (version.cutDescription) {
// version.descriptionFirstHalf = version.descriptionLong.substr(0, 200) // not gonna lie

View file

@ -106,7 +106,7 @@
<div class="schedule-category">
<div class="schedule-category-header" title="Déroulez">
<div class="schedule-category-name">
{{ item.name }} <span class="separator">-</span> {{ item.description }}
{{ item.name }} {% if item.description is not empty %}<span class="separator">-</span> {{ item.description }}{% endif %}
</div>
<svg class="schedule-category-collapse-icon"
aria-hidden="true" focusable="false" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
@ -115,7 +115,7 @@
</div>
<div class="schedule-category-table">
<div class="schedule-category-days-container">
{% for when in item.when %}
{# {% for when in item.when %}
<div class="schedule-category-day-container">
<div class="schedule-category-day">
{{ when.day }}
@ -124,8 +124,8 @@
{{ when.from }} <span class="separator">-</span> {{ when.to }}
</div>
</div>
{% endfor %}
{# {% for when in item.when %}
{% endfor %} #}
{% for when in item.when %}
<div class="schedule-category-day-container">
<div class="schedule-category-day">
{{ when.day }}
@ -133,12 +133,12 @@
<div class="schedule-category-hours">
{% for i in when.hours %}
<span>
{{ i.from }} <span class="separator">-</span> {{ i.to }}
{{ i.from }} <span class="separator">-</span> {{ i.to }}{% if not loop.last %},{% endif %}
</span>
{% endfor %}
</div>
</div>
{% endfor %} #}
{% endfor %}
</div>
</div>
</div>