mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Merge pull request #208 from LD-Reborn/207-feature-add-button-to-remove-elements-from-print-batch
Added remove button to print batch view
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user