<script type="text/template" id="alert_template">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <%= msg %>
</script>

<script type="text/template" id="save_template">
    <button type="button" class="btn btn-primary save-all">
        <i class="fa fa-hdd-o icon-white" aria-hidden="true"></i> {% trans %}Save all changes{% endtrans %}
    </button>
</script>

<script type="text/template" id="modal_template">
    <div class="modal-body">
        <p><%= msg %></p>
    </div>
    <div class="modal-footer">
        <button type="button" data-dismiss="modal" class="btn cancel">{% trans %}Close{% endtrans %}</button>
        <button type="button" class="btn btn-primary confirm">{% trans %}Ok{% endtrans %}</button>
    </div>
</script>

<script type="text/template" id="item_list_view_template">
    <div class="row-fluid">
        <div class="span12">
            <div class="create-subview"></div>
            <div class="sidebar-search-block">
                <input class="input-block-level" type="text" id="live_search"  placeholder="{% trans %}Live search{% endtrans %}"/>
            </div>
        </div>
    </div>
    <div class="row-fluid">
        <div class="span12 list-block">
            <ul id="collection-fields" class="unstyled"></ul>
        </div>
    </div>
</script>

<script type="text/template" id="create_template">
    <div class="row-fluid">
        <div class="span12">
            <div class="sidebar-add-block">
                <button type="button" class="btn btn-success btn-add-field"><i class="fa fa-plus icon-white"
                                                                               aria-hidden="true"></i>{% trans %}Add a
                    new field{% endtrans %}</button>
            </div>
            <div class="well well-small add-field-block" style="display:none">
                <h3>{% trans %}Add a new field{% endtrans %}</h3>
                <form class="form-horizontal">
                    <div class="control-group">
                        <label class="control-label" for="new-name"">{% trans %}Name{% endtrans %}</label>
                        <div class="controls">
                            <input type="text" id="new-name" class="input-block-level" placeholder="">
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="new-source">{% trans %}Source{% endtrans %}</label>
                        <div class="controls">
                            <input type="text" placeholder="XMP, IPTC ..." id="new-source" class="input-block-level" placeholder="">
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="control-group">
                        <div class="controls">
                            <button type="button" class="btn btn-success btn-submit-field"><i
                                        class="fa fa-check icon-white" aria-hidden="true"></i>{% trans %}
                                Add{% endtrans %}</button>
                            <button type="button" class="btn btn-cancel-field">{% trans %}Cancel{% endtrans %}</button>
                        </div>
                    </div>
                    <input id="new-multivalued" type="hidden" />
                </form>
            </div>
        </div>
    </div>
</script>

<script type="text/template" id="edit_template">
    <div class="edit-block">
        <table>
            <tr class="edit-order">
                <td>{% trans %}Order{% endtrans %}</td>
                <td><%= field.sorter %></td>
                <td>
                    <button type="button" class="btn btn-danger delete-field pull-right"><i
                                class="fa fa-trash-o icon-white" aria-hidden="true"></i>delete
                    </button>
                </td>
            </tr>
            <tr class="edit-name">
                <td colspan="2">
                    <%= field.name %>
                </td>
            </tr>
            <tr class="edit-label ">
                <td colspan="2" class="control-group">
                    <ul class="unstyled inline">
                        <ul class="unstyled inline">
                            <% _.each(field.labels, function(value, code) { %>
                                <li class="lng-label <%= code === lng ? 'select' : ''%>"><a href="#label_<%= code %>"><%= languages[code] %></a></li>
                            <% }); %>
                        </ul>
                    </ul>
                    <% _.each(field.labels, function(value, code) { %>
                        <input type="text" value="<%= value %>" id="label_<%= code %>" class="input-block-level input-label" <%= code === lng ? '' : 'style="display:none"'%> >
                    <% }); %>
                </td>
            </tr>
            <tr>
                <td>{% trans %}Source{% endtrans %}</td>
                <td class="control-group <%= modelErrors && modelErrors.has('tag') ? 'error' : '' %>">
                    <input id="tag" val="<%= field.tag %>" class="input-block-level"/>
                    <span class="help-block">
                        <% if(modelErrors && modelErrors.get('tag')) { %>
                            <%= modelErrors.get('tag').message %>
                        <% } %>
                    </span>
                </td>
            </tr>
            <tr>
                <td>{% trans %}DCES{% endtrans %}</td>
                <td class="dc-fields-subview"></td>
            </tr>
            <tr>
                <td colspan="2" class="dces-help-block info"></td>
            </tr>
            <tr>
                <td><label for="type">{% trans %}Type{% endtrans %}</label></td>
                <td>
                    <select id="type">
                        <option <%= field.type == '' ? 'selected' : '' %> value=""></option>
                        <option <%= field.type == 'string' ? 'selected' : '' %> value="string">string</option>
                        <option <%= field.type == 'number' ? 'selected' : '' %> value="number">number</option>
                        <option <%= field.type == 'date' ? 'selected' : '' %> value="date">date</option>
                    </select>
                </td>
            </tr>
        </table>
        <div class="edit-form">
            <table>
                <tr>
                    <td colspan="2">
                        <% if(field['vocabulary-type'] != null && field['vocabulary-type'] != '') { %>
                            <label for="vocabulary-restricted" class="checkbox">
                                <input id="vocabulary-restricted" type="checkbox" <%= field["vocabulary-restricted"] ? "checked='checked'" : "" %> />
                                {% trans %}Limited vocabulary{% endtrans %}
                            </label>
                        <% } %>
                    </td>
                </tr>
            </table>
            <h4>{% trans %}Display & action settings{% endtrans %}</h4>
            <table>
                <tr>
                    <td>
                        <label for="multi" class="checkbox">
                            <input id="multi" type="checkbox" <%= field["multi"] ? "checked='checked'" : "" %> />
                            {% trans %}Multivalued{% endtrans %}
                        </label>
                    </td>
                    <td>
                        <label id="separatorZone" style="display:<%= field.multi ? "inherit" : "none" %>" for="separator">{% trans %}Separator{% endtrans %}
                            <input style="width:50px;" id="separator" type="text" value="<%= field.separator %>" />
                        </label>
                    </td>
                </tr>

                <tr>
                    <td>
                        <label for="required" class="checkbox">
                            <input id="required" type="checkbox" <%= field.required ? "checked='checked'" : "" %> />
                            {% trans %}Mandatory{% endtrans %}
                        </label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="indexable" class="checkbox">
                            <input id="indexable" type="checkbox" <%= field.indexable ? "checked='checked'" : "" %> />
                            {% trans %}Indexable{% endtrans %}
                        </label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="readonly" class="checkbox">
                            <input id="readonly" type="checkbox" <%= field.readonly ? "checked='checked'" : "" %> />
                            {% trans %}Read-only{% endtrans %}
                        </label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="gui_editable" class="checkbox">
                            <input id="gui_editable" type="checkbox" <%= field.gui_editable ? "checked='checked'" : "" %> />
                            {% trans %}Gui-editable{% endtrans %}
                        </label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="gui_visible" class="checkbox">
                            <input id="gui_visible" type="checkbox" <%= field.gui_visible ? "checked='checked'" : "" %> />
                            {% trans %}Gui-visible{% endtrans %}
                        </label>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <label for="business" class="checkbox">
                            <input id="business" type="checkbox" <%= field.business ? "checked='checked'" : "" %> />
                            {% trans %}Business Fields{% endtrans %}
                        </label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="report" class="checkbox">
                            <input id="report" type="checkbox" <%= field.report ? "checked='checked'" : "" %> />
                            {% trans %}Report{% endtrans %}
                        </label>
                    </td>
                </tr>
                <tr>
                    <td><label for="thumbtitle">{% trans %}Display thumbnails{% endtrans %}</label></td>
                    <td>
                        <select id="thumbtitle">
                            <option value="1" <%= field.thumbtitle == "1" ? "selected" : "" %> >{{ 'Tous' | trans }}</option>
                            <option value="0" <%= field.thumbtitle == "0" ? "selected" : "" %> >{{ 'Aucun' | trans }}</option>
                            {% for code, language in languages %}
                                <option value="{{ code }}" <%= field.thumbtitle == "{{ code }}" ? "selected" : "" %> >{{ language}}</option>
                            {% endfor %}
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="aggregable">{% trans %}Aggregation{% endtrans %}</label>
                    </td>
                    <td>
                        <%= field['aggregable'] == "0" ? '{% trans %}Not aggregated{% endtrans %}' : '' %>
                        <%= field['aggregable'] == "10" ? '10 values' : '' %>
                        <%= field['aggregable'] == "20" ? '20 values' : '' %>
                        <%= field['aggregable'] == "50" ? '50 values' : '' %>
                        <%= field['aggregable'] == "100" ? '100 values' : '' %>
                        <%= field['aggregable'] == "-1" ? 'All values' : '' %>
                    </td>
                </tr>
                <tr>
                    <td><label for="vocabulary-type">{% trans %}Vocabulary type{% endtrans %}</label></td>
                    <td>
                        <select id="vocabulary-type">
                            <option <%= field['vocabulary-type'] == null ? 'selected' : '' %> value=''></option>
                            <% _.each(vocabularyTypes, function(vocab) { %>
                            <option <%= field['vocabulary-type'] == vocab.type ? 'selected' : '' %> value="<%= vocab.type %>"><%= vocab.name %></option>
                            <% }); %>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td><label for="tbranch">{% trans %}Thesaurus branch{% endtrans %}</label></td>
                    <td>
                        <input id="tbranch" type="text" value="<%= field.tbranch %>"/>
                        <div style="display: inline-block;" <%= (field.tbranch == "") ? "class='generate-cterms hidden'" : "class='generate-cterms'" %> >
                            <label for="generate_cterms" class="checkbox">
                                <input id="generate_cterms" type="checkbox" <%= field.generate_cterms ? "checked='checked'" : "" %> />
                                {% trans %}Generate-cterms{% endtrans %}</label>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</script>

<script type="text/template" id="list_row_template">
    <table>
        <tr>
            <td class="handle">
                <i class="fa fa-arrows" aria-hidden="true"></i>
            </td>
            <td rowspan="2" class="trigger-click">
                <div class="field-name"><%= name %></div>
                <div class="field-tag"><%= tag %></div>
            </td>
            <td rowspan="2" class="chip trigger-click">
                <i class="fa fa-chevron-right" aria-hidden="true"></i>
            </td>
        </tr>
        <tr>
            <td class="position">
                <%= position %>
            </td>
        </tr>
    </table>
</script>

<script type="text/template" id="dc_fields_template">
    <select id="dces-element" class="input-block-level">
        <option <%= field['dces-element'] == null ? 'selected' : '' %> value=''></option>
        <% _.each(dces_elements, function(el) { %>
            <option <%= field['dces-element'] == el.label ? 'selected' : '' %> value="<%= el.label %>">DC:<%= el.label %></option>
        <% }); %>
    </select>
</script>

<script type="text/template" id="field_error_template">
    <% if(messages.length > 0) { %>
        <div class="well well-small">
            <i class="fa fa-exclamation-circle" aria-hidden="true"></i> {% trans %}Current configuration contains some
            errors{% endtrans %}
        </div>
    <% } %>
</script>
