94 lines
5.1 KiB
HTML
94 lines
5.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>{% if item %}Update{% else %}Add{% endif %} Item</title>
|
|
{% include 'favicon.html' %}
|
|
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
|
|
<link href="{{ url_for('static', filename='css/bootstrap-icons.min.css') }}" rel="stylesheet">
|
|
<link href="{{ url_for('static', filename='css/layout.css') }}" rel="stylesheet">
|
|
<link href="{{ url_for('static', filename='css/form_page.css') }}" rel="stylesheet">
|
|
</head>
|
|
<body class="d-flex flex-column">
|
|
{% include 'header.html' %}
|
|
|
|
<main class="container mt-5">
|
|
<div class="form-container">
|
|
<h2 class="mb-4">{% if item %}Update{% else %}Add{% endif %} Item</h2>
|
|
|
|
<!-- Display error message if any -->
|
|
{% if error %}
|
|
<div class="error-message">
|
|
{{ error }}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="form-card p-4">
|
|
<form method="POST">
|
|
<div class="row">
|
|
{% for attrib in item_attributes -%}
|
|
<div class="col-md-6">
|
|
<div class="form-field">
|
|
<label for="{{ attrib.attrib_name }}" class="form-label fw-bold mb-2">
|
|
{{ attrib.display_name }}
|
|
{% if attrib.required %}<span class="text-danger">*</span>{% endif %}
|
|
</label>
|
|
|
|
{%- if attrib.html_input_type == "select" %}
|
|
<!-- Dropdown for select fields -->
|
|
<select class="form-control"
|
|
id="{{ attrib.attrib_name }}"
|
|
name="{{ attrib.attrib_name }}"
|
|
{%- if attrib.required %} required {% endif %}>
|
|
{% for option in attrib.options -%}
|
|
<option value="{{ option }}"
|
|
{%- if item and item[attrib.attrib_name] == option %} selected {% endif %}
|
|
{%- if not item and attrib.default_val is not none and attrib.default_val == option %} selected {% endif %}>
|
|
{{ option }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
{%- else %}
|
|
<!-- Input field for other inputs -->
|
|
<input class="form-control"
|
|
id="{{ attrib.attrib_name }}"
|
|
name="{{ attrib.attrib_name }}"
|
|
type="{{ attrib.html_input_type }}"
|
|
{% if attrib.required %} required {% endif %}
|
|
{% if attrib.min_val %} min="{{ attrib.min_val }}" {% endif %}
|
|
{% if attrib.max_val %} max="{{ attrib.max_val }}" {% endif %}
|
|
{% if attrib.step %} step="{{ attrib.step }}" {% endif %}
|
|
{% if attrib.max_length %} maxlength="{{ attrib.max_length }}" {% endif %}
|
|
{% if attrib.min_length %} minlength="{{ attrib.min_length }}" {% endif %}
|
|
{% if attrib.regex %} pattern="{{ attrib.regex }}" {% endif %}
|
|
{% if item %} value="{{ item[attrib.attrib_name] }}" {% endif %}
|
|
{% if not item and attrib.default_val is not none %} value="{{ attrib.default_val }}" {% endif %}>
|
|
{%- endif %}
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
|
|
<!-- Sticky action buttons -->
|
|
<div class="sticky-actions">
|
|
<div class="d-flex justify-content-between">
|
|
<button type="button"
|
|
onclick="window.location.href='/'"
|
|
class="btn btn-outline-secondary px-4">
|
|
<i class="bi bi-x-lg me-1"></i>Cancel
|
|
</button>
|
|
<button type="submit" class="btn btn-primary px-4">
|
|
<i class="bi bi-check-lg me-1"></i>
|
|
{% if item %}Update{% else %}Submit{% endif %}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
{% include 'footer.html' %}
|
|
<!-- Bootstrap JS -->
|
|
<script src="{{ url_for('static', filename='js/bootstrap.bundle.min.js') }}"></script>
|
|
</body>
|
|
</html> |