add clear lineup/availabilities, availability reminders
This commit is contained in:
@@ -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'))
|
||||
}
|
||||
@@ -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'))
|
||||
|
||||
}
|
||||
@@ -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');
|
||||
|
||||
@@ -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}
|
||||
@@ -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}
|
||||
@@ -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};
|
||||
|
||||
38
src/views/event/partials/modal_availability_reminders.hbs
Normal file
38
src/views/event/partials/modal_availability_reminders.hbs
Normal file
@@ -0,0 +1,38 @@
|
||||
<div id="modal" class="Modal Modal--clickableBg">
|
||||
<div class="Modal-content">
|
||||
<div onclick="javascript:this.closest('.Modal').remove();">{{{embeddedSvgFromPath "/teamsnap-ui/assets/icons/dismiss.svg" "Modal-iconDismiss"}}}</div>
|
||||
<div class="Modal-header">
|
||||
<div class="Modal-title">Send Reminders</div>
|
||||
</div>
|
||||
<div class="Modal-body">
|
||||
<div class="u-padSidesMd">
|
||||
<strong>Send to players who have selected:</strong>
|
||||
<div class="u-spaceTopSm"><div class="Checkbox">
|
||||
<input class="Checkbox-input" type="checkbox" name="undecidedCheckBox" id="undecidedCheckBox" checked="" value>
|
||||
<label class="Checkbox-label" for="undecidedCheckBox">Undecided</label>
|
||||
</div>
|
||||
<div class="Checkbox">
|
||||
<input class="Checkbox-input" type="checkbox" name="maybeCheckbox" id="maybeCheckbox" value="2">
|
||||
<label class="Checkbox-label" for="maybeCheckbox">Maybe</label>
|
||||
</div>
|
||||
<div class="Checkbox">
|
||||
<input class="Checkbox-input" type="checkbox" name="attendingCheckbox" id="attendingCheckbox" value="1">
|
||||
<label class="Checkbox-label" for="attendingCheckbox">Attending</label>
|
||||
</div>
|
||||
<div class="Checkbox u-padBottomNone">
|
||||
<input class="Checkbox-input" type="checkbox" name="notAttendingCheckbox" id="notAttendingCheckbox" value="0">
|
||||
<label class="Checkbox-label" for="notAttendingCheckbox">Not Attending</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Modal-footer">
|
||||
<button class="Button Button--negative" role="button" type="button" onclick="javascript:this.closest('.Modal').remove();" data-confirm="cancel">
|
||||
Cancel
|
||||
</button>
|
||||
<button class="Button Button--primary" role="button" type="button" data-confirm="yes">
|
||||
Send
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,6 +1,5 @@
|
||||
<div class="u-spaceSidesNone u-sm-spaceSidesAuto" id="event-lineup-{{event.id}}" data-event-lineup-id="{{event_lineup.id}}" data-event-id="{{event.id}}">
|
||||
<form onsubmit="onSubmit(this,event)" action="/{{team.id}}/event/{{event.id}}/lineup/{{event_lineup.id}}">
|
||||
{{>availability_reminder_modal}}
|
||||
<input type="hidden" name="event_lineup_id" value="{{event_lineup.id}}">
|
||||
{{!-- <input type="hidden" name="_csrf" value="{{csrfToken}}"> --}}
|
||||
<input type="hidden" name="csrfToken" value="{{csrfToken}}">
|
||||
@@ -41,21 +40,34 @@
|
||||
<span>Insert previous lineup</span>
|
||||
</a>
|
||||
<hr class="Divider u-spaceEndsNone">
|
||||
<a class="u-padEndsSm u-padSidesMd u-textDecorationNone" href="javascript:void(0)" onclick="openAvailabilityReminderModal(this, {{event.id}})">
|
||||
<a class="u-padEndsSm u-padSidesMd u-textDecorationNone" href="javascript:void(0)" onclick="openAvailabilityReminderModal(this, {{team.id}}, {{event.id}})">
|
||||
{{{embeddedSvgFromPath "/teamsnap-ui/assets/icons/send.svg"}}}
|
||||
<span>Availability Reminders</span>
|
||||
</a>
|
||||
<hr class="Divider u-spaceEndsNone">
|
||||
<a class="u-padEndsSm u-padSidesMd u-textDecorationNone" href="javascript:void(0)" onclick="console.log('not implemented yet')">
|
||||
<a class="u-padEndsSm u-padSidesMd u-textDecorationNone" href="javascript:void(0)" onclick="confirmModal({title:'Reset Availabilities',body:'Are sure you want to reset availabilities?'}, submitResetAvailabilities, {team_id:{{team.id}}, event_id:{{event.id}} })";>
|
||||
{{{embeddedSvgFromPath "/teamsnap-ui/assets/icons/refresh.svg"}}}
|
||||
<span>Reset All Availabilities</span>
|
||||
</a>
|
||||
<hr class="Divider u-spaceEndsNone">
|
||||
<a class="u-padEndsSm u-padSidesMd u-textDecorationNone" href="javascript:void(0)" onclick="console.log('not implemented yet')">
|
||||
<a class="u-padEndsSm u-padSidesMd u-textDecorationNone" href="javascript:void(0)" onclick="confirmModal({title:'Clear Lineup',body:'Are sure you want to clear lineup?'}, submitClearLineup, {team_id:{{team.id}}, event_id:{{event.id}}, event_lineup_id:{{event_lineup.id}} })">
|
||||
{{{embeddedSvgFromPath "/teamsnap-ui/assets/icons/trash.svg"}}}
|
||||
<span>Clear Lineup</span>
|
||||
</a>
|
||||
<div class="u-hidden">
|
||||
<hr class="Divider u-spaceEndsNone">
|
||||
<span class="u-padEndsSm u-padSidesMd u-textDecorationNone" href="javascript:void(0)" onclick="console.log('not implemented yet')">
|
||||
{{{embeddedSvgFromPath "/teamsnap-ui/assets/icons/send.svg"}}}
|
||||
<span>Availability Reminders</span>
|
||||
</span>
|
||||
<hr class="Divider u-spaceEndsNone">
|
||||
<span class="u-padEndsSm u-padSidesMd u-textDecorationNone" href="javascript:void(0)" onclick="console.log('not implemented yet')">
|
||||
<span>Reset All Availabilities</span>
|
||||
</span>
|
||||
<hr class="Divider u-spaceEndsNone">
|
||||
<span class="u-padEndsSm u-padSidesMd u-textDecorationNone" href="javascript:void(0)" onclick="console.log('not implemented yet')">
|
||||
<span>Clear Lineup</span>
|
||||
</span>
|
||||
<hr class="Divider u-spaceEndsNone">
|
||||
<span class="u-padEndsSm u-padSidesMd u-textDecorationNone" href="javascript:void(0)" onclick="console.log('not implemented yet')">
|
||||
<span>Publish</span>
|
||||
|
||||
19
src/views/modal_confirm.hbs
Normal file
19
src/views/modal_confirm.hbs
Normal file
@@ -0,0 +1,19 @@
|
||||
<div id="modal" class="Modal Modal--clickableBg">
|
||||
<div class="Modal-content">
|
||||
<div onclick="javascript:this.closest('.Modal').remove();">{{{embeddedSvgFromPath "/teamsnap-ui/assets/icons/dismiss.svg" "Modal-iconDismiss"}}}</div>
|
||||
<div class="Modal-header">
|
||||
<div class="Modal-title">{{title}}</div>
|
||||
</div>
|
||||
<div class="Modal-body">
|
||||
{{body}}
|
||||
</div>
|
||||
<div class="Modal-footer">
|
||||
<button class="Button Button--negative" role="button" type="button" onclick="javascript:this.closest('.Modal').remove();" data-confirm="cancel">
|
||||
Cancel
|
||||
</button>
|
||||
<button class="Button Button--primary" role="button" type="button" data-confirm="yes">
|
||||
Yes
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user