{{!
    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 calendar/event_item

    Calendar event item.

    The purpose of this template is to render the event item.

    Classes required for JS:
    * none

    Data attributes required for JS:
    * none

    Example context (json):
    {
        "id": 1,
        "name": "Sample event name",
        "normalisedeventtype": "course",
        "course": {
            "id": 1
        },
        "canedit": true,
        "candelete": true,
        "isactionevent": true,
        "icon": {
            "key": "i/courseevent",
            "component": "core",
            "alttext": "Some course event"
        },
        "editurl": "#",
        "url": "#"
    }
}}
<div class="calendar-event-box calendar_event_{{eventtype}}" {{!
    }} data-type="event"{{!
    }} data-course-id="{{course.id}}"{{!
    }} data-event-id="{{id}}"{{!
    }} class="event"{{!
    }} data-event-component="{{component}}"{{!
    }} data-event-eventtype="{{eventtype}}"{{!
    }} data-eventtype-{{normalisedeventtype}}="1"{{!
    }} data-event-title="{{name}}"{{!
    }} data-event-count="{{eventcount}}"{{!
    }}>
    <div class="calendar-event-row">
        <div class="calendar-event-content">
            <div class="calendar-event-settings">
                {{#canedit}}
                    {{#candelete}}
                        <a href="{{deleteurl}}" class="btn btn-sm btn-secondary mt-sm-0 mb-sm-1 my-md-0" data-action="delete">
                            {{#pix}}t/delete, core, {{#str}}delete{{/str}}{{/pix}}
                        </a>
                    {{/candelete}}
                    <a href="{{editurl}}" class="btn btn-sm btn-secondary mt-sm-0 mb-sm-3 my-md-0" data-action="edit">
                        {{#pix}}t/edit, core, {{#str}}edit{{/str}}{{/pix}}
                    </a>
                {{/canedit}}
            </div>

            <div class="calendar-event-date">{{{formattedtime}}}</div>

            <div class="calendar-event-icon">
              {{#icon}}{{#pix}} {{key}}, {{component}}, {{alttext}} {{/pix}}{{/icon}}
            </div>
            <h3 class="calendar-event-heading">{{name}}</h3>

        </div>
        <div class="calendar-event-desc">

            {{#iscategoryevent}}
                  <p class="cal-categoryevent">
                    {{#pix}} i/categoryevent, core, {{#str}} category {{/str}} {{/pix}}
                    {{{category.nestedname}}}
                  </p>
            {{/iscategoryevent}}
            {{#groupname}}
                  <p class="cal-groupname">
                    {{#pix}} i/courseevent, core, {{#str}} course {{/str}} {{/pix}}
                    <a href="{{url}}">{{{course.fullname}}}</a>
                  </p>
                  <p class="cal-groupevent">
                    {{#pix}} i/groupevent, core, {{#str}} group {{/str}} {{/pix}}
                    {{{groupname}}}
                  </p>
            {{/groupname}}

            <p>{{{description}}}</p>

            <div class="d-sm-block d-md-inline-flex align-items-center">
                {{#location}}
                <div class="d-inline-flex align-items-center badge badge-light">
                {{#pix}} i/location, core, {{#str}} location {{/str}} {{/pix}}
                <span class="ml-2">{{{.}}}</span>
                </div>
                {{/location}}
                {{#iscourseevent}}
                    <div><a href="{{url}}" class="badge badge-link badge-special">{{{course.fullname}}} <i class="fas fa-caret-right ml-1"></i></a></div>
                {{/iscourseevent}}
                {{> core_calendar/event_subscription}}
                {{#isactionevent}}
                    <a href="{{url}}" class="badge badge-link badge-secondary">{{#str}} gotoactivity, core_calendar {{/str}} <i class="fas fa-caret-right ml-1"></i></a>
                {{/isactionevent}}
                {{#groupname}}
                    <div><a href="{{url}}" class="badge badge-link badge-light">{{{course.fullname}}}</a></div>
                    <div>{{{groupname}}}</div>
                {{/groupname}}
            </div>


        </div>
    </div>
</div>
