MDL-56292 message: split up preferences templates

This commit is contained in:
Ryan Wyllie
2016-10-10 12:48:52 +08:00
committed by Mark Nelson
parent 5cdebf2d7e
commit df9986c87f
9 changed files with 581 additions and 295 deletions
+1 -1
View File
@@ -228,7 +228,7 @@ class core_message_renderer extends plugin_renderer_base {
$preferences = \core_message\api::get_all_message_preferences($processors, $providers, $user);
$notificationlistoutput = new \core_message\output\preferences\notification_list($processors, $providers,
$preferences, $user);
return $this->render_from_template('message/preferences_notifications_list',
return $this->render_from_template('message/notification_preferences',
$notificationlistoutput->export_for_template($this));
}
+2 -81
View File
@@ -23,7 +23,7 @@
* None
Data attibutes required for JS:
* None
* All data attributes are required
Context variables required for this template:
* userid The logged in user id
@@ -93,86 +93,7 @@
<table class="table table-hover preference-table" data-region="preference-table">
<tbody>
{{#components}}
{{#notifications}}
<tr data-preference-key="{{preferencekey}}">
<th>{{displayname}}</th>
<td class="align-bottom">
<div class="container-fluid">
<div class="row-fluid">
<div class="span6">
{{#str}} loggedin, message {{/str}}
{{#onlinehelphtml}}{{{.}}}{{/onlinehelphtml}}
</div>
<div class="span6">
{{#str}} loggedoff, message {{/str}}
{{#offlinehelphtml}}{{{.}}}{{/offlinehelphtml}}
</div>
</div>
</div>
</td>
</tr>
{{#processors}}
<tr class="preference-row" data-region="preference-row" data-preference-key="{{preferencekey}}">
<td class="preference-name">{{displayname}}</td>
<td {{^userconfigured}}class="disabled"{{/userconfigured}} data-processor-name="{{name}}">
{{#locked}}
<div class="dimmed_text">{{lockedmessage}}</div>
{{/locked}}
{{^locked}}
<div class="disabled-message">{{#str}} disabled, question {{/str}}</div>
<form>
<div class="container-fluid">
<div class="row-fluid">
<div class="span6">
{{#loggedin}}
<label class="preference-state"
data-toggle="tooltip"
title="{{displayname}}"
data-state="{{name}}">
<span class="accesshide">{{displayname}}</span>
<input type="checkbox"
tabindex="-1"
class="accesshide"
{{#checked}}checked{{/checked}}
{{#disableall}}disabled{{/disableall}} />
<div class="preference-state-status-container" tabindex="0">
<span class="on-text">{{#str}} on, message {{/str}}</span>
<span class="off-text">{{#str}} off, message {{/str}}</span>
{{> core/loading }}
</div>
</label>
{{/loggedin}}
</div>
<div class="span6">
{{#loggedoff}}
<label class="preference-state"
data-toggle="tooltip"
title="{{displayname}}"
data-state="{{name}}">
<span class="accesshide">{{displayname}}</span>
<input type="checkbox"
tabindex="-1"
class="accesshide"
{{#checked}}checked{{/checked}}
{{#disableall}}disabled{{/disableall}} />
<div class="preference-state-status-container" tabindex="0">
<span class="on-text">{{#str}} on, message {{/str}}</span>
<span class="off-text">{{#str}} off, message {{/str}}</span>
{{> core/loading }}
</div>
</label>
{{/loggedoff}}
</div>
</div>
</div>
</form>
{{/locked}}
</td>
</tr>
{{/processors}}
{{/notifications}}
{{> message/message_preferences_component }}
{{/components}}
</tbody>
</table>
@@ -0,0 +1,81 @@
{{!
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/message_preferences_component
The message preferences page
Classes required for JS:
* None
Data attibutes required for JS:
* All data attributes are required
Context variables required for this template:
* notifications The list of notifications
Example context (json):
{
"notifications": [
{
"displayname": "Notices about minor problems",
"preferencekey": "message_provider_moodle_notices",
"processors": [
{
"displayname": "Popup notification",
"name": "popup",
"locked": 0,
"loggedin": {
"name": "loggedin",
"displayname": "When I'm logged in",
"checked": 0,
"iconurl": "some url"
},
"loggedoff": {
"name": "loggedoff",
"displayname": "When I'm offline",
"checked": 0,
"iconurl": "some url"
},
}
]
}
]
}
}}
{{#notifications}}
<tr data-preference-key="{{preferencekey}}">
<th>{{displayname}}</th>
<td class="align-bottom">
<div class="container-fluid">
<div class="row-fluid">
<div class="span6">
{{#str}} loggedin, message {{/str}}
{{#onlinehelphtml}}{{{.}}}{{/onlinehelphtml}}
</div>
<div class="span6">
{{#str}} loggedoff, message {{/str}}
{{#offlinehelphtml}}{{{.}}}{{/offlinehelphtml}}
</div>
</div>
</div>
</td>
</tr>
{{#processors}}
{{> message/message_preferences_notification_processor }}
{{/processors}}
{{/notifications}}
@@ -0,0 +1,112 @@
{{!
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/message_preferences_notification_processor
The message preferences page
Classes required for JS:
* None
Data attibutes required for JS:
* All data attributes are required
Context variables required for this template:
* displayname The display name of the processor
* name The name of the processor
* locked Whether the processor is locked
* loggedin The logged in settings
* loggedoff The logged off settings
Example context (json):
{
"displayname": "Popup notification",
"name": "popup",
"locked": 0,
"loggedin": {
"name": "loggedin",
"displayname": "When I'm logged in",
"checked": 0,
"iconurl": "some url"
},
"loggedoff": {
"name": "loggedoff",
"displayname": "When I'm offline",
"checked": 0,
"iconurl": "some url"
},
}
}}
<tr class="preference-row" data-region="preference-row" data-preference-key="{{preferencekey}}">
<td class="preference-name">{{displayname}}</td>
<td {{^userconfigured}}class="disabled"{{/userconfigured}} data-processor-name="{{name}}">
{{#locked}}
<div class="dimmed_text">{{lockedmessage}}</div>
{{/locked}}
{{^locked}}
<div class="disabled-message">{{#str}} disabled, question {{/str}}</div>
<form>
<div class="container-fluid">
<div class="row-fluid">
<div class="span6">
{{#loggedin}}
<label class="preference-state"
data-toggle="tooltip"
title="{{displayname}}"
data-state="{{name}}">
<span class="accesshide">{{displayname}}</span>
<input type="checkbox"
tabindex="-1"
class="accesshide"
{{#checked}}checked{{/checked}}
{{#disableall}}disabled{{/disableall}} />
<div class="preference-state-status-container" tabindex="0">
<span class="on-text">{{#str}} on, message {{/str}}</span>
<span class="off-text">{{#str}} off, message {{/str}}</span>
{{> core/loading }}
</div>
</label>
{{/loggedin}}
</div>
<div class="span6">
{{#loggedoff}}
<label class="preference-state"
data-toggle="tooltip"
title="{{displayname}}"
data-state="{{name}}">
<span class="accesshide">{{displayname}}</span>
<input type="checkbox"
tabindex="-1"
class="accesshide"
{{#checked}}checked{{/checked}}
{{#disableall}}disabled{{/disableall}} />
<div class="preference-state-status-container" tabindex="0">
<span class="on-text">{{#str}} on, message {{/str}}</span>
<span class="off-text">{{#str}} off, message {{/str}}</span>
{{> core/loading }}
</div>
</label>
{{/loggedoff}}
</div>
</div>
</div>
</form>
{{/locked}}
</td>
</tr>
@@ -0,0 +1,113 @@
{{!
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/notification_preferences
The list of notifications for the notification preferences page
Classes required for JS:
* None
Data attibutes required for JS:
* All data attributes are required
Context variables required for this template:
* userid The logged in user id
* disableall If the user has disabled notifications
* components The list of notification components
Example context (json):
{
"userid": 1,
"disableall": 0,
"components": [
{
"displayname": "System",
"processors": [
{
displayname: "Popup notification",
name: "popup",
userid: 1,
contextid: 18,
hassettings: true
}
],
"notifications": [
{
"displayname": "Notices about minor problems",
"preferencekey": "message_provider_moodle_notices",
"processors": [
{
"displayname": "Popup notification",
"name": "popup",
"locked": 0,
"loggedin": {
"name": "loggedin",
"displayname": "When I'm logged in",
"checked": 0,
"iconurl": "some url"
},
"loggedoff": {
"name": "loggedoff",
"displayname": "When I'm offline",
"checked": 0,
"iconurl": "some url"
},
}
]
}
]
}
]
}
}}
<div class="preferences-page-container">
<h2>{{#str}} notificationpreferences, message {{/str}}</h2>
<div class="checkbox-container" data-region="disable-notification-container">
<input id="disable-notifications"
type="checkbox"
data-disable-notifications
{{#disableall}}checked{{/disableall}} />
<label for="disable-notifications">{{#str}} disableall, message {{/str}}</label>
{{> core/loading }}
</div>
<div class="preferences-container {{#disableall}}disabled{{/disableall}}" data-user-id="{{userid}}">
<table class="table table-hover preference-table">
<thead>
<tr>
<th>{{displayname}}</th>
{{#processors}}
{{> message/notification_preferences_processor }}
{{/processors}}
</tr>
</thead>
<tbody>
{{#components}}
{{> message/notification_preferences_component }}
{{/components}}
</tbody>
</table>
</div>
</div>
{{#js}}
require(['jquery', 'theme_bootstrapbase/bootstrap', 'core_message/preferences_notifications_list_controller'],
function($, bootstrap, controller) {
$('[data-toggle="tooltip"]').tooltip();
new controller($('.preferences-container'));
});
{{/js}}
@@ -0,0 +1,93 @@
{{!
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/notification_preferences_component
The notification preferences page
Classes required for JS:
* None
Data attibutes required for JS:
* All data attributes are required
Context variables required for this template:
* displayname The component display name
* processors The list of processors for this component
* notifications The list of notifications
Example context (json):
{
"displayname": "System",
"processors": [
{
displayname: "Popup notification",
name: "popup",
userid: 1,
contextid: 18,
hassettings: true
}
],
"notifications": [
{
"displayname": "Notices about minor problems",
"preferencekey": "message_provider_moodle_notices",
"processors": [
{
"displayname": "Popup notification",
"name": "popup",
"locked": 0,
"loggedin": {
"name": "loggedin",
"displayname": "When I'm logged in",
"checked": 0,
"iconurl": "some url"
},
"loggedoff": {
"name": "loggedoff",
"displayname": "When I'm offline",
"checked": 0,
"iconurl": "some url"
},
}
]
}
]
}
}}
<tr>
<th><h4>{{displayname}}</h4></th>
{{#processors}}
<td class="align-bottom">
<div class="container-fluid">
<div class="row-fluid">
<div class="span6">
{{#str}} loggedin, message {{/str}}
{{#onlinehelphtml}}{{{.}}}{{/onlinehelphtml}}
</div>
<div class="span6">
{{#str}} loggedoff, message {{/str}}
{{#offlinehelphtml}}{{{.}}}{{/offlinehelphtml}}
</div>
</div>
</div>
</td>
{{/processors}}
</tr>
{{#notifications}}
{{> message/notification_preferences_component_notification }}
{{/notifications}}
@@ -0,0 +1,118 @@
{{!
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/notification_preferences_component_notification
The notification preferences page
Classes required for JS:
* disabled
Data attibutes required for JS:
* All data attributes are required
Context variables required for this template:
* displayname The notification display name
* preferencekey The unique key to identify this preference
* processors The list of processors for this notification
Example context (json):
{
"displayname": "Notices about minor problems",
"preferencekey": "message_provider_moodle_notices",
"processors": [
{
"displayname": "Popup notification",
"name": "popup",
"locked": 0,
"loggedin": {
"name": "loggedin",
"displayname": "When I'm logged in",
"checked": 0,
"iconurl": "some url"
},
"loggedoff": {
"name": "loggedoff",
"displayname": "When I'm offline",
"checked": 0,
"iconurl": "some url"
},
}
]
}
}}
<tr class="preference-row" data-region="preference-row" data-preference-key="{{preferencekey}}">
<td class="preference-name">{{displayname}}</td>
{{#processors}}
<td {{^userconfigured}}class="disabled"{{/userconfigured}} data-processor-name="{{name}}">
{{#locked}}
<div class="dimmed_text">{{lockedmessage}}</div>
{{/locked}}
{{^locked}}
<div class="disabled-message">{{#str}} disabled, question {{/str}}</div>
<form>
<div class="container-fluid">
<div class="row-fluid">
<div class="span6">
{{#loggedin}}
<label class="preference-state"
data-toggle="tooltip"
title="{{displayname}}"
data-state="{{name}}">
<span class="accesshide">{{displayname}}</span>
<input type="checkbox"
tabindex="-1"
class="accesshide"
{{#checked}}checked{{/checked}}
{{#disableall}}disabled{{/disableall}} />
<div class="preference-state-status-container" tabindex="0">
<span class="on-text">{{#str}} on, message {{/str}}</span>
<span class="off-text">{{#str}} off, message {{/str}}</span>
{{> core/loading }}
</div>
</label>
{{/loggedin}}
</div>
<div class="span6">
{{#loggedoff}}
<label class="preference-state"
data-toggle="tooltip"
title="{{displayname}}"
data-state="{{name}}">
<span class="accesshide">{{displayname}}</span>
<input type="checkbox"
tabindex="-1"
class="accesshide"
{{#checked}}checked{{/checked}}
{{#disableall}}disabled{{/disableall}} />
<div class="preference-state-status-container" tabindex="0">
<span class="on-text">{{#str}} on, message {{/str}}</span>
<span class="off-text">{{#str}} off, message {{/str}}</span>
{{> core/loading }}
</div>
</label>
{{/loggedoff}}
</div>
</div>
</div>
</form>
{{/locked}}
</td>
{{/processors}}
</tr>
@@ -0,0 +1,61 @@
{{!
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/notification_preferences_processor
The list of notifications for the message preferences page
Classes required for JS:
* None
Data attibutes required for JS:
* All data attributes are required
Context variables required for this template:
* displayname The display name for the processor
* name The name of the processor
* hassettings If the processor has settings to configure
* userid The current user id
* contextid The current context id
Example context (json):
{
"displayname": "Popup notification",
"name": "popup",
"hassettings": 1,
"userid": 3,
"contextid": 3,
}
}}
<th {{^userconfigured}}class="unconfigured"{{/userconfigured}} data-processor-name="{{name}}">
{{#hassettings}}
<a href="#"
data-processor-setting
data-user-id="{{userid}}"
data-context-id="{{contextid}}"
data-name="{{name}}">
<span class="config-warning" data-toggle="tooltip" title="{{#str}} requiresconfiguration, message {{/str}}">
{{#pix}} i/risk_xss, core {{/pix}}
</span>
{{displayname}} {{#pix}} i/settings {{/pix}}
</a>
{{/hassettings}}
{{^hassettings}}
{{displayname}}
{{/hassettings}}
</th>
@@ -1,213 +0,0 @@
{{!
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/preferences_notifications_list
The list of notifications for the message preferences page
Classes required for JS:
* None
Data attibutes required for JS:
* None
Context variables required for this template:
* userid The logged in user id
* disableall If the user has disabled notifications
* components The list of notification components
Example context (json):
{
"userid": 1,
"disableall": 0,
"components": [
{
"displayname": "System",
"processors": [
{
displayname: "Popup notification",
name: "popup",
userid: 1,
contextid: 18,
hassettings: true
}
],
"notifications": [
{
"displayname": "Notices about minor problems",
"preferencekey": "message_provider_moodle_notices",
"processors": [
{
"displayname": "Popup notification",
"name": "popup",
"locked": 0,
"loggedin": {
"name": "loggedin",
"displayname": "When I'm logged in",
"checked": 0,
"iconurl": "some url"
},
"loggedoff": {
"name": "loggedoff",
"displayname": "When I'm offline",
"checked": 0,
"iconurl": "some url"
},
}
]
}
]
}
]
}
}}
<div class="preferences-page-container">
<h2>{{#str}} notificationpreferences, message {{/str}}</h2>
<div class="checkbox-container" data-region="disable-notification-container">
<input id="disable-notifications"
type="checkbox"
data-disable-notifications
{{#disableall}}checked{{/disableall}} />
<label for="disable-notifications">{{#str}} disableall, message {{/str}}</label>
{{> core/loading }}
</div>
<div class="preferences-container {{#disableall}}disabled{{/disableall}}" data-user-id="{{userid}}">
<table class="table table-hover preference-table">
<thead>
<tr>
<th>{{displayname}}</th>
{{#processors}}
<th {{^userconfigured}}class="unconfigured"{{/userconfigured}} data-processor-name="{{name}}">
{{#hassettings}}
<a href="#"
data-processor-setting
data-user-id="{{userid}}"
data-context-id="{{contextid}}"
data-name="{{name}}">
<span class="config-warning" data-toggle="tooltip" title="{{#str}} requiresconfiguration, message {{/str}}">
{{#pix}} i/risk_xss, core {{/pix}}
</span>
{{displayname}} {{#pix}} i/settings {{/pix}}
</a>
{{/hassettings}}
{{^hassettings}}
{{displayname}}
{{/hassettings}}
</th>
{{/processors}}
</tr>
</thead>
<tbody>
{{#components}}
<tr>
<th><h4>{{displayname}}</h4></th>
{{#processors}}
<td class="align-bottom">
<div class="container-fluid">
<div class="row-fluid">
<div class="span6">
{{#str}} loggedin, message {{/str}}
{{#onlinehelphtml}}{{{.}}}{{/onlinehelphtml}}
</div>
<div class="span6">
{{#str}} loggedoff, message {{/str}}
{{#offlinehelphtml}}{{{.}}}{{/offlinehelphtml}}
</div>
</div>
</div>
</td>
{{/processors}}
</tr>
{{#notifications}}
<tr class="preference-row" data-region="preference-row" data-preference-key="{{preferencekey}}">
<td class="preference-name">
{{displayname}}
</td>
{{#processors}}
<td {{^userconfigured}}class="disabled"{{/userconfigured}} data-processor-name="{{name}}">
{{#locked}}
<div class="dimmed_text">{{lockedmessage}}</div>
{{/locked}}
{{^locked}}
<div class="disabled-message">{{#str}} disabled, question {{/str}}</div>
<form>
<div class="container-fluid">
<div class="row-fluid">
<div class="span6">
{{#loggedin}}
<label class="preference-state"
data-toggle="tooltip"
title="{{displayname}}"
data-state="{{name}}">
<span class="accesshide">{{displayname}}</span>
<input type="checkbox"
tabindex="-1"
class="accesshide"
{{#checked}}checked{{/checked}}
{{#disableall}}disabled{{/disableall}} />
<div class="preference-state-status-container" tabindex="0">
<span class="on-text">{{#str}} on, message {{/str}}</span>
<span class="off-text">{{#str}} off, message {{/str}}</span>
{{> core/loading }}
</div>
</label>
{{/loggedin}}
</div>
<div class="span6">
{{#loggedoff}}
<label class="preference-state"
data-toggle="tooltip"
title="{{displayname}}"
data-state="{{name}}">
<span class="accesshide">{{displayname}}</span>
<input type="checkbox"
tabindex="-1"
class="accesshide"
{{#checked}}checked{{/checked}}
{{#disableall}}disabled{{/disableall}} />
<div class="preference-state-status-container" tabindex="0">
<span class="on-text">{{#str}} on, message {{/str}}</span>
<span class="off-text">{{#str}} off, message {{/str}}</span>
{{> core/loading }}
</div>
</label>
{{/loggedoff}}
</div>
</div>
</div>
</form>
{{/locked}}
</td>
{{/processors}}
</tr>
{{/notifications}}
{{/components}}
</tbody>
</table>
</div>
</div>
{{#js}}
require(['jquery', 'theme_bootstrapbase/bootstrap', 'core_message/preferences_notifications_list_controller'],
function($, bootstrap, controller) {
$('[data-toggle="tooltip"]').tooltip();
new controller($('.preferences-container'));
});
{{/js}}