{{!
    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_courseformat/local/content/cm/cmname

    Convenience mustache to displays a course module inplcae editable from the format renderer.

    Format plugins are free to implement an alternative inplace editable for activities.

    Example context (json):
    {
        "url": "#",
        "icon": "../../../pix/help.svg",
        "iconclass": "",
        "pluginname": "File",
        "showpluginname": 1,
        "textclasses": "",
        "purpose": "content",
        "modname": "resource",
        "activityname": {
            "displayvalue" : "<a href=\"#\">Moodle</a>",
            "value" : "Moodle",
            "itemid" : "1",
            "component" : "core_unknown",
            "itemtype" : "unknown",
            "edithint" : "Edit this",
            "editlabel" : "New name for this",
            "type" : "text",
            "options" : "",
            "linkeverything": 0
        }
    }
}}
{{#url}}
    {{#ismoodle42minus}}
        {{! In moodle 4.0 - 4.2 the template was different }}
        <div class="activity-instance d-flex flex-column">
            <div class="activitytitle media {{textclasses}} modtype_{{modname}} position-relative align-self-start">
                <div class="activityiconcontainer {{purpose}} courseicon align-self-start me-3">
                    <img src="{{{icon}}}" class="activityicon {{iconclass}}"
                         alt="{{#ismoodle40}}{{{modname}}}{{/ismoodle40}}{{^ismoodle40}}{{#cleanstr}} activityicon, moodle, {{{pluginname}}} {{/cleanstr}}{{/ismoodle40}}"
                    >
                </div>
                <div class="media-body align-self-center">
                    {{#showpluginname}}
                        <div class="text-uppercase small">
                            {{{pluginname}}}
                        </div>
                    {{/showpluginname}}
                    <div class="activityname">
                        {{#activityname}}
                            {{$ core/inplace_editable }}
                                {{> core/inplace_editable }}
                            {{/ core/inplace_editable }}
                        {{/activityname}}
                    </div>
                </div>
            </div>
        </div>
    {{/ismoodle42minus}}
    {{^ismoodle42minus}}
    {{! Icon }}
        {{#activityicon}}
            {{$ format_tiles/local/content/cm/cmicon }}
                {{> format_tiles/local/content/cm/cmicon }}
            {{/ format_tiles/local/content/cm/cmicon }}
        {{/activityicon}}

        {{! Name & Badge}}
        <div class="activity-name-area activity-instance d-flex flex-column me-2 ">
            <div class="activitytitle media {{textclasses}} modtype_{{modname}} position-relative align-self-start">
                <div class="media-body align-self-center">
                    <div class="activityname">
                        {{#activityname}}
                            {{#editing}}
                                {{! We use the core template for non subtiles if user is editing, so modals will not be launched}}
                                {{$ core/inplace_editable }}
                                    {{> core/inplace_editable }}
                                {{/ core/inplace_editable }}
                            {{/editing}}
                            {{^editing}}
                                {{! If user is not editing, we use this for non subtiles as we need to add data-action for modal launch}}
                                <a id="cm-link-{{id}}" href="{{url}}"{{#modalType}} data-action="launch-tiles-cm-modal"{{/modalType}} class="aalink stretched-link"{{#onclick}} onclick="{{onclick}}"{{/onclick}}><span class="instancename">{{{cmtitle}}}</span></a>
                        {{#modalDescriptionHTML}}
                        {{! If this is a modal capable course module, we may include the description HTML here, hidden }}
                        {{! This enables JS to grab it and add it to the modal }}
                            <div class="modal-description" style="display: none;">{{{modalDescriptionHTML}}}</div>
                        {{/modalDescriptionHTML}}
                            {{/editing}}
                        {{/activityname}}
                        {{#activitybadge}}
                            {{$ core_courseformat/local/content/cm/activitybadge }}
                                {{> core_courseformat/local/content/cm/activitybadge }}
                            {{/ core_courseformat/local/content/cm/activitybadge }}
                        {{/activitybadge}}
                    </div>
                </div>
            </div>
        </div>
    {{/ismoodle42minus}}
{{/url}}
