mirror of
https://github.com/nfonteyne/octane-website.git
synced 2026-09-03 23:24:48 +02:00
update: see next concert in calendar
This commit is contained in:
parent
bf18eb4659
commit
49979fda39
2 changed files with 28 additions and 4 deletions
|
|
@ -3,6 +3,7 @@ let state = {
|
|||
slots: [],
|
||||
personIds: [],
|
||||
rehearsals: [],
|
||||
nextConcert: null,
|
||||
};
|
||||
let me = null;
|
||||
let currentModalDate = null;
|
||||
|
|
@ -23,6 +24,11 @@ async function loadRehearsals() {
|
|||
renderCalendar();
|
||||
}
|
||||
|
||||
async function loadNextConcert() {
|
||||
state.nextConcert = await api.get('/api/setlists/next');
|
||||
renderCalendar();
|
||||
}
|
||||
|
||||
async function loadLastChecked() {
|
||||
const { last_checked } = await api.get('/api/calendar/last-checked');
|
||||
const el = document.getElementById('last-checked');
|
||||
|
|
@ -64,6 +70,8 @@ function renderCalendar() {
|
|||
const rehearsalsByDate = new Map();
|
||||
for (const r of state.rehearsals) rehearsalsByDate.set(isoDate(new Date(r.startsAt)), r);
|
||||
|
||||
const nextConcertDate = state.nextConcert ? isoDate(new Date(state.nextConcert.concert_date)) : null;
|
||||
|
||||
// Grid starts on the Monday of the current week so columns align Mon->Sun.
|
||||
const start = new Date(today);
|
||||
const dow = start.getDay();
|
||||
|
|
@ -95,16 +103,28 @@ function renderCalendar() {
|
|||
dateLabel.innerHTML = `<span class="day-num">${date.getDate()}</span>${shortMonth(date)}`;
|
||||
cell.appendChild(dateLabel);
|
||||
|
||||
const badges = document.createElement('div');
|
||||
badges.className = 'cell-badges';
|
||||
|
||||
const rehearsal = rehearsalsByDate.get(isoDate(date));
|
||||
if (rehearsal) {
|
||||
cell.classList.add('has-rehearsal');
|
||||
const badge = document.createElement('div');
|
||||
badge.className = 'cell-rehearsal-badge';
|
||||
const badge = document.createElement('span');
|
||||
badge.title = 'Répétition proposée';
|
||||
badge.textContent = '🎸';
|
||||
cell.appendChild(badge);
|
||||
badges.appendChild(badge);
|
||||
}
|
||||
|
||||
if (nextConcertDate && isoDate(date) === nextConcertDate) {
|
||||
cell.classList.add('has-concert');
|
||||
const badge = document.createElement('span');
|
||||
badge.title = `Prochain concert${state.nextConcert.name ? ' : ' + state.nextConcert.name : ''}${state.nextConcert.venue ? ' (' + state.nextConcert.venue + ')' : ''}`;
|
||||
badge.textContent = '🎤';
|
||||
badges.appendChild(badge);
|
||||
}
|
||||
|
||||
if (badges.childElementCount) cell.appendChild(badges);
|
||||
|
||||
if (isPastDay) {
|
||||
cell.classList.add('empty');
|
||||
const lbl = document.createElement('div');
|
||||
|
|
@ -565,6 +585,7 @@ async function onRemoveMyFeed(feedId) {
|
|||
await loadPeople();
|
||||
buildFilters();
|
||||
await loadRehearsals();
|
||||
await loadNextConcert();
|
||||
await loadSlots();
|
||||
await loadLastChecked();
|
||||
await loadMyFeeds();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue