{{!
    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_message/default_notification_preferences

    This template will render the default notification preferences for admin settings.

    Classes required for JS:
    * none

    Data attributes required for JS:
    * All data attributes are required

    Context variables required for this template:
    * providers Message providers
    * components Provider components
    * processors Message processors
    * preferences Saved preferences

    Example context (json):
    {
        "processors": [
            {
                "displayname": "Web",
                "name": "popup"
            }
        ],
        "components": [
            {
                "displayname": "Assignment",
                "name": "mod_assign",
                "colspan": 3,
                "providers": [
                    {
                        "name": "assign_notification",
                        "component": "mod_assign",
                        "displayname": "Assignment notifications",
                        "enabledsetting": "mod_assign_assign_notification_disable",
                        "enabledlabel": "Sending Assignment enabled status",
                        "enabled": 1,
                        "settings": [
                            {
                                "lockedsetting": "mod_assign_assign_notification_locked[popup]",
                                "locked": 1,
                                "lockedlabel": "Sending Assignment via Web locked status",
                                "enabledsetting": "mod_assign_assign_notification_enabled[popup]",
                                "enabled": 1,
                                "enabledlabel": "Sending Assignment via Web enabled status",
                                "supportsprocessor": true
                            }
                        ]
                    }
                ]
            }
        ]
    }
}}
<div class="preferences-page-container">
    <h2 id="defaultnotificationprefsheading">{{#str}} managemessageoutputs, message {{/str}}</h2>

    <div class="preferences-container">
        <table class="table table-hover preference-table" aria-labelledby="defaultnotificationprefsheading">
            <thead>
                <tr>
                    <th>
                        <span class="visually-hidden">{{#str}}preference, message{{/str}}</span>
                    </th>
                    <th>{{#str}} enabled, core_message {{/str}}</th>
                    {{#processors}}
                        <th data-processor-name="{{name}}">{{{displayname}}}</th>
                    {{/processors}}
                </tr>
            </thead>
            <tbody>
                {{#components}}
                    <tr class="preference-row"><th colspan="{{{colspan}}}">{{{displayname}}}</th></tr>
                    {{#providers}}
                        <tr class="defaultmessageoutputs">
                            <td>{{{displayname}}}</td>
                            <td>
                                <div data-preference="{{{enabledsetting}}}">
                                    <div class="form-check form-switch">
                                        <input type="checkbox"
                                            id="{{{enabledsetting}}}"
                                            name="{{{enabledsetting}}}"
                                            class="form-check-input provider_enabled"
                                            {{#enabled}}checked{{/enabled}}
                                        >
                                        <label for="{{{enabledsetting}}}" class="form-check-label">
                                            <span class="accesshide">{{enabledlabel}}</span>
                                        </label>
                                    </div>
                                </div>
                            </td>
                            {{#settings}}
                                <td class="text-start">
                                    {{#supportsprocessor}}
                                        <div data-preference="{{{enabledsetting}}}">
                                            <div class="form-check form-switch {{#locked}} dimmed_text{{/locked}} pb-1">
                                                <input type="checkbox"
                                                       id="{{{enabledsetting}}}"
                                                       name="{{{enabledsetting}}}"
                                                       class="form-check-input enabled_message_setting"
                                                       {{#enabled}}checked{{/enabled}}
                                                >
                                                <label for="{{{enabledsetting}}}" class="form-check-label">
                                                    {{#str}} enabled, core_message {{/str}}
                                                </label>
                                            </div>
                                        </div>
                                        <div data-preference="{{{lockedsetting}}}">
                                            <div class="form-check form-switch pt-1">
                                                <input type="checkbox"
                                                       id="{{{lockedsetting}}}"
                                                       name="{{{lockedsetting}}}"
                                                       class="form-check-input locked_message_setting"
                                                       {{#locked}}checked{{/locked}}
                                                >
                                                <label for="{{{lockedsetting}}}" class="form-check-label">
                                                    {{#str}} forced, core_message {{/str}}
                                                </label>
                                            </div>
                                        </div>
                                    {{/supportsprocessor}}
                                    {{^supportsprocessor}}
                                        <div class="text-center">
                                            {{#str}} notsupported, core_message {{/str}}
                                        </div>
                                    {{/supportsprocessor}}
                                </td>
                            {{/settings}}
                        </tr>
                    {{/providers}}
                {{/components}}
            </tbody>
        </table>
    </div>
</div>
{{#js}}
require(['core_message/default_notification_preferences'], function(NotificationPreferences) {
        NotificationPreferences.init();
    });
{{/js}}
