<div class="filter-append filter-body">
  {% import 'includes/filters/filter-variables.j2' as vars %}

  <p class="doc">
    {% with key='Append-datasets-filter' %}{% include "includes/help.html" %}{% endwith %}
    Combine multiple HXL datasets.
  </p>

  {% set name='append-exclude-columns%02d' % n %}
  <div id="{{ name }}" class="checkbox">
    <label>
      {% if recipe.args[name] %}
      <input
          type="checkbox"
          name="{{ name }}"
          checked="checked"
          />
      {% else %}
      <input
          type="checkbox"
          name="{{ name }}"
          />
      {% endif %}
      Exclude columns not in original dataset.
      
    </label>
  </div>

  {% set name='append-dataset%02d' % n %}
  <div class="form-group required">
    <fieldset>
      {% for n in range(1, 51) %}
      {% set dataset_name = '%s-%02d' % (name, n) %}
      {% if n == 1 or recipe.args.get(dataset_name) %}
      <div class="append-source">
        <label for="{{ dataset_name }}">URL of additional dataset</label>
        <input
            class="form-control col-sm-6"
            id="{{ dataset_name }}"
            name="{{ dataset_name }}"
            value="{{ recipe.args[dataset_name] }}"
            type="url"
            placeholder="http://example.org/dataset.csv"
            />
        <a class="pull-right small" onclick="hxl_proxy.ui.delete($(this).closest('.append-source'), 'fieldset', '.append-source')">
          Remove URL
        </a>
        {% with id='#' + dataset_name + '-field' %}
        {% include "includes/selectors.html" %}
        {% endwith %}
      </div>
      {% endif %}
      {% endfor %}
      <a
          onclick="hxl_proxy.ui.duplicate($(this).prev('.append-source'), 'fieldset', '.append-source');">Add another URL</a>
    </fieldset>
  </div>

  {% set name='append-where%02d' % n %}
  <div class="form-group">
    <label for="{{ name }}">
      Append only rows matching this query
    </label>
    <input
        id="{{ name }}"
        class="form-control"
        name="{{ name }}"
        value="{{ recipe.args[name] }}"
        pattern="^{{ vars.query_pattern }}$"
        title="{{ vars.query_help }}"
        placeholder="{{ vars.query_placeholder }}"
        />
  </div>

</div>
