<commit_before>{% import 'macros/form.html' as form %}
{% resource 'montrose/jscolor' %}
{% resource 'montrose/country.js' %}

<form id='organization-edit-form' class="dataset-form form-horizontal" method="post" data-module="basic-form"
      enctype="multipart/form-data">
  {% block error_summary %}
    {{ form.errors(error_summary) }}
  {% endblock %}

  {% block basic_fields %}
    {% set attrs = {'data-module': 'slug-preview-target'} %}
    {{ form.input('title', label=_('Name'), id='field-name', placeholder=_('My Organization'), value=data.title, error=errors.title, classes=['control-full'], attrs=attrs) }}

    {# Perhaps these should be moved into the controller? #}
    {% set prefix = h.url_for(controller='organization', action='read', id='') %}
    {% set domain = h.url_for(controller='organization', action='read', id='', qualified=true) %}
    {% set domain = domain|replace("http://", "")|replace("https://", "") %}
    {% set domain = domain|replace("/organization/", "/country/") %}
    {% set attrs = {'data-module': 'slug-preview-slug', 'data-module-prefix': domain, 'data-module-placeholder': '<country>'} %}

    {{ form.prepend('name', label=_('URL'), prepend='country', id='field-url', placeholder=_('my-organization'), value=data.name, error=errors.name, attrs=attrs, is_required=true) }}

    {{ form.markdown('description', label=_('Description'), id='field-description', placeholder=_('A little information about my organization...'), value=data.description, error=errors.description) }}

    {% set is_upload = data.image_url and not data.image_url.startswith('http') %}
    {% set is_url = data.image_url and data.image_url.startswith('http') %}

    {{ form.image_upload(data, errors, is_upload_enabled=h.uploads_enabled(), is_url=is_url, is_upload=is_upload) }}

  {% endblock %}

  {% block custom_fields %}
    {% for extra in data.extras %}
      {% set prefix = 'extras__%d__' % loop.index0 %}
      {{ form.custom(
        names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'),
        id='field-extras-%d' % loop.index,
        label=_('Custom Field'),
        values=(extra.key, extra.value, extra.deleted),
        error=errors[prefix ~ 'key'] or errors[prefix ~ 'value']
      ) }}
    {% endfor %}

    {# Add a max if 3 empty columns #}
    {% for extra in range(data.extras|count, 3) %}
      {% set index = (loop.index0 + data.extras|count) %}
      {% set prefix = 'extras__%d__' % index %}
      {{ form.custom(
        names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'),
        id='field-extras-%d' % index,
        label=_('Custom Field'),
        values=(extra.key, extra.value, extra.deleted),
        error=errors[prefix ~ 'key'] or errors[prefix ~ 'value']
      ) }}
    {% endfor %}
  {% endblock %}

  <fieldset>
    <legend><h2>{{ _('Dashboard settings') }}<a class="btn btn-info pull-right"
                                                target="_blank"
                                                href="{% url_for controller='ckanext.montrose.controllers.dashboard:DashboardsController',
                                                                 action='montrose_country_dashboard',
                                                                 name=data.name%}" >
                                                    View Dashboard
                                                    </a></h2></legend>

    {{ form.select('montrose_dashboard_is_active', 'montrose_dashboard_is_active', _('Is dashboard active?'), options=[{'value': '1', 'text': 'Yes'}, {'value': '0', 'text': 'No'}], selected=data.montrose_dashboard_is_active) }}

    {{ form.select('montrose_lang_is_active', 'montrose_lang_is_active', _('Show language selector'), options=[{'value': '1', 'text': 'Yes'}, {'value': '0', 'text': 'No'}], selected=data.montrose_lang_is_active) }}

    {{ form.select('montrose_datasets_per_page', 'montrose_datasets_per_page', _('Datasets per page'), options=[
    {'value': '5', 'text': '5'}, {'value': '10', 'text': '10'},
    {'value': '15', 'text': '15'}, {'value': '20', 'text': '20'},
    {'value': '25', 'text': '25'}, {'value': '50', 'text': '50'}], selected=data.montrose_datasets_per_page) }}

    {{ form.markdown('montrose_country_header', label=_('Dashboard header'), id='montrose_country_header', placeholder=_('Set the dashboard header text'), value=data.montrose_country_header, error=errors.montrose_country_header) }}

    {{ form.markdown('montrose_country_footer', label=_('Dashboard footer'), id='montrose_country_footer', placeholder=_('Set the dashboard footer'), value=data.montrose_country_footer, error=errors.montrose_country_footer) }}

    {{ form.markdown('montrose_country_description', label=_('Dashboard description'), id='montrose_country_description', placeholder=('Set the dashboard description'), value=data.montrose_country_description, error=errors.montrose_country_description) }}

    {{ form.markdown('montrose_country_copyright', label=_('Dashboard copyright'), id='montrose_country_copyright', placeholder=_('Set the dashboard copyright'), value=data.montrose_country_copyright, error=errors.montrose_country_copyright) }}

    {% if data.id %}

    {% snippet 'organization/snippets/colors.html', data=data %}

    <fieldset>
    <legend>{{_('Map options')}} </legend>

      {{ form.select('montrose_map', 'montrose_map', _('Choose dashboard map view'), options=h.get_org_map_views(data.id), selected=data.montrose_map) }}

      <div class="control-group control-select montrose_map_main_property">
          <label class="control-label" for="montrose_map_main_property">Select map main property</label>
          <div class="controls ">
            <select id="montrose_map_main_property" name="montrose_map_main_property"></select>
          </div>
      </div>

    </fieldset>
      <a id="new-field-btn" class="new-field-btn btn btn-default">Add field</a>


      {% snippet 'organization/snippets/charts_list.html', data=data %}

    {% endif %}

  </fieldset>

  <div class="form-actions">
    {% block delete_button %}
      {% if h.check_access('organization_delete', {'id': data.id}) %}
        {% set locale = h.dump_json({'content': _('Are you sure you want to delete this Organization? This will delete all the public and private datasets belonging to this organization.')}) %}
        <a class="btn btn-danger pull-left" href="{% url_for controller='organization', action='delete', id=data.id %}"
           data-module="confirm-action" data-module-i18n="{{ locale }}">
          {% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
      {% endif %}
    {% endblock %}
    <button class="btn btn-primary" name="save" type="submit">
      {% block save_text %}{{ _('Save Organization') }}{% endblock %}</button>
  </div>
</form><commit_msg>Change dashboard admin interface to support multiple map resources<commit_after>{% import 'macros/form.html' as form %}
{% resource 'montrose/jscolor' %}
{% resource 'montrose/country.js' %}

<form id='organization-edit-form' class="dataset-form form-horizontal" method="post" data-module="basic-form"
      enctype="multipart/form-data">
  {% block error_summary %}
    {{ form.errors(error_summary) }}
  {% endblock %}

  {% block basic_fields %}
    {% set attrs = {'data-module': 'slug-preview-target'} %}
    {{ form.input('title', label=_('Name'), id='field-name', placeholder=_('My Organization'), value=data.title, error=errors.title, classes=['control-full'], attrs=attrs) }}

    {# Perhaps these should be moved into the controller? #}
    {% set prefix = h.url_for(controller='organization', action='read', id='') %}
    {% set domain = h.url_for(controller='organization', action='read', id='', qualified=true) %}
    {% set domain = domain|replace("http://", "")|replace("https://", "") %}
    {% set domain = domain|replace("/organization/", "/country/") %}
    {% set attrs = {'data-module': 'slug-preview-slug', 'data-module-prefix': domain, 'data-module-placeholder': '<country>'} %}

    {{ form.prepend('name', label=_('URL'), prepend='country', id='field-url', placeholder=_('my-organization'), value=data.name, error=errors.name, attrs=attrs, is_required=true) }}

    {{ form.markdown('description', label=_('Description'), id='field-description', placeholder=_('A little information about my organization...'), value=data.description, error=errors.description) }}

    {% set is_upload = data.image_url and not data.image_url.startswith('http') %}
    {% set is_url = data.image_url and data.image_url.startswith('http') %}

    {{ form.image_upload(data, errors, is_upload_enabled=h.uploads_enabled(), is_url=is_url, is_upload=is_upload) }}

  {% endblock %}

  {% block custom_fields %}
    {% for extra in data.extras %}
      {% set prefix = 'extras__%d__' % loop.index0 %}
      {{ form.custom(
        names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'),
        id='field-extras-%d' % loop.index,
        label=_('Custom Field'),
        values=(extra.key, extra.value, extra.deleted),
        error=errors[prefix ~ 'key'] or errors[prefix ~ 'value']
      ) }}
    {% endfor %}

    {# Add a max if 3 empty columns #}
    {% for extra in range(data.extras|count, 3) %}
      {% set index = (loop.index0 + data.extras|count) %}
      {% set prefix = 'extras__%d__' % index %}
      {{ form.custom(
        names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'),
        id='field-extras-%d' % index,
        label=_('Custom Field'),
        values=(extra.key, extra.value, extra.deleted),
        error=errors[prefix ~ 'key'] or errors[prefix ~ 'value']
      ) }}
    {% endfor %}
  {% endblock %}

  <fieldset>
    <legend><h2>{{ _('Dashboard settings') }}<a class="btn btn-info pull-right"
                                                target="_blank"
                                                href="{% url_for controller='ckanext.montrose.controllers.dashboard:DashboardsController',
                                                                 action='montrose_country_dashboard',
                                                                 name=data.name%}" >
                                                    View Dashboard
                                                    </a></h2></legend>

    {{ form.select('montrose_dashboard_is_active', 'montrose_dashboard_is_active', _('Is dashboard active?'), options=[{'value': '1', 'text': 'Yes'}, {'value': '0', 'text': 'No'}], selected=data.montrose_dashboard_is_active) }}

    {{ form.select('montrose_lang_is_active', 'montrose_lang_is_active', _('Show language selector'), options=[{'value': '1', 'text': 'Yes'}, {'value': '0', 'text': 'No'}], selected=data.montrose_lang_is_active) }}

    {{ form.select('montrose_datasets_per_page', 'montrose_datasets_per_page', _('Datasets per page'), options=[
    {'value': '5', 'text': '5'}, {'value': '10', 'text': '10'},
    {'value': '15', 'text': '15'}, {'value': '20', 'text': '20'},
    {'value': '25', 'text': '25'}, {'value': '50', 'text': '50'}], selected=data.montrose_datasets_per_page) }}

    {{ form.markdown('montrose_country_header', label=_('Dashboard header'), id='montrose_country_header', placeholder=_('Set the dashboard header text'), value=data.montrose_country_header, error=errors.montrose_country_header) }}

    {{ form.markdown('montrose_country_footer', label=_('Dashboard footer'), id='montrose_country_footer', placeholder=_('Set the dashboard footer'), value=data.montrose_country_footer, error=errors.montrose_country_footer) }}

    {{ form.markdown('montrose_country_description', label=_('Dashboard description'), id='montrose_country_description', placeholder=('Set the dashboard description'), value=data.montrose_country_description, error=errors.montrose_country_description) }}

    {{ form.markdown('montrose_country_copyright', label=_('Dashboard copyright'), id='montrose_country_copyright', placeholder=_('Set the dashboard copyright'), value=data.montrose_country_copyright, error=errors.montrose_country_copyright) }}

    {% if data.id %}

    {% snippet 'organization/snippets/colors.html', data=data %}

      <fieldset class="map-properties">
        <legend>{{ _('Map options') }}</legend>

        {% set montrose_maps = h.montrose_convert_to_list(data.montrose_map) %}

        {% for montrose_map in montrose_maps %}

          <div id="map-field_{{ loop.index }}" class="map-fields">

            {{ form.select('montrose_map', 'montrose_map', _('Resource'), options=h.get_org_map_views(data.id), selected=montrose_map) }}

            <div class="control-group control-select montrose_map_main_property">
              <label class="control-label" for="montrose_map_main_property">Property</label>
              <div class="controls">
                <select id="montrose_map_main_property" name="montrose_map_main_property"></select>
              </div>
            </div>
            <hr>
          </div>

        {% endfor %}

      </fieldset>

      <a id="new-field-btn" class="new-field-btn btn btn-default">Add field</a>


      {% snippet 'organization/snippets/charts_list.html', data=data %}

    {% endif %}

  </fieldset>

  <div class="form-actions">
    {% block delete_button %}
      {% if h.check_access('organization_delete', {'id': data.id}) %}
        {% set locale = h.dump_json({'content': _('Are you sure you want to delete this Organization? This will delete all the public and private datasets belonging to this organization.')}) %}
        <a class="btn btn-danger pull-left" href="{% url_for controller='organization', action='delete', id=data.id %}"
           data-module="confirm-action" data-module-i18n="{{ locale }}">
          {% block delete_button_text %}{{ _('Delete') }}{% endblock %}</a>
      {% endif %}
    {% endblock %}
    <button class="btn btn-primary" name="save" type="submit">
      {% block save_text %}{{ _('Save Organization') }}{% endblock %}</button>
  </div>
</form>
{'fraction_non_alphanumeric': 0.1767528468094249, 'fraction_numerical': 0.004870013607390962, 'mean_word_length': 3.5059696676347207, 'pattern_counts': {'":': 0, '<': 68, '<?xml version=': 0, '>': 68, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '17878', 'n_tokens_mistral': 4293, 'n_tokens_neox': 4051, 'n_words': 829}