diff --git a/src/Views/Home/Assets.cshtml b/src/Views/Home/Assets.cshtml
index 6c963af..9f59067 100644
--- a/src/Views/Home/Assets.cshtml
+++ b/src/Views/Home/Assets.cshtml
@@ -80,6 +80,32 @@
@@ -222,13 +222,13 @@
@T["Attributes"]
-
+
@@ -269,7 +269,6 @@
const attributesContainer = document.getElementById('attributesContainer');
const addAttributeBtn = document.getElementById('addAttributeBtn');
- // Add a new attribute row
addAttributeBtn.addEventListener('click', () => {
const row = document.createElement('div');
row.className = 'd-flex gap-2 align-items-center attribute-row';
@@ -281,18 +280,15 @@
attributesContainer.appendChild(row);
});
- // Delegate delete button click
attributesContainer.addEventListener('click', (e) => {
if (e.target.classList.contains('btn-remove-attribute')) {
e.target.closest('.attribute-row').remove();
}
});
- // π§ Hook into the existing submit handler to include attributes
const createForm = document.getElementById('createAssetForm');
const originalHandler = createForm.onsubmit;
createForm.addEventListener('submit', (e) => {
- // Letβs patch the JSON generation just before sending
const formData = new FormData(createForm);
const jsonData = {};
@@ -307,7 +303,6 @@
target[keys[keys.length - 1]] = value;
}
- // Add Attributes as Dictionary
const attributes = {};
document.querySelectorAll('#attributesContainer .attribute-row').forEach(row => {
const name = row.querySelector('[data-attr-name]').value.trim();
@@ -320,8 +315,7 @@
jsonData.Description.Attributes = attributes;
}
- // Replace the body before sending
- e.preventDefault(); // stop default form submit
+ e.preventDefault();
fetch('/Assets/Create', {
method: 'POST',
@@ -338,9 +332,9 @@
bootstrap.Modal.getInstance(createModalEl).hide();
createForm.reset();
attributesContainer.innerHTML = '';
- showToast('β
Asset created successfully', 'success');
+ showToast('Asset created successfully', 'success');
} else {
- showToast(`β ${result.reason || 'Error creating asset'}`, 'danger');
+ showToast(`${result.reason || 'Error creating asset'}`, 'danger');
}
})
.catch(err => {