Add inventory index route and update templates for breadcrumb navigation

This commit is contained in:
Yaro Kasear 2025-06-11 13:10:02 -05:00
parent 795b23fbae
commit 14384c3d22
8 changed files with 149 additions and 53 deletions

View file

@ -0,0 +1,33 @@
{% macro breadcrumb_header(breadcrumbs=[], title=None, submit_button=False) %}
<nav class="row d-flex mb-3 justify-content-between">
<div class="col">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{{ url_for('index') }}" class="link-success link-underline-opacity-0">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-house" viewBox="0 0 16 16">
<path d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L2 8.207V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V8.207l.646.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293zM13 7.207V13.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V7.207l5-5z"/>
</svg>
</a>
</li>
{% for crumb in breadcrumbs %}
<li class="breadcrumb-item">
{% if crumb.url %}
<a href="{{ crumb.url }}" class="link-success link-underline-opacity-0">{{ crumb.label }}</a>
{% else %}
{{ crumb.label }}
{% endif %}
</li>
{% endfor %}
{% if title %}
<li class="breadcrumb-item active">{{ title }}</li>
{% endif %}
</ol>
</div>
{% if submit_button %}
<div class="col text-end">
<button type="submit" class="btn btn-primary">Save</button>
</div>
{% endif %}
</nav>
{% endmacro %}

View file

@ -1,24 +1,18 @@
<!-- templates/inventory.html -->
{% extends "layout.html" %}
{% import "_breadcrumb_fragment.html" as breadcrumbs %}
{% import "_table_fragment.html" as tables %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('index') }}">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-house"
viewBox="0 0 16 16">
<path
d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L2 8.207V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V8.207l.646.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293zM13 7.207V13.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V7.207l5-5z" />
</svg>
</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('main.list_inventory') }}">Inventory</a></li>
<li class="breadcrumb-item active">{{ item.identifier }}</li>
</ol>
</nav>
{{ breadcrumbs.breadcrumb_header(
breadcrumbs=[
{'label': "Inventory", 'url': url_for('main.list_inventory')}
],
title=title,
submit_button=False) }}
<div class="container">
<form action="POST">

View file

@ -0,0 +1,82 @@
<!-- templates/inventory_index.html -->
{% extends "layout.html" %}
{% import "_breadcrumb_fragment.html" as breadcrumbs %}
{% import "_table_fragment.html" as tables %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
{{ breadcrumbs.breadcrumb_header(
title=title
) }}
<div class="container">
{% if not category %}
<div class="row">
<div class="col">
<h2 class="display-6 text-center">Find</h2>
</div>
</div>
<div class="row text-center">
<div class="col d-flex flex-column justify-content-center">
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor"
class="bi bi-search align-self-center" viewBox="0 0 16 16">
<path
d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0" />
</svg>
Search
</div>
<div class="col">
<a href="{{ url_for('main.list_inventory') }}"
class="d-flex flex-column justify-content-center link-success link-underline-opacity-0">
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor"
class="bi bi-table align-self-center" viewBox="0 0 16 16">
<path
d="M0 2a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2zm15 2h-4v3h4zm0 4h-4v3h4zm0 4h-4v3h3a1 1 0 0 0 1-1zm-5 3v-3H6v3zm-5 0v-3H1v2a1 1 0 0 0 1 1zm-4-4h4V8H1zm0-4h4V4H1zm5-3v3h4V4zm4 4H6v3h4z" />
</svg>
List
</a>
</div>
</div>
<div class="row">
<div class="col">
<h2 class="display-6 text-center mt-5">Browse</h2>
</div>
</div>
<div class="row text-center">
<div class="col">
<a href="{{ url_for('main.inventory_index', category='user') }}"
class="d-flex flex-column justify-content-center link-success link-underline-opacity-0">
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor"
class="bi bi-person align-self-center" viewBox="0 0 16 16">
<path
d="M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6m2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0m4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4m-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10s-3.516.68-4.168 1.332c-.678.678-.83 1.418-.832 1.664z" />
</svg>
By User
</a>
</div>
<div class="col"><a href="{{ url_for('main.inventory_index', category='location') }}"
class="d-flex flex-column justify-content-center link-success link-underline-opacity-0">
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor"
class="bi bi-map align-self-center" viewBox="0 0 16 16">
<path fill-rule="evenodd"
d="M15.817.113A.5.5 0 0 1 16 .5v14a.5.5 0 0 1-.402.49l-5 1a.5.5 0 0 1-.196 0L5.5 15.01l-4.902.98A.5.5 0 0 1 0 15.5v-14a.5.5 0 0 1 .402-.49l5-1a.5.5 0 0 1 .196 0L10.5.99l4.902-.98a.5.5 0 0 1 .415.103M10 1.91l-4-.8v12.98l4 .8zm1 12.98 4-.8V1.11l-4 .8zm-6-.8V1.11l-4 .8v12.98z" />
</svg>
By Location
</a></div>
<div class="col"><a href="{{ url_for('main.inventory_index', category='type') }}"
class="d-flex flex-column justify-content-center link-success link-underline-opacity-0">
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor"
class="bi bi-motherboard align-self-center" viewBox="0 0 16 16">
<path
d="M11.5 2a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5m2 0a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5m-10 8a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zm0 2a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1zM5 3a1 1 0 0 0-1 1h-.5a.5.5 0 0 0 0 1H4v1h-.5a.5.5 0 0 0 0 1H4a1 1 0 0 0 1 1v.5a.5.5 0 0 0 1 0V8h1v.5a.5.5 0 0 0 1 0V8a1 1 0 0 0 1-1h.5a.5.5 0 0 0 0-1H9V5h.5a.5.5 0 0 0 0-1H9a1 1 0 0 0-1-1v-.5a.5.5 0 0 0-1 0V3H6v-.5a.5.5 0 0 0-1 0zm0 1h3v3H5zm6.5 7a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h2a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5z" />
<path
d="M1 2a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2v-2H.5a.5.5 0 0 1-.5-.5v-1A.5.5 0 0 1 .5 9H1V8H.5a.5.5 0 0 1-.5-.5v-1A.5.5 0 0 1 .5 6H1V5H.5a.5.5 0 0 1-.5-.5v-2A.5.5 0 0 1 .5 2zm1 11a1 1 0 0 0 1 1h11a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1z" />
</svg>
By Type
</a></div>
</div>
{% endif %}
</div>
{% endblock %}

View file

@ -1,20 +1,17 @@
<!-- templates/table.html -->
{% extends "layout.html" %}
{% import "_breadcrumb_fragment.html" as breadcrumbs %}
{% import "_table_fragment.html" as tables %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('index') }}">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-house" viewBox="0 0 16 16">
<path d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L2 8.207V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V8.207l.646.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293zM13 7.207V13.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V7.207l5-5z"/>
</svg>
</a></li>
<li class="breadcrumb-item active">{{ title }}</li>
</ol>
{{ breadcrumbs.breadcrumb_header(
title=title
) }}
{% import "_table_fragment.html" as tables %}
{{ tables.render_table(header, rows, entry_route) }}
{{ tables.render_pagination(endpoint, page, has_prev, has_next, total_pages) }}
{% endblock %}

View file

@ -1,24 +1,19 @@
<!-- templates/user.html -->
{% extends "layout.html" %}
{% import "_breadcrumb_fragment.html" as breadcrumbs %}
{% import "_table_fragment.html" as tables %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('index') }}">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-house"
viewBox="0 0 16 16">
<path
d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L2 8.207V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V8.207l.646.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293zM13 7.207V13.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V7.207l5-5z" />
</svg>
</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('main.list_users') }}">Users</a></li>
<li class="breadcrumb-item active">{{ user.full_name }}</li>
</ol>
</nav>
{{ breadcrumbs.breadcrumb_header(
title=title,
breadcrumbs=[
{'label': 'Users', 'url': url_for('main.list_users')}
]
) }}
<div class="container">
<form action="POST">

View file

@ -1,6 +1,7 @@
<!-- templates/worklog.html -->
{% extends "layout.html" %}
{% import "_breadcrumb_fragment.html" as breadcrumbs %}
{% import "_table_fragment.html" as tables %}
{% block title %}{{ title }}{% endblock %}
@ -8,24 +9,13 @@
{% block content %}
<nav>
<form action="POST">
<div class="row d-flex mb-3 justify-content-between">
<div class="col">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('index') }}">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-house" viewBox="0 0 16 16">
<path
d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L2 8.207V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V8.207l.646.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293zM13 7.207V13.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V7.207l5-5z" />
</svg>
</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('main.list_worklog') }}">Work Log</a></li>
<li class="breadcrumb-item active">{{ title }}</li>
</ol>
</div>
<div class="col text-end">
<button type="submit" class="btn btn-primary">Save</button>
</div>
</div>
{{ breadcrumbs.breadcrumb_header(
breadcrumbs=[
{'label': 'Work Log', 'url': url_for('main.list_worklog')}
],
title=title,
submit_button=True
) }}
<div class="container">
<div class="row">