!function(e){function i(s){if(t[s])return t[s].exports;var n=t[s]={exports:{},id:s,loaded:!1};return e[s].call(n.exports,n,n.exports,i),n.loaded=!0,n.exports}var t={};return i.m=e,i.c=t,i.p="",i(0)}([function(e,i,t){e.exports={el:"#roles",mixins:[t(1)],data:{role:{},config:window.$config},ready:function(){$(this.$el).on("change.uk.sortable",this.reorder)},computed:{current:function(){return _.find(this.roles,"id",this.config.role)||this.roles[0]}},methods:{edit:function(e){this.$set("role",$.extend({},e||{})),this.$refs.modal.open()},save:function(){this.role&&(this.Roles.save({id:this.role.id},{role:this.role}).then(function(e){var i=e.data;if(this.role.id){var t=_.findIndex(this.roles,"id",this.role.id);this.roles.splice(t,1,i.role),this.$notify("Role saved")}else this.roles.push(i.role),this.$notify("Role added")},function(e){this.$notify(e.data,"danger")}),this.$refs.modal.close())},remove:function(e){this.Roles.remove({id:e.id},function(){this.roles.splice(_.findIndex(this.roles,{id:e.id}),1)})},reorder:function(e,i){i&&(i.element.children().each(function(e){this.__vfrag__.scope.$set("role.priority",e)}),this.Roles.save({id:"bulk"},{roles:this.roles},function(e){this.$notify("Roles reordered.")},function(e){this.$notify(e,"danger")}))}}},Vue.ready(e.exports)},function(e,i){e.exports={data:function(){return window.$data},created:function(){this.Roles=this.$resource("api/user/role{/id}"),this.debounced=[],this.saveCb=Vue.util.debounce(function(){this.Roles.save({id:"bulk"},{roles:this.debounced}).then(function(){this.$notify("Permissions saved")}),this.debounced=[]}.bind(this),1e3)},computed:{authenticated:function(){return this.roles.filter(function(e){return e.authenticated})[0]}},methods:{savePermissions:function(e){_.find(this.debounced,"id",e.id)||this.debounced.push(e),this.saveCb()},addPermission:function(e,i){return e.administrator?null:e.permissions.push(i)},hasPermission:function(e,i){return-1!==e.permissions.indexOf(i)},isInherited:function(e,i){return!e.locked&&this.hasPermission(this.authenticated,i)},showFakeCheckbox:function(e,i){return e.administrator||this.isInherited(e,i)&&!this.hasPermission(e,i)}}}}]);