diff --git a/client/galaxy/scripts/mvc/collection/list-collection-creator.js b/client/galaxy/scripts/mvc/collection/list-collection-creator.js index c1f69d12f61..117ad52db52 100644 --- a/client/galaxy/scripts/mvc/collection/list-collection-creator.js +++ b/client/galaxy/scripts/mvc/collection/list-collection-creator.js @@ -62,10 +62,10 @@ var DatasetCollectionElementView = Backbone.View.extend( BASE_MVC.LoggableMixin var view = this, parentWidth = this.$el.parent().width(); this.$el.animate({ 'margin-right' : parentWidth }, 'fast', function(){ - view.destroy(); view.trigger( 'discard', { source : view }); + view.destroy(); }); }, @@ -147,7 +147,10 @@ var ListCollectionCreator = Backbone.View.extend( BASE_MVC.LoggableMixin ).exten elementViewClass : DatasetCollectionElementView, /** the class this creator will create and save */ collectionClass : HDCA.HistoryListDatasetCollection, - className : 'list-collection-creator collection-creator flex-row-container', + className : 'list-collection-creator collection-creator flex-row-container', + + /** minimum number of valid elements to start with in order to build a collection of this type */ + minElements : 1, defaultAttributes : { //TODO: remove - use new collectionClass().save() @@ -284,10 +287,13 @@ var ListCollectionCreator = Backbone.View.extend( BASE_MVC.LoggableMixin ).exten // ------------------------------------------------------------------------ rendering // templates : ListCollectionCreator.templates, - /** render the entire interface */ render : function( speed, callback ){ //this.debug( '-- _render' ); + if( this.workingElements.length < this.minElements ){ + return this._renderInvalid( speed, callback ); + } + this.$el.empty().html( this.templates.main() ); this._renderHeader( speed ); this._renderMiddle( speed ); @@ -298,6 +304,21 @@ var ListCollectionCreator = Backbone.View.extend( BASE_MVC.LoggableMixin ).exten return this; }, + + /** render a simplified interface aimed at telling the user why they can't move forward */ + _renderInvalid : function( speed, callback ){ + //this.debug( '-- _render' ); + this.$el.empty().html( this.templates.invalidInitial({ + problems: this.invalidElements, + elements: this.workingElements, + })); + if( typeof this.oncancel === 'function' ){ + this.$( '.cancel-create.btn' ).show(); + } + this.trigger( 'rendered', this ); + return this; + }, + /** render the header section */ _renderHeader : function( speed, callback ){ var $header = this.$( '.header' ).empty().html( this.templates.header() ) @@ -350,6 +371,17 @@ var ListCollectionCreator = Backbone.View.extend( BASE_MVC.LoggableMixin ).exten } }, + _disableNameAndCreate : function( disable ){ + disable = !_.isUndefined( disable )? disable : true; + if( disable ){ + this.$( '.collection-name' ).prop( 'disabled', true ); + this.$( '.create-collection' ).toggleClass( 'disabled', true ); + // } else { + // this.$( '.collection-name' ).prop( 'disabled', false ); + // this.$( '.create-collection' ).removeClass( 'disable' ); + } + }, + // ------------------------------------------------------------------------ rendering elements /** conv. to the main list display DOM */ $list : function(){ @@ -369,17 +401,18 @@ var ListCollectionCreator = Backbone.View.extend( BASE_MVC.LoggableMixin ).exten _renderList : function( speed, callback ){ //this.debug( '-- _renderList' ); var creator = this, - $tmp = jQuery( '
' ); + $tmp = jQuery( '' ), + $list = creator.$list(); _.each( this.elementViews, function( view ){ view.destroy(); creator.removeElementView( view ); }); - if( !this.workingElements.length ){ - this._renderNoValidElements(); - return; - } + // if( !this.workingElements.length ){ + // this._renderNoValidElements(); + // return; + // } creator.workingElements.forEach( function( element ){ var elementView = creator._createElementView( element ); @@ -387,8 +420,14 @@ var ListCollectionCreator = Backbone.View.extend( BASE_MVC.LoggableMixin ).exten }); creator._renderClearSelected(); - creator.$list().empty().append( $tmp.children() ); + $list.empty().append( $tmp.children() ); _.invoke( creator.elementViews, 'render' ); + + if( $list.height() > $list.css( 'max-height' ) ){ + $list.css( 'border-width', '1px 0px 1px 0px' ); + } else { + $list.css( 'border-width', '0px' ); + } }, /** create an element view, cache in elementViews, set up listeners, and return */ @@ -442,13 +481,15 @@ var ListCollectionCreator = Backbone.View.extend( BASE_MVC.LoggableMixin ).exten /** render a message in the list that no elements remain to create a collection */ _renderNoElementsLeft : function(){ + this._disableNameAndCreate( true ); this.$( '.collection-elements' ).append( this.templates.noElementsLeft() ); }, - /** render a message in the list that no valid elements were found to create a collection */ - _renderNoValidElements : function(){ - this.$( '.collection-elements' ).append( this.templates.noValidElements() ); - }, + // /** render a message in the list that no valid elements were found to create a collection */ + // _renderNoValidElements : function(){ + // this._disableNameAndCreate( true ); + // this.$( '.collection-elements' ).append( this.templates.noValidElements() ); + // }, // ------------------------------------------------------------------------ API /** convert element into JSON compatible with the collections API */ @@ -874,7 +915,7 @@ var ListCollectionCreator = Backbone.View.extend( BASE_MVC.LoggableMixin ).exten /** shown in list when all elements are discarded */ invalidElements : _.template([ - _l( 'The following selections could not be included due to problems' ), + _l( 'The following selections could not be included due to problems:' ), '"+JSON.stringify(c.responseJSON)+"":": "+d}b._showAlert(content,"alert-danger")},events:{"click .more-help":"_clickMoreHelp","click .less-help":"_clickLessHelp","click .main-help":"_toggleHelp","click .header .alert button":"_hideAlert","click .reset":"reset","click .clear-selected":"clearSelectedElements","click .collection-elements":"clearSelectedElements","dragover .collection-elements":"_dragoverElements","drop .collection-elements":"_dropElements","collection-element.dragstart .collection-elements":"_elementDragstart","collection-element.dragend .collection-elements":"_elementDragend","change .collection-name":"_changeName","keydown .collection-name":"_nameCheckForEnter","click .cancel-create":function(){"function"==typeof this.oncancel&&this.oncancel.call(this)},"click .create-collection":"_clickCreate"},_clickMoreHelp:function(a){a.stopPropagation(),this.$(".main-help").addClass("expanded"),this.$(".more-help").hide()},_clickLessHelp:function(a){a.stopPropagation(),this.$(".main-help").removeClass("expanded"),this.$(".more-help").show()},_toggleHelp:function(a){a.stopPropagation(),this.$(".main-help").toggleClass("expanded"),this.$(".more-help").toggle()},_showAlert:function(a,b){b=b||"alert-danger",this.$(".main-help").hide(),this.$(".header .alert").attr("class","alert alert-dismissable").addClass(b).show().find(".alert-message").html(a)},_hideAlert:function(){this.$(".main-help").show(),this.$(".header .alert").hide()},reset:function(){this._instanceSetUp(),this._elementsSetUp(),this.render()},clearSelectedElements:function(){this.$(".collection-elements .collection-element").removeClass("selected"),this.$(".collection-elements-controls > .clear-selected").hide()},_dragoverElements:function(a){a.preventDefault();var b=this.$list();this._checkForAutoscroll(b,a.originalEvent.clientY);var c=this._getNearestElement(a.originalEvent.clientY);this.$(".element-drop-placeholder").remove();var d=$('');c.size()?c.before(d):b.append(d)},_checkForAutoscroll:function(a,b){var c=2,d=a.offset(),e=a.scrollTop(),f=b-d.top,g=d.top+a.outerHeight()-b;f>=0&&f
",f(["Collections of datasets are permanent, ordered lists of datasets that can be passed to tools and ","workflows in order to have analyses done on each member of the entire group. This interface allows ","you to create a collection and re-order the final collection."].join("")),"
","",f(['Once your collection is complete, enter a name and ','click "Create list".'].join("")),"
"].join("")),invalidElements:_.template([f("The following selections could not be included due to problems"),""+JSON.stringify(c.responseJSON)+"":": "+d}b._showAlert(content,"alert-danger")},events:{"click .more-help":"_clickMoreHelp","click .less-help":"_clickLessHelp","click .main-help":"_toggleHelp","click .header .alert button":"_hideAlert","click .reset":"reset","click .clear-selected":"clearSelectedElements","click .collection-elements":"clearSelectedElements","dragover .collection-elements":"_dragoverElements","drop .collection-elements":"_dropElements","collection-element.dragstart .collection-elements":"_elementDragstart","collection-element.dragend .collection-elements":"_elementDragend","change .collection-name":"_changeName","keydown .collection-name":"_nameCheckForEnter","click .cancel-create":function(){"function"==typeof this.oncancel&&this.oncancel.call(this)},"click .create-collection":"_clickCreate"},_clickMoreHelp:function(a){a.stopPropagation(),this.$(".main-help").addClass("expanded"),this.$(".more-help").hide()},_clickLessHelp:function(a){a.stopPropagation(),this.$(".main-help").removeClass("expanded"),this.$(".more-help").show()},_toggleHelp:function(a){a.stopPropagation(),this.$(".main-help").toggleClass("expanded"),this.$(".more-help").toggle()},_showAlert:function(a,b){b=b||"alert-danger",this.$(".main-help").hide(),this.$(".header .alert").attr("class","alert alert-dismissable").addClass(b).show().find(".alert-message").html(a)},_hideAlert:function(){this.$(".main-help").show(),this.$(".header .alert").hide()},reset:function(){this._instanceSetUp(),this._elementsSetUp(),this.render()},clearSelectedElements:function(){this.$(".collection-elements .collection-element").removeClass("selected"),this.$(".collection-elements-controls > .clear-selected").hide()},_dragoverElements:function(a){a.preventDefault();var b=this.$list();this._checkForAutoscroll(b,a.originalEvent.clientY);var c=this._getNearestElement(a.originalEvent.clientY);this.$(".element-drop-placeholder").remove();var d=$('');c.size()?c.before(d):b.append(d)},_checkForAutoscroll:function(a,b){var c=2,d=a.offset(),e=a.scrollTop(),f=b-d.top,g=d.top+a.outerHeight()-b;f>=0&&f
",f(["Collections of datasets are permanent, ordered lists of datasets that can be passed to tools and ","workflows in order to have analyses done on each member of the entire group. This interface allows ","you to create a collection and re-order the final collection."].join("")),"
","",f(['Once your collection is complete, enter a name and ','click "Create list".'].join("")),"
"].join("")),invalidElements:_.template([f("The following selections could not be included due to problems:"),"",d(["Pair collections are permanent collections containing two datasets: one forward and one reverse. ","Often these are forward and reverse reads. The pair collections can be passed to tools and ","workflows in order to have analyses done on both datasets. This interface allows ","you to create a pair, name it, and swap which is forward and which reverse."].join("")),"
","",d(['Once your collection is complete, enter a name and ','click "Create list".'].join("")),"
"].join("")),invalidInitial:_.template(['",d(["Pair collections are permanent collections containing two datasets: one forward and one reverse. ","Often these are forward and reverse reads. The pair collections can be passed to tools and ","workflows in order to have analyses done on both datasets. This interface allows ","you to create a pair, name it, and swap which is forward and which reverse."].join("")),"
","",d(['Once your collection is complete, enter a name and ','click "Create list".'].join("")),"
"].join("")),invalidInitial:_.template(['