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

  <p class="doc">
    {% with key='Merge-columns-filter' %}{% include "includes/help.html" %}{% endwith %}
    Add columns from another dataset, based on common keys.
  </p>

  {% include 'includes/filters/label-field.html' %}

  {% set name='merge-url%02d' % n %}
  <div class="form-group required">
    <label for="{{ name }}">
      URL of merge dataset (pull extra data from here)
    </label>
    <input
        id="{{ name }}"
        class="form-control"
        id="{{ name }}-field"
        name="{{ name }}"
        type="url"
        value="{{ recipe.args[name] }}"
        required="required"
        placeholder="http://example.org/data-to-merge.csv"
        />
    {% with id='#' + name + '-field' %}
    {% include "includes/selectors.html" %}
    {% endwith %}
  </div>

  {% set name='merge-keys%02d' % n %}
  <div class="form-group required">
    <label for="{{ name }}">
      Shared keys (values that are the same in both datasets)
    </label>
    <input
        id="{{ name }}"
        class="form-control"
        name="{{ name }}"
        value="{{ recipe.args[name] }}"
        required="required"
        pattern="^{{ vars.filters_pattern }}$"
        title="{{ vars.filters_help }}"
        placeholder="{{ vars.filters_placeholder }}"
        />
  </div>

  {% set name='merge-tags%02d' % n %}
  <div class="form-group required">
    <label for="{{ name }}">
      Tags to copy from other dataset
    </label>
    <input
        id="{{ name }}"
        class="form-control"
        name="{{ name }}"
        value="{{ recipe.args[name] }}"
        required="required"
        pattern="^{{ vars.filters_pattern }}$"
        title="{{ vars.filters_help }}"
        placeholder="{{ vars.filters_placeholder }}"
        />
  </div>

  {% set name='merge-replace%02d' % n %}
  <div class="checkbox">
    <label>
      <input
          type="checkbox"
          name="{{ name }}"
          {% if recipe.args[name] %}
          checked="checked"
          {% endif %}
          />
      Use existing columns where possible.
    </label>
  </div>

  {% set name='merge-overwrite%02d' % n %}
  <div class="checkbox">
    <label>
      <input
          type="checkbox"
          name="{{ name }}"
          {% if recipe.args[name] %}
          checked="checked"
          {% endif %}
          />
      Overwrite existing values.
    </label>
  </div>

</div>
