Disable inventory if item not available.

This commit is contained in:
Yaro Kasear 2025-07-14 09:19:35 -05:00
parent 0533f09851
commit 1051dc8492
2 changed files with 36 additions and 23 deletions

View file

@ -1,6 +1,6 @@
{% import "fragments/_icon_fragment.html" as icons %} {% import "fragments/_icon_fragment.html" as icons %}
{% macro render_image(id, image=None) %} {% macro render_image(id, image=None, enabled=True) %}
<!-- Image fragment --> <!-- Image fragment -->
<div class="image-slot text-center"> <div class="image-slot text-center">
{% if image %} {% if image %}
@ -12,6 +12,7 @@
<div class="modal-body text-center"> <div class="modal-body text-center">
<img src="{{ url_for('static', filename=image.filename) }}" alt="Image of ID {{ id }}" class="img-fluid"> <img src="{{ url_for('static', filename=image.filename) }}" alt="Image of ID {{ id }}" class="img-fluid">
</div> </div>
{% if enabled %}
<div class="modal-footer justify-content-between"> <div class="modal-footer justify-content-between">
<button class="btn btn-danger" onclick="ImageWidget.deleteImage('{{ id }}', '{{ image.id }}')"> <button class="btn btn-danger" onclick="ImageWidget.deleteImage('{{ id }}', '{{ image.id }}')">
{{ icons.render_icon('trash') }} {{ icons.render_icon('trash') }}
@ -29,10 +30,12 @@
{{ icons.render_icon('upload') }} {{ icons.render_icon('upload') }}
</label> </label>
</div> </div>
{% endif %}
</div> </div>
</div> </div>
</div> </div>
{% else %} {% else %}
{% if enabled %}
<a href="#" class="link-secondary" onclick="document.getElementById('image-upload-input-{{ id }}').click(); return false;"> <a href="#" class="link-secondary" onclick="document.getElementById('image-upload-input-{{ id }}').click(); return false;">
{{ icons.render_icon('image', 256) }} {{ icons.render_icon('image', 256) }}
</a> </a>
@ -44,5 +47,6 @@
<input type="hidden" name="caption" value="Uploaded via UI"> <input type="hidden" name="caption" value="Uploaded via UI">
</form> </form>
{% endif %} {% endif %}
{% endif %}
</div> </div>
{% endmacro %} {% endmacro %}

View file

@ -13,42 +13,50 @@
delete_button= item.id != None delete_button= item.id != None
) }} ) }}
{% if item.condition in ["Removed", "Disposed"] %}
<div class="alert alert-danger">
This item is not available and cannot be edited.
</div>
{% endif %}
<input type="hidden" id="inventoryId" value="{{ item.id }}"> <input type="hidden" id="inventoryId" value="{{ item.id }}">
<div class="container"> <div class="container">
<div class="row align-items-center"> <div class="row align-items-center">
<div class="col"> <div class="col">
<label for="timestamp" class="form-label">Date Entered</label> <label for="timestamp" class="form-label">Date Entered</label>
<input type="date" class="form-control" name="timestamp" value="{{ item.timestamp.date().isoformat() }}"> <input type="date" class="form-control-plaintext" name="timestamp" value="{{ item.timestamp.date().isoformat() }}" readonly>
</div> </div>
<div class="col"> <div class="col">
<label for="identifier" class="form-label">Identifier</label> <label for="identifier" class="form-label">Identifier</label>
<input type="text" class="form-control-plaintext" value="{{ item.identifier }}" readonly> <input type="text" class="form-control-plaintext" value="{{ item.identifier }}" readonly>
</div> </div>
{% if not item.condition in ["Removed", "Disposed"] %}
<div class="col"> <div class="col">
{{ images.render_image(item.id, item.image) }} {{ images.render_image(item.id, item.image, enabled = item.condition not in ["Removed", "Disposed"]) }}
</div> </div>
{% endif %}
</div> </div>
<div class="row"> <div class="row">
<div class="col-4"> <div class="col-4">
<label for="name" class="form-label">Inventory #</label> <label for="name" class="form-label">Inventory #</label>
<input type="text" class="form-control" name="name" placeholder="-" <input type="text" class="form-control" name="name" placeholder="-"
value="{{ item.name or '' }}"> value="{{ item.name or '' }}"{% if item.condition in ["Removed", "Disposed"] %} disabled{% endif %}>
</div> </div>
<div class="col-4"> <div class="col-4">
<label for="serial" class="form-label">Serial #</label> <label for="serial" class="form-label">Serial #</label>
<input type="text" class="form-control" name="serial" placeholder="-" <input type="text" class="form-control" name="serial" placeholder="-"
value="{{ item.serial if item.serial else '' }}"> value="{{ item.serial if item.serial else '' }}"{% if item.condition in ["Removed", "Disposed"] %} disabled{% endif %}>
</div> </div>
<div class="col-4"> <div class="col-4">
<label for="barcode" class="form-label">Bar Code #</label> <label for="barcode" class="form-label">Bar Code #</label>
<input type="text" class="form-control" name="barcode" placeholder="-" <input type="text" class="form-control" name="barcode" placeholder="-"
value="{{ item.barcode if item.barcode else '' }}"> value="{{ item.barcode if item.barcode else '' }}"{% if item.condition in ["Removed", "Disposed"] %} disabled{% endif %}>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-4"> <div class="col-4">
<label for="brand" class="form-label">Brand</label> <label for="brand" class="form-label">Brand</label>
<select class="form-select" id="brand" name="brand"> <select class="form-select" id="brand" name="brand"{% if item.condition in ["Removed", "Disposed"] %} disabled{% endif %}>
<option>-</option> <option>-</option>
{% for brand in brands %} {% for brand in brands %}
<option value="{{ brand.id }}" {% if brand.id==item.brand_id %} selected{% endif %}>{{ brand.name }} <option value="{{ brand.id }}" {% if brand.id==item.brand_id %} selected{% endif %}>{{ brand.name }}
@ -58,11 +66,11 @@
</div> </div>
<div class="col-4"> <div class="col-4">
<label for="model" class="form-label">Model</label> <label for="model" class="form-label">Model</label>
<input type="text" class="form-control" name="model" placeholder="-" value="{{ item.model if item.model else '' }}"> <input type="text" class="form-control" name="model" placeholder="-" value="{{ item.model if item.model else '' }}"{% if item.condition in ["Removed", "Disposed"] %} disabled{% endif %}>
</div> </div>
<div class="col-4"> <div class="col-4">
<label for="type" class="form-label">Category</label> <label for="type" class="form-label">Category</label>
<select name="type" id="type" class="form-select"> <select name="type" id="type" class="form-select"{% if item.condition in ["Removed", "Disposed"] %} disabled{% endif %}>
<option>-</option> <option>-</option>
{% for t in types %} {% for t in types %}
<option value="{{ t.id }}" {% if t.id==item.type_id %} selected{% endif %}>{{ t.description }} <option value="{{ t.id }}" {% if t.id==item.type_id %} selected{% endif %}>{{ t.description }}
@ -79,7 +87,7 @@
{{ links.entry_link('user', item.owner_id) }} {{ links.entry_link('user', item.owner_id) }}
{% endif %} {% endif %}
</label> </label>
<select class="form-select" id="userList"> <select class="form-select" id="userList"{% if item.condition in ["Removed", "Disposed"] %} disabled{% endif %}>
<option>-</option> <option>-</option>
{% for user in users %} {% for user in users %}
<option value="{{ user.id }}" {% if user.id==item.owner_id %} selected{% endif %}>{{ user.full_name <option value="{{ user.id }}" {% if user.id==item.owner_id %} selected{% endif %}>{{ user.full_name
@ -89,7 +97,7 @@
</div> </div>
<div class="col-4"> <div class="col-4">
<label for="location" class="form-label">Location</label> <label for="location" class="form-label">Location</label>
<select class="form-select" id="room"> <select class="form-select" id="room"{% if item.condition in ["Removed", "Disposed"] %} disabled{% endif %}>
<option>-</option> <option>-</option>
{% for room in rooms %} {% for room in rooms %}
<option value="{{ room.id }}" {% if room.id==item.location_id %} selected{% endif %}>{{ <option value="{{ room.id }}" {% if room.id==item.location_id %} selected{% endif %}>{{
@ -111,7 +119,7 @@
<div class="col-2 d-flex align-items-center justify-content-center" style="margin-top: 1.9rem;"> <div class="col-2 d-flex align-items-center justify-content-center" style="margin-top: 1.9rem;">
<div class="form-check mb-0"> <div class="form-check mb-0">
<input type="checkbox" class="form-check-input" id="shared" name="shared" {% if item.shared %}checked{% <input type="checkbox" class="form-check-input" id="shared" name="shared" {% if item.shared %}checked{%
endif %}> endif %}{% if item.condition in ["Removed", "Disposed"] %} disabled{% endif %}>
<label for="shared" class="form-check-label">Shared?</label> <label for="shared" class="form-check-label">Shared?</label>
</div> </div>
</div> </div>
@ -122,7 +130,8 @@
id = "notes", id = "notes",
title = "Notes & Comments", title = "Notes & Comments",
mode = 'view' if item.id else 'edit', mode = 'view' if item.id else 'edit',
content = item.notes if item.notes else '' content = item.notes if item.notes else '',
enabled = item.condition not in ["Removed", "Disposed"]
) }} ) }}
</div> </div>
{% if worklog %} {% if worklog %}