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 {
|
||||
const newSpiel = await pool.query('INSERT INTO spiele (name) VALUES ($1) RETURNING id', [spielName]);
|
||||
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 {
|
||||
|
|
|
@ -40,8 +40,42 @@
|
|||
<h3>Aufwärmen:</h3>
|
||||
|
||||
<% if (training.aufwaermleiter_name) { %>
|
||||
<p><strong>Leitung:</strong>
|
||||
<%= training.aufwaermleiter_name %></p>
|
||||
<div id="viewAufwaermenLeiter" class="mt-5">
|
||||
<p><strong>Leitung:</strong>
|
||||
<%= 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 { %>
|
||||
<form method="POST" action="/update-leader">
|
||||
<p><strong>Leitung:</strong>
|
||||
|
@ -53,14 +87,47 @@
|
|||
<% }) %>
|
||||
</select>
|
||||
<% if (session && session.role === 'admin') { %>
|
||||
<button type="submit">Speichern</button>
|
||||
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||
<% } %>
|
||||
</form></p>
|
||||
<% } %>
|
||||
|
||||
<% if (training.aufwaermen_name) { %>
|
||||
<p><strong>Spiel:</strong>
|
||||
<%= training.aufwaermen_name %></p>
|
||||
<div id="viewAufwaermen" class="mt-5">
|
||||
<p><strong>Spiel:</strong>
|
||||
<%= 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 { %>
|
||||
<form method="POST" action="/update-training">
|
||||
<p><strong>Spiel:</strong>
|
||||
|
@ -73,7 +140,7 @@
|
|||
</datalist>
|
||||
<input list="spiele" id="spielName" name="spielName">
|
||||
<% if (session && session.role === 'admin') { %>
|
||||
<button type="submit">Speichern</button>
|
||||
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||
<% } %>
|
||||
</form></p>
|
||||
<% } %>
|
||||
|
@ -82,8 +149,43 @@
|
|||
<h3>Spiel: </h3>
|
||||
|
||||
<% if (training.spielleiter_name) { %>
|
||||
<p><strong>Leitung:</strong>
|
||||
<%= training.spielleiter_name %></p>
|
||||
<div id="viewSpielLeiter" class="mt-5">
|
||||
<p><strong>Leitung:</strong>
|
||||
<%= 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 { %>
|
||||
<form method="POST" action="/update-leader">
|
||||
<p><strong>Leitung:</strong>
|
||||
|
@ -95,15 +197,50 @@
|
|||
<% }) %>
|
||||
</select>
|
||||
<% if (session && session.role === 'admin') { %>
|
||||
<button type="submit">Speichern</button>
|
||||
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||
<% } %>
|
||||
</form></p>
|
||||
<% } %>
|
||||
|
||||
|
||||
<% if (training.spiel_name) { %>
|
||||
<p><strong>Spiel:</strong>
|
||||
<%= training.spiel_name %>
|
||||
<div id="viewSpiel" class="mt-5">
|
||||
<p><strong>Spiel:</strong>
|
||||
<%= 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 { %>
|
||||
|
||||
<form method="POST" action="/update-training">
|
||||
|
@ -117,7 +254,7 @@
|
|||
</datalist>
|
||||
<input list="spiele" id="spielName" name="spielName">
|
||||
<% if (session && session.role === 'admin') { %>
|
||||
<button type="submit">Speichern</button>
|
||||
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||
<% } %>
|
||||
</form>
|
||||
|
||||
|
|
Loading…
Reference in New Issue