',
+//TODO: remove logic from template
+ '<% if( collection.type === "list" ){ %>',
+ _l( 'a list of datasets' ),
+ '<% } else if( collection.type === "paired" ){ %>',
+ _l( 'a pair of datasets' ),
+ '<% } else if( collection.type === "list:paired" ){ %>',
+ _l( 'a list of paired datasets' ),
+ '<% } %>',
+ '
',
+ '
',
'
',
+ // where the datasets/hdas are added
+ ''
+ ].join( '' ));
- '
',
- '<% if( collection.name ){ %>',
- '
<%= collection.hid %> : <%= collection.name %>
',
- '<% } %>',
- '
',
+ // we override here in order to pass the localizer (_L) into the template scope - since we use it as a fn within
+ return {
+ panel : function( json ){
+ return _panelTemplate({ _l: _l, collection: json });
+ }
+ };
+}());
- //'
',
- // _l( 'You are currently viewing a deleted history!' ),
- // '
',
- //'<% } %>',
- //
- //'
',
- // '<% if( history.message ){ %>',
- // // should already be localized
- // '
<%= history.message %>
',
- // '<% } %>',
- //'
',
- //
- //'
',
- // _l( 'You are over your disk quota' ), '. ',
- // _l( 'Tool execution is on hold until your disk usage drops below your allocated quota' ), '.',
- //'
',
- //
- //'',
- //'',
- //'
',
- // '
',
- // '',
- // '',
- // '
',
- // '',
- //'
',
- '
',
- // end history controls
- // where the datasets/hdas are added
- ''
-
-].join( '' );
-
-CollectionPanel.templates = {
- panel : function( JSON ){
- return _.template( _panelTemplate, JSON, { variable: 'collection' });
+// =============================================================================
+/** @class non-editable, read-only View/Controller for a dataset collection. */
+var ListCollectionPanel = CollectionPanel.extend({
+ DCEViewClass : DC_BASE.HDADCEBaseView,
+ // ........................................................................ misc
+ /** string rep */
+ toString : function(){
+ return 'ListCollectionPanel(' + (( this.model )?( this.model.get( 'name' )):( '' )) + ')';
}
-};
+});
+
+
+// =============================================================================
+/** @class non-editable, read-only View/Controller for a dataset collection. */
+var PairCollectionPanel = ListCollectionPanel.extend({
+ // ........................................................................ misc
+ /** string rep */
+ toString : function(){
+ return 'PairCollectionPanel(' + (( this.model )?( this.model.get( 'name' )):( '' )) + ')';
+ }
+});
+
+
+// =============================================================================
+/** @class non-editable, read-only View/Controller for a dataset collection. */
+var ListOfPairsCollectionPanel = CollectionPanel.extend({
+ DCEViewClass : DC_BASE.DCDCEBaseView,
+ // ........................................................................ misc
+ /** string rep */
+ toString : function(){
+ return 'ListOfPairsCollectionPanel(' + (( this.model )?( this.model.get( 'name' )):( '' )) + ')';
+ }
+});
//==============================================================================
return {
- CollectionPanel: CollectionPanel
+ CollectionPanel : CollectionPanel,
+ ListCollectionPanel : ListCollectionPanel,
+ PairCollectionPanel : PairCollectionPanel,
+ ListOfPairsCollectionPanel : ListOfPairsCollectionPanel
};
});
diff --git a/static/scripts/mvc/collection/dataset-collection-base.js b/static/scripts/mvc/collection/dataset-collection-base.js
index ab0f1f27e12..4914c9cc72f 100644
--- a/static/scripts/mvc/collection/dataset-collection-base.js
+++ b/static/scripts/mvc/collection/dataset-collection-base.js
@@ -29,7 +29,82 @@ var DCBaseView = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend({
this.log( 'DCBaseView.initialize:', attributes );
},
-//TODO: render has been removed from the inheritance chain here, so this won't work when called as is
+ // ........................................................................ render main
+ /** Render this content, set up ui.
+ * @param {Boolean} fade whether or not to fade out/in when re-rendering
+ * @fires rendered when rendered
+ * @fires rendered:ready when first rendered and NO running HDAs
+ * @returns {Object} this HDABaseView
+ */
+ render : function( fade ){
+ var $newRender = this._buildNewRender();
+ this._queueNewRender( $newRender, fade );
+ return this;
+ },
+
+ _buildNewRender : function(){
+ // create a new render using a skeleton template, render title buttons, render body, and set up events, etc.
+ var $newRender = $( this.templates.skeleton( this.model.toJSON() ) );
+ $newRender.find( '.primary-actions' ).append( this._render_primaryActions() );
+ this._setUpBehaviors( $newRender );
+ //this._renderSelectable( $newRender );
+ return $newRender;
+ },
+
+ /** Fade out the old el, replace with new dom, then fade in.
+ * @param {Boolean} fade whether or not to fade out/in when re-rendering
+ * @fires rendered when rendered
+ * @fires rendered:ready when first rendered and NO running HDAs
+ */
+ _queueNewRender : function( $newRender, fade ) {
+ fade = ( fade === undefined )?( true ):( fade );
+ var view = this;
+
+ // fade the old render out (if desired)
+ if( fade ){
+ $( view ).queue( function( next ){ this.$el.fadeOut( view.fxSpeed, next ); });
+ }
+ // empty the old render, swap in the new render contents
+ $( view ).queue( function( next ){
+//TODO:?? change to replaceWith pattern?
+ this.$el.empty().attr( 'class', view.className ).append( $newRender.children() );
+ next();
+ });
+ // fade the new in
+ if( fade ){
+ $( view ).queue( function( next ){ this.$el.fadeIn( view.fxSpeed, next ); });
+ }
+ // trigger an event to know we're ready
+ $( view ).queue( function( next ){
+ this.trigger( 'rendered', view );
+ next();
+ });
+ },
+
+ /** set up js behaviors, event handlers for elements within the given container
+ * @param {jQuery} $container jq object that contains the elements to process (defaults to this.$el)
+ */
+ _setUpBehaviors : function( $container ){
+ $container = $container || this.$el;
+ make_popup_menus( $container );
+ $container.find( '[title]' ).tooltip({ placement : 'bottom' });
+ },
+
+ // ........................................................................ titlebar buttons
+ /** Render icon-button group for the common, most easily accessed actions.
+ * @returns {jQuery} rendered DOM or null
+ */
+ _render_primaryActions : function(){
+ // override
+ return [];
+ },
+
+ // ......................................................................... misc
+ events : {
+ 'click .title-bar' : function( event ){
+ this.trigger( 'expanded', this );
+ }
+ },
// ......................................................................... misc
/** String representation */
@@ -40,37 +115,23 @@ var DCBaseView = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend({
});
/** templates for DCBaseViews (skeleton and body) */
-DCBaseView.templates = (function(){
+DCBaseView.templates = DCBaseView.prototype.templates = (function(){
// use closure to run underscore template fn only once at module load
var skeletonTemplate = _.template([
- '
',
- '
',
- '<% if ( collection.deleted ) { %>',
- '
',
- _l( 'This collection has been deleted.' ),
- '
',
+ '<% } %>',
+
+ '<% } %>',
+ // end if !deleted
+
+ '
'
+ ].join( '' ));
+
+ // we override here in order to pass the localizer (_L) into the template scope - since we use it as a fn within
+ return {
+ skeleton : function( json ){
+ return skeletonTemplate({ _l: _l, element: json, hda: json.object });
+ },
+ details : function( json ){
+ return detailsTemplate({ _l: _l, element: json, hda: json.object });
+ }
+ };
+}());
+
+
+//==============================================================================
+/** @class Read only view for DatasetCollectionElement.
+ * @name DCBaseView
+ *
+ * @augments Backbone.View
+ * @borrows LoggableMixin#logger as #logger
+ * @borrows LoggableMixin#log as #log
+ * @constructs
+ */
+var DCDCEBaseView = DCEBaseView.extend({
+
+ /** logger used to record this.log messages, commonly set to console */
+ // comment this out to suppress log output
+ //logger : console,
+
+ // ......................................................................... misc
+ /** String representation */
+ expand : function(){
+ this.trigger( 'expanded', this );
+ },
+
+ // ......................................................................... misc
+ /** String representation */
+ toString : function(){
+ var modelString = ( this.model )?( this.model + '' ):( '(no model)' );
+ return 'DCDCEBaseView(' + modelString + ')';
+ }
+});
+
+/** templates for DCBaseViews (skeleton and body) */
+DCDCEBaseView.templates = DCDCEBaseView.prototype.templates = (function(){
+// use closure to run underscore template fn only once at module load
+ var skeletonTemplate = _.template([
+ '
',
+ '',
+ '
',
+ '',
+ '
',
+ '<%- element.element_identifier %>',
+ '
',
+//TODO: currently correct, but needs logic if more nested types are added
+ '
', _l( 'paired datasets' ), '
',
+ '
',
+ '',
+ '
'
+ ].join( '' ));
+
+ // we override here in order to pass the localizer (_L) into the template scope - since we use it as a fn within
+ return {
+ skeleton : function( json ){
+ return skeletonTemplate({ _l: _l, element: json, collection: json.object });
+ }
+ };
+}());
//==============================================================================
return {
DCBaseView : DCBaseView,
- //NestedDCBaseView : NestedDCBaseView,
+ DCEBaseView : DCEBaseView,
+ HDADCEBaseView : HDADCEBaseView,
+ DCDCEBaseView : DCDCEBaseView
};
});
diff --git a/static/scripts/mvc/collection/hdca-base.js b/static/scripts/mvc/collection/hdca-base.js
index f44369eef31..f3ec68e5046 100644
--- a/static/scripts/mvc/collection/hdca-base.js
+++ b/static/scripts/mvc/collection/hdca-base.js
@@ -22,8 +22,9 @@ var HDCABaseView = _super.extend( BASE_MVC.mixin( HCVMixin, {
// comment this out to suppress log output
//logger : console,
+//TODO: not a dataset
/** */
- className : "dataset hda history-panel-hda",
+ className : "dataset hdca history-panel-hda",
/** */
initialize : function( attributes ){
@@ -52,6 +53,26 @@ var HDCABaseView = _super.extend( BASE_MVC.mixin( HCVMixin, {
return $body;
},
+ /** In this override, do not slide down or render any body/details - allow the container to handle it
+ * @fires expanded when a body has been expanded
+ */
+ expand : function(){
+ this.warn( this + '.expand' );
+ var contentView = this;
+
+ // fetch first if no details in the model
+ if( this.model.inReadyState() && !this.model.hasDetails() ){
+ // we need the change event on HDCA's for the elements to be processed - so silent == false
+ this.model.fetch().always( function( model ){
+ contentView.expanded = true;
+ contentView.trigger( 'expanded', contentView );
+ });
+ } else {
+ contentView.expanded = true;
+ contentView.trigger( 'expanded', contentView );
+ }
+ },
+
// ......................................................................... misc
/** String representation */
toString : function(){
@@ -64,7 +85,8 @@ var HDCABaseView = _super.extend( BASE_MVC.mixin( HCVMixin, {
HDCABaseView.templates = HDCABaseView.prototype.templates = (function(){
// use closure to run underscore template fn only once at module load
var skeletonTemplate = _.template([
- '
','<% if( collection.collection_type === "list" ){ %>',b("a list of datasets"),'<% } else if( collection.collection_type === "paired" ){ %>',b("a pair of datasets"),'<% } else if( collection.collection_type === "list:paired" ){ %>',b("a list of paired datasets"),"<% } %>","
","
",'',"
"].join(""));var i=_.template(['
','
',b("A dataset collection."),"
"].join(""));return{skeleton:function(j){return h({_l:b,collection:j})},body:function(j){return i({_l:b,collection:j})}}}());return{HDCABaseView:e}});
\ No newline at end of file
diff --git a/static/scripts/packed/mvc/collection/hdca-edit.js b/static/scripts/packed/mvc/collection/hdca-edit.js
index 82007faed38..70f1975eabd 100644
--- a/static/scripts/packed/mvc/collection/hdca-edit.js
+++ b/static/scripts/packed/mvc/collection/hdca-edit.js
@@ -1 +1 @@
-define(["mvc/dataset/states","mvc/collection/hdca-base","utils/localization"],function(a,e,b){var d=e.HDCABaseView;var c=d.extend({initialize:function(f){d.prototype.initialize.call(this,f)},_render_titleButtons:function(){this.log(this+"._render_titleButtons");return d.prototype._render_titleButtons.call(this).concat([this._render_deleteButton()])},_render_deleteButton:function(){var f=this,g={title:b("Delete"),classes:"dataset-delete",onclick:function(){f.$el.find(".icon-btn.dataset-delete").trigger("mouseout");f.model["delete"]()}};if(f.model.get("deleted")){g={title:b("Dataset collection is already deleted"),disabled:true}}g.faIcon="fa-times";return faIconButton(g)},toString:function(){var f=(this.model)?(this.model+""):("(no model)");return"HDCAEditView("+f+")"}});return{HDCAEditView:c}});
\ No newline at end of file
+define(["mvc/dataset/states","mvc/collection/hdca-base","utils/localization"],function(a,e,b){var d=e.HDCABaseView;var c=d.extend({initialize:function(f){d.prototype.initialize.call(this,f)},_render_primaryActions:function(){this.log(this+"._render_primaryActions");return d.prototype._render_primaryActions.call(this).concat([this._render_deleteButton()])},_render_deleteButton:function(){var f=this,g={title:b("Delete"),classes:"dataset-delete",onclick:function(){f.$el.find(".icon-btn.dataset-delete").trigger("mouseout");f.model["delete"]()}};if(f.model.get("deleted")){g={title:b("Dataset collection is already deleted"),disabled:true}}g.faIcon="fa-times";return faIconButton(g)},toString:function(){var f=(this.model)?(this.model+""):("(no model)");return"HDCAEditView("+f+")"}});return{HDCAEditView:c}});
\ No newline at end of file
diff --git a/static/scripts/packed/mvc/collection/hdca-model.js b/static/scripts/packed/mvc/collection/hdca-model.js
index 3a97cde815b..e4ebe67c516 100644
--- a/static/scripts/packed/mvc/collection/hdca-model.js
+++ b/static/scripts/packed/mvc/collection/hdca-model.js
@@ -1 +1 @@
-define(["mvc/history/history-content-base","mvc/collection/collection-model","utils/localization"],function(j,d,a){var h=j.HistoryContentMixin,c=d.DatasetCollection.extend(h);var i=d.ListDatasetCollection,e=i.extend(h).extend({initialize:function(m,l){i.prototype.initialize.call(this,m,l);h.initialize.call(this,m,l);this.set("state","ok",{silent:true})},toString:function(){return(["HistoryListDatasetCollection(",this.get("name"),")"].join(""))}});var k=d.PairDatasetCollection,g=k.extend(h).extend({initialize:function(m,l){k.prototype.initialize.call(this,m,l);h.initialize.call(this,m,l);this.set("state","ok",{silent:true})},toString:function(){return(["HistoryPairDatasetCollection(",this.get("name"),")"].join(""))}});var f=d.ListPairedDatasetCollection,b=f.extend(h).extend({initialize:function(m,l){f.prototype.initialize.call(this,m,l);h.initialize.call(this,m,l);this.set("state","ok",{silent:true})},toString:function(){return(["HistoryListPairedDatasetCollection(",this.get("name"),")"].join(""))}});return{HistoryDatasetCollection:c,HistoryListDatasetCollection:e,HistoryPairDatasetCollection:g,HistoryListPairedDatasetCollection:b}});
\ No newline at end of file
+define(["mvc/history/history-content-base","mvc/collection/collection-model","utils/localization"],function(i,c,a){var g=i.HistoryContentMixin,h=c.ListDatasetCollection,j=c.PairDatasetCollection,f=c.ListPairedDatasetCollection;var d=h.extend(g).extend({initialize:function(l,k){h.prototype.initialize.call(this,l,k);g.initialize.call(this,l,k);this.set("state","ok",{silent:true})},toString:function(){return(["HistoryListDatasetCollection(",this.get("name"),")"].join(""))}});var e=j.extend(g).extend({initialize:function(l,k){j.prototype.initialize.call(this,l,k);g.initialize.call(this,l,k);this.set("state","ok",{silent:true})},toString:function(){return(["HistoryPairDatasetCollection(",this.get("name"),")"].join(""))}});var b=f.extend(g).extend({initialize:function(l,k){f.prototype.initialize.call(this,l,k);g.initialize.call(this,l,k);this.set("state","ok",{silent:true})},toString:function(){return(["HistoryListPairedDatasetCollection(",this.get("name"),")"].join(""))}});return{HistoryListDatasetCollection:d,HistoryPairDatasetCollection:e,HistoryListPairedDatasetCollection:b}});
\ No newline at end of file
diff --git a/static/scripts/packed/mvc/dataset/hda-base.js b/static/scripts/packed/mvc/dataset/hda-base.js
index fb24637db90..c1521b2d348 100644
--- a/static/scripts/packed/mvc/dataset/hda-base.js
+++ b/static/scripts/packed/mvc/dataset/hda-base.js
@@ -1 +1 @@
-define(["mvc/dataset/states","mvc/history/history-content-base-view","mvc/data","utils/localization"],function(c,h,b,e){var f=h.HistoryContentBaseView;var d=f.extend({tagName:"div",className:"dataset hda history-panel-hda",id:function(){return"hda-"+this.model.get("id")},fxSpeed:"fast",initialize:function(i){if(i.logger){this.logger=this.model.logger=i.logger}this.log(this+".initialize:",i);f.prototype.initialize.call(this,i);this.defaultPrimaryActionButtonRenderers=[this._render_showParamsButton];this.linkTarget=i.linkTarget||"_blank";this.draggable=i.draggable||false;this._setUpListeners()},_setUpListeners:function(){this.model.on("change",function(j,i){if(this.model.changedAttributes().state&&this.model.inReadyState()&&this.expanded&&!this.model.hasDetails()){this.model.fetch()}else{this.render()}},this)},render:function(i){this.$el.find("[title]").tooltip("destroy");this.urls=this.model.urls();return f.prototype.render.call(this,i)},_render_titleButtons:function(){return[this._render_displayButton()]},_render_displayButton:function(){if((this.model.get("state")===c.NOT_VIEWABLE)||(this.model.get("state")===c.DISCARDED)||(!this.model.get("accessible"))){return null}var j={target:this.linkTarget,classes:"dataset-display"};if(this.model.get("purged")){j.disabled=true;j.title=e("Cannot display datasets removed from disk")}else{if(this.model.get("state")===c.UPLOAD){j.disabled=true;j.title=e("This dataset must finish uploading before it can be viewed")}else{if(this.model.get("state")===c.NEW){j.disabled=true;j.title=e("This dataset is not yet viewable")}else{j.title=e("View data");j.href=this.urls.display;var i=this;j.onclick=function(k){if(Galaxy.frame&&Galaxy.frame.active){Galaxy.frame.add({title:"Data Viewer: "+i.model.get("name"),type:"other",content:function(l){var m=new b.TabularDataset({id:i.model.get("id")});$.when(m.fetch()).then(function(){b.createTabularDatasetChunkedView({model:m,parent_elt:l,embedded:true,height:"100%"})})}});k.preventDefault()}}}}}j.faIcon="fa-eye";return faIconButton(j)},_render_downloadButton:function(){if(this.model.get("purged")||!this.model.hasData()){return null}var j=this.urls,k=this.model.get("meta_files");if(_.isEmpty(k)){return $(['','',""].join(""))}var l="dataset-"+this.model.get("id")+"-popup",i=['
"].join(""));d.templates=d.prototype.templates={skeleton:function(i){return a({_l:e,hda:i})},body:function(i){return g({_l:e,hda:i})}};return{HDABaseView:d}});
\ No newline at end of file
+define(["mvc/dataset/states","mvc/history/history-content-base-view","mvc/data","utils/localization"],function(c,h,b,e){var f=h.HistoryContentBaseView;var d=f.extend({tagName:"div",className:"dataset hda history-content",id:function(){return"hda-"+this.model.get("id")},fxSpeed:"fast",initialize:function(i){if(i.logger){this.logger=this.model.logger=i.logger}this.log(this+".initialize:",i);f.prototype.initialize.call(this,i);this.defaultPrimaryActionButtonRenderers=[this._render_showParamsButton];this.linkTarget=i.linkTarget||"_blank";this.draggable=i.draggable||false;this._setUpListeners()},_setUpListeners:function(){this.model.on("change",function(j,i){if(this.model.changedAttributes().state&&this.model.inReadyState()&&this.expanded&&!this.model.hasDetails()){this.model.fetch()}else{this.render()}},this)},render:function(i){this.$el.find("[title]").tooltip("destroy");this.urls=this.model.urls();return f.prototype.render.call(this,i)},_render_primaryActions:function(){return[this._render_displayButton()]},_render_displayButton:function(){if((this.model.get("state")===c.NOT_VIEWABLE)||(this.model.get("state")===c.DISCARDED)||(!this.model.get("accessible"))){return null}var j={target:this.linkTarget,classes:"display-btn"};if(this.model.get("purged")){j.disabled=true;j.title=e("Cannot display datasets removed from disk")}else{if(this.model.get("state")===c.UPLOAD){j.disabled=true;j.title=e("This dataset must finish uploading before it can be viewed")}else{if(this.model.get("state")===c.NEW){j.disabled=true;j.title=e("This dataset is not yet viewable")}else{j.title=e("View data");j.href=this.urls.display;var i=this;j.onclick=function(k){if(Galaxy.frame&&Galaxy.frame.active){Galaxy.frame.add({title:"Data Viewer: "+i.model.get("name"),type:"other",content:function(l){var m=new b.TabularDataset({id:i.model.get("id")});$.when(m.fetch()).then(function(){b.createTabularDatasetChunkedView({model:m,parent_elt:l,embedded:true,height:"100%"})})}});k.preventDefault()}}}}}j.faIcon="fa-eye";return faIconButton(j)},_render_downloadButton:function(){if(this.model.get("purged")||!this.model.hasData()){return null}var j=this.urls,k=this.model.get("meta_files");if(_.isEmpty(k)){return $(['','',""].join(""))}var l="dataset-"+this.model.get("id")+"-popup",i=['