}
add_td_input('comment', dat_line.comment, 40);
- // delete button
- td_del = add_td(tr);
+ // line deletion and addition buttons
+ td_add_del = add_td(tr);
+ add_button(td_add_del, 'add new', false, function() {
+ new_line = {error: '', comment: '', booking_line: {account: '', amount: '', currency: ''}};
+ dat_lines.splice(i + 1, 0, new_line);
+ });
if (i > 0) {
- add_button(td_del, 'delete', i > 0 ? false : true, function() { dat_lines.splice(i, 1); });
+ add_button(td_add_del, 'delete', i > 0 ? false : true, function() {
+ dat_lines.splice(i, 1);
+ });
}
// add error explanation row if necessary
}
}
- // add "add line" row
- const tr = document.createElement("tr");
- table.appendChild(tr);
- const td = add_td(tr, 5);
- add_button(td, 'add line', false, function() {
- new_line = {error: '', comment: '', booking_line: {account: '', amount: '', currency: ''}};
- dat_lines.push(new_line);
- });
-
// make all rows alternate background color for better readability
Array.from(table.rows).forEach((tr) => {
tr.classList.add('alternating');