diff --git a/static/edited_csv.js b/static/edited_csv.js
index afa2a35..36959f3 100644
--- a/static/edited_csv.js
+++ b/static/edited_csv.js
@@ -1,25 +1,21 @@
function collectEditedData(event) {
+ const headers = [...document.querySelectorAll('.table-new-assets thead th')].map(th => th.dataset.attrib);
const rows = document.querySelectorAll('.table-new-assets tbody tr');
const assets = [];
rows.forEach(row => {
const cells = row.querySelectorAll('td');
- assets.push({
- assettag: cells[0].innerText,
- hostname: cells[1].innerText,
- warrantyfrom: cells[2].innerText,
- status: cells[3].innerText,
- staffnum: cells[4].innerText
- });
+ let asset = {};
+ headers.forEach((attrib, i) => asset[attrib] = cells[i].innerText);
+ assets.push(asset);
});
- // Add edited data to a hidden input
const input = document.createElement('input');
input.type = 'hidden';
input.name = 'assets';
input.value = JSON.stringify(assets);
document.querySelector('form').appendChild(input);
- event.target.submit(); // Submit the form after attaching data
+ event.target.submit();
return true;
-}
\ No newline at end of file
+}
diff --git a/templates/csv_preview.html b/templates/csv_preview.html
index 011eb4a..461d0b4 100644
--- a/templates/csv_preview.html
+++ b/templates/csv_preview.html
@@ -16,7 +16,7 @@
{% for attrib, config in item_attributes.items() %}
- {{ config.display_name }} |
+ {{ config.display_name }} |
{% endfor %}
@@ -38,7 +38,7 @@
{% for attrib, config in item_attributes.items() %}
- {{ config.display_name }} |
+ {{ config.display_name }} |
{% endfor %}