{{!
  This file is part of Moodle - http://moodle.org/

  Moodle is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  Moodle is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template core_reportbuilder/local/settings/filters

    Template for custom report filters settings area

    Example context (json):
    {
        "filters": [{
            "hasavailablefilters": true,
            "availablefilters": [{
                "optiongroup": [{
                    "text": "User",
                    "values": [{
                        "value": 1,
                        "visiblename": "User name"
                    }]
                }]
            }],
            "hasactivefilters": true,
            "activefilters": [{
                "heading": "Email address",
                "entityname": "user",
                "headingeditable": "Email address"
            }]
        }]
    }
}}

<div data-region="settings-filters">
    {{#filters}}
        {{#hasavailablefilters}}
            <div class="reportbuilder-filters-select">
                <label for="addfilterselect" class="sr-only">{{#str}}selectafilter, core_reportbuilder{{/str}}</label>
                <select id="addfilterselect" name="addfilterselect" data-action="report-add-filter" class="w-100 custom-select">
                    <option value="0"></option>
                    {{#availablefilters}}
                        {{#optiongroup}}
                            <option disabled class="suggestions-heading">{{text}}</option>
                            {{#values}}
                                <option value="{{value}}">{{visiblename}}</option>
                            {{/values}}
                        {{/optiongroup}}
                    {{/availablefilters}}
                </select>
            </div>
        {{/hasavailablefilters}}

        <div data-region="active-filters" class="form-vertical">
            {{#hasactivefilters}}
                <ul class="list-group reportbuilder-sortable-list mt-2 ml-0">
                    {{#activefilters}}
                        <li class="list-group-item list-group-item-action d-flex align-items-start text-dark"
                            data-region="active-filter" data-filter-id="{{id}}" data-filter-name="{{heading}}" data-filter-position="{{sortorder}}">
                            <span class="btn btn-secondary p-1 mr-2">{{>core/drag_handle}}</span>
                            <div>
                                <div class="d-flex px-2">
                                    <small class="text-muted">{{entityname}} &bull; {{heading}}</small>
                                </div>
                                <div>
                                    {{{headingeditable}}}
                                </div>
                            </div>
                            <button class="btn btn-link p-0 ml-auto"
                                    type="button"
                                    data-action="report-remove-filter"
                                    title="{{#str}}deletefilter, core_reportbuilder, {{{heading}}}{{/str}}"
                                    aria-label="{{#str}}deletefilter, core_reportbuilder, {{{heading}}}{{/str}}">
                                    <span class="btn btn-danger p-1">
                                         {{#pix}}e/cancel, core{{/pix}}
                                    </span>
                            </button>
                        </li>
                    {{/activefilters}}
                </ul>
            {{/hasactivefilters}}

            {{^hasactivefilters}}
                {{< core_reportbuilder/local/settings/empty_message }}
                    {{$nothingtoshow}} {{#str}} nofilters, core_reportbuilder {{/str}} {{/nothingtoshow}}
                {{/ core_reportbuilder/local/settings/empty_message }}
            {{/hasactivefilters}}
        </div>
    {{/filters}}
</div>
