tao-test/app/funcAcl/views/js/loader/funcAcl.min.js

11 lines
6.4 KiB
JavaScript

define("funcAcl/controller/acl",["jquery","context","util/encode","i18n"],function($,context,encode,__){function loadModules(role,successCallback){$("#aclModules ul.group-list").empty(),$("#aclActions ul.group-list").empty(),$("#aclRoles ul.included-roles").empty(),""!==role&&$.ajax({type:"POST",url:context.root_url+"funcAcl/Admin/getModules",data:"role="+role,dataType:"json",success:function(data){for(var r in data.includedRoles){$("<li>"+encode.html(data.includedRoles[r])+"</li>").appendTo($("#aclRoles ul.included-roles"))}for(var e in data.extensions){var ext=data.extensions[e];if(!data.locked||"none"!==ext.access){switch(ext.access){case"inherited":
groupCheckboxTitle=__("Inherited access to the extension"),extra=" has-inherited";break;case"full":groupCheckboxTitle=__("Revoke access rights to the entire extension"),extra=" has-allaccess";break;case"partial":extra=" has-access",groupCheckboxTitle=__("Grant access rights to the entire extension");break;default:extra="",groupCheckboxTitle=__("Grant access rights to the entire extension")}var m,$group=$('<li class="group expendable closed'+extra+'"><div class="group-title"><span class="icon icon-right"/> <span class="title">'+ext.label+"</span>"+(data.locked?"":'<span class="selector all '+("inherited"==ext.access?"has-inherited":"checkable"
)+'" title="'+groupCheckboxTitle+'"></span>')+"</div><ul></ul></li>");switch($group.acldata("uri",ext.uri),ext.access){case"full":$(".selector",$group).click(function(e){e.stopPropagation(),Access2None($(this))});break;case"partial":case"none":$(".selector",$group).click(function(e){e.stopPropagation(),Access2All($(this))})}for(m in $(".group-title",$group).click(function(e){$(this).parent().hasClass("open")?($(this).removeClass("open"),$(this).parent().removeClass("open").addClass("closed"),$(this).find(".icon").removeClass("icon-down").addClass("icon-right"),$(this).parent().find(".selected").removeClass("selected")):($(this).addClass("open"),$(this
).parent().removeClass("closed").addClass("open"),$(this).find(".icon").removeClass("icon-right").addClass("icon-down"))}),ext.modules){var mod=ext.modules[m];if(!data.locked||"none"!==mod.access){switch(mod.access){case"inherited":modCheckboxTitle=__("Inherited access to the controller"),extra=" has-inherited";break;case"full":modCheckboxTitle=__("Revoke access rights to the entire controller"),extra=" has-allaccess";break;case"partial":extra=" has-access",modCheckboxTitle=__("Grant access rights to the entire controller");break;default:extra="",modCheckboxTitle=__("Grant access rights to the entire controller")}var $el=$(
'<li class="selectable'+extra+'"><span class="label">'+mod.label+"</span>"+(data.locked?"":'<span class="selector '+("inherited"==mod.access?"has-inherited":"checkable")+'" title="'+modCheckboxTitle+'"></span>')+"</li>");switch($el.acldata("uri",mod.uri),mod.access){case"full":$(".selector",$el).click(function(e){e.stopPropagation(),Access2None($(this))});break;case"partial":case"none":$(".selector",$el).click(function(e){e.stopPropagation(),Access2All($(this))})}$el.click(function(){$("#aclModules .selectable").removeClass("selected"),$(this).addClass("selected"),loadActions($("#roles").val(),$(this).acldata("uri"))}),$el.appendTo($("ul",$group))}}
$group.appendTo($("#aclModules ul.group-list"))}}void 0!==successCallback&&successCallback()}})}function loadActions(role,module,successCallback){$.ajax({type:"POST",url:context.root_url+"funcAcl/Admin/getActions",data:"role="+role+"&module="+module,dataType:"json",success:function(data){for(e in $("#aclActions ul.group-list").empty(),data){var act=data[e];if(!act.locked||"none"!==act.access){var $el="";switch(act.access){case"inherited":actCheckBoxTitle=__("Inherited access to the action");break;case"full":$el=" has-allaccess",actCheckBoxTitle=__("Revoke access rights to the action");break;default:actCheckBoxTitle=__("Grant access rights to the action")}
$el=$('<li class="selectable'+$el+'"'+(act.locked?' style="cursor: default"':"")+'><span class="label">'+e+"</span>"+(act.locked?"":'<span class="selector '+("inherited"==act.access?"has-inherited":"checkable")+'" title="'+actCheckBoxTitle+'"></span>')+"</li>");switch($el.acldata("uri",act.uri),act.access){case"full":$(".selector",$el).click(function(e){e.stopPropagation(),Access2None($(this))});break;case"none":$(".selector",$el).click(function(e){e.stopPropagation(),Access2All($(this))})}$el.appendTo($("#aclActions ul.group-list"))}}void 0!==successCallback&&successCallback()}})}function Access2All(el){actOnUri($(el).closest("li").removeClass("has-access"
).addClass("has-allaccess").acldata("uri"),"add",$("#roles").val()),el.unbind("click").click(function(e){e.stopPropagation(),Access2None($(this))})}function Access2None(el){actOnUri($(el).closest("li").removeClass("has-access").removeClass("has-allaccess").acldata("uri"),"remove",$("#roles").val()),el.unbind("click").click(function(e){e.stopPropagation(),Access2All($(this))})}function actOnUri(uri,act,role){var action="";switch(uri.split("#")[1].split("_")[0]){case"e":action="Extension";break;case"m":action="Module";break;case"a":action="Action"}switch(act){case"add":action="add"+action+"Access";break;case"remove":action="remove"+action+"Access"}$.ajax({
type:"POST",url:context.root_url+"funcAcl/Admin/"+action,data:"role="+role+"&uri="+uri,dataType:"json",success:function(data){var open=[];$("#aclModules .group.expendable.open").each(function(){open.push($(this).index())});var $el=$("#aclModules .selected"),selectedUri=null;$el.length&&(selectedUri=$el.acldata("uri"),$el.index());loadModules($("#roles").val(),function(){for(var i in open)$("#aclModules .group.expendable:eq("+open[i]+")").removeClass("closed").addClass("open").find(".group-title").addClass("open");null!=selectedUri&&($("#aclModules .open li").each(function(){$(this).acldata("uri")==selectedUri&&$(this).addClass("selected")}),loadActions($(
"#roles").val(),selectedUri))})}})}return $.fn.acldata=function(key,val){return void 0!==val&&($.expr.attrHandle[key]=function(elem){return $(elem).attr(key)||$(elem).data(key)}),$.fn.data.apply(this,arguments)},{start:function(){$("#roles").change(function(){""===$("#roles").val()?$("#roleactions").hide():$("#roleactions").show(),loadModules($("#roles").val())}).change()}}}),define("funcAcl/controller/routes",[],function(){"use strict";return{Admin:{actions:{index:"controller/acl"}}}}),define("funcAcl/loader/funcAcl.bundle",function(){});
//# sourceMappingURL=funcAcl.min.js.map