mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
0a4047ab31
Unfortunately the babel minify-mangle plugin seems to be abandoned and in certain circumstances can be very buggy. The only safe options are to disable it, or to switch to a different minification library. Not minifying our javascript is not ideal, so this commit updates the javascript tasks to use a rollup, combined with babel, and terser. Babel still converts code from ES/UMD/AMD to AMD modules with the relevant browser support, whilst terser minifies the code. The rollup bundler handles tracking and creation of sourcemaps, and supports better parallelisation of the tasks. Since the upgrade to Node LTS/Gallium requires an upgrade to @babel/core and eslint, which change the built files anyway, this seems like the ideal time to make this change.
8 lines
4.7 KiB
JavaScript
8 lines
4.7 KiB
JavaScript
/**
|
|
* @copyright 2015 Martin Mastny <mastnym@vscht.cz>
|
|
* @since 3.0
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
*/
|
|
define("core/permissionmanager",["jquery","core/config","core/notification","core/templates","core/yui"],(function($,config,notification,templates,Y){var contextid,contextname,adminurl,overideableroles,SELECTORS_ADDROLE="a.allowlink, a.prohibitlink",SELECTORS_REMOVEROLE="a.preventlink, a.unprohibitlink",SELECTORS_UNPROHIBIT="a.unprohibitlink",rolesloadedevent=$.Event("rolesloaded"),panel=null,_loadOverideableRoles=function(){var params={contextid:contextid,getroles:1,sesskey:config.sesskey};$.post(adminurl+"roles/ajax.php",params,null,"json").done((function(data){try{overideableroles=data,(_loadOverideableRoles=function(){$("body").trigger(rolesloadedevent)})()}catch(err){notification.exception(err)}})).fail((function(jqXHR,status,error){notification.exception(error)}))},changePermissions=function(row,roleid,action){var params={contextid:contextid,roleid:roleid,sesskey:M.cfg.sesskey,action:action,capability:row.data("name")};$.post(adminurl+"roles/ajax.php",params,null,"json").done((function(data){var action=data;try{var templatedata={rolename:overideableroles[roleid],roleid:roleid,adminurl:adminurl,imageurl:M.util.image_url("t/delete","moodle")};switch(action){case"allow":templatedata.spanclass="allowed",templatedata.linkclass="preventlink",templatedata.action="prevent",templatedata.icon="t/delete",templatedata.iconalt=M.util.get_string("deletexrole","core_role",overideableroles[roleid]);break;case"prohibit":templatedata.spanclass="forbidden",templatedata.linkclass="unprohibitlink",templatedata.action="unprohibit",templatedata.icon="t/delete",templatedata.iconalt=M.util.get_string("deletexrole","core_role",overideableroles[roleid]);break;case"prevent":return void row.find('a[data-role-id="'+roleid+'"]').first().closest(".allowed").remove();case"unprohibit":return void row.find('a[data-role-id="'+roleid+'"]').first().closest(".forbidden").remove();default:return}templates.render("core/permissionmanager_role",templatedata).done((function(content){if("allow"==action)$(content).insertBefore(row.find(".allowmore").first());else if("prohibit"==action){$(content).insertBefore(row.find(".prohibitmore").first());var allowedLink=row.find(".allowedroles").first().find('a[data-role-id="'+roleid+'"]');allowedLink&&allowedLink.first().closest(".allowed").remove()}panel.hide()})).fail(notification.exception)}catch(err){notification.exception(err)}})).fail((function(jqXHR,status,error){notification.exception(error)}))},handleAddRole=function(e){e.preventDefault();var link=$(e.currentTarget);$("body").one("rolesloaded",(function(){Y.use("moodle-core-notification-dialogue",(function(){var i,existingrolelinks,action=link.data("action"),row=link.closest("tr.rolecap"),confirmationDetails={cap:row.data("humanname"),context:contextname},message=M.util.get_string("role"+action+"info","core_role",confirmationDetails);null===panel&&(panel=new M.core.dialogue({draggable:!0,modal:!0,closeButton:!0,width:"450px"})),panel.set("headerContent",M.util.get_string("role"+action+"header","core_role"));var roles=[];switch(action){case"allow":existingrolelinks=row.find(SELECTORS_REMOVEROLE);break;case"prohibit":existingrolelinks=row.find(SELECTORS_UNPROHIBIT)}for(i in overideableroles){var disabled="";existingrolelinks.filter("[data-role-id='"+i+"']").length&&(disabled="disabled");var roledetails={roleid:i,rolename:overideableroles[i],disabled:disabled};roles.push(roledetails)}templates.render("core/permissionmanager_panelcontent",{message:message,roles:roles}).done((function(content){panel.set("bodyContent",content),panel.show(),$("div.role_buttons").on("click","button",(function(e){var roleid=$(e.currentTarget).data("role-id");changePermissions(row,roleid,action)}))})).fail(notification.exception)}))})),_loadOverideableRoles()},handleRemoveRole=function(e){e.preventDefault();var link=$(e.currentTarget);$("body").one("rolesloaded",(function(){var action=link.data("action"),roleid=link.data("role-id"),row=link.closest("tr.rolecap"),questionDetails={role:overideableroles[roleid],cap:row.data("humanname"),context:contextname};notification.confirm(M.util.get_string("confirmunassigntitle","core_role"),M.util.get_string("confirmrole"+action,"core_role",questionDetails),M.util.get_string("confirmunassignyes","core_role"),M.util.get_string("confirmunassignno","core_role"),(function(){changePermissions(row,roleid,action)}))})),_loadOverideableRoles()};return{initialize:function(args){contextid=args.contextid,contextname=args.contextname,adminurl=args.adminurl;var body=$("body");body.on("click",SELECTORS_ADDROLE,handleAddRole),body.on("click",SELECTORS_REMOVEROLE,handleRemoveRole)}}}));
|
|
|
|
//# sourceMappingURL=permissionmanager.min.js.map
|