This commit is contained in:
klaas 2024-09-07 16:34:23 +02:00
parent cb562870da
commit ed88167612
2 changed files with 139 additions and 0 deletions

71
views/project.ejs Normal file
View File

@ -0,0 +1,71 @@
<%- include('partials/header') %>
<div id="view" class="mt-5">
<h1><%= projekt.name %></h1>
<p><%= projekt.kurzbeschreibung %></p>
<p><%= projekt.beschreibung %></p>
<p>
<a href="<%= projekt.repository_link %>" target="_blank">Repository Link</a>
</p>
<a href="/projects">Zurück zur Projektliste</a>
<% if (session && session.role === 'admin') { %>
<button class="btn btn-primary" onclick="toggleDivs()">
Zum Edit-Modus wechseln
</button>
<% } %>
</div>
<% if (session && session.role === 'admin') { %>
<div id="edit" class="mt-5 d-none">
<form action="/projectedit" method="post">
<input type="hidden" name="id" value="<%=projekt.id%>" />
<label for="name" class="form-label">Name</label>
<input
type="text"
class="form-control"
id="name"
name="name"
value="<%=projekt.name%>"
/>
<label for="kurzbeschreibung" class="form-label">Kurzbeschreibung</label>
<input
type="text"
class="form-control"
id="kurzbeschreibung"
name="kurzbeschreibung"
value="<%=projekt.kurzbeschreibung%>"
/>
<label for="beschreibung" class="form-label">Beschreibung</label>
<input
type="text"
class="form-control"
id="beschreibung"
name="beschreibung"
value="<%=projekt.beschreibung%>"
/>
<label for="repository_link" class="form-label">Repository Link</label>
<input
type="text"
class="form-control"
id="repository_link"
name="repository_link"
value="<%=projekt.repository_link%>"
/>
<button type="submit" class="btn btn-primary">Speichern</button>
</form>
<button class="btn btn-secondary" onclick="toggleDivs()">
Zum View-Modus wechseln
</button>
</div>
<% } %>
<script>
function toggleDivs() {
$("#view").toggleClass("d-none d-block");
$("#edit").toggleClass("d-none d-block");
}
</script>
<%- include('partials/footer') %>

68
views/projects.ejs Normal file
View File

@ -0,0 +1,68 @@
<%- include('partials/header') %>
<h1>Meine Projekte</h1>
<ul>
<% projekte.forEach(projekt => { %>
<li>
<h2><a href="/project/<%= projekt.id %>"><%= projekt.name %></a></h2>
<p><%= projekt.kurzbeschreibung %></p>
</li>
<% }) %>
</ul>
<% if (session && session.role === 'admin') { %>
<button
type="button"
class="btn btn-primary"
data-bs-toggle="modal"
data-bs-target="#newProject"
>
Neues Projekt
</button>
<!-- Modal -->
<div
class="modal fade"
id="newProject"
tabindex="-1"
aria-labelledby="newProjectModalLabel"
aria-hidden="true"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">
Neues Projekt anlegen
</h5>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">
<form action="/projects" method="post">
<label for="name" class="form-label">Name</label>
<input type="text" class="form-control" id="name" name="name" />
<label for="beschreibung" class="form-label">Beschreibung</label>
<input
type="text"
class="form-control"
id="beschreibung"
name="beschreibung"
/>
<button type="submit" class="btn btn-primary">Create</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
Close
</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<% } %> <%- include('partials/footer') %>