{{!
    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/ruleslist

    Classes required for JS:
    * none

    Data attributes required for JS:
    * data-region

    Example context (json):
    {
        "rules" : [
            {

                "id": 1,
                "name" : "Rule name",
                "contextid": 1,
                "actionname" : "actionname",
                "conditionname" : "conditionname",
                "localizedrulename" : "localizedrulename",
                "localizedactionname" : "localizedactionname",
                "localizedconditionname" : "localizedconditionname"

            }
        ],
        "contextid": 1
    }
}}

<div class="booking-rules-container">
    {{#enableaddbutton}}
        <div class="btn btn-success booking-rules-addnewrulebtn" data-action="edit-or-new" data-id="0" data-contextid="{{contextid}}">
            <i class="fa fa-plus-square" aria-hidden="true"></i>&nbsp;{{#str}} addbookingrule, mod_booking {{/str}}
        </div>
    {{/enableaddbutton}}
    {{^enableaddbutton}}
        <div class="alert alert-warning">
            {{#str}} useprotoenablemorerules, mod_booking {{/str}}
        </div>
    {{/enableaddbutton}}
    <ul class="mt-3 list-group booking-rules-list">
        {{#rules}}
        <li class="list-group-item {{#isactive}}ruleactive{{/isactive}} {{^isactive}}ruleinactive{{/isactive}}">
            <div class="d-flex justify-content-between">
                <h5>
                    {{name}}
                </h5>
                <div class="btn-group" role="group" aria-label="Booking rule buttons">
                    <div class="btn btn-sm btn-outline-danger" data-action="delete" data-id="{{id}}" data-name="{{name}}" data-contextid="{{contextid}}">
                        <i class="fa fa-trash" aria-hidden="true"></i> {{#str}} delete {{/str}}
                    </div>
                    <div class="btn btn-sm btn-outline-primary" data-action="edit-or-new" data-id="{{id}}" data-name="{{name}}" data-contextid="{{contextid}}">
                        <i class="fa fa-pencil" aria-hidden="true"></i> {{#str}} edit {{/str}}
                    </div>
                </div>
            </div>
            <div class="container">
                <div class="row">
                    <div class="col-sm-1 text-right">
                        <small>
                            {{#isactive}}<i class="fa fa-check" aria-hidden="true"></i> {{/isactive}}
                            {{^isactive}}<i class="fa fa-ban" aria-hidden="true"></i> {{/isactive}}
                        </small>
                    </div>
                    <div class="col-sm-11">
                        <small>
                            {{#isactive}} {{#str}} bookingruleisactive, mod_booking {{/str}} {{/isactive}}
                            {{^isactive}} {{#str}} bookingruleisnotactive, mod_booking {{/str}} {{/isactive}}
                        </small>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-1 text-right">
                        <small><i class="fa fa-bolt" aria-hidden="true"></i></small>
                    </div>
                    <div class="col-sm-11">
                        <small>{{localizedrulename}}</small>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-1 text-right">
                        <small><i class="fa fa-list-ul" aria-hidden="true"></i></small>
                    </div>
                    <div class="col-sm-11">
                        <small>{{localizedconditionname}}</small>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-1 text-right">
                        <small><i class="fa fa-play" aria-hidden="true"></i></small>
                    </div>
                    <div class="col-sm-11">
                        <small>{{localizedactionname}}</small>
                    </div>
                </div>
            </div>
        </li>
        {{/rules}}
    </ul>
    {{#displayothercontexts}}
        <div class="mt-4">
            <h5 class="mb-3">{{#str}} bookingrulesothercontextheading, mod_booking {{/str}}</h5>
            {{#rulesothercontext}}
                <div>
                    <a href="{{linktorulesininstance}}" target="_blank">
                        <i class="fa fa-fw fa-graduation-cap" aria-hidden="true"></i>
                        {{coursename}}
                        <i class="fa fa-fw fa-calendar-check-o" aria-hidden="true"></i>
                        {{bookingname}}
                    </a>
                </div>
            {{/rulesothercontext}}
            {{^rulesothercontext}}
                <div>{{#str}} bookingrulesnootherfound, mod_booking {{/str}}</div>
            {{/rulesothercontext}}
        </div>
    {{/displayothercontexts}}
</div>
