{% extends 'bom/bom-base.html' %}

{% load static %}
{% load materializecss %}

{% block head-title %}{{ title }}{% endblock %}

{% block bom-menu %}
    <li><a href="{% url 'bom:part-info' part_id=part.id %}">Cancel</a></li>
{% endblock %}


{% block content %}
    <div class="container-app">
    {% if profile.role == 'A' %}
        <div class="row">
            <form action="{% url 'bom:manufacturer-part-edit' manufacturer_part_id=manufacturer_part.id %}" method="post" class="col s12">
                {% csrf_token %}
                {{ manufacturer_form.non_field_errors }}
                {{ manufacturer_part_form.non_field_errors }}
                {{ manufacturer_form.errors }}
                {{ manufacturer_part_form.errors }}
                <div class="row">
                    <div class="col">
                        <p>Manufacturer <i>(skip if custom part)</i></p>
                    </div>
                </div>
                <div class="row">
                    <div class="fieldWrapper col s6">
                        <label for="{{ manufacturer_part_form.manufacturer.id_for_label }}">Select existing Manufacturer</label>
                        {{ manufacturer_part_form.manufacturer.errors }}
                        {{ manufacturer_part_form.manufacturer }}
                    </div>
                    <div class="fieldWrapper col s6">
                        <label for="{{ manufacturer_form.name.id_for_label }}">-or- Create New Manufacturer</label>
                        {{ manufacturer_form.name.errors }}
                        {{ manufacturer_form.name }}
                    </div>
                </div>
                <div class="row">
                    <div class="fieldWrapper col s6">
                        <label for="{{ manufacturer_part_form.manufacturer_part_number.id_for_label }}"><b>Manufacturer Part Number</b></label>
                        {{ manufacturer_part_form.manufacturer_part_number.errors }}
                        {{ manufacturer_part_form.manufacturer_part_number }}
                    </div>
                    <div class="fieldWrapper col s6">
                        <label for="{{ manufacturer_part_form.link.id_for_label }}"><b>Manufacturer Part Link</b></label>
                        {{ manufacturer_part_form.link.errors }}
                        {{ manufacturer_part_form.link }}
                    </div>
                    {% if part.number_class.mouser_enabled %}
{#                    <label for="{{ manufacturer_part_form.source_mouser.id_for_label }}"><b>Disable sourcing info from Mouser</b></label>#}
                    {{ manufacturer_part_form.mouser_disable.errors }}
                    {{ manufacturer_part_form.mouser_disable|materializecss:'col s6 input-field' }}
                    {% endif %}
                </div>
                <div class="row">
                    <div class="col s6">
                        <a href="javascript:history.back()" class="waves-effect waves-light btn-flat grey-text lighten-1" style="margin-left: -16px;">Cancel</a>
                    </div>
                    <div class="col s6 right-align">
                        <button class="waves-effect waves-light btn btn-primary" type="submit" name="action">Save
                        </button>
                    </div>
                </div>
            </form>
        </div>
    {% else %}
        {% include 'bom/nothing-to-see.html' with required_privilege='Admin' %}
    {% endif %}
    </div>
{% endblock %}