assetflow/src/frontend/manage/categoryManager.eta.html

72 lines
3.1 KiB
HTML

<%~ E.includeFile("../partials/head.eta.html", {"title": "Settings - Category"}) %> <%~ E.includeFile("../partials/controls.eta.html", {"active": "SETT_CAT"}) %>
<%~ E.includeFile("../partials/deleteModal.eta.html") %>
<h1>Categories</h1>
<div class="container">
<!-- Create new category button -->
<div class="row">
<div class="col-12">
<a href="/settings/category/new" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#editCategoryModal" onclick="primeCreateNew()">Create new category</a>
</div>
</div>
<div class="modal fade" id="editCategoryModal" tabindex="-1" aria-labelledby="editCategoryModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="editCategoryModalLabel">Edit a category</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form class="frontendForm" method="patch" data-target="/api/v1/categories" id="CategoryModalForm">
<div class="modal-body">
<div class="mb-3">
<label for="editCategoryModalName" class="form-label">Name</label>
<input type="text" class="form-control" id="editCategoryModalName" name="name" required />
<div id="editCategoryModalNameText" class="form-text">This name should be unqiue.</div>
</div>
<div class="mb-3">
<label for="editCategoryModalDescription" class="form-label">Description</label>
<input type="text" class="form-control" id="editCategoryModalDescription" name="description" />
<div id="editCategoryModalDescText" class="form-text">Optional</div>
</div>
<input type="text" id="editCategoryModalId" name="id" hidden />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
</div>
</div>
<!-- Table with all categories -->
<table class="table align-middle">
<thead>
<tr>
<!-- <th scope="col">#</th> -->
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<% it.items.forEach(function(user){ %>
<tr id="listEntry-<%= user.id %>">
<td scope="row" data-bs-toggle="tooltip" data-bs-placement="left" data-bs-title="ID: <%= user.id %>"><%= user.name %></td>
<td><%= user.description %></td>
<td>
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#editCategoryModal" onclick="primeEdit(); getDataForEdit('<%= user.name %>')"><i class="bi bi-pencil"></i></button>
<button class="btn btn-danger" onclick="preFillDeleteModalNxt('<%= user.name %>','categories','Category', 'name')" data-bs-toggle="modal" data-bs-target="#staticBackdrop"><i class="bi bi-trash"></i></button>
</td>
</tr>
<% }) %>
</tbody>
</table>
</div>
<script src="/js/editCategory.js"></script>
<%~ E.includeFile("../partials/controlsFoot.eta.html") %> <%~ E.includeFile("../partials/foot.eta.html") %>