Adding ability to add attachment points when editing augmented part
This commit is contained in:
1 parent
ceae27a12e
commit
d67b4ceb65
7 files changed
+355
-1
No files matched your search
@@ -0,0 +1,36 @@
|
||||
{% if apoint.iso_thread %}
|
||||
{% set conn_type = "ISO" %}
|
||||
{% set conn_label = "M" ~ apoint.iso_thread.diameter_mm ~ "×" ~ apoint.iso_thread.pitch_mm %}
|
||||
{% elif apoint.unc_thread %}
|
||||
{% set conn_type = "UNC" %}
|
||||
{% set conn_label = apoint.unc_thread.diameter_fraction ~ "-" ~ apoint.unc_thread.tpi ~ " " ~ apoint.unc_thread.series.value %}
|
||||
{% elif apoint.clamp_connection %}
|
||||
{% set conn_type = "Clamp" %}
|
||||
{% if apoint.clamp_connection.min_mm is not none %}
|
||||
{% set conn_label = apoint.clamp_connection.min_mm ~ "–" ~ apoint.clamp_connection.max_mm ~ " mm" %}
|
||||
{% else %}
|
||||
{% set conn_label = apoint.clamp_connection.min_in ~ "–" ~ apoint.clamp_connection.max_in ~ " in" %}
|
||||
{% endif %}
|
||||
{% elif apoint.static_connection %}
|
||||
{% set conn_type = "Static" %}
|
||||
{% set conn_label = apoint.static_connection.od_mm ~ " mm OD" %}
|
||||
{% else %}
|
||||
{% set conn_type = "—" %}
|
||||
{% set conn_label = "—" %}
|
||||
{% endif %}
|
||||
<div id="augmented-part-ap-{{ apoint.id }}" class="ap-item">
|
||||
<span class="ap-item-name">{{ apoint.attachment_point_name.name }}</span>
|
||||
<span class="ap-item-type">{{ conn_type }}</span>
|
||||
<code class="ap-item-conn">{{ conn_label }}</code>
|
||||
<div class="row-actions">
|
||||
<button class="btn btn-ghost"
|
||||
hx-get="/admin/augmented-parts/{{ apoint.augmented_part_id }}/attachment-points/{{ apoint.id }}/edit"
|
||||
hx-target="#augmented-part-ap-{{ apoint.id }}"
|
||||
hx-swap="outerHTML">Edit</button>
|
||||
<button class="btn btn-danger"
|
||||
hx-delete="/admin/augmented-parts/{{ apoint.augmented_part_id }}/attachment-points/{{ apoint.id }}"
|
||||
hx-target="#ap-{{ apoint.augmented_part_id }}-attachment-points"
|
||||
hx-swap="outerHTML"
|
||||
hx-confirm="Delete this attachment point?">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,45 @@
|
||||
{% if apoint.iso_thread_id %}{% set current_type = "iso_thread" %}
|
||||
{% elif apoint.unc_thread_id %}{% set current_type = "unc_thread" %}
|
||||
{% elif apoint.clamp_connection_id %}{% set current_type = "clamp_connection" %}
|
||||
{% elif apoint.static_connection_id %}{% set current_type = "static_connection" %}
|
||||
{% else %}{% set current_type = "" %}{% endif %}
|
||||
{# _attachment_point_connection_select.html expects `ap` for pre-selection #}
|
||||
{% set ap = apoint %}
|
||||
{% set connection_type = current_type %}
|
||||
<div id="augmented-part-ap-{{ apoint.id }}">
|
||||
<form hx-post="/admin/augmented-parts/{{ apoint.augmented_part_id }}/attachment-points/{{ apoint.id }}"
|
||||
hx-target="#augmented-part-ap-{{ apoint.id }}"
|
||||
hx-swap="outerHTML"
|
||||
class="inline-edit" style="padding:0.3rem 0">
|
||||
<label>Name
|
||||
<select name="attachment_point_name_id" required>
|
||||
{% for apn in attachment_point_names %}
|
||||
<option value="{{ apn.id }}" {{ "selected" if apn.id == apoint.attachment_point_name_id }}>{{ apn.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
<label>Type
|
||||
<select name="connection_type" required
|
||||
hx-get="/admin/attachment-points/connection-options"
|
||||
hx-target="#edit-ap-{{ apoint.id }}-connection-options"
|
||||
hx-trigger="change"
|
||||
hx-include="[name='connection_type']">
|
||||
<option value="">— type —</option>
|
||||
<option value="iso_thread" {{ "selected" if current_type == "iso_thread" }}>ISO Thread</option>
|
||||
<option value="unc_thread" {{ "selected" if current_type == "unc_thread" }}>UNC Thread</option>
|
||||
<option value="clamp_connection" {{ "selected" if current_type == "clamp_connection" }}>Clamp Connection</option>
|
||||
<option value="static_connection" {{ "selected" if current_type == "static_connection" }}>Static Connection</option>
|
||||
</select>
|
||||
</label>
|
||||
<div id="edit-ap-{{ apoint.id }}-connection-options">
|
||||
{% include "admin/_attachment_point_connection_select.html" %}
|
||||
</div>
|
||||
<div class="row-actions">
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
<button type="button" class="btn btn-ghost"
|
||||
hx-get="/admin/augmented-parts/{{ apoint.augmented_part_id }}/attachment-points/{{ apoint.id }}/row"
|
||||
hx-target="#augmented-part-ap-{{ apoint.id }}"
|
||||
hx-swap="outerHTML">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,38 @@
|
||||
<div id="ap-{{ augmented_part_id }}-attachment-points" class="ap-inline-section">
|
||||
<h3>Attachment Points</h3>
|
||||
|
||||
{% for apoint in attachment_points_list %}
|
||||
{% include "admin/_augmented_part_ap_row.html" %}
|
||||
{% else %}
|
||||
<p class="muted" style="font-size:0.85rem;margin:0 0 0.5rem">No attachment points yet.</p>
|
||||
{% endfor %}
|
||||
|
||||
<form hx-post="/admin/augmented-parts/{{ augmented_part_id }}/attachment-points"
|
||||
hx-target="#ap-{{ augmented_part_id }}-attachment-points"
|
||||
hx-swap="outerHTML"
|
||||
class="inline-edit" style="margin-top:0.5rem">
|
||||
<label>Name
|
||||
<select name="attachment_point_name_id" required>
|
||||
<option value="">— select —</option>
|
||||
{% for apn in attachment_point_names %}
|
||||
<option value="{{ apn.id }}">{{ apn.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
<label>Type
|
||||
<select name="connection_type" required
|
||||
hx-get="/admin/attachment-points/connection-options"
|
||||
hx-target="#ap-{{ augmented_part_id }}-add-connection-options"
|
||||
hx-trigger="change"
|
||||
hx-include="[name='connection_type']">
|
||||
<option value="">— type —</option>
|
||||
<option value="iso_thread">ISO Thread</option>
|
||||
<option value="unc_thread">UNC Thread</option>
|
||||
<option value="clamp_connection">Clamp Connection</option>
|
||||
<option value="static_connection">Static Connection</option>
|
||||
</select>
|
||||
</label>
|
||||
<div id="ap-{{ augmented_part_id }}-add-connection-options"></div>
|
||||
<button type="submit" class="btn btn-primary">Add</button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,6 +1,7 @@
|
||||
<tr id="augmented-part-{{ ap.id }}">
|
||||
<td colspan="9">
|
||||
<form hx-post="/admin/augmented-parts/{{ ap.id }}"
|
||||
<form id="augmented-part-edit-form-{{ ap.id }}"
|
||||
hx-post="/admin/augmented-parts/{{ ap.id }}"
|
||||
hx-target="#augmented-part-{{ ap.id }}"
|
||||
hx-swap="outerHTML"
|
||||
class="inline-edit">
|
||||
@@ -52,5 +53,10 @@
|
||||
hx-swap="outerHTML">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div hx-get="/admin/augmented-parts/{{ ap.id }}/attachment-points"
|
||||
hx-trigger="load"
|
||||
hx-swap="outerHTML">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
Reference in new issue
Block a user