define(["libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(a,b,c){var d=Backbone.View.extend({el:"#center",model:null,options:{},events:{"click .toolbtn_save_permissions":"savePermissions"},initialize:function(a){this.options=_.extend(this.options,a),this.options.id&&this.fetchFolder()},fetchFolder:function(c){this.options=_.extend(this.options,c),this.model=new b.FolderAsModel({id:this.options.id});var d=this;this.model.fetch({success:function(){d.options.show_permissions?d.showPermissions():d.render()},error:function(b,c){"undefined"!=typeof c.responseJSON?a.error(c.responseJSON.err_msg+" Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}}):a.error("An error ocurred. Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}})},render:function(a){$(".tooltip").remove(),this.options=_.extend(this.options,a);var b=this.templateFolder();this.$el.html(b({item:this.model})),$(".peek").html(this.model.get("peek")),$("#center [data-toggle]").tooltip()},shareFolder:function(){a.info("Feature coming soon.")},goBack:function(){Galaxy.libraries.library_router.back()},showPermissions:function(b){this.options=_.extend(this.options,b),$(".tooltip").remove();var c=!1;Galaxy.currUser&&(c=Galaxy.currUser.isAdmin());var d=this.templateFolderPermissions();this.$el.html(d({folder:this.model,is_admin:c}));var e=this;void 0===this.options.fetched_permissions?$.get((window.galaxy_config?galaxy_config.root:"/")+"api/folders/"+e.id+"/permissions?scope=current").done(function(a){e.prepareSelectBoxes({fetched_permissions:a})}).fail(function(){a.error("An error occurred while attempting to fetch folder permissions.")}):this.prepareSelectBoxes({}),$("#center [data-toggle]").tooltip(),$("#center").css("overflow","auto")},_serializeRoles:function(a){for(var b=[],c=0;c=0;b--)ids_list.push(a[b].id);return ids_list},savePermissions:function(){var b=this,c=this._extractIds(this.addSelectObject.$el.select2("data")),d=this._extractIds(this.manageSelectObject.$el.select2("data")),e=this._extractIds(this.modifySelectObject.$el.select2("data"));$.post((window.galaxy_config?galaxy_config.root:"/")+"api/folders/"+b.id+"/permissions?action=set_permissions",{"add_ids[]":c,"manage_ids[]":d,"modify_ids[]":e}).done(function(c){b.showPermissions({fetched_permissions:c}),a.success("Permissions saved.")}).fail(function(){a.error("An error occurred while attempting to set folder permissions.")})},templateFolder:function(){var a=[];return a.push('
'),a.push('
'),a.push(' '),a.push(' /datasets/<%- item.id %>/permissions">'),a.push(' '),a.push("
"),a.push("

"),a.push(" This dataset is unrestricted so everybody can access it. Just share the URL of this page. "),a.push(' '),a.push("

"),a.push('
'),a.push(' '),a.push(" "),a.push(' '),a.push(' '),a.push(" "),a.push(' <% if (item.get("file_ext")) { %>'),a.push(" "),a.push(' '),a.push(' '),a.push(" "),a.push(" <% } %>"),a.push("
">Name<%= _.escape(item.get("name")) %>
Data type<%= _.escape(item.get("file_ext")) %>
"),a.push("
"),a.push("
"),_.template(a.join(""))},templateFolderPermissions:function(){var a=[];return a.push('
'),a.push('
'),a.push(' ">'),a.push("
"),a.push('

Folder: <%= _.escape(folder.get("name")) %>

'),a.push('
'),a.push("<% if (is_admin) { %>"),a.push("You are logged in as an administrator therefore you can manage any folder on this Galaxy instance. Please make sure you understand the consequences."),a.push("<% } else { %>"),a.push("You can assign any number of roles to any of the following permission types. However please read carefully the implications of such actions."),a.push("<% }%>"),a.push("
"),a.push('
'),a.push("

Folder permissions

"),a.push("

Roles that can manage permissions on this folder

"),a.push('
'),a.push('
User with any of these roles can manage permissions on this folder.
'),a.push("

Roles that can add items to this folder

"),a.push('
'),a.push('
User with any of these roles can add items to this folder (folders and datasets).
'),a.push("

Roles that can modify this folder

"),a.push('
'),a.push('
User with any of these roles can modify this folder (name, etc.).
'),a.push(''),a.push("
"),a.push("
"),_.template(a.join(""))}});return{FolderView:d}}); //# sourceMappingURL=../../../maps/mvc/library/library-folder-view.js.map