Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,20 @@ <h1>Inventory</h1>
{% endif %}
{% endwith %}

<h2>Add New Item</h2>
<button id="toggleFormBtn" class="btn btn-primary mb-3">
<i class="fas fa-plus"></i> Add New Item
</button>

<div id="itemFormContainer" style="display: none;">
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h5 class="mb-0">Add New Item</h5>
<button type="button" class="close" id="closeForm">
<span>&times;</span>
</button>
</div>
<div class="card-body">

<form method="POST" enctype="multipart/form-data">
<div class="form-group">
<label for="title">Title:</label>
Expand Down Expand Up @@ -227,6 +240,9 @@ <h2>Add New Item</h2>

<button type="submit" class="btn btn-primary">Add Item</button>
</form>
</div>
</div>
</div>

<h2>Current Items</h2>
{% for item in items.items %}
Expand Down Expand Up @@ -287,6 +303,30 @@ <h5 class="card-title">
</nav>
</div>

<script>
document.getElementById('toggleFormBtn').addEventListener('click', function() {
const form = document.getElementById('itemFormContainer');
const btn = this;

if (form.style.display === 'none') {
form.style.display = 'block';
btn.innerHTML = '<i class="fas fa-times"></i> Close Form';
btn.classList.replace('btn-primary', 'btn-danger');
} else {
form.style.display = 'none';
btn.innerHTML = '<i class="fas fa-plus"></i> Add New Item';
btn.classList.replace('btn-danger', 'btn-primary');
}
});

document.getElementById('closeForm').addEventListener('click', function() {
document.getElementById('itemFormContainer').style.display = 'none';
const btn = document.getElementById('toggleFormBtn');
btn.innerHTML = '<i class="fas fa-plus"></i> Add New Item';
btn.classList.replace('btn-danger', 'btn-primary');
});
</script>

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
Expand Down
Loading