{% extends "codenerix/addmodal.html" %}
{% load i18n %}
{% comment %}

django-codenerix

Codenerix GNU

Project URL : http://www.codenerix.com

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

{% endcomment %}

{% block form_head %}
    <div class="modal-header">
        <h3 class="modal-title text-center">{% trans "Adding new" %} {{form.get_name}}</h3>
    </div>
    <div class="row clearfix">
    <div class="modal-body">
{% endblock %}
{% block form_action %}{% endblock %}

{% block buttons_top %}{% endblock %}
{% block buttons_bottom %}{% endblock %}
{% block extra_form_bottom %}

{% if form.packs %}
<br>
    <div class="col-md-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>{% trans "Options" %}</strong>
            </div>
            <div class="panel-body">
                <table class="table table-condensed table-hover list ng-scope" ng-init="packs=[]">
                    <thead>
                        <tr>
                            <td>{% trans "Option" %}</td>
                            <td>{% trans "Product" %}</td>
                        </tr>
                    </thead>
                    <tbody>
                        {% verbatim %}
                        <tr ng-repeat="(k, option) in packs['__JSON_DATA__']">
                            <td>{{ option.label }}</td>
                            <td>
                                <select class="form-control form-control ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required" name="packs[{{option.id}}]" ng-required="true" required="true">
                                    <option ng-repeat="product in option.products" value="{{ product.pk }}">
                                        {{ product.name }}
                                    </option>
                                </select>
                                {% comment %}
                                <select 
                                    class="form-control form-control ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required" 
                                    name="packs[{{option.id}}]"
                                    ng-required="true" 
                                    required="true" 
                                    ng-model="dmy1023692965.packs[option.id]"
                                    ng-options="product as product.name for product in option.products">
                                </select>
                                {% endcomment %}
                            </td>
                        </tr>
                        {% endverbatim %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
{% endif %}
{% endblock %}
{% block form_bottom %}
    </div>
</div>
<div class="modal-footer">
    <label  class="sr-only"  for="submit_save">{% trans "Save" %}</label>
    <button type="button" id="submit_save" ng-click="submit({{form.form_name}})" class="btn btn-sm btn-info" ng-disabled="{{ form.form_name }}.$invalid" ng-if="{{form.form_name}}.$dirty">{% trans "Save" %}</button>
    <label  class="sr-only"  for="cancel">{% trans "Cancel" %}</label>
    <button type="button" class="btn btn-sm btn-danger" ng-click="cancel()">{% trans "Cancel" %}</button>
</div>
{% endblock %}
