mirror of
https://github.com/moodle/moodle.git
synced 2025-07-25 00:02:18 +02:00
MDL-51139 tool_lp: Fix some javascript that was broken by a merge
The user learning plans page menus were broken by some refactoring. Fixed during merge by Fred: - Added space between icons and strings in action menu - Recent changes caused the plans page to die when listing templates
This commit is contained in:
committed by
Frederic Massart
parent
679bce3692
commit
d65b912df2
2
admin/tool/lp/amd/build/plandelete.min.js
vendored
2
admin/tool/lp/amd/build/plandelete.min.js
vendored
@@ -1 +1 @@
|
||||
define(["jquery","core/templates","core/ajax","core/notification","core/str"],function(a,b,c,d,e){var f=0,g=0,h=function(c,d){a('[data-region="plans"]').replaceWith(c),b.runTemplateJS(d)},i=function(a){b.render("tool_lp/plans_page",a).done(h).fail(d.exception)},j=function(){var a=c.call([{methodname:"tool_lp_delete_plan",args:{id:f}},{methodname:"tool_lp_data_for_plans_page",args:{userid:g}}]);a[1].done(i).fail(d.exception)},k=function(b){b.preventDefault(),f=a(this).attr("data-planid");var g=c.call([{methodname:"tool_lp_read_plan",args:{id:f}}]);g[0].done(function(a){e.get_strings([{key:"confirm",component:"moodle"},{key:"deleteplan",component:"tool_lp",param:a.name},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],j)}).fail(d.exception)}).fail(d.exception)};return{init:function(){a('[data-region="plans"]').on("click",'[data-action="deleteplan"]',k),g=a('[data-region="plans"]').attr("data-userid")}}});
|
||||
define(["jquery","core/templates","core/ajax","core/notification","core/str"],function(a,b,c,d,e){var f=0,g=0,h=function(c,d){a('[data-region="plans"]').replaceWith(c),b.runTemplateJS(d)},i=function(a){b.render("tool_lp/plans_page",a).done(h).fail(d.exception)},j=function(){var a=c.call([{methodname:"tool_lp_delete_plan",args:{id:f}},{methodname:"tool_lp_data_for_plans_page",args:{userid:g}}]);a[1].done(i).fail(d.exception)},k=function(b){b.preventDefault(),f=a(this).attr("data-planid"),g=a(this).attr("data-userid");var h=c.call([{methodname:"tool_lp_read_plan",args:{id:f}}]);h[0].done(function(a){e.get_strings([{key:"confirm",component:"moodle"},{key:"deleteplan",component:"tool_lp",param:a.name},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],j)}).fail(d.exception)}).fail(d.exception)};return{deleteHandler:k}});
|
@@ -74,8 +74,9 @@ define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'
|
||||
*/
|
||||
var confirmDelete = function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
planid = $(this).attr('data-planid');
|
||||
userid = $(this).attr('data-userid');
|
||||
|
||||
var requests = ajax.call([{
|
||||
methodname: 'tool_lp_read_plan',
|
||||
@@ -104,19 +105,12 @@ define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str'
|
||||
|
||||
return {
|
||||
// Public variables and functions.
|
||||
|
||||
/**
|
||||
* Initialise this plugin. Just attaches some event handlers to the delete entries in the menu.
|
||||
* Expose the event handler for delete.
|
||||
* @method deleteHandler
|
||||
* @param {Event} e
|
||||
*/
|
||||
init: function() {
|
||||
// Init this module.
|
||||
$('[data-region="plans"]').on(
|
||||
"click",
|
||||
'[data-action="deleteplan"]',
|
||||
confirmDelete
|
||||
);
|
||||
userid = $('[data-region="plans"]').attr('data-userid');
|
||||
}
|
||||
deleteHandler: confirmDelete,
|
||||
|
||||
};
|
||||
});
|
||||
|
@@ -83,8 +83,8 @@ class plans_page implements renderable, templatable {
|
||||
$data->pluginbaseurl = (new moodle_url('/admin/tool/lp'))->out(true);
|
||||
|
||||
// Attach standard objects as mustache can not parse \tool_lp\plan objects.
|
||||
$data->plans = array();
|
||||
if ($this->plans) {
|
||||
$data->plans = array();
|
||||
foreach ($this->plans as $plan) {
|
||||
$data->plans[] = $plan->to_record();
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ if ($USER->id === $userid && !has_any_capability($owncapabilities, $context) &&
|
||||
// Passing the templates list to the form.
|
||||
$templates = array();
|
||||
if ($manageplans) {
|
||||
$templates = \tool_lp\api::list_templates();
|
||||
$templates = \tool_lp\api::list_templates('', '', 0, 0, context_system::instance(), 'children');
|
||||
}
|
||||
|
||||
$customdata = array('id' => $id, 'userid' => $userid, 'templates' => $templates);
|
||||
|
@@ -33,7 +33,7 @@
|
||||
* navigation - array of strings containing buttons for navigation
|
||||
}}
|
||||
|
||||
<div data-region="plans" data-userid="{{userid}}">
|
||||
<div data-region="plans">
|
||||
<table class="generaltable fullwidth">
|
||||
<caption>{{#str}}listplanscaption, tool_lp{{/str}}</caption>
|
||||
<thead>
|
||||
@@ -53,17 +53,21 @@
|
||||
<td>
|
||||
{{#usercanupdate}}
|
||||
<div style="display: inline-block;">
|
||||
<ul class="planactions hide">
|
||||
<ul title="{{#str}}edit{{/str}}" class="planactions">
|
||||
<li>
|
||||
<a href="#">{{#str}}edit{{/str}}</a><b class="caret"></b>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="{{pluginbaseurl}}/editplan.php?id={{id}}">
|
||||
{{#pix}}t/edit{{/pix}}{{#str}}editthisplan, tool_lp{{/str}}
|
||||
{{#pix}}t/edit{{/pix}} {{#str}}editthisplan, tool_lp{{/str}}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a data-action="deleteplan" data-planid="{{id}}" href="#">
|
||||
{{#pix}}t/delete{{/pix}}{{#str}}deletethisplan, tool_lp{{/str}}
|
||||
<a data-action="deleteplan" data-planid="{{id}}" data-userid="{{userid}}" href="#">
|
||||
{{#pix}}t/delete{{/pix}} {{#str}}deletethisplan, tool_lp{{/str}}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</ul>
|
||||
{{/usercanupdate}}
|
||||
</div>
|
||||
@@ -88,12 +92,12 @@
|
||||
{{#js}}
|
||||
// Initialise the JS.
|
||||
require(['tool_lp/plandelete',
|
||||
'core/menu'],
|
||||
function(deleteMod, menu) {
|
||||
'tool_lp/menubar'],
|
||||
function(deleteMod, menubar) {
|
||||
|
||||
deleteMod.init();
|
||||
|
||||
menu.menu('{{#str}}edit{{/str}}', '.planactions');
|
||||
menubar.enhance('.planactions', {
|
||||
"[data-action='deleteplan']": deleteMod.deleteHandler
|
||||
});
|
||||
});
|
||||
|
||||
{{/js}}
|
||||
|
Reference in New Issue
Block a user