Skip to content

Commit

Permalink
Merge branch 'backport_2613' into release_16.04
Browse files Browse the repository at this point in the history
(and rebuild client)
  • Loading branch information
dannon committed Jul 21, 2016
2 parents 95c64c0 + 0d49b06 commit 132bd4d
Show file tree
Hide file tree
Showing 27 changed files with 200 additions and 58 deletions.
44 changes: 27 additions & 17 deletions client/galaxy/scripts/mvc/collection/collection-li.js
Expand Up @@ -33,30 +33,23 @@ var DCListItemView = FoldoutListItemView.extend(
/** event listeners */
_setUpListeners : function(){
FoldoutListItemView.prototype._setUpListeners.call( this );
// re-rendering on deletion
this.listenTo( this.model, 'change', function( model, options ){
if( _.isEqual( _.keys( model.changed ), [ 'deleted' ] ) ){
// if the model has changed deletion status render it entirely
if( _.has( model.changed, 'deleted' ) ){
this.render();

// if the model has been decorated after the fact with the element count,
// render the subtitle where the count is displayed
} else if( _.has( model.changed, 'element_count' ) ){
this.$( '> .title-bar .subtitle' ).replaceWith( this._renderSubtitle() );
}
});
},

// ......................................................................... rendering
//TODO:?? possibly move to listItem
/** render a subtitle to show the user what sort of collection this is */
_renderSubtitle : function(){
var $subtitle = $( '<div class="subtitle"></div>' );
//TODO: would be good to get this in the subtitle
//var len = this.model.elements.length;
switch( this.model.get( 'collection_type' ) ){
case 'list':
return $subtitle.text( _l( 'a list of datasets' ) );
case 'paired':
return $subtitle.text( _l( 'a pair of datasets' ) );
case 'list:paired':
return $subtitle.text( _l( 'a list of paired datasets' ) );
}
return $subtitle;
return $( this.templates.subtitle( this.model.toJSON(), this ) );
},

// ......................................................................... foldout
Expand Down Expand Up @@ -122,9 +115,26 @@ DCListItemView.prototype.templates = (function(){
'</div>'
], 'collection' );

// use element identifier
var subtitleTemplate = BASE_MVC.wrapTemplate([
'<div class="subtitle">',
'<% var countText = collection.element_count? ( collection.element_count + " " ) : ""; %>',
'<% if( collection.collection_type === "list" ){ %>',
_l( 'a list of <%- countText %>datasets' ),
'<% } else if( collection.collection_type === "paired" ){ %>',
_l( 'a pair of datasets' ),
'<% } else if( collection.collection_type === "list:paired" ){ %>',
_l( 'a list of <%- countText %>dataset pairs' ),
'<% } else if( collection.collection_type === "list:list" ){ %>',
_l( 'a list of <%- countText %>dataset lists' ),
'<% } %>',
'</div>'
], 'collection' );

return _.extend( {}, FoldoutListItemView.prototype.templates, {
warnings : warnings,
titleBar : titleBarTemplate
warnings : warnings,
titleBar : titleBarTemplate,
subtitle : subtitleTemplate
});
}());

Expand Down
54 changes: 51 additions & 3 deletions client/galaxy/scripts/mvc/collection/collection-model.js
Expand Up @@ -504,10 +504,58 @@ var ListPairedDatasetCollection = DatasetCollection.extend(
});


//==============================================================================
/** @class Backbone model for a list dataset collection within a list:list dataset collection. */
var NestedListDCDCE = ListDatasetCollection.extend( BASE_MVC.mixin( DatasetCollectionElementMixin,
/** @lends NestedListDCDCE.prototype */{

/** This is both a collection and a collection element - call the constructor */
constructor : function( attributes, options ){
this.debug( '\t NestedListDCDCE.constructor:', attributes, options );
DatasetCollectionElementMixin.constructor.call( this, attributes, options );
},

/** String representation. */
toString : function(){
var objStr = ( this.object )?( '' + this.object ):( this.get( 'element_identifier' ) );
return ([ 'NestedListDCDCE(', objStr, ')' ].join( '' ));
}
}));


//==============================================================================
/** @class Backbone collection containing list dataset collections. */
var NestedListDCDCECollection = NestedDCDCECollection.extend({

/** We know this collection is composed of only nested pair collections */
model: NestedListDCDCE,

/** String representation. */
toString : function(){
return ([ 'NestedListDCDCECollection(', this.length, ')' ].join( '' ));
}
});


//==============================================================================
/** @class Backbone Model for a DatasetCollection (list) that contains other lists. */
var ListOfListsDatasetCollection = DatasetCollection.extend({

/** list:paired is the only collection that itself contains collections */
collectionClass : NestedListDCDCECollection,

/** String representation. */
toString : function(){
return ([ 'ListOfListsDatasetCollection(', this.get( 'name' ), ')' ].join( '' ));
}
});


//==============================================================================
return {
ListDatasetCollection : ListDatasetCollection,
PairDatasetCollection : PairDatasetCollection,
ListPairedDatasetCollection : ListPairedDatasetCollection
ListDatasetCollection : ListDatasetCollection,
PairDatasetCollection : PairDatasetCollection,
ListPairedDatasetCollection : ListPairedDatasetCollection,
ListOfListsDatasetCollection: ListOfListsDatasetCollection
};
});
24 changes: 22 additions & 2 deletions client/galaxy/scripts/mvc/collection/collection-view-edit.js
Expand Up @@ -128,7 +128,7 @@ var NestedPairCollectionViewEdit = PairCollectionViewEdit.extend(


// =============================================================================
/** @class non-editable, read-only View/Controller for a dataset collection. */
/** @class editable, View/Controller for a list of pairs dataset collection. */
var ListOfPairsCollectionViewEdit = CollectionViewEdit.extend(
/** @lends ListOfPairsCollectionView.prototype */{

Expand All @@ -146,11 +146,31 @@ var ListOfPairsCollectionViewEdit = CollectionViewEdit.extend(
});


// =============================================================================
/** @class View/Controller for a list of lists dataset collection. */
var ListOfListsCollectionViewEdit = CollectionViewEdit.extend(
/** @lends ListOfListsCollectionView.prototype */{

//TODO: not strictly needed - due to switch in CollectionView._getContentClass
/** sub view class used for nested collections */
NestedDCDCEViewClass : DC_EDIT.NestedDCDCEListItemEdit.extend({
foldoutPanelClass : NestedPairCollectionViewEdit
}),

// ........................................................................ misc
/** string rep */
toString : function(){
return 'ListOfListsCollectionViewEdit(' + (( this.model )?( this.model.get( 'name' )):( '' )) + ')';
}
});


//==============================================================================
return {
CollectionViewEdit : CollectionViewEdit,
ListCollectionViewEdit : ListCollectionViewEdit,
PairCollectionViewEdit : PairCollectionViewEdit,
ListOfPairsCollectionViewEdit : ListOfPairsCollectionViewEdit
ListOfPairsCollectionViewEdit : ListOfPairsCollectionViewEdit,
ListOfListsCollectionViewEdit : ListOfListsCollectionViewEdit
};
});
21 changes: 20 additions & 1 deletion client/galaxy/scripts/mvc/collection/collection-view.js
Expand Up @@ -153,6 +153,8 @@ CollectionView.prototype.templates = (function(){
_l( 'a pair of datasets' ),
'<% } else if( collection.collection_type === "list:paired" ){ %>',
_l( 'a list of paired datasets' ),
'<% } else if( collection.collection_type === "list:list" ){ %>',
_l( 'a list of dataset lists' ),
'<% } %>',
'</div>',
'</div>',
Expand Down Expand Up @@ -215,11 +217,28 @@ var ListOfPairsCollectionView = CollectionView.extend(
});


// =============================================================================
/** @class non-editable, read-only View/Controller for a list of lists dataset collection. */
var ListOfListsCollectionView = CollectionView.extend({

/** sub view class used for nested collections */
NestedDCDCEViewClass : DC_LI.NestedDCDCEListItemView.extend({
foldoutPanelClass : PairCollectionView
}),

/** string rep */
toString : function(){
return 'ListOfListsCollectionView(' + (( this.model )?( this.model.get( 'name' )):( '' )) + ')';
}
});


//==============================================================================
return {
CollectionView : CollectionView,
ListCollectionView : ListCollectionView,
PairCollectionView : PairCollectionView,
ListOfPairsCollectionView : ListOfPairsCollectionView
ListOfPairsCollectionView : ListOfPairsCollectionView,
ListOfListsCollectionView : ListOfListsCollectionView
};
});
2 changes: 2 additions & 0 deletions client/galaxy/scripts/mvc/history/hdca-li-edit.js
Expand Up @@ -26,6 +26,8 @@ var HDCAListItemEdit = _super.extend(
return DC_VIEW_EDIT.PairCollectionViewEdit;
case 'list:paired':
return DC_VIEW_EDIT.ListOfPairsCollectionViewEdit;
case 'list:list':
return DC_VIEW_EDIT.ListOfListsCollectionViewEdit;
}
throw new TypeError( 'Uknown collection_type: ' + this.model.get( 'collection_type' ) );
},
Expand Down
2 changes: 2 additions & 0 deletions client/galaxy/scripts/mvc/history/hdca-li.js
Expand Up @@ -38,6 +38,8 @@ var HDCAListItemView = _super.extend(
return DC_VIEW.PairCollectionView;
case 'list:paired':
return DC_VIEW.ListOfPairsCollectionView;
case 'list:list':
return DC_VIEW.ListOfListsCollectionView;
}
throw new TypeError( 'Uknown collection_type: ' + this.model.get( 'collection_type' ) );
},
Expand Down
38 changes: 31 additions & 7 deletions client/galaxy/scripts/mvc/history/hdca-model.js
Expand Up @@ -18,7 +18,8 @@ TODO:
var hcontentMixin = HISTORY_CONTENT.HistoryContentMixin,
ListDC = DC_MODEL.ListDatasetCollection,
PairDC = DC_MODEL.PairDatasetCollection,
ListPairedDC = DC_MODEL.ListPairedDatasetCollection;
ListPairedDC = DC_MODEL.ListPairedDatasetCollection,
ListOfListsDC = DC_MODEL.ListOfListsDatasetCollection;

//==============================================================================
/** Override to post to contents route w/o id. */
Expand Down Expand Up @@ -91,11 +92,8 @@ var HistoryPairDatasetCollection = PairDC.extend( hcontentMixin ).extend(


//==============================================================================
/** @class Backbone model for List of Pairs Dataset Collection within a History.
* @constructs
*/
var HistoryListPairedDatasetCollection = ListPairedDC.extend( hcontentMixin ).extend(
/** @lends HistoryListPairedDatasetCollection.prototype */{
/** @class Backbone model for List of Pairs Dataset Collection within a History. */
var HistoryListPairedDatasetCollection = ListPairedDC.extend( hcontentMixin ).extend({

defaults : _.extend( _.clone( ListPairedDC.prototype.defaults ), {
history_content_type: 'dataset_collection',
Expand All @@ -118,10 +116,36 @@ var HistoryListPairedDatasetCollection = ListPairedDC.extend( hcontentMixin ).ex
});


//==============================================================================
/** @class Backbone model for List of Lists Dataset Collection within a History. */
var HistoryListOfListsDatasetCollection = ListOfListsDC.extend( hcontentMixin ).extend({

defaults : _.extend( _.clone( ListOfListsDC.prototype.defaults ), {
history_content_type: 'dataset_collection',
collection_type : 'list:list',
model_class : 'HistoryDatasetCollectionAssociation'
}),

initialize : function( model, options ){
ListOfListsDC.prototype.initialize.call( this, model, options );
hcontentMixin.initialize.call( this, model, options );
},

/** Override to post to contents route w/o id. */
save : buildHDCASave( ListOfListsDC.prototype.save ),

/** String representation. */
toString : function(){
return ([ 'HistoryListOfListsDatasetCollection(', this.get( 'name' ), ')' ].join( '' ));
}
});


//==============================================================================
return {
HistoryListDatasetCollection : HistoryListDatasetCollection,
HistoryPairDatasetCollection : HistoryPairDatasetCollection,
HistoryListPairedDatasetCollection : HistoryListPairedDatasetCollection
HistoryListPairedDatasetCollection : HistoryListPairedDatasetCollection,
HistoryListOfListsDatasetCollection : HistoryListOfListsDatasetCollection
};
});
19 changes: 18 additions & 1 deletion client/galaxy/scripts/mvc/history/history-contents.js
Expand Up @@ -44,12 +44,16 @@ var HistoryContents = Backbone.Collection
return new HDCA_MODEL.HistoryPairDatasetCollection( attrs, options );
case 'list:paired':
return new HDCA_MODEL.HistoryListPairedDatasetCollection( attrs, options );
case 'list:list':
return new HDCA_MODEL.HistoryListOfListsDatasetCollection( attrs, options );
}
// This is a hack inside a hack:
// Raise a plain object with validationError to fake a model.validationError
// (since we don't have a model to use validate with)
// (the outer hack being the mixed content/model function in this collection)
return { validationError : 'Unknown collection_type: ' + attrs.history_content_type };
var msg = 'Unknown collection_type: ' + attrs.collection_type;
console.warn( msg, attrs );
return { validationError : msg };
}
return { validationError : 'Unknown history_content_type: ' + attrs.history_content_type };
},
Expand Down Expand Up @@ -205,6 +209,19 @@ var HistoryContents = Backbone.Collection
return this.fetch( options );
},

/** specialty fetch method for retrieving the element_counts of all hdcas in the history */
fetchCollectionCounts : function( options ){
options = options || {};
options.data = _.defaults({
keys : [ 'type_id', 'element_count' ].join( ',' ),
q : 'history_content_type',
qv : 'dataset_collection',
}, options.data || {} );
options.merge = true;
options.remove = false;
return this.fetch( options );
},

/** using a queue, perform ajaxFn on each of the models in this collection */
ajaxQueue : function( ajaxFn, options ){
var deferred = jQuery.Deferred(),
Expand Down

0 comments on commit 132bd4d

Please sign in to comment.