Add: File upload page style
Add bootstrap css and layout to "csv upload" page for import/update
This commit is contained in:
parent
4e3b7dff33
commit
7baa484d50
@ -17,10 +17,10 @@
|
||||
Add New Item
|
||||
</a>
|
||||
<a href="/import_from_csv" class="btn btn-sm btn-outline-light" title="Bulk-add new items from a CSV file">
|
||||
Import CSV
|
||||
Import from CSV
|
||||
</a>
|
||||
<a href="/edit_using_csv" class="btn btn-sm btn-outline-light" title="Bulk-update existing items using a CSV file">
|
||||
Edit CSV
|
||||
Update with CSV
|
||||
</a>
|
||||
<form action="/export_csv" method="POST" class="d-inline">
|
||||
<button type="submit" class="btn btn-sm btn-outline-light" title="Download all data as a CSV file">
|
||||
|
@ -6,42 +6,118 @@
|
||||
<title>Upload CSV File</title>
|
||||
{% include 'favicon.html' %}
|
||||
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
|
||||
<style>
|
||||
.upload-container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.error-details {
|
||||
background-color: #f8d7da;
|
||||
border-left: 4px solid #dc3545;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{% include 'header.html' %}
|
||||
<main class="container mt-5 pt-3">
|
||||
<h1>Upload CSV File</h1>
|
||||
|
||||
<main class="container mt-5 pt-4">
|
||||
<div class="upload-container">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h2">
|
||||
{% if mode == "import" %}
|
||||
<i class="bi bi-upload me-2"></i>Import Items From CSV
|
||||
{% elif mode == "edit" %}
|
||||
<i class="bi bi-pencil-square me-2"></i>Update Items Using CSV
|
||||
{% endif %}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<!-- Display flash messages (only errors) -->
|
||||
{% with messages = get_flashed_messages(category_filter=["error"]) %}
|
||||
{% if messages %}
|
||||
<details>
|
||||
<summary>Errors found during submission (click to expand):</summary>
|
||||
<ul>
|
||||
{% for message in messages %}
|
||||
<li>{{ message }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</details>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
<!-- Flash messages (errors only) -->
|
||||
{% with messages = get_flashed_messages(category_filter=["error"]) %}
|
||||
{% if messages %}
|
||||
<div class="alert alert-danger error-details mb-4">
|
||||
<h2 class="h5 mb-3">Errors found during submission:</h2>
|
||||
<ul class="mb-0">
|
||||
{% for message in messages %}
|
||||
<li>{{ message }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
<!-- Upload form -->
|
||||
<form method="POST" enctype="multipart/form-data"
|
||||
{% if mode == "import" %}
|
||||
action="/import_from_csv"
|
||||
{% elif mode == "edit" %}
|
||||
action="/edit_using_csv"
|
||||
{% endif %}
|
||||
>
|
||||
<label for="file">Choose a CSV file:</label>
|
||||
<input type="file" id="file" name="file" accept=".csv" required>
|
||||
<br><br>
|
||||
<button type="submit">Upload</button>
|
||||
<button type="button" onclick="window.location.href='/'">Cancel</button>
|
||||
</form>
|
||||
<!-- Upload form card -->
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<form method="POST" enctype="multipart/form-data"
|
||||
{% if mode == "import" %}
|
||||
action="/import_from_csv"
|
||||
{% elif mode == "edit" %}
|
||||
action="/edit_using_csv"
|
||||
{% endif %}>
|
||||
|
||||
<div class="mb-4">
|
||||
<label for="file" class="form-label fw-bold">Select CSV File:</label>
|
||||
<input class="form-control form-control-lg"
|
||||
type="file"
|
||||
id="file"
|
||||
name="file"
|
||||
accept=".csv"
|
||||
required>
|
||||
<div class="form-text">
|
||||
Please upload a properly formatted CSV file
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-end gap-3">
|
||||
<a href="/" class="btn btn-outline-secondary">Cancel</a>
|
||||
<button type="submit" class="btn btn-primary px-4">
|
||||
Upload
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Optional help section -->
|
||||
<div class="mt-4">
|
||||
<div class="accordion" id="helpAccordion">
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header">
|
||||
<button class="accordion-button collapsed"
|
||||
type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#helpContent">
|
||||
<i class="bi bi-question-circle me-2"></i>
|
||||
CSV Format Help
|
||||
</button>
|
||||
</h2>
|
||||
<div id="helpContent"
|
||||
class="accordion-collapse collapse"
|
||||
data-bs-parent="#helpAccordion">
|
||||
<div class="accordion-body">
|
||||
<!-- Add your CSV format instructions here -->
|
||||
<p>Your CSV should include the following columns:</p>
|
||||
<ul>
|
||||
<li><code>id</code> - Required for edits</li>
|
||||
<li><code>name</code> - Item name</li>
|
||||
<!-- Add more columns as needed -->
|
||||
</ul>
|
||||
<a href="/sample.csv" class="btn btn-sm btn-outline-primary">
|
||||
Download Sample CSV
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<!-- Bootstrap JS (for dropdowns) -->
|
||||
|
||||
<!-- Bootstrap Icons (optional) -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
|
||||
|
||||
<!-- Bootstrap JS -->
|
||||
<script src="{{ url_for('static', filename='js/bootstrap.bundle.min.js') }}"></script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user