/* 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'); document.getElementById('modal_caller').innerHTML = i+1; document.getElementById('form_edit_entry_rowpos').value = i+1; document.getElementById('form_delete_entry_rowpos').value = i+1; let cells = row.cells; for (let j = 1; j < cells.length; j++) { document.getElementById(`form_edit_entry_${j}`).value = cells[j].innerHTML; } }; }; row.onclick = createClickHandler(row); } }); function toggle_edit_tname() { let span = document.getElementById('tname'); if (!edit_mode) { span.innerHTML = `
`; edit_mode = true; document.getElementById('pencil_button_edit_tname').hidden = true; } else { document.getElementById('pencil_button_edit_tname').hidden = false; span.innerHTML = `${tblname}`; edit_mode = false; } } function edit_tname() { document.getElementById('form_edit_table').submit(); toggle_edit_tname(); } 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; }