{% extends BASE_TEMPLATE %}

{% load staticfiles %}

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

{% block title %}
<link rel="stylesheet" type="text/css" href="{% static 'bom/style.css' %}" />
Edit Part {{ part.full_part_number }}
{% endblock %}

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

{% block content %}
<div class="row">
    <form action="{% url 'bom:part-edit' part_id=part.id %}" method="post" class="col s12">
        {% csrf_token %}

        {{ form.non_field_errors }}
        <div class="row">
            <div class="fieldWrapper col s6">
                {{ form.number_class.errors }}
                <label for="{{ form.number_class.id_for_label }}"><b>Part Number Class:</b></label>
                {{ form.number_class }}
            </div>
            <div class="fieldWrapper col s3">
                {{ form.number_item.errors }}
                <label for="{{ form.number_item.id_for_label }}">Part Number:</label>
                {{ form.number_item }}
            </div>
            <div class="fieldWrapper col s3">
                {{ form.number_variation.errors }}
                <label for="{{ form.number_variation.id_for_label }}">Part Variation:</label>
                {{ form.number_variation }}
            </div>
        </div>
        <div class="row">
            <div class="fieldWrapper col s2">
                {{ form.revision.errors }}
                <label for="{{ form.revision.id_for_label }}"><b>Revision</b><br></label>
                {{ form.revision }}
            </div>
            <div class="fieldWrapper col s10">
                {{ form.description.errors }}
                <label for="{{ form.description.id_for_label }}"><b>Description</b> <i>(Max 255 characters.)</i></label>
                {{ form.description }}
            </div>
        </div>
        <div class="row">
            <div class="fieldWrapper col s12">
                {{ form.primary_manufacturer_part.errors }}
                <label for="{{ form.primary_manufacturer_part.id_for_label }}"><b>Primary Manufacturer Part</b></label>
                {{ form.primary_manufacturer_part }}
            </div>
        </div>

        <button class="waves-effect waves-light btn green lighten-1" type="submit" name="action">Save</button>
        <a href="{% url 'bom:part-info' part_id=part.id %}" class="waves-effect waves-light btn green lighten-1">Cancel</a>
        <a href="{% url 'bom:part-delete' part_id=part.id %}" onclick="return confirm('Are you sure? This part will be deleted forever!')" class="waves-effect waves-light btn red lighten-1">Delete Part</a>
    </form>
</div>
{% endblock %}