{% extends "base.html" %}

{% block title %}{{ _('Location Type') }} — {{ service_name }}{% endblock %}

{% block stylesheets %}
  {{ super() }}
  <link rel="stylesheet" href="{{ fingerprinted_static('bootstrap-select/css/bootstrap-select.min.css') }}"/>
{% endblock %}

{% block template_values %}
  {% do set_template_value("language_info.english_id", ENGLISH.id) %}

  {{ super() }}
{% endblock %}

{% block scripts %}
  {{ super() }}
  <script src="{{ fingerprinted_static('bootstrap-select/js/bootstrap-select.min.js') }}"></script>
  <script src="{{ fingerprinted_static('sampledb/js/page/location_type_form.js') }}" type="module"></script>
{% endblock %}

{% block content %}
  <form method="post">
    {{ location_type_form.hidden_tag() }}

    <div class="form-group row" style="padding-right: 10px">
      <label for="select-languages" class="control-label col-md-10">{{ _("Languages") }}</label>
      <select class="selectpicker btn-xs select-language col-md-2" data-style="btn-default btn-xs" multiple="multiple" name="translation-languages" id="select-languages">
        {% for language in languages %}
          <option value="{{ language.id }}" {% if language.id == ENGLISH.id %} disabled="disabled" selected="selected" {% endif %} {% if language.id in translation_language_ids %} selected="selected"{% endif %} data-name="{{ language.names | get_translated_text }}">{{ language.names | get_translated_text }}</option>
        {% endfor %}
      </select>
    </div>
    <div class="form-group">
      <div class="form-group" style="margin-bottom: 0">
          <label class="control-label">{{ _('Name') }}</label>
      </div>
      {% for language in languages %}
        <div class="form-group" data-language-id="{{ language.id }}">
          <div class="input-group">
            <input type="text" class="form-control" name="name_{{ language.id }}" placeholder="{{ _('Name') }}" value="{{ translated_texts.name.get(language.lang_code, '') }}" data-empty-text="{{ _("Please enter a name.") }}" data-max-length="100" data-max-length-text="{{ _("Please enter a shorter name (at most 100 characters).") }}">
            <span class="input-group-addon language-addon">{{ language.names | get_translated_text }}</span>
          </div>
          <span class="help-block"></span>
        </div>
      {% endfor %}
    </div>
    <div class="form-group">
      <div class="form-group" style="margin-bottom: 0">
          <label class="control-label">{{ _('Location Name (Singular)') }}</label>
      </div>
      {% for language in languages %}
        <div class="form-group" data-language-id="{{ language.id }}">
          <div class="input-group">
            <input type="text" class="form-control" name="location_name_singular_{{ language.id }}" placeholder="{{ _('Location Name (Singular)') }}" value="{{ translated_texts.location_name_singular.get(language.lang_code, '') }}" data-empty-text="{{ _("Please enter a name.") }}" data-max-length="100" data-max-length-text="{{ _("Please enter a shorter name (at most 100 characters).") }}">
            <span class="input-group-addon language-addon">{{ language.names | get_translated_text }}</span>
          </div>
          <span class="help-block"></span>
        </div>
      {% endfor %}
    </div>
    <div class="form-group">
      <div class="form-group" style="margin-bottom: 0">
          <label class="control-label">{{ _('Location Name (Plural)') }}</label>
      </div>
      {% for language in languages %}
        <div class="form-group" data-language-id="{{ language.id }}">
          <div class="input-group">
            <input type="text" class="form-control" name="location_name_plural_{{ language.id }}" placeholder="{{ _('Location Name (Plural)') }}" value="{{ translated_texts.location_name_plural.get(language.lang_code, '') }}" data-empty-text="{{ _("Please enter a name.") }}" data-max-length="100" data-max-length-text="{{ _("Please enter a shorter name (at most 100 characters).") }}">
            <span class="input-group-addon language-addon">{{ language.names | get_translated_text }}</span>
          </div>
          <span class="help-block"></span>
        </div>
      {% endfor %}
    </div>
    <div class="checkbox">
      <label for="input-admin_only" style="font-weight:400">
        <input type="checkbox" id="input-admin_only" name="{{ location_type_form.admin_only.name }}" {% if location_type_form.admin_only.data %}checked="checked"{% endif %}> {{ _('Only administrators can create locations of this type') }}
      </label>
    </div>
    <div class="checkbox">
      <label for="input-enable_parent_location" style="font-weight:400">
        <input type="checkbox" id="input-enable_parent_location" name="{{ location_type_form.enable_parent_location.name }}" {% if location_type_form.enable_parent_location.data %}checked="checked"{% endif %}> {{ _('Locations of this type may have a parent location') }}
      </label>
    </div>
    <div class="checkbox">
      <label for="input-enable_sub_locations" style="font-weight:400">
        <input type="checkbox" id="input-enable_sub_locations" name="{{ location_type_form.enable_sub_locations.name }}" {% if location_type_form.enable_sub_locations.data %}checked="checked"{% endif %}> {{ _('Locations of this type may have sub-locations') }}
      </label>
    </div>
    <div class="checkbox">
      <label for="input-enable_object_assignments" style="font-weight:400">
        <input type="checkbox" id="input-enable_object_assignments" name="{{ location_type_form.enable_object_assignments.name }}" {% if location_type_form.enable_object_assignments.data %}checked="checked"{% endif %}> {{ _('Objects may be assigned to locations of this type') }}
      </label>
    </div>
    <div class="checkbox {% if config['DISABLE_INSTRUMENTS'] %}hidden{% endif %}">
      <label for="input-enable_instruments" style="font-weight:400">
        <input type="checkbox" id="input-enable_instruments" name="{{ location_type_form.enable_instruments.name }}" {% if location_type_form.enable_instruments.data %}checked="checked"{% endif %}> {{ _('Instruments may be assigned to locations of this type') }}
      </label>
    </div>
    <div class="checkbox">
      <label for="input-enable_responsible_users" style="font-weight:400">
        <input type="checkbox" id="input-enable_responsible_users" name="{{ location_type_form.enable_responsible_users.name }}" {% if location_type_form.enable_responsible_users.data %}checked="checked"{% endif %}> {{ _('Locations of this type may have responsible users') }}
      </label>
    </div>
    <div class="checkbox">
      <label for="input-enable_capacities" style="font-weight:400">
        <input type="checkbox" id="input-enable_capacities" name="{{ location_type_form.enable_capacities.name }}" {% if location_type_form.enable_capacities.data %}checked="checked"{% endif %}> {{ _('Locations of this type have a limited storage capacity') }}
      </label>
    </div>
    <div class="checkbox">
      <label for="input-show_location_log" style="font-weight:400">
        <input type="checkbox" id="input-show_location_log" name="{{ location_type_form.show_location_log.name }}" {% if location_type_form.show_location_log.data %}checked="checked"{% endif %}> {{ _('Show a log for locations of this type') }}
      </label>
    </div>
    <div class="form-group row clearfix" style="padding-right:0.75em">
      <div class="col-md-3 col-md-offset-6">
        <a href="{{ url_for('.location_types') }}" class="btn btn-default pull-right" style="width:20em">{{ _('Cancel') }}</a>
      </div>
      <div class="col-md-3">
        <button type="submit" class="btn btn-primary pull-right" style="width:20em">{{ submit_text }}</button>
      </div>
    </div>
  </form>
{% endblock %}
