87 lines
3.4 KiB
HTML
87 lines
3.4 KiB
HTML
{% from "_connection_macros.html" import connection_spec %}
|
|
{%- macro mag(v) -%}{{ v | int if v == v | int else v | round(1) }}{%- endmacro -%}
|
|
{%- macro magnification_range(info) -%}
|
|
{%- if info and info.magnification_min is not none and info.magnification_max is not none -%}
|
|
{{ mag(info.magnification_min) }}-{{ mag(info.magnification_max) }}
|
|
{%- elif info and info.magnification_min is not none -%}
|
|
{{ mag(info.magnification_min) }}
|
|
{%- elif info and info.magnification_max is not none -%}
|
|
{{ mag(info.magnification_max) }}
|
|
{%- endif -%}
|
|
{%- endmacro -%}
|
|
{%- macro magnification(info) -%}
|
|
{%- set range = magnification_range(info) -%}
|
|
{%- if range -%}
|
|
{{ range }}x{% if info.objective_lens_diameter_mm is not none %}{{ mag(info.objective_lens_diameter_mm) }}{% endif %}
|
|
{%- else -%}
|
|
<span class="muted">—</span>
|
|
{%- endif -%}
|
|
{%- endmacro -%}
|
|
<div id="scopes-table-card" class="card" style="overflow-x:auto">
|
|
<table class="table sortable">
|
|
<thead>
|
|
<tr>
|
|
{% if can_write_scopes %}
|
|
<th data-sort-off><input type="checkbox" id="scopes-select-all" title="Select all"></th>
|
|
{% endif %}
|
|
<th>Scope</th>
|
|
<th>Manufacturer</th>
|
|
<th>Model</th>
|
|
<th>Type</th>
|
|
<th>Magnification</th>
|
|
<th>Objective thread</th>
|
|
{% for ct in column_types %}
|
|
<th data-sort-off>{{ ct.name }}</th>
|
|
{% endfor %}
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for row in rows %}
|
|
{% set scope = row.scope %}
|
|
{% set info = row.info %}
|
|
<tr id="scope-row-{{ scope.id }}">
|
|
{% if can_write_scopes %}
|
|
<td><input type="checkbox" name="scope_ids" value="{{ scope.id }}"></td>
|
|
{% endif %}
|
|
<td>
|
|
<strong><a href="/admin/augmented-parts/{{ scope.id }}">{{ scope.description }}</a></strong>
|
|
{% if scope.sku %}<br><span class="muted">{{ scope.sku }}</span>{% endif %}
|
|
</td>
|
|
<td>{{ scope.manufacturer.name if scope.manufacturer else "—" }}</td>
|
|
<td>{{ scope.scope_model.name if scope.scope_model else "—" }}</td>
|
|
<td>{{ scope.sub_part_type.name if scope.sub_part_type else "—" }}</td>
|
|
<td>{{ magnification(info) }}</td>
|
|
<td>
|
|
{% if row.objective_attachment_point %}
|
|
<code>{{ connection_spec(row.objective_attachment_point) }}</code>
|
|
{% elif info and info.objective_thread_pitch %}
|
|
{{ info.objective_thread_pitch }}
|
|
{% else %}<span class="muted">—</span>{% endif %}
|
|
</td>
|
|
{% for ct in column_types %}
|
|
{% set entries = row.cells.get(ct.id) %}
|
|
<td>
|
|
{% if entries %}
|
|
{% for e in entries %}
|
|
<div class="fit-cell-item">
|
|
<span class="fit-badge fit-badge-{{ e.label }}">{{ e.label | capitalize }}</span>
|
|
<a href="/admin/augmented-parts/{{ e.part.id }}">{{ e.part.description | truncate(48) }}</a>
|
|
</div>
|
|
{% endfor %}
|
|
{% else %}
|
|
<span class="muted">—</span>
|
|
{% endif %}
|
|
</td>
|
|
{% endfor %}
|
|
</tr>
|
|
{% else %}
|
|
<tr>
|
|
<td colspan="{{ 6 + column_types | length + (1 if can_write_scopes else 0) }}" class="muted">
|
|
No scopes match your search.
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|