This will permanently delete the category and all its associated data.
Items will be kept but will be unassigned from this category.
diff --git a/static/css/dashboard.css b/static/css/dashboard.css
index de0a3ab..5e4efa4 100644
--- a/static/css/dashboard.css
+++ b/static/css/dashboard.css
@@ -91,6 +91,7 @@ body {
box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}
+/*
.autocomplete-items {
position: absolute;
z-index: 99;
@@ -98,7 +99,7 @@ body {
left: 0;
right: 0;
}
-
+*/
.rotate {
transform: rotate(-90deg) !important;
transition: 0.5s;
diff --git a/static/js/editItems.js b/static/js/editItems.js
new file mode 100644
index 0000000..046484e
--- /dev/null
+++ b/static/js/editItems.js
@@ -0,0 +1,77 @@
+
+function primeCreateNew() {
+ // Clear the form
+ $('.form-control').val('');
+ const form = document.getElementById('ItemModalForm');
+ document.getElementById('itemModifyModalLabel').innerText= "Create a new item";
+ form.setAttribute('method', 'POST');
+ return true;
+}
+
+function primeEdit() {
+ const form = document.getElementById('ItemModalForm');
+ document.getElementById('itemModifyModalLabel').innerText = 'Edit an item';
+ form.setAttribute('method', 'PATCH');
+ return true;
+}
+
+function getDataForEdit(id) {
+ $.ajax({
+ type: 'get',
+ url: `/api/v1/items?id=${id}`,
+ success: function (data) {
+ const result = JSON.parse(data);
+
+ // Get elements inside the editCategoryModal
+ const modal_itemName = document.getElementById('itemModifyModalName');
+ const modal_itemComment = document.getElementById('itemModifyModalComment');
+ const modal_itemAmount = document.getElementById('itemModifyModalAmount');
+ const modal_itemSKU = document.getElementById('itemModifyModalSKU');
+ const modal_itemStorageLocation = document.getElementById('itemModifyModalStorageLocation');
+ const modal_itemManufacturer = document.getElementById('itemModifyModalManuf');
+ const modal_itemCategory = document.getElementById('itemModifyModalCategory');
+ const modal_itemStatus = document.getElementById('itemModifyModalStatus');
+ const modal_itemid = document.getElementById('itemModifyModalId');
+
+ modal_itemName.value = result.name;
+ modal_itemComment.value = result.comment;
+ modal_itemAmount.value = result.amount;
+ modal_itemSKU.value = result.SKU;
+ modal_itemManufacturer.value = result.manufacturer;
+
+ // Select the correct option in the dropdown
+ const modal_itemCategoryOptions = modal_itemCategory.options;
+ for (let i = 0; i < modal_itemCategoryOptions.length; i++) {
+ if (modal_itemCategoryOptions[i].value == result.category.id) {
+ modal_itemCategoryOptions[i].selected = true;
+ }
+ }
+
+ // Select the correct option in the dropdown
+ const modal_itemStatusOptions = modal_itemStatus.options;
+ for (let i = 0; i < modal_itemStatusOptions.length; i++) {
+ if (modal_itemStatusOptions[i].value == result.status.id) {
+ modal_itemStatusOptions[i].selected = true;
+ }
+ }
+
+ // Select the correct option in the dropdown
+ const modal_itemStorageLocationOptions = modal_itemStorageLocation.options;
+ for (let i = 0; i < modal_itemStorageLocationOptions.length; i++) {
+ if (modal_itemStorageLocationOptions[i].value == result.storageLocation.id) {
+ modal_itemStorageLocationOptions[i].selected = true;
+ }
+ }
+
+ modal_itemid.value = result.id;
+ },
+ error: function (data) {
+ console.log('!!!! ERROR !!!!', data);
+ // Hide overlay with spinner
+ $('.loader-overlay').removeClass('active');
+ // Close the modal
+ $('.modal').modal('hide');
+ createNewToast('
Something went wrong. The category does no longer exist.', "text-bg-danger")
+ }
+ });
+}
\ No newline at end of file
diff --git a/static/js/formHandler.js b/static/js/formHandler.js
index b2a4583..6b616dc 100644
--- a/static/js/formHandler.js
+++ b/static/js/formHandler.js
@@ -1,5 +1,6 @@
var amountOfForms = $('.frontendForm').length;
$('.frontendForm').each(function () {
+ // TODO Handle empty strings as null or undefined, not as ''
$(this).on('submit', function (e) {
e.preventDefault(); // Prevent the form from submitting via the browser
@@ -108,7 +109,7 @@ function preFillDeleteModalNxt(id, route, name, requestIdent='id') {
document.getElementById('deleteNamePlaceholder').innerText = 'Deleted';
$('#staticBackdrop').modal('hide');
- createNewToast(`
Something went wrong. The ${name} does no longer exist.', "text-bg-danger`)
+ createNewToast(`
Something went wrong. The ${name} does no longer exist.`, `text-bg-danger`)
}
});
}
diff --git a/static/js/searchBox.js b/static/js/searchBox.js
index 16bf68e..f1705c9 100644
--- a/static/js/searchBox.js
+++ b/static/js/searchBox.js
@@ -3,7 +3,9 @@ const autocompleteBox = document.getElementById("autocomplete-items");
autocompleteBox.style.display = "none";
function handleSearchChange(e) {
console.log(e.target.value);
-
+ // document.getElementById("SearchBox").setAttribute("data-bs-content", "Search results will show up here soon")
+
+
return; // No you won't. I'm not done yet.
// Check if known prefix is used (either > or #)
if(e.target.value != "" ) {