{% load i18n %}
{# Restviews Create new item based on bootstrap3 #}

<div id="rv_{{ grid }}NewItem" class="modal" tabindex="-1" role="dialog"
     aria-labelledby="NewItem" aria-hidden="true" data-bind="with: {{ grid }}">
    <div class="modal-dialog" data-bind="if: canCreate">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">&times;</button>
                <h4 class="modal-title">{% trans "Create new item" %}</h4>
            </div>
            <div class="modal-body">

                <div class="hidden alert"
                     id="rv_{{ grid }}NewItemAlert">
                </div>

                <form id="rv_{{ grid }}NewItemForm" class="form-horizontal"
                      role="form">
                    <!-- ko foreach: fieldsCreate -->

                    <!-- ko if: hidden -->

                    <input type="hidden" data-form="New"
                           data-bind="rvInput: '{{ grid }}'"
                    >

                    <!-- /ko -->

                    <!-- ko ifnot: hidden -->

                    <div class="form-group">
                        <label
                            data-form="New"
                            data-bind="rvLabel: '{{ grid }}'"
                            class="col-sm-2 control-label">
                        </label>
                        <div class="col-sm-10">
                            <!-- ko if: type == "datetime" || type == "date"
                            || type == "time"
                            -->
                            <div class='input-group date'
                                 data-bind="attr: {
                                    'id': 'rv_New' + type + '{{ grid }}' +
                                    _field
                                 }"
                            >
                                <input
                                    data-form="New"
                                    data-bind="rvInput: '{{ grid }}'"
                                    class="form-control">

                                <span class="input-group-addon">
                                    <!-- ko if: type == 'time' -->
                                    <span class="glyphicon glyphicon-time">
                                    </span>
                                    <!-- /ko -->
                                    <!-- ko ifnot: type == 'time' -->
                                    <span class="glyphicon glyphicon-calendar">
                                    </span>
                                    <!-- /ko -->
                                </span>

                            </div>
                            <!-- /ko -->
                            <!-- ko if: type == "text" -->
                            <textarea
                                data-form="New"
                                data-bind="rvInput: '{{ grid }}'"
                                class="form-control"
                                ></textarea>
                            <!-- /ko -->
                            <!-- ko ifnot: (type == "text" || type ==
                            "datetime" || type == "date" || type == "time")
                            -->
                            <input
                                data-form="New"
                                data-bind="rvInput: '{{ grid }}'"
                                class="form-control">
                            <!-- /ko -->
                        </div>
                    </div>

                    <!-- /ko -->

                    <!-- /ko -->
                </form>
                <em class="pull-right">{% trans "* - required" %}</em>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default"
                        id="rv_cancelNewItem{{ grid }}"
                        data-dismiss="modal">{% trans "Cancel" %}</button>
                <button type="button"
                        onclick="
                            rv.saveForm(
                            'rv_{{ grid }}NewItemForm',
                            '{{ grid }}',
                            false
                            )"
                        id="rv_saveNewItem{{ grid }}"
                        class="btn btn-primary">
                    {% trans "Save" %}
                </button>
            </div>
        </div>
    </div>
</div>