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

View file

@ -106,7 +106,7 @@
<div class="schedule-category"> <div class="schedule-category">
<div class="schedule-category-header" title="Déroulez"> <div class="schedule-category-header" title="Déroulez">
<div class="schedule-category-name"> <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> </div>
<svg class="schedule-category-collapse-icon" <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"> 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>
<div class="schedule-category-table"> <div class="schedule-category-table">
<div class="schedule-category-days-container"> <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-container">
<div class="schedule-category-day"> <div class="schedule-category-day">
{{ when.day }} {{ when.day }}
@ -124,8 +124,8 @@
{{ when.from }} <span class="separator">-</span> {{ when.to }} {{ when.from }} <span class="separator">-</span> {{ when.to }}
</div> </div>
</div> </div>
{% endfor %} {% endfor %} #}
{# {% for when in item.when %} {% for when in item.when %}
<div class="schedule-category-day-container"> <div class="schedule-category-day-container">
<div class="schedule-category-day"> <div class="schedule-category-day">
{{ when.day }} {{ when.day }}
@ -133,12 +133,12 @@
<div class="schedule-category-hours"> <div class="schedule-category-hours">
{% for i in when.hours %} {% for i in when.hours %}
<span> <span>
{{ i.from }} <span class="separator">-</span> {{ i.to }} {{ i.from }} <span class="separator">-</span> {{ i.to }}{% if not loop.last %},{% endif %}
</span> </span>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
{% endfor %} #} {% endfor %}
</div> </div>
</div> </div>
</div> </div>