diff --git a/src/Views/Shared/_Batch.cshtml b/src/Views/Shared/_Batch.cshtml
index 7bd64f2..7521065 100644
--- a/src/Views/Shared/_Batch.cshtml
+++ b/src/Views/Shared/_Batch.cshtml
@@ -100,9 +100,17 @@
downButton.setAttribute('data-batchId', i);
downButton.className = 'btn btn-sm btn-primary';
downButton.textContent = '↓';
+ let removeButton = document.createElement('button');
+ removeButton.setAttribute('data-action', 'remove');
+ removeButton.setAttribute('data-batchId', i);
+ removeButton.className = 'btn btn-sm btn-danger';
+ removeButton.innerHTML = 'X';
+
container.appendChild(upButton);
container.appendChild(document.createElement('br'));
container.appendChild(downButton);
+ container.appendChild(document.createElement('br'));
+ container.appendChild(removeButton);
upButton.addEventListener('click', function() {
moveCardInBatch(upButton.parentElement.parentElement.parentElement.parentElement.attributes["data-card-index"].value, "up");
});
@@ -110,6 +118,24 @@
downButton.addEventListener('click', function() {
moveCardInBatch(downButton.parentElement.parentElement.parentElement.parentElement.attributes["data-card-index"].value, "down");
});
+ removeButton.addEventListener('click', async function() {
+ const index = parseInt(removeButton.closest('[data-card-index]').getAttribute('data-card-index'));
+ let batch = getAssetIdsFromBatch();
+ if (batch && batch.length > index) {
+ batch.splice(index, 1);
+ localStorage.setItem("printBatch", JSON.stringify(batch));
+ }
+
+ await renderBarcodePreview("printPreviewContainer");
+
+ removeButton.closest('.card').remove();
+
+ document.querySelectorAll('#printModal .card').forEach((card, newIndex) => {
+ card.setAttribute('data-card-index', newIndex);
+ const title = card.querySelector('.card-title strong');
+ if (title) title.textContent = `Asset ${newIndex + 1}:`;
+ });
+ });
} catch (error) {
console.error(`Error fetching asset ${assetId}:`, error);
const errorDiv = document.createElement('div');