{% extends 'generic/_base.html' %} {% load static %} {% load helpers %} {% load i18n %} {% comment %} Field-pair builder: NetBox fields left, InvenTree fields right, linked rows for the mapping's current pairs. The server renders everything (pairs, selects, the compatibility greying of the InvenTree options) and embeds the fields matrix as JSON; mapping-builder.js progressively enhances add/remove, the dynamic greying per chosen NetBox field and the pointer sub-attribute select. The server re-validates on POST — the greying is UX, not enforcement. {% endcomment %} {% block title %}{{ object }} · {% trans "Field pair builder" %}{% endblock %} {% block subtitle %}
{% endblock subtitle %} {% block content %} {% if errors %} {% endif %} {% if not fields_data %} {% endif %}
{% csrf_token %} {# Two-column pair table: NetBox (left) ↔ InvenTree (right) #}
{% trans "Field pairs" %}
{% for row in pair_rows %} {% empty %} {% endfor %}
{% trans "NetBox field" %} {% trans "Sub-attribute" %} {% trans "InvenTree field" %} {% trans "Transform" %}
{{ row.netbox_label }} {{ row.netbox_field }} {{ row.netbox_type }} {{ row.netbox_subfield|placeholder }} ↔ {{ row.inventree_field }} {{ row.inventree_type }} {{ row.transform }}
{% trans "No field pairs yet — link the first pair below." %}
{% if fields_data %} {# Add-pair row: NetBox select (left) → InvenTree select (right) #}
{% trans "Link a new pair" %}
{% trans "Required: this pointer is projected onto a text field as one of its attributes." %}
↔
{% trans "Greyed-out fields do not accept the selected NetBox field's type." %}
{% endif %}
{% trans "Cancel" %}
{% if fields_data %} {# The fields matrix for the client-side enhancement (no secrets — metadata only) #} {{ fields_data|json_script:'builder-fields' }} {% endif %} {% endblock content %}