{% load i18n %}

    <div class="modal" id="columns-form-modal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content modal-lg">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" tabindex="-1">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title">
                        {% trans 'Column' %}
                    </h4>
                </div>

                <div class="modal-body">
                    <div class="row">
                        <formgroup
                            class="col-md-4"
                            data-id="table"
                            data-type="selectnumber"
                            data-label="{{ meta.Column.table.verbose_name }}"
                            data-help="{{ meta.Column.table.help_text }}"
                            data-model="service.values.table"
                            data-errors="service.errors.table"
                            data-options="service.tables"
                            data-options-label="label">
                        </formgroup>
                        <formgroup
                            class="col-md-6"
                            data-id="name"
                            data-type="text"
                            data-label="{{ meta.Column.name.verbose_name }}"
                            data-help="{{ meta.Column.name.help_text }}"
                            data-model="service.values.name"
                            data-errors="service.errors.name">
                        </formgroup>
                        <formgroup
                            class="col-md-2"
                            data-id="order"
                            data-type="number"
                            data-label="{{ meta.Column.order.verbose_name }}"
                            data-help="{{ meta.Column.order.help_text }}"
                            data-model="service.values.order"
                            data-errors="service.errors.order">
                        </formgroup>
                    </div>
                    <formgroup
                        data-id="description"
                        data-type="textarea"
                        data-label="{{ meta.Column.description.verbose_name }}"
                        data-help="{{ meta.Column.description.help_text }}"
                        data-model="service.values.description"
                        data-errors="service.errors.description">
                    </formgroup>
                    <div class="row">
                        <formgroup
                            class="col-md-4"
                            data-id="unit"
                            data-type="text"
                            data-label="{{ meta.Column.unit.verbose_name }}"
                            data-model="service.values.unit"
                            data-errors="service.errors.unit">
                        </formgroup>
                        <formgroup
                            class="col-md-4"
                            data-id="ucd"
                            data-type="text"
                            data-label="{{ meta.Column.ucd.verbose_name }}"
                            data-model="service.values.ucd"
                            data-errors="service.errors.ucd">
                        </formgroup>
                        <formgroup
                            class="col-md-4"
                            data-id="utype"
                            data-type="text"
                            data-label="{{ meta.Column.utype.verbose_name }}"
                            data-model="service.values.utype"
                            data-errors="service.errors.utype">
                        </formgroup>
                    </div>
                    <div class="row">
                        <formgroup
                            class="col-md-6"
                            data-id="datatype"
                            data-type="text"
                            data-label="{{ meta.Column.datatype.verbose_name }}"
                            data-help="{{ meta.Column.datatype.help_text }}"
                            data-model="service.values.datatype"
                            data-errors="service.errors.datatype">
                        </formgroup>
                        <formgroup
                            class="col-md-6"
                            data-id="arraysize"
                            data-type="number"
                            data-label="{{ meta.Column.arraysize.verbose_name }}"
                            data-help="{{ meta.Column.arraysize.help_text }}"
                            data-model="service.values.arraysize"
                            data-errors="service.errors.arraysize">
                        </formgroup>
                    </div>
                    <formgroup
                        data-id="index_for"
                        data-type="text"
                        data-label="{{ meta.Column.index_for.verbose_name }}"
                        data-help="{{ meta.Column.index_for.help_text }}"
                        data-model="service.values.index_for"
                        data-errors="service.errors.index_for">
                    </formgroup>
                    <formgroup
                        data-id="principal"
                        data-type="checkbox"
                        data-label="{{ meta.Column.principal.verbose_name }}"
                        data-help="{{ meta.Column.principal.help_text }}"
                        data-model="service.values.principal"
                        data-errors="service.errors.principal">
                    </formgroup>
                    <formgroup
                        data-id="indexed"
                        data-type="checkbox"
                        data-label="{{ meta.Column.indexed.verbose_name }}"
                        data-help="{{ meta.Column.indexed.help_text }}"
                        data-model="service.values.indexed"
                        data-errors="service.errors.indexed">
                    </formgroup>
                    <formgroup
                        data-id="std"
                        data-type="checkbox"
                        data-label="{{ meta.Column.std.verbose_name }}"
                        data-help="{{ meta.Column.std.help_text }}"
                        data-model="service.values.std"
                        data-errors="service.errors.std">
                    </formgroup>
                    {% if settings.METADATA_COLUMN_PERMISSIONS %}
                    <div class="row">
                        <formgroup
                            class="col-md-6"
                            data-id="access_level"
                            data-type="select"
                            data-label="{{ meta.Column.access_level.verbose_name }}"
                            data-help="{{ meta.Column.access_level.help_text }}"
                            data-model="service.values.access_level"
                            data-errors="service.errors.access_level"
                            data-options="service.accesslevels"
                            data-options-label="text">
                        </formgroup>
                        <formgroup
                            class="col-md-6"
                            data-id="metadata_access_level"
                            data-type="select"
                            data-label="{{ meta.Column.metadata_access_level.verbose_name }}"
                            data-help="{{ meta.Column.metadata_access_level.help_text }}"
                            data-model="service.values.metadata_access_level"
                            data-errors="service.errors.metadata_access_level"
                            data-options="service.accesslevels"
                            data-options-label="text">
                        </formgroup>
                    </div>
                    <formgroup
                        data-id="groups"
                        data-type="multicheckbox"
                        data-label="{% trans 'Groups with access' %}"
                        data-model="service.values.groups"
                        data-errors="service.errors.groups"
                        data-options="service.groups"
                        data-options-label="name">
                    </formgroup>
                    {% endif %}
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        {% trans 'Close' %}
                    </button>
                    <button type="button" class="btn btn-default"
                        ng-click="service.discoverItem('columns')">
                        {% trans 'Autofill' %}
                    </button>
                    <button type="button" class="btn btn-primary"
                            ng-click="service.submitFormModal('columns')">
                        {% trans 'Save' %}
                    </button>
                </div>
            </div>
        </div>
    </div>
