Spiel und Aufwärmen editierbar für Admins
This commit is contained in:
parent
935ccf9d5c
commit
f18615ecdf
2
app.js
2
app.js
|
@ -477,7 +477,7 @@ app.post('/update-training', requireAuth, async (req, res) => {
|
||||||
} else {
|
} else {
|
||||||
const newSpiel = await pool.query('INSERT INTO spiele (name) VALUES ($1) RETURNING id', [spielName]);
|
const newSpiel = await pool.query('INSERT INTO spiele (name) VALUES ($1) RETURNING id', [spielName]);
|
||||||
spielId = newSpiel.rows[0].id;
|
spielId = newSpiel.rows[0].id;
|
||||||
req.session.message = [title = 'Neues Spiel', body = 'Das Spiel ${ spielName } wurde angelegt.', type = 'Success'];
|
req.session.message = [title = 'Neues Spiel', body = 'Das Spiel ${ spielName } wurde angelegt.'];
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -40,8 +40,42 @@
|
||||||
<h3>Aufwärmen:</h3>
|
<h3>Aufwärmen:</h3>
|
||||||
|
|
||||||
<% if (training.aufwaermleiter_name) { %>
|
<% if (training.aufwaermleiter_name) { %>
|
||||||
|
<div id="viewAufwaermenLeiter" class="mt-5">
|
||||||
<p><strong>Leitung:</strong>
|
<p><strong>Leitung:</strong>
|
||||||
<%= training.aufwaermleiter_name %></p>
|
<%= training.aufwaermleiter_name %>
|
||||||
|
|
||||||
|
<% if (session && session.role === 'admin') { %>
|
||||||
|
<button class="btn btn-primary" onclick="toggleDivsAufwaermenLeiter()">Edit</button>
|
||||||
|
<% } %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% if (session && session.role === 'admin') { %>
|
||||||
|
<div id="editAufwaermenLeiter" class="mt-5 d-none">
|
||||||
|
<form method="POST" action="/update-leader">
|
||||||
|
<p><strong>Leitung:</strong>
|
||||||
|
<input type="hidden" name="trainingId" value="<%= training.id %>">
|
||||||
|
<input type="hidden" name="type" value="aufwaermleiter">
|
||||||
|
<select name="leaderId">
|
||||||
|
<% aufwaermleiterCandidates.forEach(candidate => { %>
|
||||||
|
<option value="<%= candidate.id %>"><%= candidate.name %> (<%= Math.floor(candidate.weeks_since_last) %> Wochen)</option>
|
||||||
|
<% }) %>
|
||||||
|
</select>
|
||||||
|
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||||
|
<button class="btn btn-danger" onclick="toggleDivsAufwaermenLeiter()">cancel</button>
|
||||||
|
</form></p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function toggleDivsAufwaermenLeiter() {
|
||||||
|
$('#viewAufwaermenLeiter').toggleClass('d-none d-block');
|
||||||
|
$('#editAufwaermenLeiter').toggleClass('d-none d-block');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<form method="POST" action="/update-leader">
|
<form method="POST" action="/update-leader">
|
||||||
<p><strong>Leitung:</strong>
|
<p><strong>Leitung:</strong>
|
||||||
|
@ -53,14 +87,47 @@
|
||||||
<% }) %>
|
<% }) %>
|
||||||
</select>
|
</select>
|
||||||
<% if (session && session.role === 'admin') { %>
|
<% if (session && session.role === 'admin') { %>
|
||||||
<button type="submit">Speichern</button>
|
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||||
<% } %>
|
<% } %>
|
||||||
</form></p>
|
</form></p>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<% if (training.aufwaermen_name) { %>
|
<% if (training.aufwaermen_name) { %>
|
||||||
|
<div id="viewAufwaermen" class="mt-5">
|
||||||
<p><strong>Spiel:</strong>
|
<p><strong>Spiel:</strong>
|
||||||
<%= training.aufwaermen_name %></p>
|
<%= training.aufwaermen_name %>
|
||||||
|
|
||||||
|
<% if (session && session.role === 'admin') { %>
|
||||||
|
<button class="btn btn-primary" onclick="toggleDivsAufwaermen()">edit</button>
|
||||||
|
<% } %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% if (session && session.role === 'admin') { %>
|
||||||
|
<div id="editAufwaermen" class="mt-5 d-none">
|
||||||
|
<form method="POST" action="/update-training">
|
||||||
|
<p><strong>Spiel:</strong>
|
||||||
|
<input type="hidden" name="trainingId" value="<%= training.id %>">
|
||||||
|
<input type="hidden" name="type" value="aufwaermen">
|
||||||
|
<datalist id="spiele">
|
||||||
|
<% aufwaermenCandidates.forEach(candidate => { %>
|
||||||
|
<option value="<%= candidate.name %>"><%= candidate.name %></option>
|
||||||
|
<% }) %>
|
||||||
|
</datalist>
|
||||||
|
<input list="spiele" value="<%= training.aufwaermen_name %>" id="spielName" name="spielName">
|
||||||
|
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||||
|
<button class="btn btn-danger" onclick="toggleDivsAufwaermen()">cancel</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</p></div>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function toggleDivsAufwaermen() {
|
||||||
|
$('#viewAufwaermen').toggleClass('d-none d-block');
|
||||||
|
$('#editAufwaermen').toggleClass('d-none d-block');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<form method="POST" action="/update-training">
|
<form method="POST" action="/update-training">
|
||||||
<p><strong>Spiel:</strong>
|
<p><strong>Spiel:</strong>
|
||||||
|
@ -73,7 +140,7 @@
|
||||||
</datalist>
|
</datalist>
|
||||||
<input list="spiele" id="spielName" name="spielName">
|
<input list="spiele" id="spielName" name="spielName">
|
||||||
<% if (session && session.role === 'admin') { %>
|
<% if (session && session.role === 'admin') { %>
|
||||||
<button type="submit">Speichern</button>
|
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||||
<% } %>
|
<% } %>
|
||||||
</form></p>
|
</form></p>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
@ -82,8 +149,43 @@
|
||||||
<h3>Spiel: </h3>
|
<h3>Spiel: </h3>
|
||||||
|
|
||||||
<% if (training.spielleiter_name) { %>
|
<% if (training.spielleiter_name) { %>
|
||||||
|
<div id="viewSpielLeiter" class="mt-5">
|
||||||
<p><strong>Leitung:</strong>
|
<p><strong>Leitung:</strong>
|
||||||
<%= training.spielleiter_name %></p>
|
<%= training.spielleiter_name %>
|
||||||
|
|
||||||
|
<% if (session && session.role === 'admin') { %>
|
||||||
|
<button class="btn btn-primary" onclick="toggleDivsSpielLeiter()">edit</button>
|
||||||
|
<% } %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% if (session && session.role === 'admin') { %>
|
||||||
|
<div id="editSpielLeiter" class="mt-5 d-none">
|
||||||
|
<form method="POST" action="/update-leader">
|
||||||
|
<p><strong>Leitung:</strong>
|
||||||
|
<input type="hidden" name="trainingId" value="<%= training.id %>">
|
||||||
|
<input type="hidden" name="type" value="spielleiter">
|
||||||
|
<select name="leaderId">
|
||||||
|
<% spielleiterCandidates.forEach(candidate => { %>
|
||||||
|
<option value="<%= candidate.id %>"><%= candidate.name %> (<%= Math.floor(candidate.weeks_since_last) %> Wochen)</option>
|
||||||
|
<% }) %>
|
||||||
|
</select>
|
||||||
|
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||||
|
<button class="btn btn-danger" onclick="toggleDivsSpielLeiter()">cancel</button>
|
||||||
|
</form></p>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function toggleDivsSpielLeiter() {
|
||||||
|
$('#viewSpielLeiter').toggleClass('d-none d-block');
|
||||||
|
$('#editSpielLeiter').toggleClass('d-none d-block');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<form method="POST" action="/update-leader">
|
<form method="POST" action="/update-leader">
|
||||||
<p><strong>Leitung:</strong>
|
<p><strong>Leitung:</strong>
|
||||||
|
@ -95,15 +197,50 @@
|
||||||
<% }) %>
|
<% }) %>
|
||||||
</select>
|
</select>
|
||||||
<% if (session && session.role === 'admin') { %>
|
<% if (session && session.role === 'admin') { %>
|
||||||
<button type="submit">Speichern</button>
|
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||||
<% } %>
|
<% } %>
|
||||||
</form></p>
|
</form></p>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
|
||||||
<% if (training.spiel_name) { %>
|
<% if (training.spiel_name) { %>
|
||||||
|
<div id="viewSpiel" class="mt-5">
|
||||||
<p><strong>Spiel:</strong>
|
<p><strong>Spiel:</strong>
|
||||||
<%= training.spiel_name %>
|
<%= training.spiel_name %>
|
||||||
|
|
||||||
|
<% if (session && session.role === 'admin') { %>
|
||||||
|
<button class="btn btn-primary" onclick="toggleDivsSpiel()">edit</button>
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% if (session && session.role === 'admin') { %>
|
||||||
|
<div id="editSpiel" class="mt-5 d-none">
|
||||||
|
<form method="POST" action="/update-training">
|
||||||
|
<p><strong>Spiel:</strong>
|
||||||
|
<input type="hidden" name="trainingId" value="<%= training.id %>">
|
||||||
|
<input type="hidden" name="type" value="spiel">
|
||||||
|
<datalist id="spiele">
|
||||||
|
<% aufwaermenCandidates.forEach(candidate => { %>
|
||||||
|
<option value="<%= candidate.name %>"><%= candidate.name %></option>
|
||||||
|
<% }) %>
|
||||||
|
</datalist>
|
||||||
|
<input list="spiele" id="spielName" name="spielName" value=" <%= training.spiel_name %>">
|
||||||
|
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||||
|
<button class="btn btn-danger" onclick="toggleDivsSpiel()">cancel</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function toggleDivsSpiel() {
|
||||||
|
$('#viewSpiel').toggleClass('d-none d-block');
|
||||||
|
$('#editSpiel').toggleClass('d-none d-block');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
|
|
||||||
<form method="POST" action="/update-training">
|
<form method="POST" action="/update-training">
|
||||||
|
@ -117,7 +254,7 @@
|
||||||
</datalist>
|
</datalist>
|
||||||
<input list="spiele" id="spielName" name="spielName">
|
<input list="spiele" id="spielName" name="spielName">
|
||||||
<% if (session && session.role === 'admin') { %>
|
<% if (session && session.role === 'admin') { %>
|
||||||
<button type="submit">Speichern</button>
|
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||||
<% } %>
|
<% } %>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue