{% load static %}
{% load i18n %}


<input type="hidden" name="view" id="filterView" value="">
  <div class="oh-dropdown__filter-body">
    <div class="oh-accordion">
      <div class="oh-accordion-header">{% trans "Allowance" %}</div>
      <div class="oh-accordion-body">
        <div class="row">
          <div class="col-sm-6">
            <div class="oh-input-group">
              <label class="oh-label">{% trans "Taxable" %}</label>
              {{ f.form.is_taxable }}
            </div>
          </div>
          <div class="col-sm-6">
            <div class="oh-input-group">
              <label class="oh-label">{% trans "Condition Based" %}</label>
              {{ f.form.is_condition_based }}
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-sm-6">
            <div class="oh-input-group">
              <label class="oh-label">{% trans "Fixed" %}</label>
              {{ f.form.is_fixed }}
            </div>
          </div>
          <div class="col-sm-6">
            <div class="oh-input-group">
              <label class="oh-label">{% trans "Based" %}</label>
              {{ f.form.based_on }}
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="oh-dropdown__filter-footer">
    <button type="submit" class="oh-btn oh-btn--secondary oh-btn--small w-100 filterButton" id="filterSubmit">
      {% trans "Filter" %}
    </button>
  </div>

<script>
  $("#filterForm").submit(function (e) {
    var formData = $(this).serialize();
    count = 0;
    formData.split("&").forEach(function (field) {
      parts = field.split("=");
      value = parts[1];
      if (parts[0] !== "view"){
        if (value && value !== "unknown") {
          count++;
        }
      }
    });
    $("#filterCount").empty();
    if (count > 0) {
      $("#filterCount").text("(" + count + ")");
    }
    // $('#field').attr('hx-vals',`{'data':${formData}}` );
  });
</script>
