commit/galaxy-central: martenson: libraries: some serious refactoring, caching of subviews; base-mvc initialAttrs default setting (empty object)
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/813a11e7b98a/ Changeset: 813a11e7b98a User: martenson Date: 2014-03-28 19:17:57 Summary: libraries: some serious refactoring, caching of subviews; base-mvc initialAttrs default setting (empty object) Affected #: 12 files diff -r 876bc02f522fa636fd42c91b22e6588be8833176 -r 813a11e7b98ac4a20abf3a185a7233a6a947a3c4 static/scripts/galaxy.library.js --- a/static/scripts/galaxy.library.js +++ b/static/scripts/galaxy.library.js @@ -36,23 +36,19 @@ var GalaxyLibrary = Backbone.View.extend({ initialize : function(){ - toolbarView = new mod_librarytoolbar_view.ToolbarView(); - galaxyLibraryview = new mod_librarylist_view.GalaxyLibraryview(); + // toolbarView = new mod_librarytoolbar_view.ToolbarView(); + toolbarView = null; + // libraryListView = new mod_librarylist_view.LibraryListView(); + libraryListView = null; library_router = new LibraryRouter(); - + folderContentView = null; library_router.on('route:libraries', function() { // initialize and render the toolbar first toolbarView = new mod_librarytoolbar_view.ToolbarView(); // initialize and render libraries second - galaxyLibraryview = new mod_librarylist_view.GalaxyLibraryview(); - }); - - library_router.on('route:sort_libraries', function(sort_by, order) { - // sort libraries list - galaxyLibraryview.sortLibraries(sort_by, order); - galaxyLibraryview.render(); + libraryListView = new mod_librarylist_view.LibraryListView(); }); library_router.on('route:folder_content', function(id) { diff -r 876bc02f522fa636fd42c91b22e6588be8833176 -r 813a11e7b98ac4a20abf3a185a7233a6a947a3c4 static/scripts/mvc/base-mvc.js --- a/static/scripts/mvc/base-mvc.js +++ b/static/scripts/mvc/base-mvc.js @@ -53,6 +53,7 @@ */ var SessionStorageModel = Backbone.Model.extend({ initialize : function( initialAttrs ){ + initialAttrs = initialAttrs || {}; // create unique id if none provided initialAttrs.id = ( !_.isString( initialAttrs.id ) )?( _.uniqueId() ):( initialAttrs.id ); this.id = initialAttrs.id; diff -r 876bc02f522fa636fd42c91b22e6588be8833176 -r 813a11e7b98ac4a20abf3a185a7233a6a947a3c4 static/scripts/mvc/library/library-librarylist-view.js --- a/static/scripts/mvc/library/library-librarylist-view.js +++ b/static/scripts/mvc/library/library-librarylist-view.js @@ -1,42 +1,61 @@ // dependencies define([ - "galaxy.masthead", + "galaxy.masthead", + "mvc/base-mvc", "utils/utils", "libs/toastr", - "mvc/library/library-model"], -function(mod_masthead, + "mvc/library/library-model", + "mvc/library/library-libraryrow-view"], +function(mod_masthead, + mod_baseMVC, mod_utils, mod_toastr, - mod_library_model) { + mod_library_model, + mod_library_libraryrow_view) { + +// ============================================================================ +/** session storage for library preferences */ +var LibraryPrefs = mod_baseMVC.SessionStorageModel.extend({ + defaults : { + with_deleted : false + } +}); // galaxy library view -var GalaxyLibraryview = Backbone.View.extend({ +var LibraryListView = Backbone.View.extend({ el: '#libraries_element', events: { - 'click .edit_library_btn' : 'edit_button_event', - 'click .save_library_btn' : 'save_library_modification', - 'click .cancel_library_btn' : 'cancel_library_modification', - 'click .delete_library_btn' : 'delete_library', - 'click .undelete_library_btn' : 'undelete_library' + 'click .edit_library_btn' : 'edit_button_event', + 'click .save_library_btn' : 'save_library_modification', + 'click .cancel_library_btn' : 'cancel_library_modification', + 'click .delete_library_btn' : 'delete_library', + 'click .undelete_library_btn' : 'undelete_library', + 'click .sort-libraries-link' : 'sort_clicked' }, modal: null, collection: null, + preferences: null, + + // map of library model ids to library views = cache + rowViews: {}, + // initialize initialize : function(){ var viewContext = this; + + this.rowViews = {}; + + this.preferences = new LibraryPrefs(); + this.collection = new mod_library_model.Libraries(); this.collection.fetch({ success: function(libraries){ viewContext.render(); - // initialize the library tooltips - $("#center [data-toggle]").tooltip(); - // modification of upper DOM element to show scrollbars due to the #center element inheritance - $("#center").css('overflow','auto'); }, error: function(model, response){ mod_toastr.error('An error occured. Please try again.'); @@ -50,7 +69,7 @@ render: function (options) { var template = this.templateLibraryList(); var libraries_to_render = null; - var include_deleted = false; + var include_deleted = this.preferences.get('with_deleted'); var models = null if (typeof options !== 'undefined'){ include_deleted = typeof options.with_deleted !== 'undefined' ? options.with_deleted : false; @@ -69,10 +88,52 @@ libraries_to_render = []; } - this.$el.html(template({libraries: libraries_to_render, order: this.collection.sort_order})); + this.$el.html(template({length: libraries_to_render.length, order: this.collection.sort_order})); + + this.renderRows(libraries_to_render); + // initialize the library tooltips + $("#center [data-toggle]").tooltip(); + // modification of upper DOM element to show scrollbars due to the #center element inheritance + $("#center").css('overflow','auto'); }, - /** Sorts the underlying collection according to the parameters received through URL. + renderRows: function(libraries_to_render){ + for (var i = 0; i < libraries_to_render.length; i++) { + var library = libraries_to_render[i]; + var cachedView = _.findWhere(this.rowViews, {id: library.get('id')}); + if (cachedView !== undefined){ + this.$el.find('#library_list_body').append(cachedView.el); + } else { + var rowView = new mod_library_libraryrow_view.LibraryRowView(library); + this.$el.find('#library_list_body').append(rowView.el); + // save new rowView to cache + this.rowViews[library.get('id')] = rowView; + } + }; + }, + + /** Handle the user toggling the deleted visibility by: + * (1) storing the new value in the persistent storage + * (2) re-rendering the list + * @returns {Boolean} new show_hidden setting + */ + // toggleShowHidden : function( show ){ + // show = ( show !== undefined )?( show ):( !this.storage.get( 'show_hidden' ) ); + // this.storage.set( 'show_hidden', show ); + // this.renderRows(); + // return this.storage.get( 'show_hidden' ); + // }, + + sort_clicked : function(){ + if (this.collection.sort_order == 'asc'){ + this.sortLibraries('name','desc'); + } else { + this.sortLibraries('name','asc'); + } + this.render(); + }, + + /** Sorts the underlying collection according to the parameters received. Currently supports only sorting by name. */ sortLibraries: function(sort_by, order){ if (sort_by === 'name'){ @@ -104,31 +165,18 @@ tmpl_array = []; tmpl_array.push('<div class="library_container table-responsive">'); - tmpl_array.push('<% if(libraries.length === 0) { %>'); + tmpl_array.push('<% if(length === 0) { %>'); tmpl_array.push("<div>I see no libraries. Why don't you create one?</div>"); tmpl_array.push('<% } else{ %>'); tmpl_array.push('<table class="grid table table-condensed">'); tmpl_array.push(' <thead>'); - tmpl_array.push(' <th style="width:30%;"><a title="Click to reverse order" href="#sort/name/<% if(order==="desc"||order===null){print("asc")}else{print("desc")} %>">name</a><span title="Sorted alphabetically" class="fa fa-sort-alpha-<%- order %>"></span></th>'); + tmpl_array.push(' <th style="width:30%;"><a class="sort-libraries-link" title="Click to reverse order" href="#">name</a><span title="Sorted alphabetically" class="fa fa-sort-alpha-<%- order %>"></span></th>'); tmpl_array.push(' <th style="width:22%;">description</th>'); tmpl_array.push(' <th style="width:22%;">synopsis</th> '); tmpl_array.push(' <th style="width:26%;"></th> '); tmpl_array.push(' </thead>'); - tmpl_array.push(' <tbody>'); - tmpl_array.push(' <% _.each(libraries, function(library) { %>'); - tmpl_array.push(' <tr class="<% if(library.get("deleted") === true){print("active");}%>" data-id="<%- library.get("id") %>">'); - tmpl_array.push(' <td><span data-toggle="tooltip" data-placement="top" title="Item is public" class="fa fa-globe fa-lg"></span><a href="#folders/<%- library.get("root_folder_id") %>"><%- library.get("name") %></a></td>'); - tmpl_array.push(' <td><%= _.escape(library.get("description")) %></td>'); - tmpl_array.push(' <td><%= _.escape(library.get("synopsis")) %></td>'); - tmpl_array.push(' <td class="right-center">'); - tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Modify library" class="primary-button btn-xs edit_library_btn" type="button"><span class="fa fa-pencil"></span></button>'); - tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Save changes" class="primary-button btn-xs save_library_btn" type="button" style="display:none;"><span class="fa fa-floppy-o"> Save</span></button>'); - tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Discard changes" class="primary-button btn-xs cancel_library_btn" type="button" style="display:none;"><span class="fa fa-times"> Cancel</span></button>'); - tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Delete library (can be undeleted later)" class="primary-button btn-xs delete_library_btn" type="button" style="display:none;"><span class="fa fa-trash-o"> Delete</span></button>'); - tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Undelete library" class="primary-button btn-xs undelete_library_btn" type="button" style="display:none;"><span class="fa fa-unlock"> Undelete</span></button>'); - tmpl_array.push(' </td>'); - tmpl_array.push(' </tr>'); - tmpl_array.push(' <% }); %>'); + tmpl_array.push(' <tbody id="library_list_body">'); + // library item views will attach here tmpl_array.push(' </tbody>'); tmpl_array.push('</table>'); tmpl_array.push('<% }%>'); @@ -202,11 +250,15 @@ toggle_library_modification: function($library_row){ var library = this.collection.get($library_row.data('id')); + $library_row.find('.public_lib_ico').toggle(); + $library_row.find('.deleted_lib_ico').toggle(); $library_row.find('.edit_library_btn').toggle(); + $library_row.find('.upload_library_btn').toggle(); + $library_row.find('.permission_library_btn').toggle(); $library_row.find('.save_library_btn').toggle(); $library_row.find('.cancel_library_btn').toggle(); if (library.get('deleted')){ - $library_row.find('.undelete_library_btn').toggle(); + // $library_row.find('.undelete_library_btn').toggle(); } else { $library_row.find('.delete_library_btn').toggle(); } @@ -369,7 +421,7 @@ // return return { - GalaxyLibraryview: GalaxyLibraryview + LibraryListView: LibraryListView }; }); diff -r 876bc02f522fa636fd42c91b22e6588be8833176 -r 813a11e7b98ac4a20abf3a185a7233a6a947a3c4 static/scripts/mvc/library/library-libraryrow-view.js --- /dev/null +++ b/static/scripts/mvc/library/library-libraryrow-view.js @@ -0,0 +1,65 @@ +// dependencies +define([ + "galaxy.masthead", + "utils/utils", + "libs/toastr", + "mvc/library/library-model"], +function(mod_masthead, + mod_utils, + mod_toastr, + mod_library_model) { + +// galaxy library row view +var LibraryRowView = Backbone.View.extend({ + + initialize : function(library){ + this.render(library); + }, + + render: function(library){ + var tmpl = this.templateRow(); + this.setElement(tmpl({library:library})); + this.set_up_visual_features(library); + }, + + set_up_visual_features: function(library){ + if (library.get('deleted') === true){ + this.$el.addClass('active'); + } + this.$el.show(); + }, + + templateRow: function() { + tmpl_array = []; + + tmpl_array.push(' <tr style="display:none;" data-id="<%- library.get("id") %>">'); + tmpl_array.push(' <td><a href="#folders/<%- library.get("root_folder_id") %>"><%- library.get("name") %></a></td>'); + tmpl_array.push(' <td><%= _.escape(library.get("description")) %></td>'); + tmpl_array.push(' <td><%= _.escape(library.get("synopsis")) %></td>'); + tmpl_array.push(' <td class="right-center">'); + tmpl_array.push(' <% if(library.get("deleted") === true) { %>'); + tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" title="Marked deleted" style="color:grey;" class="fa fa-ban fa-lg deleted_lib_ico"></span>'); + tmpl_array.push(' <% } else if(library.get("public") === true) { %>'); + tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" title="Public" style="color:grey;" class="fa fa-globe fa-lg public_lib_ico"></span>'); + tmpl_array.push(' <% }%>'); + tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Upload to library" class="primary-button btn-xs upload_library_btn" type="button"><span class="fa fa-upload"></span></button>'); + tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Modify library" class="primary-button btn-xs edit_library_btn" type="button"><span class="fa fa-pencil"></span></button>'); + tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Modify permissions" class="primary-button btn-xs permission_library_btn" type="button"><span class="fa fa-group"></span></button>'); + tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Save changes" class="primary-button btn-xs save_library_btn" type="button" style="display:none;"><span class="fa fa-floppy-o"> Save</span></button>'); + tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Discard changes" class="primary-button btn-xs cancel_library_btn" type="button" style="display:none;"><span class="fa fa-times"> Cancel</span></button>'); + tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Delete library (can be undeleted later)" class="primary-button btn-xs delete_library_btn" type="button" style="display:none;"><span class="fa fa-trash-o"> Delete</span></button>'); + tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Undelete library" class="primary-button btn-xs undelete_library_btn" type="button" style="display:none;"><span class="fa fa-unlock"> Undelete</span></button>'); + tmpl_array.push(' </td>'); + tmpl_array.push(' </tr>'); + + return _.template(tmpl_array.join('')); + } + +}); + + // return +return { + LibraryRowView: LibraryRowView +}; + +}); diff -r 876bc02f522fa636fd42c91b22e6588be8833176 -r 813a11e7b98ac4a20abf3a185a7233a6a947a3c4 static/scripts/mvc/library/library-librarytoolbar-view.js --- a/static/scripts/mvc/library/library-librarytoolbar-view.js +++ b/static/scripts/mvc/library/library-librarytoolbar-view.js @@ -23,15 +23,17 @@ delegate_modal: function(event){ // probably should refactor to have this functionality in this view, not in the library view - galaxyLibraryview.show_library_modal(event); + libraryListView.show_library_modal(event); }, // include or exclude deleted libraries from the view check_include_deleted: function(event){ if (event.target.checked){ - galaxyLibraryview.render( {'with_deleted': true} ); + libraryListView.preferences.set({'with_deleted': true}); + libraryListView.render(); } else{ - galaxyLibraryview.render({'with_deleted': false}); + libraryListView.preferences.set({'with_deleted': false}); + libraryListView.render(); } }, diff -r 876bc02f522fa636fd42c91b22e6588be8833176 -r 813a11e7b98ac4a20abf3a185a7233a6a947a3c4 static/scripts/mvc/library/library-model.js --- a/static/scripts/mvc/library/library-model.js +++ b/static/scripts/mvc/library/library-model.js @@ -3,7 +3,19 @@ // LIBRARY var Library = Backbone.Model.extend({ - urlRoot: '/api/libraries/' + urlRoot: '/api/libraries/', + + /** based on show_deleted + * would this lib show in the list of lib's? + * @param {Boolean} show_deleted are we showing deleted libraries? + */ + isVisible : function(show_deleted){ + var isVisible = true; + if( (!show_delete) && (this.get('deleted')) ){ + isVisible = false; + } + return isVisible; + } }); // FOLDER AS MODEL @@ -19,8 +31,25 @@ sort_key: 'name', // default - sort_order: null // default + sort_order: null, // default + initialize : function(options){ + options = options || {}; + }, + + /** Get every 'shown' library in this collection based on deleted filter + * @param {Boolean} show_deleted are we showing deleted libraries? + * @returns array of library models + */ + getVisible : function(show_deleted, filters){ + filters = filters || []; + // always filter by show deleted first + var filteredLibraries = new Libraries( this.filter( function( item ){ + return item.isVisible(show_deleted); + })); + + return filteredLibraries; + } }); // ITEM diff -r 876bc02f522fa636fd42c91b22e6588be8833176 -r 813a11e7b98ac4a20abf3a185a7233a6a947a3c4 static/scripts/packed/galaxy.library.js --- a/static/scripts/packed/galaxy.library.js +++ b/static/scripts/packed/galaxy.library.js @@ -1,1 +1,1 @@ -var library_router=null;define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/library/library-folderlist-view","mvc/library/library-librarylist-view","mvc/library/library-librarytoolbar-view"],function(e,c,g,h,a,f,d){var i=Backbone.Router.extend({routes:{"":"libraries","sort/:sort_by/:order":"sort_libraries","folders/:id":"folder_content","folders/:folder_id/download/:format":"download"}});var b=Backbone.View.extend({initialize:function(){toolbarView=new d.ToolbarView();galaxyLibraryview=new f.GalaxyLibraryview();library_router=new i();folderContentView=null;library_router.on("route:libraries",function(){toolbarView=new d.ToolbarView();galaxyLibraryview=new f.GalaxyLibraryview()});library_router.on("route:sort_libraries",function(k,j){galaxyLibraryview.sortLibraries(k,j);galaxyLibraryview.render()});library_router.on("route:folder_content",function(j){if(!folderContentView){folderContentView=new a.FolderContentView()}folderContentView.render({id:j})});library_router.on("route:download",function(j,k){if($("#center").find(":checked").length===0){library_router.navigate("folders/"+j,{trigger:true,replace:true})}else{folderContentView.download(j,k);library_router.navigate("folders/"+j,{trigger:false,replace:true})}});Backbone.history.start({pushState:false})}});return{GalaxyApp:b}}); \ No newline at end of file +var library_router=null;define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/library/library-folderlist-view","mvc/library/library-librarylist-view","mvc/library/library-librarytoolbar-view"],function(e,c,g,h,a,f,d){var i=Backbone.Router.extend({routes:{"":"libraries","sort/:sort_by/:order":"sort_libraries","folders/:id":"folder_content","folders/:folder_id/download/:format":"download"}});var b=Backbone.View.extend({initialize:function(){toolbarView=null;libraryListView=null;library_router=new i();folderContentView=null;library_router.on("route:libraries",function(){toolbarView=new d.ToolbarView();libraryListView=new f.LibraryListView()});library_router.on("route:folder_content",function(j){if(!folderContentView){folderContentView=new a.FolderContentView()}folderContentView.render({id:j})});library_router.on("route:download",function(j,k){if($("#center").find(":checked").length===0){library_router.navigate("folders/"+j,{trigger:true,replace:true})}else{folderContentView.download(j,k);library_router.navigate("folders/"+j,{trigger:false,replace:true})}});Backbone.history.start({pushState:false})}});return{GalaxyApp:b}}); \ No newline at end of file diff -r 876bc02f522fa636fd42c91b22e6588be8833176 -r 813a11e7b98ac4a20abf3a185a7233a6a947a3c4 static/scripts/packed/mvc/base-mvc.js --- a/static/scripts/packed/mvc/base-mvc.js +++ b/static/scripts/packed/mvc/base-mvc.js @@ -1,1 +1,1 @@ -define([],function(){var c={logger:null,log:function(){if(this.logger){var d=this.logger.log;if(typeof this.logger.log==="object"){d=Function.prototype.bind.call(this.logger.log,this.logger)}return d.apply(this.logger,arguments)}return undefined}};var a=Backbone.Model.extend({initialize:function(e){e.id=(!_.isString(e.id))?(_.uniqueId()):(e.id);this.id=e.id;var d=(!this.isNew())?(this._read(this)):({});this.clear({silent:true});this.save(_.extend({},this.defaults,d,e),{silent:true});this.on("change",function(){this.save()})},sync:function(g,e,d){if(!d.silent){e.trigger("request",e,{},d)}var f;switch(g){case"create":f=this._create(e);break;case"read":f=this._read(e);break;case"update":f=this._update(e);break;case"delete":f=this._delete(e);break}if(f!==undefined||f!==null){if(d.success){d.success()}}else{if(d.error){d.error()}}return f},_create:function(d){var e=d.toJSON(),f=sessionStorage.setItem(d.id,JSON.stringify(e));return(f===null)?(f):(e)},_read:function(d){return JSON.parse(sessionStorage.getItem(d.id))},_update:function(d){return d._create(d)},_delete:function(d){return sessionStorage.removeItem(d.id)},isNew:function(){return !sessionStorage.hasOwnProperty(this.id)},_log:function(){return JSON.stringify(this.toJSON(),null," ")},toString:function(){return"SessionStorageModel("+this.id+")"}});(function(){a.prototype=_.omit(a.prototype,"url","urlRoot")}());var b={hiddenUntilActivated:function(d,f){f=f||{};this.HUAVOptions={$elementShown:this.$el,showFn:jQuery.prototype.toggle,showSpeed:"fast"};_.extend(this.HUAVOptions,f||{});this.HUAVOptions.hasBeenShown=this.HUAVOptions.$elementShown.is(":visible");this.hidden=this.isHidden();if(d){var e=this;d.on("click",function(g){e.toggle(e.HUAVOptions.showSpeed)})}},isHidden:function(){return(this.HUAVOptions.$elementShown.is(":hidden"))},toggle:function(){if(this.hidden){if(!this.HUAVOptions.hasBeenShown){if(_.isFunction(this.HUAVOptions.onshowFirstTime)){this.HUAVOptions.hasBeenShown=true;this.HUAVOptions.onshowFirstTime.call(this)}}if(_.isFunction(this.HUAVOptions.onshow)){this.HUAVOptions.onshow.call(this);this.trigger("hiddenUntilActivated:shown",this)}this.hidden=false}else{if(_.isFunction(this.HUAVOptions.onhide)){this.HUAVOptions.onhide.call(this);this.trigger("hiddenUntilActivated:hidden",this)}this.hidden=true}return this.HUAVOptions.showFn.apply(this.HUAVOptions.$elementShown,arguments)}};return{LoggableMixin:c,SessionStorageModel:a,HiddenUntilActivatedViewMixin:b}}); \ No newline at end of file +define([],function(){var c={logger:null,log:function(){if(this.logger){var d=this.logger.log;if(typeof this.logger.log==="object"){d=Function.prototype.bind.call(this.logger.log,this.logger)}return d.apply(this.logger,arguments)}return undefined}};var a=Backbone.Model.extend({initialize:function(e){e=e||{};e.id=(!_.isString(e.id))?(_.uniqueId()):(e.id);this.id=e.id;var d=(!this.isNew())?(this._read(this)):({});this.clear({silent:true});this.save(_.extend({},this.defaults,d,e),{silent:true});this.on("change",function(){this.save()})},sync:function(g,e,d){if(!d.silent){e.trigger("request",e,{},d)}var f;switch(g){case"create":f=this._create(e);break;case"read":f=this._read(e);break;case"update":f=this._update(e);break;case"delete":f=this._delete(e);break}if(f!==undefined||f!==null){if(d.success){d.success()}}else{if(d.error){d.error()}}return f},_create:function(d){var e=d.toJSON(),f=sessionStorage.setItem(d.id,JSON.stringify(e));return(f===null)?(f):(e)},_read:function(d){return JSON.parse(sessionStorage.getItem(d.id))},_update:function(d){return d._create(d)},_delete:function(d){return sessionStorage.removeItem(d.id)},isNew:function(){return !sessionStorage.hasOwnProperty(this.id)},_log:function(){return JSON.stringify(this.toJSON(),null," ")},toString:function(){return"SessionStorageModel("+this.id+")"}});(function(){a.prototype=_.omit(a.prototype,"url","urlRoot")}());var b={hiddenUntilActivated:function(d,f){f=f||{};this.HUAVOptions={$elementShown:this.$el,showFn:jQuery.prototype.toggle,showSpeed:"fast"};_.extend(this.HUAVOptions,f||{});this.HUAVOptions.hasBeenShown=this.HUAVOptions.$elementShown.is(":visible");this.hidden=this.isHidden();if(d){var e=this;d.on("click",function(g){e.toggle(e.HUAVOptions.showSpeed)})}},isHidden:function(){return(this.HUAVOptions.$elementShown.is(":hidden"))},toggle:function(){if(this.hidden){if(!this.HUAVOptions.hasBeenShown){if(_.isFunction(this.HUAVOptions.onshowFirstTime)){this.HUAVOptions.hasBeenShown=true;this.HUAVOptions.onshowFirstTime.call(this)}}if(_.isFunction(this.HUAVOptions.onshow)){this.HUAVOptions.onshow.call(this);this.trigger("hiddenUntilActivated:shown",this)}this.hidden=false}else{if(_.isFunction(this.HUAVOptions.onhide)){this.HUAVOptions.onhide.call(this);this.trigger("hiddenUntilActivated:hidden",this)}this.hidden=true}return this.HUAVOptions.showFn.apply(this.HUAVOptions.$elementShown,arguments)}};return{LoggableMixin:c,SessionStorageModel:a,HiddenUntilActivatedViewMixin:b}}); \ No newline at end of file diff -r 876bc02f522fa636fd42c91b22e6588be8833176 -r 813a11e7b98ac4a20abf3a185a7233a6a947a3c4 static/scripts/packed/mvc/library/library-librarylist-view.js --- a/static/scripts/packed/mvc/library/library-librarylist-view.js +++ b/static/scripts/packed/mvc/library/library-librarylist-view.js @@ -1,1 +1,1 @@ -define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model"],function(a,c,e,b){var d=Backbone.View.extend({el:"#libraries_element",events:{"click .edit_library_btn":"edit_button_event","click .save_library_btn":"save_library_modification","click .cancel_library_btn":"cancel_library_modification","click .delete_library_btn":"delete_library","click .undelete_library_btn":"undelete_library"},modal:null,collection:null,initialize:function(){var f=this;this.collection=new b.Libraries();this.collection.fetch({success:function(g){f.render();$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},error:function(h,g){e.error("An error occured. Please try again.")}})},render:function(g){var h=this.templateLibraryList();var i=null;var f=false;var j=null;if(typeof g!=="undefined"){f=typeof g.with_deleted!=="undefined"?g.with_deleted:false;j=typeof g.models!=="undefined"?g.models:null}if(this.collection!==null&&j===null){if(f){i=this.collection.models}else{i=this.collection.where({deleted:false})}}else{if(j!==null){i=j}else{i=[]}}this.$el.html(h({libraries:i,order:this.collection.sort_order}))},sortLibraries:function(g,f){if(g==="name"){if(f==="asc"){this.collection.sort_order="asc";this.collection.comparator=function(i,h){if(i.get("name").toLowerCase()>h.get("name").toLowerCase()){return 1}if(h.get("name").toLowerCase()>i.get("name").toLowerCase()){return -1}return 0}}else{if(f==="desc"){this.collection.sort_order="desc";this.collection.comparator=function(i,h){if(i.get("name").toLowerCase()>h.get("name").toLowerCase()){return -1}if(h.get("name").toLowerCase()>i.get("name").toLowerCase()){return 1}return 0}}}this.collection.sort()}},templateLibraryList:function(){tmpl_array=[];tmpl_array.push('<div class="library_container table-responsive">');tmpl_array.push("<% if(libraries.length === 0) { %>");tmpl_array.push("<div>I see no libraries. Why don't you create one?</div>");tmpl_array.push("<% } else{ %>");tmpl_array.push('<table class="grid table table-condensed">');tmpl_array.push(" <thead>");tmpl_array.push(' <th style="width:30%;"><a title="Click to reverse order" href="#sort/name/<% if(order==="desc"||order===null){print("asc")}else{print("desc")} %>">name</a><span title="Sorted alphabetically" class="fa fa-sort-alpha-<%- order %>"></span></th>');tmpl_array.push(' <th style="width:22%;">description</th>');tmpl_array.push(' <th style="width:22%;">synopsis</th> ');tmpl_array.push(' <th style="width:26%;"></th> ');tmpl_array.push(" </thead>");tmpl_array.push(" <tbody>");tmpl_array.push(" <% _.each(libraries, function(library) { %>");tmpl_array.push(' <tr class="<% if(library.get("deleted") === true){print("active");}%>" data-id="<%- library.get("id") %>">');tmpl_array.push(' <td><span data-toggle="tooltip" data-placement="top" title="Item is public" class="fa fa-globe fa-lg"></span><a href="#folders/<%- library.get("root_folder_id") %>"><%- library.get("name") %></a></td>');tmpl_array.push(' <td><%= _.escape(library.get("description")) %></td>');tmpl_array.push(' <td><%= _.escape(library.get("synopsis")) %></td>');tmpl_array.push(' <td class="right-center">');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Modify library" class="primary-button btn-xs edit_library_btn" type="button"><span class="fa fa-pencil"></span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Save changes" class="primary-button btn-xs save_library_btn" type="button" style="display:none;"><span class="fa fa-floppy-o"> Save</span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Discard changes" class="primary-button btn-xs cancel_library_btn" type="button" style="display:none;"><span class="fa fa-times"> Cancel</span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Delete library (can be undeleted later)" class="primary-button btn-xs delete_library_btn" type="button" style="display:none;"><span class="fa fa-trash-o"> Delete</span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Undelete library" class="primary-button btn-xs undelete_library_btn" type="button" style="display:none;"><span class="fa fa-unlock"> Undelete</span></button>');tmpl_array.push(" </td>");tmpl_array.push(" </tr>");tmpl_array.push(" <% }); %>");tmpl_array.push(" </tbody>");tmpl_array.push("</table>");tmpl_array.push("<% }%>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateNewLibraryInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_library_modal">');tmpl_array.push(" <form>");tmpl_array.push(' <input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push(' <input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push(' <input type="text" name="Synopsis" value="" placeholder="Synopsis">');tmpl_array.push(" </form>");tmpl_array.push("</div>");return tmpl_array.join("")},save_library_modification:function(i){var h=$(i.target).closest("tr");var f=this.collection.get(h.data("id"));var g=false;var k=h.find(".input_library_name").val();if(typeof k!=="undefined"&&k!==f.get("name")){if(k.length>2){f.set("name",k);g=true}else{e.warning("Library name has to be at least 3 characters long");return}}var j=h.find(".input_library_description").val();if(typeof j!=="undefined"&&j!==f.get("description")){f.set("description",j);g=true}var l=h.find(".input_library_synopsis").val();if(typeof l!=="undefined"&&l!==f.get("synopsis")){f.set("synopsis",l);g=true}if(g){f.save(null,{patch:true,success:function(m){e.success("Changes to library saved");galaxyLibraryview.toggle_library_modification(h)},error:function(n,m){e.error("An error occured during updating the library :(")}})}},edit_button_event:function(f){this.toggle_library_modification($(f.target).closest("tr"))},toggle_library_modification:function(i){var f=this.collection.get(i.data("id"));i.find(".edit_library_btn").toggle();i.find(".save_library_btn").toggle();i.find(".cancel_library_btn").toggle();if(f.get("deleted")){i.find(".undelete_library_btn").toggle()}else{i.find(".delete_library_btn").toggle()}if(i.find(".edit_library_btn").is(":hidden")){var g=f.get("name");var k='<input type="text" class="form-control input_library_name" placeholder="name">';i.children("td").eq(0).html(k);if(typeof g!==undefined){i.find(".input_library_name").val(g)}var h=f.get("description");var k='<input type="text" class="form-control input_library_description" placeholder="description">';i.children("td").eq(1).html(k);if(typeof h!==undefined){i.find(".input_library_description").val(h)}var j=f.get("synopsis");var k='<input type="text" class="form-control input_library_synopsis" placeholder="synopsis">';i.children("td").eq(2).html(k);if(typeof j!==undefined){i.find(".input_library_synopsis").val(j)}}else{i.children("td").eq(0).html(f.get("name"));i.children("td").eq(1).html(f.get("description"));i.children("td").eq(2).html(f.get("synopsis"))}},cancel_library_modification:function(h){var g=$(h.target).closest("tr");var f=this.collection.get(g.data("id"));this.toggle_library_modification(g);g.children("td").eq(0).html(f.get("name"));g.children("td").eq(1).html(f.get("description"));g.children("td").eq(2).html(f.get("synopsis"))},undelete_library:function(h){var g=$(h.target).closest("tr");var f=this.collection.get(g.data("id"));this.toggle_library_modification(g);f.url=f.urlRoot+f.id+"?undelete=true";f.destroy({success:function(i){i.set("deleted",false);galaxyLibraryview.collection.add(i);g.removeClass("active");e.success("Library has been undeleted")},error:function(){e.error("An error occured while undeleting the library :(")}})},delete_library:function(h){var g=$(h.target).closest("tr");var f=this.collection.get(g.data("id"));this.toggle_library_modification(g);f.destroy({success:function(i){g.remove();i.set("deleted",true);galaxyLibraryview.collection.add(i);e.success("Library has been marked deleted")},error:function(){e.error("An error occured during deleting the library :(")}})},redirectToHome:function(){window.location="../"},redirectToLogin:function(){window.location="/user/login"},show_library_modal:function(g){g.preventDefault();g.stopPropagation();var f=this;this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Create New Library",body:this.templateNewLibraryInModal(),buttons:{Create:function(){f.create_new_library_event()},Close:function(){f.modal.hide()}}})},create_new_library_event:function(){var h=this.serialize_new_library();if(this.validate_new_library(h)){var g=new b.Library();var f=this;g.save(h,{success:function(i){f.collection.add(i);f.modal.hide();f.clear_library_modal();f.render();e.success("Library created")},error:function(){e.error("An error occured :(")}})}else{e.error("Library's name is missing")}return false},clear_library_modal:function(){$("input[name='Name']").val("");$("input[name='Description']").val("");$("input[name='Synopsis']").val("")},serialize_new_library:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val(),synopsis:$("input[name='Synopsis']").val()}},validate_new_library:function(f){return f.name!==""}});return{GalaxyLibraryview:d}}); \ No newline at end of file +define(["galaxy.masthead","mvc/base-mvc","utils/utils","libs/toastr","mvc/library/library-model","mvc/library/library-libraryrow-view"],function(c,h,e,f,d,a){var b=h.SessionStorageModel.extend({defaults:{with_deleted:false}});var g=Backbone.View.extend({el:"#libraries_element",events:{"click .edit_library_btn":"edit_button_event","click .save_library_btn":"save_library_modification","click .cancel_library_btn":"cancel_library_modification","click .delete_library_btn":"delete_library","click .undelete_library_btn":"undelete_library","click .sort-libraries-link":"sort_clicked"},modal:null,collection:null,preferences:null,rowViews:{},initialize:function(){var i=this;this.rowViews={};this.preferences=new b();this.collection=new d.Libraries();this.collection.fetch({success:function(j){i.render()},error:function(k,j){f.error("An error occured. Please try again.")}})},render:function(j){var k=this.templateLibraryList();var l=null;var i=this.preferences.get("with_deleted");var m=null;if(typeof j!=="undefined"){i=typeof j.with_deleted!=="undefined"?j.with_deleted:false;m=typeof j.models!=="undefined"?j.models:null}if(this.collection!==null&&m===null){if(i){l=this.collection.models}else{l=this.collection.where({deleted:false})}}else{if(m!==null){l=m}else{l=[]}}this.$el.html(k({length:l.length,order:this.collection.sort_order}));this.renderRows(l);$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},renderRows:function(n){for(var m=0;m<n.length;m++){var l=n[m];var k=_.findWhere(this.rowViews,{id:l.get("id")});if(k!==undefined){this.$el.find("#library_list_body").append(k.el)}else{var j=new a.LibraryRowView(l);this.$el.find("#library_list_body").append(j.el);this.rowViews[l.get("id")]=j}}},sort_clicked:function(){if(this.collection.sort_order=="asc"){this.sortLibraries("name","desc")}else{this.sortLibraries("name","asc")}this.render()},sortLibraries:function(j,i){if(j==="name"){if(i==="asc"){this.collection.sort_order="asc";this.collection.comparator=function(l,k){if(l.get("name").toLowerCase()>k.get("name").toLowerCase()){return 1}if(k.get("name").toLowerCase()>l.get("name").toLowerCase()){return -1}return 0}}else{if(i==="desc"){this.collection.sort_order="desc";this.collection.comparator=function(l,k){if(l.get("name").toLowerCase()>k.get("name").toLowerCase()){return -1}if(k.get("name").toLowerCase()>l.get("name").toLowerCase()){return 1}return 0}}}this.collection.sort()}},templateLibraryList:function(){tmpl_array=[];tmpl_array.push('<div class="library_container table-responsive">');tmpl_array.push("<% if(length === 0) { %>");tmpl_array.push("<div>I see no libraries. Why don't you create one?</div>");tmpl_array.push("<% } else{ %>");tmpl_array.push('<table class="grid table table-condensed">');tmpl_array.push(" <thead>");tmpl_array.push(' <th style="width:30%;"><a class="sort-libraries-link" title="Click to reverse order" href="#">name</a><span title="Sorted alphabetically" class="fa fa-sort-alpha-<%- order %>"></span></th>');tmpl_array.push(' <th style="width:22%;">description</th>');tmpl_array.push(' <th style="width:22%;">synopsis</th> ');tmpl_array.push(' <th style="width:26%;"></th> ');tmpl_array.push(" </thead>");tmpl_array.push(' <tbody id="library_list_body">');tmpl_array.push(" </tbody>");tmpl_array.push("</table>");tmpl_array.push("<% }%>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateNewLibraryInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_library_modal">');tmpl_array.push(" <form>");tmpl_array.push(' <input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push(' <input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push(' <input type="text" name="Synopsis" value="" placeholder="Synopsis">');tmpl_array.push(" </form>");tmpl_array.push("</div>");return tmpl_array.join("")},save_library_modification:function(l){var k=$(l.target).closest("tr");var i=this.collection.get(k.data("id"));var j=false;var n=k.find(".input_library_name").val();if(typeof n!=="undefined"&&n!==i.get("name")){if(n.length>2){i.set("name",n);j=true}else{f.warning("Library name has to be at least 3 characters long");return}}var m=k.find(".input_library_description").val();if(typeof m!=="undefined"&&m!==i.get("description")){i.set("description",m);j=true}var o=k.find(".input_library_synopsis").val();if(typeof o!=="undefined"&&o!==i.get("synopsis")){i.set("synopsis",o);j=true}if(j){i.save(null,{patch:true,success:function(p){f.success("Changes to library saved");galaxyLibraryview.toggle_library_modification(k)},error:function(q,p){f.error("An error occured during updating the library :(")}})}},edit_button_event:function(i){this.toggle_library_modification($(i.target).closest("tr"))},toggle_library_modification:function(l){var i=this.collection.get(l.data("id"));l.find(".public_lib_ico").toggle();l.find(".deleted_lib_ico").toggle();l.find(".edit_library_btn").toggle();l.find(".upload_library_btn").toggle();l.find(".permission_library_btn").toggle();l.find(".save_library_btn").toggle();l.find(".cancel_library_btn").toggle();if(i.get("deleted")){}else{l.find(".delete_library_btn").toggle()}if(l.find(".edit_library_btn").is(":hidden")){var j=i.get("name");var n='<input type="text" class="form-control input_library_name" placeholder="name">';l.children("td").eq(0).html(n);if(typeof j!==undefined){l.find(".input_library_name").val(j)}var k=i.get("description");var n='<input type="text" class="form-control input_library_description" placeholder="description">';l.children("td").eq(1).html(n);if(typeof k!==undefined){l.find(".input_library_description").val(k)}var m=i.get("synopsis");var n='<input type="text" class="form-control input_library_synopsis" placeholder="synopsis">';l.children("td").eq(2).html(n);if(typeof m!==undefined){l.find(".input_library_synopsis").val(m)}}else{l.children("td").eq(0).html(i.get("name"));l.children("td").eq(1).html(i.get("description"));l.children("td").eq(2).html(i.get("synopsis"))}},cancel_library_modification:function(k){var j=$(k.target).closest("tr");var i=this.collection.get(j.data("id"));this.toggle_library_modification(j);j.children("td").eq(0).html(i.get("name"));j.children("td").eq(1).html(i.get("description"));j.children("td").eq(2).html(i.get("synopsis"))},undelete_library:function(k){var j=$(k.target).closest("tr");var i=this.collection.get(j.data("id"));this.toggle_library_modification(j);i.url=i.urlRoot+i.id+"?undelete=true";i.destroy({success:function(l){l.set("deleted",false);galaxyLibraryview.collection.add(l);j.removeClass("active");f.success("Library has been undeleted")},error:function(){f.error("An error occured while undeleting the library :(")}})},delete_library:function(k){var j=$(k.target).closest("tr");var i=this.collection.get(j.data("id"));this.toggle_library_modification(j);i.destroy({success:function(l){j.remove();l.set("deleted",true);galaxyLibraryview.collection.add(l);f.success("Library has been marked deleted")},error:function(){f.error("An error occured during deleting the library :(")}})},redirectToHome:function(){window.location="../"},redirectToLogin:function(){window.location="/user/login"},show_library_modal:function(j){j.preventDefault();j.stopPropagation();var i=this;this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Create New Library",body:this.templateNewLibraryInModal(),buttons:{Create:function(){i.create_new_library_event()},Close:function(){i.modal.hide()}}})},create_new_library_event:function(){var k=this.serialize_new_library();if(this.validate_new_library(k)){var j=new d.Library();var i=this;j.save(k,{success:function(l){i.collection.add(l);i.modal.hide();i.clear_library_modal();i.render();f.success("Library created")},error:function(){f.error("An error occured :(")}})}else{f.error("Library's name is missing")}return false},clear_library_modal:function(){$("input[name='Name']").val("");$("input[name='Description']").val("");$("input[name='Synopsis']").val("")},serialize_new_library:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val(),synopsis:$("input[name='Synopsis']").val()}},validate_new_library:function(i){return i.name!==""}});return{LibraryListView:g}}); \ No newline at end of file diff -r 876bc02f522fa636fd42c91b22e6588be8833176 -r 813a11e7b98ac4a20abf3a185a7233a6a947a3c4 static/scripts/packed/mvc/library/library-libraryrow-view.js --- /dev/null +++ b/static/scripts/packed/mvc/library/library-libraryrow-view.js @@ -0,0 +1,1 @@ +define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model"],function(b,d,e,c){var a=Backbone.View.extend({initialize:function(f){this.render(f)},render:function(g){var f=this.templateRow();this.setElement(f({library:g}));this.set_up_visual_features(g)},set_up_visual_features:function(f){if(f.get("deleted")===true){this.$el.addClass("active")}this.$el.show()},templateRow:function(){tmpl_array=[];tmpl_array.push(' <tr style="display:none;" data-id="<%- library.get("id") %>">');tmpl_array.push(' <td><a href="#folders/<%- library.get("root_folder_id") %>"><%- library.get("name") %></a></td>');tmpl_array.push(' <td><%= _.escape(library.get("description")) %></td>');tmpl_array.push(' <td><%= _.escape(library.get("synopsis")) %></td>');tmpl_array.push(' <td class="right-center">');tmpl_array.push(' <% if(library.get("deleted") === true) { %>');tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" title="Marked deleted" style="color:grey;" class="fa fa-ban fa-lg deleted_lib_ico"></span>');tmpl_array.push(' <% } else if(library.get("public") === true) { %>');tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" title="Public" style="color:grey;" class="fa fa-globe fa-lg public_lib_ico"></span>');tmpl_array.push(" <% }%>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Upload to library" class="primary-button btn-xs upload_library_btn" type="button"><span class="fa fa-upload"></span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Modify library" class="primary-button btn-xs edit_library_btn" type="button"><span class="fa fa-pencil"></span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Modify permissions" class="primary-button btn-xs permission_library_btn" type="button"><span class="fa fa-group"></span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Save changes" class="primary-button btn-xs save_library_btn" type="button" style="display:none;"><span class="fa fa-floppy-o"> Save</span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Discard changes" class="primary-button btn-xs cancel_library_btn" type="button" style="display:none;"><span class="fa fa-times"> Cancel</span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Delete library (can be undeleted later)" class="primary-button btn-xs delete_library_btn" type="button" style="display:none;"><span class="fa fa-trash-o"> Delete</span></button>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Undelete library" class="primary-button btn-xs undelete_library_btn" type="button" style="display:none;"><span class="fa fa-unlock"> Undelete</span></button>');tmpl_array.push(" </td>");tmpl_array.push(" </tr>");return _.template(tmpl_array.join(""))}});return{LibraryRowView:a}}); \ No newline at end of file diff -r 876bc02f522fa636fd42c91b22e6588be8833176 -r 813a11e7b98ac4a20abf3a185a7233a6a947a3c4 static/scripts/packed/mvc/library/library-librarytoolbar-view.js --- a/static/scripts/packed/mvc/library/library-librarytoolbar-view.js +++ b/static/scripts/packed/mvc/library/library-librarytoolbar-view.js @@ -1,1 +1,1 @@ -define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model"],function(a,d,e,c){var b=Backbone.View.extend({el:"#center",events:{"click #create_new_library_btn":"delegate_modal","click #include_deleted_chk":"check_include_deleted"},initialize:function(){this.render()},delegate_modal:function(f){galaxyLibraryview.show_library_modal(f)},check_include_deleted:function(f){if(f.target.checked){galaxyLibraryview.render({with_deleted:true})}else{galaxyLibraryview.render({with_deleted:false})}},render:function(){var f=this.templateToolBar();this.$el.html(f())},templateToolBar:function(){tmpl_array=[];tmpl_array.push('<div id="libraries_container" style="width: 90%; margin: auto; margin-top:2em; overflow: auto !important; ">');tmpl_array.push(' <div id="toolbar_form" margin-top:0.5em; ">');tmpl_array.push(' <h3>Data Libraries Beta Test. This is work in progress. Please report problems & ideas via <a href="mailto:galaxy-bugs@bx.psu.edu?Subject=DataLibrariesBeta_Feedback" target="_blank">email</a> and <a href="https://trello.com/c/nwYQNFPK/56-data-library-ui-progressive-display-of-fold..." target="_blank">Trello</a>.</h3>');tmpl_array.push(' <div id="library_toolbar">');tmpl_array.push(' <input id="include_deleted_chk" style="margin: 0;" type="checkbox">include deleted</input>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Create New Library" id="create_new_library_btn" class="primary-button" type="button"><span class="fa fa-plus"></span> New Library</button>');tmpl_array.push(" </div>");tmpl_array.push(" </div>");tmpl_array.push(' <div id="libraries_element">');tmpl_array.push(" </div>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))}});return{ToolbarView:b}}); \ No newline at end of file +define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model"],function(a,d,e,c){var b=Backbone.View.extend({el:"#center",events:{"click #create_new_library_btn":"delegate_modal","click #include_deleted_chk":"check_include_deleted"},initialize:function(){this.render()},delegate_modal:function(f){libraryListView.show_library_modal(f)},check_include_deleted:function(f){if(f.target.checked){libraryListView.preferences.set({with_deleted:true});libraryListView.render()}else{libraryListView.preferences.set({with_deleted:false});libraryListView.render()}},render:function(){var f=this.templateToolBar();this.$el.html(f())},templateToolBar:function(){tmpl_array=[];tmpl_array.push('<div id="libraries_container" style="width: 90%; margin: auto; margin-top:2em; overflow: auto !important; ">');tmpl_array.push(' <div id="toolbar_form" margin-top:0.5em; ">');tmpl_array.push(' <h3>Data Libraries Beta Test. This is work in progress. Please report problems & ideas via <a href="mailto:galaxy-bugs@bx.psu.edu?Subject=DataLibrariesBeta_Feedback" target="_blank">email</a> and <a href="https://trello.com/c/nwYQNFPK/56-data-library-ui-progressive-display-of-fold..." target="_blank">Trello</a>.</h3>');tmpl_array.push(' <div id="library_toolbar">');tmpl_array.push(' <input id="include_deleted_chk" style="margin: 0;" type="checkbox">include deleted</input>');tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Create New Library" id="create_new_library_btn" class="primary-button" type="button"><span class="fa fa-plus"></span> New Library</button>');tmpl_array.push(" </div>");tmpl_array.push(" </div>");tmpl_array.push(' <div id="libraries_element">');tmpl_array.push(" </div>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))}});return{ToolbarView:b}}); \ No newline at end of file diff -r 876bc02f522fa636fd42c91b22e6588be8833176 -r 813a11e7b98ac4a20abf3a185a7233a6a947a3c4 static/scripts/packed/mvc/library/library-model.js --- a/static/scripts/packed/mvc/library/library-model.js +++ b/static/scripts/packed/mvc/library/library-model.js @@ -1,1 +1,1 @@ -define([],function(){var e=Backbone.Model.extend({urlRoot:"/api/libraries/"});var a=Backbone.Model.extend({urlRoot:"/api/folders"});var h=Backbone.Collection.extend({url:"/api/libraries",model:e,sort_key:"name",sort_order:null});var f=Backbone.Model.extend({urlRoot:"/api/libraries/datasets"});var c=Backbone.Collection.extend({model:f});var d=Backbone.Model.extend({defaults:{folder:new c(),full_path:"unknown",urlRoot:"/api/folders/",id:"unknown"},parse:function(j){this.full_path=j[0].full_path;this.get("folder").reset(j[1].folder_contents);return j}});var b=Backbone.Model.extend({urlRoot:"/api/histories/"});var g=Backbone.Model.extend({url:"/api/histories/"});var i=Backbone.Collection.extend({url:"/api/histories",model:g});return{Library:e,FolderAsModel:a,Libraries:h,Item:f,Folder:c,FolderContainer:d,HistoryItem:b,GalaxyHistory:g,GalaxyHistories:i}}); \ No newline at end of file +define([],function(){var e=Backbone.Model.extend({urlRoot:"/api/libraries/",isVisible:function(k){var j=true;if((!show_delete)&&(this.get("deleted"))){j=false}return j}});var a=Backbone.Model.extend({urlRoot:"/api/folders"});var h=Backbone.Collection.extend({url:"/api/libraries",model:e,sort_key:"name",sort_order:null,initialize:function(j){j=j||{}},getVisible:function(k,l){l=l||[];var j=new h(this.filter(function(m){return m.isVisible(k)}));return j}});var f=Backbone.Model.extend({urlRoot:"/api/libraries/datasets"});var c=Backbone.Collection.extend({model:f});var d=Backbone.Model.extend({defaults:{folder:new c(),full_path:"unknown",urlRoot:"/api/folders/",id:"unknown"},parse:function(j){this.full_path=j[0].full_path;this.get("folder").reset(j[1].folder_contents);return j}});var b=Backbone.Model.extend({urlRoot:"/api/histories/"});var g=Backbone.Model.extend({url:"/api/histories/"});var i=Backbone.Collection.extend({url:"/api/histories",model:g});return{Library:e,FolderAsModel:a,Libraries:h,Item:f,Folder:c,FolderContainer:d,HistoryItem:b,GalaxyHistory:g,GalaxyHistories:i}}); \ No newline at end of file Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org