{{!
    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/course-event-list

    This template renders a list of events for the myoverview block
    sort by courses view.

    Example context (json):
    {
         "urls": {
            "noevents": "#"
        }
    }
}}
<div data-region="event-list-container"
     data-limit="{{$limit}}20{{/limit}}"
     data-course-id="{{$courseid}}{{/courseid}}"
     data-last-id="{{$lastid}}{{/lastid}}"
     data-midnight="{{midnight}}"
     id="event-list-container-{{$courseid}}{{/courseid}}">

    <div data-region="event-list-content">
        {{< block_myoverview/event-list-group }}
            {{$title}}{{#str}} recentlyoverdue, block_myoverview {{/str}}{{/title}}
            {{$extratitleclasses}}text-danger{{/extratitleclasses}}
            {{$startday}}-14{{/startday}}
            {{$endday}}0{{/endday}}
            {{$eventlistitems}}
                {{> block_myoverview/course-event-list-items }}
            {{/eventlistitems}}
        {{/ block_myoverview/event-list-group }}
        {{< block_myoverview/event-list-group }}
            {{$title}}{{#str}} today {{/str}}{{/title}}
            {{$extratitleclasses}}{{/extratitleclasses}}
            {{$startday}}0{{/startday}}
            {{$endday}}1{{/endday}}
            {{$eventlistitems}}
                {{> block_myoverview/course-event-list-items }}
            {{/eventlistitems}}
        {{/ block_myoverview/event-list-group }}
        {{< block_myoverview/event-list-group }}
            {{$title}}{{#str}} next7days, block_myoverview {{/str}}{{/title}}
            {{$extratitleclasses}}{{/extratitleclasses}}
            {{$startday}}1{{/startday}}
            {{$endday}}7{{/endday}}
            {{$eventlistitems}}
                {{> block_myoverview/course-event-list-items }}
            {{/eventlistitems}}
        {{/ block_myoverview/event-list-group }}
        {{< block_myoverview/event-list-group }}
            {{$title}}{{#str}} next30days, block_myoverview {{/str}}{{/title}}
            {{$extratitleclasses}}{{/extratitleclasses}}
            {{$startday}}7{{/startday}}
            {{$endday}}30{{/endday}}
            {{$eventlistitems}}
                {{> block_myoverview/course-event-list-items }}
            {{/eventlistitems}}
        {{/ block_myoverview/event-list-group }}
        {{< block_myoverview/event-list-group }}
            {{$title}}{{#str}} future, block_myoverview {{/str}}{{/title}}
            {{$extratitleclasses}}{{/extratitleclasses}}
            {{$startday}}30{{/startday}}
            {{$endday}}{{/endday}}
            {{$eventlistitems}}
                {{> block_myoverview/course-event-list-items }}
            {{/eventlistitems}}
        {{/ block_myoverview/event-list-group }}

        <div class="text-xs-center text-center m-b-1">
            <button type="button" class="btn btn-secondary" data-action="view-more">
                {{#str}} viewmore {{/str}}
                <span class="hidden" data-region="loading-icon-container">
                    {{> core/loading }}
                </span>
            </button>
        </div>
    </div>
    <div class="hidden text-xs-center text-center m-y-3" data-region="empty-message">
        <img class="empty-placeholder-image-sm"
             src="{{urls.noevents}}"
             alt="{{#str}} noevents, block_myoverview {{/str}}"
             role="presentation">
        <p class="text-muted m-t-1">{{#str}} noevents, block_myoverview {{/str}}</p>
        <a href="{{viewurl}}" class="btn"
           aria-label="{{#str}} viewcoursename, block_myoverview, {{{fullnamedisplay}}} {{/str}}">
            {{#str}} viewcourse, block_myoverview {{/str}}
        </a>
    </div>
</div>
{{#js}}
require(['jquery', 'block_myoverview/event_list'], function($, EventList) {
    var root = $("#event-list-container-{{$courseid}}{{/courseid}}");
    EventList.registerEventListeners(root);
});
{{/js}}
