Features erledigt markieren

This commit is contained in:
Klaas Börgmann 2025-01-09 21:43:31 +01:00
parent 1ea63c6743
commit adf955cbc7
2 changed files with 21 additions and 0 deletions

15
app.js
View File

@ -1196,6 +1196,21 @@ app.get("/feature", requireAuth, async (req, res) => {
} }
}); });
app.post("/featuredone", requireAdmin, async (req, res) => {
const { id } = req.body;
try {
const featureResult = await pool.query(
"UPDATE features set done = true WHERE id = $1",
[id]
);
res.redirect("/feature");
} catch (error) {
console.error("Error:", error);
req.session.message = ["Error", error, "error"];
res.render("feature", { features, session: req.session });
}
});
app.post("/feature", requireAdmin, async (req, res) => { app.post("/feature", requireAdmin, async (req, res) => {
const { title, body, type, urgency, user } = req.body; const { title, body, type, urgency, user } = req.body;
const userResult = await pool.query( const userResult = await pool.query(

View File

@ -56,6 +56,12 @@
<div> <div>
<strong><u> <%= feature.title %> </strong><%= date.getDate() %>.<%= date.getMonth() + 1 %>.<%= date.getFullYear() %> - <%= date.getHours() %>:<%= date.getMinutes() %> - ( <%= feature.type === 1 ? 'Feature' : feature.type === 2 ? 'Bug' : 'Design' %>)</u> <%= feature.done ? '(erledigt)' : '' %></br> <strong><u> <%= feature.title %> </strong><%= date.getDate() %>.<%= date.getMonth() + 1 %>.<%= date.getFullYear() %> - <%= date.getHours() %>:<%= date.getMinutes() %> - ( <%= feature.type === 1 ? 'Feature' : feature.type === 2 ? 'Bug' : 'Design' %>)</u> <%= feature.done ? '(erledigt)' : '' %></br>
<p> <%= feature.body %> </p> <p> <%= feature.body %> </p>
<% if (session.userName === 'klaas' && feature.done == false) { %>
<form method="post" action="/featureDone">
<input type="hidden" name="id" value="<%= feature.id %>">
<button type="submit" class="btn btn-success">Erledigt</button>
</form>
<% } %>
</div> </div>
<% }) %> <% }) %>