From 07446570c1d4cf1f39649d0431d4c2c8d6ffc546 Mon Sep 17 00:00:00 2001 From: Anthony Correa Date: Mon, 27 May 2024 15:04:34 -0500 Subject: [PATCH] add clear lineup/availabilities, availability reminders --- src/controllers/event.js | 38 +- src/controllers/eventlineup.js | 29 ++ src/public/js/eventlineup.js | 471 +++++------------- src/routes/event.js | 3 + src/routes/eventlineup.js | 1 + src/routes/index.js | 6 + .../partials/modal_availability_reminders.hbs | 38 ++ src/views/eventlineup/edit.hbs | 20 +- src/views/modal_confirm.hbs | 19 + 9 files changed, 266 insertions(+), 359 deletions(-) create mode 100644 src/views/event/partials/modal_availability_reminders.hbs create mode 100644 src/views/modal_confirm.hbs diff --git a/src/controllers/event.js b/src/controllers/event.js index 4c61301..5011b05 100644 --- a/src/controllers/event.js +++ b/src/controllers/event.js @@ -21,6 +21,10 @@ exports.helpers = { exports.partials = path.join(__dirname, "../views/event/partials") +exports.confirmModalAvailabilityReminders = async (req, res) => { + res.status(200).render("event/partials/modal_availability_reminders") +} + exports.getEvents = async (req, res, next) => { const {user, team, layout} = req const bulkLoadTypes = ["event", "availabilitySummary"] @@ -70,19 +74,49 @@ exports.getEvent = async (req, res, next) => { exports.sendAvailabilityReminders = async (req,res,next) => { await Promise.all(req.promises) + if (!req.body || ! (req.body.event_id && req.body.memberIds)) { + res.status(400).send('Malformed post') + } if (req.params.event_id != req.body.eventId) { // Load actual event. Do I want this to be an error? probably - res.status(500).send() + res.status(400).send('Event ID parameter does not match the POST body') + return; } const {event} = req const {eventId, memberIds} = req.body const sendingMember = req.members.find(m=>m.userId==req.user.id) try { - await teamsnap.sendAvailabilityReminders(event, sendingMember, memberIds) + // await teamsnap.sendAvailabilityReminders(event, sendingMember, memberIds) res.status(200).send('OK') } catch (err) { res.status(500).send() } return +} + +exports.submitResetAvailabilities = async (req,res,next) => { + await Promise.all(req.promises) + if (!req.body || ! (req.body.event_id && req.body.memberIds)) { + res.status(400).send('Malformed post') + } + + if (req.params.event_id != req.body.event_id) { + // Load actual event. Do I want this to be an error? probably + res.status(400).send('Event ID parameter does not match the POST body'); + return + } + + const {event_id, memberIds} = req.body + const reset_promises = [] + + const availabilities = await teamsnap.loadAvailabilities({eventId: event_id}, teamsnapCallback); + + availabilities.filter(availability =>memberIds.includes(availability.memberId.toString())).forEach( availability => { + availability.statusCode = teamsnap.AVAILABILITIES.NONE + const promise = teamsnap.saveAvailability(availability, teamsnapCallback) + reset_promises.push(promise) + }) + await Promise.all(reset_promises) + .then(res.status(200).send('OK')) } \ No newline at end of file diff --git a/src/controllers/eventlineup.js b/src/controllers/eventlineup.js index 3fbf38b..4314330 100644 --- a/src/controllers/eventlineup.js +++ b/src/controllers/eventlineup.js @@ -164,4 +164,33 @@ const processPostedEventLineupEntries = (body, eventLineupEntries, eventLineup) } }) return {newEventLineupEntries, eventLineupEntries, deleteEventLineupEntries} +} + +exports.submitDeleteEventLineupEntries = async (req,res) => { + await Promise.all(req.promises); + const {event_lineup, event_lineup_entries} = req + let event_id + let memberIds + + if (!req.body || ! (req.body.event_id && req.body.memberIds)) { + res.status(400).send('Malformed post') + } else if (req.params.event_id != req.body.event_id) { + // Load actual event. Do I want this to be an error? probably + res.status(400).send('Event ID parameter does not match the POST body'); + return + } else { + event_id = req.body.event_id + memberIds = req.body.memberIds + } + + const deletion_promises = [] + + event_lineup_entries.filter(entry =>memberIds.includes(entry.memberId.toString())).forEach( entry => { + const promise = teamsnap.deleteEventLineupEntry(entry, teamsnapCallback) + deletion_promises.push(promise) + }) + + await Promise.all(deletion_promises) + .then(res.status(202).send('OK')) + } \ No newline at end of file diff --git a/src/public/js/eventlineup.js b/src/public/js/eventlineup.js index df5034b..0226599 100644 --- a/src/public/js/eventlineup.js +++ b/src/public/js/eventlineup.js @@ -110,149 +110,104 @@ function refreshFlags(){ } -function copyEmailTable(itemEl, subject, recipients) { - // Create container for the HTML - // [1] - let bcLineup = itemEl.closest(".benchcoach-lineup"); - var container = document.createElement("div"); - var tbl = document.createElement("table"); - - let thead = tbl.createTHead(); - let thead_row = thead.insertRow(); - let thead_row_cell = thead_row.insertCell(); - thead_row_cell.appendChild(document.createElement("h3").appendChild(document.createTextNode("STARTING LINEUP"))); - thead_row_cell.colSpan = 3; - thead_row_cell.classList.add("title-cell"); - var tbody = tbl.createTBody(); - for (row of bcLineup.querySelector(".table-benchcoach-startinglineup").rows) { - let tr = tbody.insertRow(); - cell = tr.insertCell(); - cell.classList.add("sequence-cell"); - cell.appendChild(document.createTextNode(parseInt(row.dataset.order) + 1)); - cell = tr.insertCell(); - cell.appendChild(document.createTextNode(row.dataset.playerName)); - cell.classList.add("name-cell"); - tr.insertCell().appendChild(document.createTextNode(row.dataset.position)); - } - - if (bcLineup.querySelector(".table-benchcoach-startingpositionalonly").rows.length > 0) { - var tr = tbody.insertRow(); - cell = tr.insertCell(); - cell.colSpan = 3; - cell.appendChild(document.createTextNode("STARTING (POS. ONLY)")); - cell.classList.add("title-cell"); - - for (row of bcLineup.querySelector(".table-benchcoach-startingpositionalonly").rows) { - var tr = tbody.insertRow(); - cell = tr.insertCell(); - cell.classList.add("sequence-cell"); - cell.appendChild(document.createTextNode("")); - cell = tr.insertCell(); - cell.appendChild(document.createTextNode(row.dataset.playerName)); - cell.classList.add("name-cell"); - tr.insertCell().appendChild(document.createTextNode(row.dataset.position)); +function openAvailabilityReminderModal (el, team_id, event_id) { + const url = `/${team_id}/event/${event_id}/modal-confirm-availability-reminders/` + const form = el.closest('form') + const form_data = new FormData (form) + fetch(url) + .then((response) => { + if (response.ok) { + return response.text(); + } else { + return Promise.reject(response.text()); } - } + }) + .then((html) => { + const parser = new DOMParser() + const modal = parser.parseFromString(html, 'text/html') + const modal_node = modal.firstElementChild.querySelector('#modal') + modal_node.classList.add('is-open') + const modal_node_accept = modal.querySelector('Button[data-confirm=yes]') + const checked = Array.from(el.querySelectorAll('input:checked')).map + const body = document.querySelector('body') + body.appendChild(modal_node) + modal_node_accept.addEventListener( + "click", ()=>{ + // const memberIds = form_data.getAll('memberId') + const csrf_token = form_data.get('csrfToken') + const selected_status_codes = Array.from(document.querySelectorAll('input:checked')).map(e=>e.value) + const slots = Array.from(document.querySelectorAll('.lineup-slot')).filter( + slot =>{ + const slot_status_code = slot.querySelector('input[name=availabilityStatusCode]').value + return selected_status_codes.includes(slot_status_code) + } + ) + const memberIds = slots.map( + slot => slot.querySelector('input[name=memberId]').value + ) + + console.log("sending reminders", el, event_id, memberIds, csrf_token) + sendAvailabilityReminder(el, event_id, memberIds, csrf_token) + body.removeChild(modal_node) + } + ) + }) + +} - if (bcLineup.querySelector(".table-benchcoach-bench").rows.length > 0) { - var tr = tbody.insertRow(); - cell = tr.insertCell(); - cell.colSpan = 3; - cell.appendChild(document.createTextNode("SUBS")); - cell.classList.add("title-cell"); +function confirmModal(prompt, fn, options) { + const url = "/modal-confirm" + const params = new URLSearchParams(prompt) + url.search = params.toString() - for (row of bcLineup.querySelector(".table-benchcoach-bench").rows) { - var tr = tbody.insertRow(); - cell = tr.insertCell(); - cell.classList.add("sequence-cell"); - availability_status = { - None: "UNK", - 0: "NO", - 2: "MAY", - 1: "YES", - }[row.dataset.availabilityStatuscode]; - cell.appendChild(document.createTextNode(availability_status)); - cell = tr.insertCell(); - cell.appendChild(document.createTextNode(row.dataset.playerName)); - cell.classList.add("name-cell"); - tr.insertCell().appendChild(document.createTextNode("")); + fetch(url+"?"+params.toString(), {method:"GET"}) + .then((response) => { + if (response.ok) { + return response.text(); + } else { + return Promise.reject(response.text()); } - } + }) + .then((html) => { + const parser = new DOMParser() + const modal = parser.parseFromString(html, 'text/html') + const modal_node = modal.firstElementChild.querySelector('#modal') + modal_node.classList.add('is-open') + const modal_node_accept = modal.querySelector('Button[data-confirm=yes]') + const body = document.querySelector('body') + body.appendChild(modal_node) + modal_node_accept.addEventListener("click", ()=>{fn(options);body.removeChild(modal_node)}) + }) +} - if (bcLineup.querySelector(".table-benchcoach-out").rows.length > 0) { - var tr = tbody.insertRow(); - cell = tr.insertCell(); - cell.colSpan = 3; - cell.appendChild(document.createTextNode("OUT")); - cell.classList.add("title-cell"); +function submitClearLineup(options){ + console.log('clearing lineup...') + const {team_id, event_id, event_lineup_id} = options + const url = `/${team_id}/event/${event_id}/lineup/${event_lineup_id}/delete` + const form = document.querySelector(`#event-lineup-${event_id} form`); + const data = new FormData(form); + const memberIds = data.getAll('memberId') - for (row of bcLineup.querySelector(".table-benchcoach-out").rows) { - var tr = tbody.insertRow(); - cell = tr.insertCell(); - cell.classList.add("sequence-cell"); - availability_status = { - None: "UNK", - 0: "NO", - 1: "MAY", - 2: "YES", - }[row.dataset.availabilityStatuscode]; - cell.appendChild(document.createTextNode(availability_status)); - tr.insertCell().appendChild(document.createTextNode(row.dataset.playerName)); - tr.insertCell().appendChild(document.createTextNode("")); - } - } + console.log(url) + fetch(url, {method:"POST", body: JSON.stringify({memberIds, event_id}), headers: {"Content-Type": "application/json"}}) + .finally(()=>{location.reload()});//refresh page +} - container.appendChild(tbl); - for (cell of container.getElementsByClassName("title-cell")) { - cell.setAttribute("style", "font-weight:bold;background-color:#323669;color:#fff;padding:2px 5px;"); - } +function submitResetAvailabilities(options){ + const {team_id, event_id} = options + const url = `/${team_id}/event/${event_id}/reset_availabilities` + const form = document.querySelector(`#event-lineup-${event_id} form`); + const data = new FormData(form); + const memberIds = data.getAll('memberId') - for (cell of container.getElementsByClassName("sequence-cell")) { - cell.setAttribute("style", "font-weight:bold;padding:2px 5px;"); - } - - for (cell of container.getElementsByClassName("name-cell")) { - cell.setAttribute("style", "width:200px;"); - } - - // Detect all style sheets of the page - var activeSheets = Array.prototype.slice.call(document.styleSheets).filter(function (sheet) { - return !sheet.disabled; - }); - - // Mount the container to the DOM to make `contentWindow` available - // [3] - document.body.appendChild(container); - - // Copy to clipboard - // [4] - window.getSelection().removeAllRanges(); - - var range = document.createRange(); - range.selectNode(container); - window.getSelection().addRange(range); - - // [5.1] - document.execCommand("copy"); - - // [5.2] - for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = true; - - // [5.3] - // document.execCommand('copy') - - // [5.4] - for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = false; - - // Remove the container - // [6] - document.body.removeChild(container); - subject_encoded = encodeURIComponent(subject); - window.open("readdle-spark://compose?recipient=manager@chihounds.com&subject=" + subject + "&bcc=" + recipients); + console.log('submitting...', url) + fetch(url, {method:"POST", body: JSON.stringify({memberIds, event_id}), headers: {"Content-Type": "application/json"}}) + .finally(()=>{location.reload()});//refresh page } function emailModal(el, url) { form = el.closest("form"); + console.log(form) data = new FormData(form); fetch(url, { @@ -278,17 +233,15 @@ function emailModal(el, url) { email_modal_node.classList.add('is-open') body.appendChild(email_modal_node) tinymce.init({ - selector:`#lineup-email-data-${data.get('event_lineup_id')} #email-editor`, + selector:`textarea#email-editor`, content_css:"/css/application.css", plugins: 'image', menubar: false, toolbar: 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | outdent indent | image', paste_data_images: true, statusbar:false}) - // tinymce.activeEditor.setContent("Team,") - // lineup_table_div.innerHTML = lineup_table - // email_modal.classList.add("is-open"); - // email_modal.querySelector(".Modal-body").innerHTML = html; + tinymce.remove(); + }); } @@ -340,184 +293,6 @@ async function onSubmit(form, event) { }, 3000) } -function copyEmailTable(itemEl, subject, recipients) { - // Create container for the HTML - // [1] - let bcLineup = itemEl.closest(".event-lineup"); - var container = document.createElement("div"); - var tbl = document.createElement("table"); - - let thead = tbl.createTHead(); - let thead_row = thead.insertRow(); - let thead_row_cell = thead_row.insertCell(); - thead_row_cell.appendChild(document.createElement("h3").appendChild(document.createTextNode("STARTING LINEUP"))); - thead_row_cell.colSpan = 3; - thead_row_cell.classList.add("title-cell"); - var tbody = tbl.createTBody(); - - lineup_slots_starting = bcLineup.querySelectorAll(".starting .slot-set .lineup-slot"); - - for (node of lineup_slots_starting) { - console.log("node", node); - let tr = tbody.insertRow(); - cell = tr.insertCell(); - cell.classList.add("sequence-cell"); - sequence = node.querySelector("input[name*='sequence']").value; - console.log(sequence); - cell.appendChild(document.createTextNode(parseInt(sequence) + 1)); - name = node.querySelector("div:has(.lastname)"); - cell = tr.insertCell(); - cell.appendChild(document.createTextNode(name.textContent)); - cell.classList.add("name-cell"); - position_label = node.querySelector("input[name*='label']").value; - tr.insertCell().appendChild(document.createTextNode(position_label)); - } - - lineup_slots_position_only = bcLineup.querySelector(".position-only .slot-set .lineup-slot"); - console.log("lineup slots position", lineup_slots_position_only); - if (lineup_slots_position_only.length > 0) { - var tr = tbody.insertRow(); - cell = tr.insertCell(); - cell.colSpan = 3; - cell.appendChild(document.createTextNode("STARTING (POS. ONLY)")); - cell.classList.add("title-cell"); - - for (node of lineup_slots_position_only) { - var tr = tbody.insertRow(); - cell = tr.insertCell(); - cell.classList.add("sequence-cell"); - cell.appendChild(document.createTextNode("")); - cell = tr.insertCell(); - name = node.querySelector("div:has(.lastname)"); - cell.appendChild(document.createTextNode(name.textCotent)); - cell.classList.add("name-cell"); - position_label = node.querySelector("input[name*='label']").value; - tr.insertCell().appendChild(document.createTextNode(position_label)); - } - } - - lineup_slots_bench = bcLineup.querySelector(".bench .slot-set .lineup-slot"); - if (lineup_slots_bench > 0) { - var tr = tbody.insertRow(); - cell = tr.insertCell(); - cell.colSpan = 3; - cell.appendChild(document.createTextNode("SUBS")); - cell.classList.add("title-cell"); - - for (node of lineup_slots_bench) { - var tr = tbody.insertRow(); - cell = tr.insertCell(); - cell.classList.add("sequence-cell"); - - div_avail_code = node.querySelector("div[class*='availability-status-code']"); - if (div_with_avail_code.classList.includes("availability-status-code-1")) { - cell.appendChild(document.createTextNode("YES")); - } else if (div_with_avail_code.classList.includes("availability-status-code-2")) { - cell.appendChild(document.createTextNode("MAY")); - } else if (div_with_avail_code.classList.includes("availability-status-code-0")) { - cell.appendChild(document.createTextNode("NO")); - } else { - cell.appendChild(document.createTextNode("UNK")); - } - cell = tr.insertCell(); - name = node.querySelector("div:has(.lastname)"); - cell.appendChild(document.createTextNode(name.textCotent)); - cell.classList.add("name-cell"); - tr.insertCell().appendChild(document.createTextNode("")); - } - } - - lineup_slots_out = bcLineup.querySelector(".out .slot-set .lineup-slot"); - if (lineup_slots_out > 0) { - var tr = tbody.insertRow(); - cell = tr.insertCell(); - cell.colSpan = 3; - cell.appendChild(document.createTextNode("OUT")); - cell.classList.add("title-cell"); - - for (node of lineup_slots_out) { - var tr = tbody.insertRow(); - cell = tr.insertCell(); - cell.classList.add("sequence-cell"); - div_avail_code = node.querySelector("div[class*='availability-status-code']"); - if (div_with_avail_code.classList.includes("availability-status-code-1")) { - cell.appendChild(document.createTextNode("YES")); - } else if (div_with_avail_code.classList.includes("availability-status-code-2")) { - cell.appendChild(document.createTextNode("MAY")); - } else if (div_with_avail_code.classList.includes("availability-status-code-0")) { - cell.appendChild(document.createTextNode("NO")); - } else { - cell.appendChild(document.createTextNode("UNK")); - } - cell = tr.insertCell(); - name = node.querySelector("div:has(.lastname)"); - cell.appendChild(document.createTextNode(name.textCotent)); - cell.classList.add("name-cell"); - tr.insertCell().appendChild(document.createTextNode("")); - } - } - - container.appendChild(tbl); - for (cell of container.getElementsByClassName("title-cell")) { - cell.setAttribute("style", "font-weight:bold;background-color:#323669;color:#fff;padding:2px 5px;"); - } - - for (cell of container.getElementsByClassName("sequence-cell")) { - cell.setAttribute("style", "font-weight:bold;padding:2px 5px;"); - } - - for (cell of container.getElementsByClassName("name-cell")) { - cell.setAttribute("style", "width:200px;"); - } - - // Detect all style sheets of the page - var activeSheets = Array.prototype.slice.call(document.styleSheets).filter(function (sheet) { - return !sheet.disabled; - }); - - // Mount the container to the DOM to make `contentWindow` available - // [3] - document.body.appendChild(container); - - // Copy to clipboard - // [4] - window.getSelection().removeAllRanges(); - - var range = document.createRange(); - range.selectNode(container); - window.getSelection().addRange(range); - - // [5.1] - document.execCommand("copy"); - - // [5.2] - for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = true; - - // [5.3] - // document.execCommand('copy') - - // [5.4] - for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = false; - - // Remove the container - // [6] - document.body.removeChild(container); - subject_encoded = encodeURIComponent(subject); - window.open("readdle-spark://compose?recipient=manager@chihounds.com&subject=" + subject + "&bcc=" + recipients); -} - -function toggleChildSlots (element) { - console.log(element); - console.log(element.closest(".slot-set")) - for (lineup_slot of document.querySelectorAll("[id^=lineup-out] .lineup-slot")) { - console.log(lineup_slot) - const cells = lineup_slot.querySelectorAll('.Panel-cell:has(.sequence), .Panel-cell:has(.drag-handle), .Panel-cell:has(.position-select-box), button:has(+.position-label-flags)') - Array.from(cells).forEach(cell=>{ - cell.classList.toggle('u-hidden') - }) - } -} - async function copyEmailTable (element) { // range=document.createRange(); // window.getSelection().removeAllRanges(); @@ -581,6 +356,30 @@ async function copyEmailTable (element) { window.getSelection().removeAllRanges(); } +function toggleChildSlots (element) { + console.log(element); + console.log(element.closest(".slot-set")) + for (lineup_slot of document.querySelectorAll("[id^=lineup-out] .lineup-slot")) { + console.log(lineup_slot) + const cells = lineup_slot.querySelectorAll('.Panel-cell:has(.sequence), .Panel-cell:has(.drag-handle), .Panel-cell:has(.position-select-box), button:has(+.position-label-flags)') + Array.from(cells).forEach(cell=>{ + cell.classList.toggle('u-hidden') + }) + } +} + + +function initSlots () { + const slots = Array.from(document.querySelectorAll('.lineup-slot')) + slots.forEach(slot=>{ + if (slot.dataset.initialSlotset) { + const parent = document.querySelector(`#${slot.dataset.initialSlotset} .slot-set`) + parent.appendChild(slot) + slot.removeAttribute('data-initial-slotset') + } + }) +} + function insertLineup(direction, teamId, eventId, element) { const currentUrl = window.location.href; let search_params @@ -636,27 +435,6 @@ function insertLineup(direction, teamId, eventId, element) { } -function initSlots () { - const slots = Array.from(document.querySelectorAll('.lineup-slot')) - slots.forEach(slot=>{ - if (slot.dataset.initialSlotset) { - const parent = document.querySelector(`#${slot.dataset.initialSlotset} .slot-set`) - parent.appendChild(slot) - slot.removeAttribute('data-initial-slotset') - } - }) -} - -function openAvailabilityReminderModal (el, event_id) { - console.log(el) - const form = el.closest("form"); - console.log(`#availability-reminder-modal-${event_id}`) - data = new FormData(form); - const modal = form.querySelector(`#availability-reminder-modal-${event_id}`) - modal.classList.toggle('is-open') - -} - function initPage (){ colorPositions(); initSlots(); @@ -701,24 +479,11 @@ function initPage (){ } } -function mailToLink(el, protocol='mailto') { - console.log(el) - console.log(el.dataset) - const {to, bcc, subject} = el.dataset - const params = new URLSearchParams({ - bcc, subject: encodeURIComponent(subject), - }) - const url = `${protocol}:${to}?${params}` - console.log(url) - // location.href=`mailto:${to}${params}` - const windowRef = window.open(url, '_blank'); - windowRef.focus(); -} - -function sparkMailToLink(el) { - const protocol = 'readdle-spark' - const {to, bcc, subject} = el.dataset - const url = `${protocol}://compose?recipient=${to}&bcc=${bcc}&subject=${encodeURIComponent(subject)}` +function mailToLink(el, protocol) { + const {to, bcc} = el.dataset + const subject = document.getElementById('email-subject').value + const email_body = document.getElementById('email-editor').value + const url = `${protocol}://compose?recipient=${to}&bcc=${bcc}&subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(email_body)}` console.log(url) // location.href=`mailto:${to}${params}` const windowRef = window.open(url, '_blank'); diff --git a/src/routes/event.js b/src/routes/event.js index f7ce0d6..1e9b638 100644 --- a/src/routes/event.js +++ b/src/routes/event.js @@ -74,4 +74,7 @@ router.post("/:team_id([0-9]+)/event/:event_id([0-9]+)/availability_reminders", // router.get("/:team_id([0-9]+)/event/:event_id([0-9]+)/lineup", eventsController.getLineup); // router.get("/:team_id([0-9]+)/event/:event_id([0-9]+)/lineup_card", eventsController.getLineupCard); +router.get("/:team_id([0-9]+)/event/:event_id([0-9]+)/modal-confirm-availability-reminders/", eventsController.confirmModalAvailabilityReminders) +router.post("/:team_id([0-9]+)/event/:event_id([0-9]+)/reset_availabilities",upload.none(), eventsController.submitResetAvailabilities) + module.exports = {router, loadEvent, loadEvents} \ No newline at end of file diff --git a/src/routes/eventlineup.js b/src/routes/eventlineup.js index 7274f0e..df9345b 100644 --- a/src/routes/eventlineup.js +++ b/src/routes/eventlineup.js @@ -57,6 +57,7 @@ router.get("/:team_id([0-9]+)/event/:event_id([0-9]+)/lineup/adjacent", doubleCs router.post("/:team_id([0-9]+)/event/:event_id([0-9]+)/lineup/:event_lineup_id([0-9]+)/email", upload.none(), doubleCsrfProtection, eventsLineupController.getEventLineupEmail ) router.get ("/:team_id([0-9]+)/event/:event_id([0-9]+)/lineup/:event_lineup_id([0-9]+)", upload.none(), doubleCsrfProtection, eventsLineupController.getEventLineup); router.post("/:team_id([0-9]+)/event/:event_id([0-9]+)/lineup/:event_lineup_id([0-9]+)", upload.none(), doubleCsrfProtection, eventsLineupController.postEventLineup); +router.post("/:team_id([0-9]+)/event/:event_id([0-9]+)/lineup/:event_lineup_id([0-9]+)/delete", upload.none(), eventsLineupController.submitDeleteEventLineupEntries); module.exports = {router, loadEventLineup} \ No newline at end of file diff --git a/src/routes/index.js b/src/routes/index.js index b006e7a..80fb442 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -27,4 +27,10 @@ router.get("/", (req,res,next) => { router.get("/:team_id([0-9]+)/members", membersController.getMembers); +router.get("/modal-confirm/", (req,res) => { + const {title, body} = req.query + res.render('modal_confirm', {title, body} ) +} +) + module.exports = {router, partials}; diff --git a/src/views/event/partials/modal_availability_reminders.hbs b/src/views/event/partials/modal_availability_reminders.hbs new file mode 100644 index 0000000..d7ab9ce --- /dev/null +++ b/src/views/event/partials/modal_availability_reminders.hbs @@ -0,0 +1,38 @@ + \ No newline at end of file diff --git a/src/views/eventlineup/edit.hbs b/src/views/eventlineup/edit.hbs index df6b3de..e9def4c 100644 --- a/src/views/eventlineup/edit.hbs +++ b/src/views/eventlineup/edit.hbs @@ -1,6 +1,5 @@
- {{>availability_reminder_modal}} {{!-- --}} @@ -41,21 +40,34 @@ Insert previous lineup
- + {{{embeddedSvgFromPath "/teamsnap-ui/assets/icons/send.svg"}}} Availability Reminders
- + {{{embeddedSvgFromPath "/teamsnap-ui/assets/icons/refresh.svg"}}} Reset All Availabilities
- + {{{embeddedSvgFromPath "/teamsnap-ui/assets/icons/trash.svg"}}} Clear Lineup
+
+ + {{{embeddedSvgFromPath "/teamsnap-ui/assets/icons/send.svg"}}} + Availability Reminders + +
+ + Reset All Availabilities + +
+ + Clear Lineup +
Publish diff --git a/src/views/modal_confirm.hbs b/src/views/modal_confirm.hbs new file mode 100644 index 0000000..f50abc8 --- /dev/null +++ b/src/views/modal_confirm.hbs @@ -0,0 +1,19 @@ + \ No newline at end of file