{{!
    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 mod_booking/subbookingslist

    Classes required for JS:
    * none

    Example context (json):
    {
        "optionid": 3,
        "cmid": 3,
        "subbookings": [
            {
                "id": 14,
                "name": "my name",
                "localizedsubbookingname": "Localized subbooking name 1"
            }
        ]
    }
}}

<div class="booking-subbookings-container">
    <div class="btn btn-success bookingsubbooking-button"
        data-action="add"
        data-id="0"
        data-cmid="{{cmid}}"
        data-optionid="{{optionid}}">
        <i class="fa fa-plus-square" aria-hidden="true"></i>&nbsp;{{#str}} bookingsubbookingadd, mod_booking {{/str}}
    </div>
    <ul class="mt-3 list-group booking-subbookings-list">
        {{#subbookings}}
        <li class="list-group-item">
            <div class="d-flex justify-content-between">
                <h5><i class="fa fa-puzzle-piece" aria-hidden="true"></i> {{name}}</h5>
                <div class="btn-group" role="group" aria-label="Booking subbooking buttons">
                    <div class="btn btn-sm btn-outline-danger bookingsubbooking-button"
                        data-action="delete"
                        data-id="{{id}}"
                        data-cmid="{{cmid}}"
                        data-name="{{name}}"
                        data-optionid="{{optionid}}">
                        <i class="fa fa-trash" aria-hidden="true"></i> {{#str}} delete {{/str}}
                    </div>
                    <div class="btn btn-sm btn-outline-primary bookingsubbooking-button"
                        data-action="edit"
                        data-id="{{id}}"
                        data-cmid="{{cmid}}"
                        data-name="{{name}}"
                        data-optionid="{{optionid}}">
                        <i class="fa fa-pencil" aria-hidden="true"></i> {{#str}} edit {{/str}}
                    </div>
                </div>
            </div>
            <div class="container">
                <div class="row">
                    <small>{{localizedsubbookingname}}</small>
                </div>
            </div>
        </li>
        {{/subbookings}}
    </ul>
</div>

{{#js}}
    require(['mod_booking/dynamicsubbookingsform'], function(init) {
    init.init(['div.bookingsubbooking-button']);
    });
{{/js}}