fix: member template

This commit is contained in:
Martin Eyben 2024-12-04 21:22:03 +00:00
parent 3ba2416855
commit e7d2a62b4a

View File

@ -9,27 +9,30 @@
</title> </title>
<%- include('partials/links.ejs') %> <%- include('partials/links.ejs') %>
<style> <style>
#box-register-form { #box-register-form {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
max-width: max(30vw, 60ch); max-width: max(30vw, 60ch);
margin: auto; margin: auto;
} }
#box-register-form select, #box-register-form input { #box-register-form select,
padding: .5rem 1rem; #box-register-form input {
} padding: .5rem 1rem;
}
i { color: var(--bg); } i {
</style> color: var(--bg);
}
</style>
<script> <script>
function removeBox(id) { function removeBox(id) {
fetch(window.location.origin + '/boxes/' + id + '/' + <%= member.id_member%>, { method: 'DELETE' }).then(r => window.location.reload()); fetch(window.location.origin + '/boxes/' + id + '/' + <%= member.id_member %>, {method: 'DELETE'}).then(r => window.location.reload());
} }
</script> </script>
</head> </head>
<body> <body>
@ -46,65 +49,67 @@
<pre> <pre>
id: <%= member.id_member%> id: <%= member.id_member%>
name: <%= member.name%> name: <%= member.name%>
</pre> </pre>
<h2>Liste des boites enregistrées</h2> <h2>Liste des boites enregistrées</h2>
<form name="title" action="/boxes/register" id="box-register-form" method="POST"> <form name="title" action="/boxes/register" id="box-register-form" method="POST">
<input type="hidden" name="id_member" id="id_member" value="<%= member.id_member %>"> <input type="hidden" name="id_member" id="id_member" value="<%= member.id_member %>">
<label for="id_box">id de la boite</label> <label for="id_box">id de la boite</label>
<select name="id_box" id="id_box"> <select name="id_box" id="id_box">
<% allboxes.forEach(function(box) { %> <% allboxes.forEach(function(box) { %>
<option value="<%=box.id%>"><%=box.id%></option> <option value="<%=box.id%>">
<% }); %> <%=box.id%>
</select> </option>
<% }); %>
</select>
<label for="quantity">Quantité</label> <label for="quantity">Quantité</label>
<input type="number" name="quantity" min="0" step="1" id="quantity"> <input type="number" name="quantity" min="0" step="1" id="quantity">
<input type="submit" value="Ajouter"> <input type="submit" value="Ajouter">
</form> </form>
<div class="table"> <div class="table">
<table> <table>
<thead> <thead>
<tr>
<th>Id</th>
<th>Nom</th>
<th>Nombre de pièces</th>
<th>Quantité</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<% boxes.forEach(function(box) { %>
<tr> <tr>
<td> <th>Id</th>
<%=box.first.id%> <th>Nom</th>
</td> <th>Nombre de pièces</th>
<td> <th>Quantité</th>
<%=box.first.title%> <th></th>
</td> <th></th>
<td><%- box.first.pieces.reduce( (p,q)=> p + q.second, 0
)
-%></td>
<td>
<%=box.second%>
</td>
<td><a href="/boxes/byid/<%=box.first.id%>"><i class="fa-solid fa-eye"></i></a></td>
<td><button onclick="removeBox(<%=box.first.id%>)"><i class="fa-solid fa-trash"></i></button></td>
</tr> </tr>
</thead>
<tbody>
<% boxes.forEach(function(box) { %>
<tr>
<td>
<%=box.first.id%>
</td>
<td>
<%=box.first.title%>
</td>
<td><%- box.first.pieces.reduce( (p,q)=> p + q.second, 0
)
-%></td>
<td>
<%=box.second%>
</td>
<td><a href="/boxes/byid/<%=box.first.id%>"><i class="fa-solid fa-eye"></i></a></td>
<td><button onclick="removeBox(<%=box.first.id%>)"><i class="fa-solid fa-trash"></i></button></td>
</tr>
<% }); %> <% }); %>
</tbody> </tbody>
</table> </table>
<div class="box"></div> <div class="box"></div>
</div> </div>
<h2> <h2>
@ -168,19 +173,26 @@
<td> <td>
<%=model.name%> <%=model.name%>
</td> </td>
<td><a href="/membres/byid/<%=model.creator%>"><i class="fa-solid fa-user"></i> <% if (model.creator===undefined) {%>
<%=model.creator%>
</a></td> <td></td>
<td><a href="/models/byname/<%=model.name%>"><i class="fa-solid fa-eye"></i></a></td> <% } else {%>
<td><a href="/membres/byid/<%=model.creator.id_member%>"><i class="fa-solid fa-user"></i>
<%=model.creator.name%>
</a></td>
<% } %>
<td><a href="/models/byname/<%=model.name%>"><i class="fa-solid fa-eye"></i></a></td>
</tr> </tr>
<% }); %> <% }); %>
</tbody> </tbody>
</table> </table>
<div class="box"></div> <div class="box"></div>
</div> </div>
</main> </main>
</body> </body>
</html> </html>