shimatta-kenkyusho/shimatta_kenkyusho/templates/parts/modals/edit-component-modal.html

74 lines
4.1 KiB
HTML

{% comment "" %}
Needs following context:
- heading
- form EditComponentForm
{% endcomment %}
{% load static %}
{% load crispy_forms_tags %}
<div class="modal fade" id="comp-edit-modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h2>{{heading}}</h2>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<div class="modal-body">
{{form.name|as_crispy_field}}
{{form.datasheet_link|as_crispy_field}}
{{form.description|as_crispy_field}}
<div class="mb-3">
<label class="form-label" for="{{form.manufacturer.id_for_label}}">Manufacturer</label>
<div class="dropdown">
<input autocomplete="off" data-bs-toggle="dropdown" class="form-control{% if form.manufacturer.errors %} is-invalid{% endif %}" type="text" id="{{form.manufacturer.id_for_label}}" name="{{form.manufacturer.name}}" value="{{form.manufacturer.value}}">
<ul id="{{form.manufacturer.id_for_label}}-ac-ul" class="dropdown-menu">
</ul>
</div>
</div>
<div class="mb-3">
<label class="form-label" for="{{form.package.id_for_label}}">Package</label>
<div class="dropdown">
<input autocomplete="off" data-bs-toggle="dropdown" class="form-control{% if form.package.errors %} is-invalid{% endif %}" type="text" id="{{form.package.id_for_label}}" name="{{form.package.name}}" value="{{form.package.value}}">
<ul id="{{form.package.id_for_label}}-ac-ul" class="dropdown-menu">
</ul>
</div>
</div>
<div class="mb-3">
<label class="form-label" for="{{form.component_type.id_for_label}}">Component Type</label>
<div class="dropdown">
<input autocomplete="off" data-bs-toggle="dropdown" class="form-control{% if form.component_type.errors %} is-invalid{% endif %}" type="text" id="{{form.component_type.id_for_label}}" name="{{form.component_type.name}}" value="{{form.component_type.value}}">
<ul id="{{form.component_type.id_for_label}}-ac-ul" class="dropdown-menu">
</ul>
</div>
</div>
<div class="mb-3">
<label class="form-label" for="{{form.pref_distri.id_for_label}}">Preferred Distributor</label>
<div class="dropdown">
<input autocomplete="off" data-bs-toggle="dropdown" class="form-control{% if form.pref_distri.errors %} is-invalid{% endif %}" type="text" id="{{form.pref_distri.id_for_label}}" name="{{form.pref_distri.name}}" value="{{form.pref_distri.value}}">
<ul id="{{form.pref_distri.id_for_label}}-ac-ul" class="dropdown-menu">
</ul>
</div>
</div>
<div class="mb-3">
{{form.image|as_crispy_field}}
</div>
</div>
<div class="modal-footer">
<input type="submit" name="submit-edit-comp" class="btn btn-primary" value="Save">
</div>
</form>
</div>
</div>
</div>
<script type="text/javascript">
const edit_comp_modal_ids = {
'package': '{{form.package.id_for_label}}',
'manufacturer': '{{form.manufacturer.id_for_label}}',
'component_type': '{{form.component_type.id_for_label}}',
'pref_distri': '{{form.pref_distri.id_for_label}}',
}
</script>
<script type="text/javascript" src="{% static 'js/edit-component-modal.js' %}"></script>