From afccacbf9e1b0690a22a815100dcae76e58420fb Mon Sep 17 00:00:00 2001 From: LD-Reborn Date: Fri, 10 Oct 2025 12:14:22 +0200 Subject: [PATCH] Removed stray comments from Assets.cshtml, Fixed success toast not showing --- src/Views/Home/Assets.cshtml | 72 +++++++++++++++++------------------- 1 file changed, 33 insertions(+), 39 deletions(-) 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 => {