{{!
    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 block_myoverview/nav-grouping-selector

    This template renders grouping dropdown.

    Example context (json):
    {
        "allincludinghidden": false,
        "all": true,
        "inprogress": false,
        "future": false,
        "past": false,
        "favourites": false,
        "hidden": false,
        "displaygroupingallincludinghidden": false,
        "displaygroupingall": true,
        "displaygroupinginprogress": true,
        "displaygroupingfuture": true,
        "displaygroupingpast": true,
        "displaygroupingfavourites": true,
        "displaygroupinghidden": true,
        "displaygroupingselector": true
    }
}}
{{#displaygroupingselector}}
<div class="dropdown mb-1 mr-auto">
    <button id="groupingdropdown" type="button" class="btn btn-sm btn-outline-primary dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-label="{{#str}} aria:groupingdropdown, block_myoverview {{/str}}">
        {{#pix}} i/filter {{/pix}}
        <span class="d-sm-inline-block" data-active-item-text>
            {{#allincludinghidden}}{{#str}} allincludinghidden, block_myoverview {{/str}}{{/allincludinghidden}}
            {{#all}}{{#str}} all, block_myoverview {{/str}}{{/all}}
            {{#inprogress}}{{#str}} inprogress, block_myoverview {{/str}}{{/inprogress}}
            {{#future}}{{#str}} future, block_myoverview {{/str}}{{/future}}
            {{#past}}{{#str}} past, block_myoverview {{/str}}{{/past}}
            {{#favourites}}{{#str}} favourites, block_myoverview {{/str}}{{/favourites}}
            {{#hidden}}{{#str}} hiddencourses, block_myoverview {{/str}}{{/hidden}}
            {{selectedcustomfield}}
        </span>
    </button>
    <ul class="dropdown-menu" data-show-active-item data-active-item-text aria-labelledby="groupingdropdown">
        {{#displaygroupingallincludinghidden}}
        <li>
            <a class="dropdown-item {{#allincludinghidden}}active{{/allincludinghidden}}" href="#" data-filter="grouping" data-value="allincludinghidden" data-pref="allincludinghidden" aria-label="{{#str}} aria:allcoursesincludinghidden, block_myoverview {{/str}}" aria-controls="courses-view-{{uniqid}}">
                {{#str}} allincludinghidden, block_myoverview {{/str}}
            </a>
        </li>
        {{/displaygroupingallincludinghidden}}
        {{#displaygroupingall}}
        <li class="dropdown-divider" role="presentation">
            <span class="filler">&nbsp;</span>
        </li>
        <li>
            <a class="dropdown-item {{#all}}active{{/all}}" href="#" data-filter="grouping" data-value="all" data-pref="all" aria-label="{{#str}} aria:allcourses, block_myoverview {{/str}}" aria-controls="courses-view-{{uniqid}}">
                {{#str}} all, block_myoverview {{/str}}
            </a>
        </li>
        {{/displaygroupingall}}
        {{#displaygroupinginprogress}}
        <li class="dropdown-divider" role="presentation">
            <span class="filler">&nbsp;</span>
        </li>
        <li>
            <a class="dropdown-item {{#inprogress}}active{{/inprogress}}" href="#" data-filter="grouping" data-value="inprogress" data-pref="inprogress" aria-label="{{#str}} aria:inprogress, block_myoverview {{/str}}" aria-controls="courses-view-{{uniqid}}">
                {{#str}} inprogress, block_myoverview {{/str}}
            </a>
        </li>
        {{/displaygroupinginprogress}}
        {{#displaygroupingfuture}}
            {{^displaygroupinginprogress}}
            <li class="dropdown-divider" role="presentation">
                <span class="filler">&nbsp;</span>
            </li>
            {{/displaygroupinginprogress}}
        <li>
            <a class="dropdown-item {{#future}}active{{/future}}" href="#" data-filter="grouping" data-value="future" data-pref="future" aria-label="{{#str}} aria:future, block_myoverview {{/str}}" aria-controls="courses-view-{{uniqid}}">
                {{#str}} future, block_myoverview {{/str}}
            </a>
        </li>
        {{/displaygroupingfuture}}
        {{#displaygroupingpast}}
            {{^displaygroupinginprogress}}
                {{^displaygroupingfuture}}
                <li class="dropdown-divider" role="presentation">
                    <span class="filler">&nbsp;</span>
                </li>
                {{/displaygroupingfuture}}
            {{/displaygroupinginprogress}}
        <li>
            <a class="dropdown-item {{#past}}active{{/past}}" href="#" data-filter="grouping" data-value="past" data-pref="past" aria-label="{{#str}} aria:past, block_myoverview {{/str}}" aria-controls="courses-view-{{uniqid}}">
                {{#str}} past, block_myoverview {{/str}}
            </a>
        </li>
        {{/displaygroupingpast}}
        {{#displaygroupingcustomfield}}
            <li class="dropdown-divider" role="presentation">
                <span class="filler">&nbsp;</span>
            </li>
            {{#customfieldvalues}}
                <li>
                    <a class="dropdown-item {{#active}}active{{/active}}" href="#" data-filter="grouping"
                       data-value="customfield" data-pref="customfield" data-customfieldvalue="{{value}}"
                       aria-label="{{#str}}aria:customfield, block_myoverview, {{name}}{{/str}}"
                       aria-controls="courses-view-{{uniqid}}">
                        {{name}}
                    </a>
                </li>
            {{/customfieldvalues}}
        {{/displaygroupingcustomfield}}
        {{#displaygroupingfavourites}}
        <li class="dropdown-divider" role="presentation">
            <span class="filler">&nbsp;</span>
        </li>
        <li>
            <a class="dropdown-item {{#favourites}}active{{/favourites}}" href="#" data-filter="grouping" data-value="favourites"  data-pref="favourites" aria-label="{{#str}} aria:favourites, block_myoverview {{/str}}" aria-controls="courses-view-{{uniqid}}">
                {{#str}} favourites, block_myoverview {{/str}}
            </a>
        {{/displaygroupingfavourites}}
        {{#displaygroupinghidden}}
        <li class="dropdown-divider" role="presentation">
            <span class="filler">&nbsp;</span>
        </li>
        <li>
            <a class="dropdown-item {{#hidden}}active{{/hidden}}" href="#" data-filter="grouping" data-value="hidden"  data-pref="hidden" aria-label="{{#str}} aria:hiddencourses, block_myoverview {{/str}}" aria-controls="courses-view-{{uniqid}}">
                {{#str}} hiddencourses, block_myoverview {{/str}}
            </a>
        </li>
        {{/displaygroupinghidden}}
    </ul>
</div>
{{/displaygroupingselector}}
{{^displaygroupingselector}}
<div class="mb-1 mr-auto">
    <span class="filler">&nbsp;</span>
</div>
{{/displaygroupingselector}}
