Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/**
2
 * Handle actions on learning plan templates via ajax.
3
 *
4
 * @module     tool_lp/templateactions
5
 * @copyright  2015 Damyon Wiese <damyon@moodle.com>
6
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
7
 */
8
define("tool_lp/templateactions",["jquery","core/templates","core/ajax","core/notification","core/str","tool_lp/actionselector"],(function($,templates,ajax,notification,str,Actionselector){var pagecontextid=0,templateid=0,deleteplans=!0,updatePage=function(newhtml,newjs){$('[data-region="managetemplates"]').replaceWith(newhtml),templates.runTemplateJS(newjs)},reloadList=function(context){templates.render("tool_lp/manage_templates_page",context).done(updatePage).fail(notification.exception)},doDelete=function(){ajax.call([{methodname:"core_competency_delete_template",args:{id:templateid,deleteplans:deleteplans}},{methodname:"tool_lp_data_for_templates_manage_page",args:{pagecontext:{contextid:pagecontextid}}}])[1].done(reloadList).fail(notification.exception)};return{deleteHandler:function(e){e.preventDefault();var id=$(this).attr("data-templateid");templateid=id,deleteplans=!0;var requests=ajax.call([{methodname:"core_competency_read_template",args:{id:templateid}},{methodname:"core_competency_template_has_related_data",args:{id:templateid}}]);requests[0].done((function(template){requests[1].done((function(templatehasrelateddata){templatehasrelateddata?str.get_strings([{key:"deletetemplate",component:"tool_lp",param:template.shortname},{key:"deletetemplatewithplans",component:"tool_lp"},{key:"deleteplans",component:"tool_lp"},{key:"unlinkplanstemplate",component:"tool_lp"},{key:"confirm",component:"moodle"},{key:"cancel",component:"moodle"}]).done((function(strings){var actions=[{text:strings[2],value:"delete"},{text:strings[3],value:"unlink"}],actionselector=new Actionselector(strings[0],strings[1],actions,strings[4],strings[5]);actionselector.display(),actionselector.on("save",(function(e,data){"delete"!=data.action&&(deleteplans=!1),doDelete()}))})).fail(notification.exception):str.get_strings([{key:"confirm",component:"moodle"},{key:"deletetemplate",component:"tool_lp",param:template.shortname},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done((function(strings){notification.confirm(strings[0],strings[1],strings[2],strings[3],doDelete)})).fail(notification.exception)})).fail(notification.exception)})).fail(notification.exception)},duplicateHandler:function(e){e.preventDefault(),templateid=$(this).attr("data-templateid"),ajax.call([{methodname:"core_competency_duplicate_template",args:{id:templateid}},{methodname:"tool_lp_data_for_templates_manage_page",args:{pagecontext:{contextid:pagecontextid}}}])[1].done(reloadList).fail(notification.exception)},init:function(contextid){pagecontextid=contextid}}}));
9
 
10
//# sourceMappingURL=templateactions.min.js.map