/* This file is part of inventur. * inventur is a simple web app using rocket to help maintain inventory data. * Copyright (C) 2024 Johannes Randerath * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ let edit_mode = false; document.addEventListener("DOMContentLoaded", (event) => { let rows = document.getElementById("content_table").getElementsByTagName('tbody')[0].rows; for (let i = 0; i < rows.length; i++) { let row = rows[i]; let createClickHandler = function(r) { return function() { $('#edit_entry_modal').modal('show'); let row_pos = $(this).find('td').first().html(); $('#modal_caller').html(row_pos); $('#form_edit_entry_rowpos').val(row_pos); $('#form_delete_entry_rowpos').val(row_pos); let cells = row.cells; for (let j = 1; j < cells.length; j++) { $(`#form_edit_entry_${j}`).val(cells[j].innerHTML); } }; }; row.onclick = createClickHandler(row); } }); function edit_column(clmn_index) { document.getElementById('form_edit_column_name').value = column_names[clmn_index]; document.getElementById('form_edit_column_type').value = column_types[clmn_index]; document.getElementById('modal_caller').innerHTML = column_names[clmn_index]; document.getElementById('form_delete_column_idintbl').value = clmn_index + 1; document.getElementById('form_edit_column_idintbl').value = clmn_index + 1; }