{% extends BASE_TEMPLATE %}

{% load staticfiles %}
{% load materializecss %}

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

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

{% block menu %}
<li><a href="{% url 'bom:home' %}">Cancel</a></li>
{% endblock%}

{% block content %}
<div class="row">
    <form action="{% url 'bom:create-part' %}" method="post" class="col s12">
        {% csrf_token %}
        {{ part_form.non_field_errors }}
        {{ manufacturer_form.non_field_errors }}
        {{ manufacturer_part_form.non_field_errors }}
        {{ part_form.errors }}
        {{ manufacturer_form.errors }}
        {{ manufacturer_part_form.errors }}
        <div class="row">
            <!-- For some reason using django's default form, number_class form validation errors don't show up, seems to be working with the materializecss filter -->
            {{ part_form.number_class|materializecss:'s6' }}
            {{ part_form.number_item|materializecss:'s3' }}
            {{ part_form.number_variation|materializecss:'s3' }}
        </div>
        <div class="row">
                {{ part_form.revision|materializecss:'s2' }}
                {{ part_form.description|materializecss:'s10' }}
        </div>
        <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">
            {{ manufacturer_part_form.manufacturer_part_number|materializecss:'s6' }}
        </div>

        <button class="waves-effect waves-light btn green lighten-1" type="submit" name="action">Save</button>
        <a href="{% url 'bom:home' %}" class="waves-effect waves-light btn green lighten-1">Cancel</a>
    </form>
</div>
{% endblock %}