update: add date to calendar when clicking on calendar and see who accepted the proposition

This commit is contained in:
Nathan FONTEYNE 2026-07-20 14:54:57 +02:00
parent 44dacf4196
commit f61deeac22
3 changed files with 24 additions and 3 deletions

View file

@ -67,6 +67,7 @@
<button type="button" class="icon-btn secondary modal-close" id="modal-close">&times;</button> <button type="button" class="icon-btn secondary modal-close" id="modal-close">&times;</button>
<div class="modal-date card-title" id="modal-date"></div> <div class="modal-date card-title" id="modal-date"></div>
<div id="modal-concert-section"></div> <div id="modal-concert-section"></div>
<div id="modal-rehearsal-section"></div>
<div id="modal-availability-section"> <div id="modal-availability-section">
<div class="modal-time note" id="modal-time"></div> <div class="modal-time note" id="modal-time"></div>
<div class="modal-section"> <div class="modal-section">

View file

@ -61,6 +61,20 @@ function concertLinksHtml(concert) {
`; `;
} }
function rehearsalInfoHtml(r) {
const linkArgs = { uid: `rehearsal-${r.id}`, title: 'Répétition Octane', startISO: r.startsAt, endISO: r.endsAt, location: r.location };
return `
<div class="modal-section">
<div class="modal-section-title">Répétition proposée</div>
<p class="note" style="margin:0.25rem 0 0.5rem">${r.location ? escapeHtml(r.location) + ' · ' : ''}${formatTime(r.startsAt)} ${formatTime(r.endsAt)} · Proposée par ${escapeHtml(r.proposedByName)}</p>
${rehearsalAcceptedByHtml(r)}
<div class="rehearsal-actions">
${calendarLinksMenuHtml(linkArgs, 'repetition.ics')}
</div>
</div>
`;
}
async function loadLastChecked() { async function loadLastChecked() {
const { last_checked } = await api.get('/api/calendar/last-checked'); const { last_checked } = await api.get('/api/calendar/last-checked');
const el = document.getElementById('last-checked'); const el = document.getElementById('last-checked');
@ -199,14 +213,16 @@ function renderCalendar() {
} }
cell.appendChild(dotsEl); cell.appendChild(dotsEl);
cell.addEventListener('click', () => openModal(date, slot, visible, concert)); cell.addEventListener('click', () => openModal(date, slot, visible, concert, rehearsal));
const countEl = document.createElement('div'); const countEl = document.createElement('div');
countEl.className = 'cell-count'; countEl.className = 'cell-count';
countEl.textContent = avail.length + '/' + visible.length; countEl.textContent = avail.length + '/' + visible.length;
cell.appendChild(countEl); cell.appendChild(countEl);
} else if (concert) { } else if (concert) {
cell.addEventListener('click', () => openModal(date, null, [], concert)); cell.addEventListener('click', () => openModal(date, null, [], concert, rehearsal));
} else if (rehearsal) {
cell.addEventListener('click', () => openModal(date, null, [], null, rehearsal));
} else { } else {
cell.classList.add('empty'); cell.classList.add('empty');
const lbl = document.createElement('div'); const lbl = document.createElement('div');
@ -286,7 +302,7 @@ function pollWorkflowStatus(btn, maxMs = 180000, intervalMs = 4000) {
}, intervalMs); }, intervalMs);
} }
function openModal(date, slot, visible, concert) { function openModal(date, slot, visible, concert, rehearsal) {
const avail = visible.filter((p) => p.is_available); const avail = visible.filter((p) => p.is_available);
const busy = visible.filter((p) => !p.is_available); const busy = visible.filter((p) => !p.is_available);
@ -314,6 +330,9 @@ function openModal(date, slot, visible, concert) {
const concertSection = document.getElementById('modal-concert-section'); const concertSection = document.getElementById('modal-concert-section');
concertSection.innerHTML = concert ? concertLinksHtml(concert) : ''; concertSection.innerHTML = concert ? concertLinksHtml(concert) : '';
const rehearsalSection = document.getElementById('modal-rehearsal-section');
rehearsalSection.innerHTML = rehearsal ? rehearsalInfoHtml(rehearsal) : '';
const renderPeople = (list, containerId) => { const renderPeople = (list, containerId) => {
const el = document.getElementById(containerId); const el = document.getElementById(containerId);
el.innerHTML = ''; el.innerHTML = '';

View file

@ -47,6 +47,7 @@ router.post(
location: location ? location.trim() : null, location: location ? location.trim() : null,
proposedBy: req.user.id, proposedBy: req.user.id,
}); });
await rehearsalsRepo.upsertVote(rehearsal.id, req.user.id, 'accept');
discord.notifyAll( discord.notifyAll(
discord.rehearsalProposedMessage({ userName: req.user.name, startsAt: rehearsal.starts_at, location: rehearsal.location }) discord.rehearsalProposedMessage({ userName: req.user.name, startsAt: rehearsal.starts_at, location: rehearsal.location })
); );