Add inventory availability route and update inventory index layout
- Introduced a new route for displaying available inventory items. - Sorted inventory items by identifier in both the list and available inventory routes. - Updated the inventory index template to include a link to the new available inventory route. - Cleaned up the layout by removing the toast container.
This commit is contained in:
parent
ccfbf3927e
commit
1d42433258
3 changed files with 25 additions and 5 deletions
|
@ -17,7 +17,7 @@ def list_inventory():
|
|||
|
||||
query = db.session.query(Inventory)
|
||||
query = eager_load_inventory_relationships(query)
|
||||
query = query.order_by(Inventory.inventory_name, Inventory.barcode, Inventory.serial)
|
||||
# query = query.order_by(Inventory.inventory_name, Inventory.barcode, Inventory.serial)
|
||||
|
||||
if filter_by and id:
|
||||
column = FILTER_MAP.get(filter_by)
|
||||
|
@ -41,6 +41,7 @@ def list_inventory():
|
|||
return "Invalid filter_by parameter", 400
|
||||
|
||||
inventory = query.all()
|
||||
inventory = sorted(inventory, key=lambda i: i.identifier)
|
||||
|
||||
return render_template(
|
||||
'table.html',
|
||||
|
@ -205,3 +206,18 @@ def delete_inventory_item(id):
|
|||
db.session.rollback()
|
||||
return jsonify({"success": False, "error": str(e)}), 400
|
||||
|
||||
@main.route("/inventory_available")
|
||||
def inventory_available():
|
||||
query = eager_load_inventory_relationships(db.session.query(Inventory).filter(Inventory.condition == "Working"))
|
||||
|
||||
inventory = query.all()
|
||||
inventory = sorted(inventory, key=lambda i: i.identifier)
|
||||
|
||||
return render_template(
|
||||
"table.html",
|
||||
title = "Available Inventory",
|
||||
breadcrumb = [{'label': 'Inventory', 'url': url_for('main.inventory_index')}],
|
||||
header=inventory_headers,
|
||||
rows=[{"id": item.id, "cells": [row_fn(item) for row_fn in inventory_headers.values()]} for item in inventory],
|
||||
entry_route = 'inventory_item'
|
||||
)
|
|
@ -21,6 +21,14 @@ title=title
|
|||
{{ links.category_link(endpoint = 'inventory_index', label = 'By Location', icon_html = icons.render_icon('map', 32), arguments = {'category': 'location'}) }}
|
||||
{{ links.category_link(endpoint = 'inventory_index', label = 'By Type', icon_html = icons.render_icon('motherboard', 32), arguments = {'category': 'type'}) }}
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h2 class="display-6 text-center mt-5">Reports</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
{{ links.category_link(endpoint = 'inventory_available', label = 'Available', icon_html = icons.render_icon('box-seam', 32)) }}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="container">
|
||||
{% for line in listing %}
|
||||
|
|
|
@ -55,10 +55,6 @@
|
|||
<main class="container-flex m-5">
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<!-- Toast Container -->
|
||||
<div id="toast-container" class="toast-container position-fixed bottom-0 end-0 p-3"></div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.6/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-j1CDi7MgGQ12Z7Qab0qlWQ/Qqz24Gc6BM0thvEMVjHnfYGF0rmFCozFSxQBxwHKO"
|
||||
crossorigin="anonymous"></script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue