Inventur/templates/base_modals.html.tera
2024-08-29 16:30:19 +02:00

121 lines
4.8 KiB
Plaintext

{# 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 <https://www.gnu.org/licenses/>.
#}
{% block modal_new_table %}
<!-- Create new table -->
<div class="modal fade" id="new_table" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5">New table</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="form_create_table" method="post" action="/table/create">
<div class="mb-3">
<label for="new_table_name" class="form-label">Name</label>
<input type="text" class="form-control" name="name" aria-describedby="new_table_name_label">
<div id="new_table_name_label" class="form-text">Name of the new table</div>
</div>
<div class="mb-3">
<div class="row" id="columns">
<div class="col-auto align-bottom me-1">
<label for="field_index" class="form-label">#</label>
<div class="form-text" id="field_index"><strong>1</strong></div>
</div>
<div class="col-auto">
<label for="fields" class="form-label">Column name</label>
<input type="text" class="form-control" id="field_name" aria-describedby="field_name_label" name="field_names">
</div>
<div class="col-auto">
<label for="field_type" class="form-label">Data type</label>
<select class="form-select" aria-label="data type" name="field_types">
<option value="0" selected>Text</option>
<option value="1">Number</option>
</select>
</div>
</div>
</div>
<div id="dynamic_columns">
<!-- Columns added using plus button -->
</div>
</form>
<div class="row justify-content-center mb-3 mt-3">
<div class="col-auto">
<button class="btn btn-primary" type="button" onclick="add_column()"><i class="bi bi-plus-lg"></i></button>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Close</button>
<button class="btn btn-primary" type="button" onclick="create_table()">Create</button>
</div>
</div>
</div>
</div>
{% endblock modal_new_table %}
{% block modal_import_table %}
<!-- Import new table -->
<div class="modal fade" id="import_table" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5">Import new table</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form action="/table/import" method="post" id="form_import_table">
<label for="import_name" class="form-label">Name</label>
<input type="text" class="form-control" id="import_name" name="name">
<label for="import_file" class="form-label">File</label>
<input id="import_columns" name="columns" hidden>
<input id="import_rows" name="rows" hidden>
</form>
<input type="file" class="form-control" id="import_file" name="name" accept="text/csv">
</div>
<div class="modal-footer">
<button class="btn btn-secondary" data-bs-dismiss="modal" type="button">Close</button>
<button class="btn btn-primary" type="button" onclick="import_table();">Import</button>
</div>
</div>
</div>
</div>
{% endblock modal_import_table %}
{% block modal_confirm_delete %}
<!-- Confirm delete -->
<div class="modal fade" id="confirm_delete_modal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5">Confirm deletion</h1>
</div>
<div class="modal-body">
<h5>Are you sure you want to delete this <span id="confirm_delete_modal_entity"></span>?</h5>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" data-bs-dismiss="modal" type="button"><i class="bi bi-x"></i></button>
<button class="btn btn-danger" type="button" data-bs-dismiss="modal" id="confirm_delete_modal_button"><i class="bi bi-trash3-fill"></i></button>
</div>
</div>
</div>
</div>
{% endblock modal_confirm_delete %}