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 %}
{% macro render_image(id, image=None) %}
{% macro render_image(id, image=None, enabled=True) %}
<!-- Image fragment -->
<div class="image-slot text-center">
{% if image %}
@ -12,6 +12,7 @@
<div class="modal-body text-center">
<img src="{{ url_for('static', filename=image.filename) }}" alt="Image of ID {{ id }}" class="img-fluid">
</div>
{% if enabled %}
<div class="modal-footer justify-content-between">
<button class="btn btn-danger" onclick="ImageWidget.deleteImage('{{ id }}', '{{ image.id }}')">
{{ icons.render_icon('trash') }}
@ -29,20 +30,23 @@
{{ icons.render_icon('upload') }}
</label>
</div>
{% endif %}
</div>
</div>
</div>
{% else %}
<a href="#" class="link-secondary" onclick="document.getElementById('image-upload-input-{{ id }}').click(); return false;">
{{ icons.render_icon('image', 256) }}
</a>
<form method="POST" enctype="multipart/form-data" id="image-upload-form-{{ id }}" class="d-none">
<input type="file" id="image-upload-input-{{ id }}" name="file"
onchange="ImageWidget.submitImageUpload('{{ id }}')">
<input type="hidden" name="target_model" value="inventory">
<input type="hidden" name="model_id" value="{{ id }}">
<input type="hidden" name="caption" value="Uploaded via UI">
</form>
{% if enabled %}
<a href="#" class="link-secondary" onclick="document.getElementById('image-upload-input-{{ id }}').click(); return false;">
{{ icons.render_icon('image', 256) }}
</a>
<form method="POST" enctype="multipart/form-data" id="image-upload-form-{{ id }}" class="d-none">
<input type="file" id="image-upload-input-{{ id }}" name="file"
onchange="ImageWidget.submitImageUpload('{{ id }}')">
<input type="hidden" name="target_model" value="inventory">
<input type="hidden" name="model_id" value="{{ id }}">
<input type="hidden" name="caption" value="Uploaded via UI">
</form>
{% endif %}
{% endif %}
</div>
{% endmacro %}

View file

@ -13,42 +13,50 @@
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 }}">
<div class="container">
<div class="row align-items-center">
<div class="col">
<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 class="col">
<label for="identifier" class="form-label">Identifier</label>
<input type="text" class="form-control-plaintext" value="{{ item.identifier }}" readonly>
</div>
{% if not item.condition in ["Removed", "Disposed"] %}
<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>
{% endif %}
</div>
<div class="row">
<div class="col-4">
<label for="name" class="form-label">Inventory #</label>
<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 class="col-4">
<label for="serial" class="form-label">Serial #</label>
<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 class="col-4">
<label for="barcode" class="form-label">Bar Code #</label>
<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 class="row">
<div class="col-4">
<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>
{% for brand in brands %}
<option value="{{ brand.id }}" {% if brand.id==item.brand_id %} selected{% endif %}>{{ brand.name }}
@ -58,11 +66,11 @@
</div>
<div class="col-4">
<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 class="col-4">
<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>
{% for t in types %}
<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) }}
{% endif %}
</label>
<select class="form-select" id="userList">
<select class="form-select" id="userList"{% if item.condition in ["Removed", "Disposed"] %} disabled{% endif %}>
<option>-</option>
{% for user in users %}
<option value="{{ user.id }}" {% if user.id==item.owner_id %} selected{% endif %}>{{ user.full_name
@ -89,7 +97,7 @@
</div>
<div class="col-4">
<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>
{% for room in rooms %}
<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="form-check mb-0">
<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>
</div>
</div>
@ -122,7 +130,8 @@
id = "notes",
title = "Notes & Comments",
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>
{% if worklog %}