Skip to content

Commit

Permalink
Serializers, History: account for dataset collections when serializin…
Browse files Browse the repository at this point in the history
…g 'empty'; UI, Collections: show deleted and hidden warnings in the list item views
  • Loading branch information
carlfeberhard committed Mar 20, 2015
1 parent 1e55206 commit e36e51e
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 25 deletions.
11 changes: 11 additions & 0 deletions client/galaxy/scripts/mvc/collection/collection-li.js
Expand Up @@ -29,6 +29,17 @@ var DCListItemView = FoldoutListItemView.extend(
FoldoutListItemView.prototype.initialize.call( this, attributes );
},

/** event listeners */
_setUpListeners : function(){
FoldoutListItemView.prototype._setUpListeners.call( this );
// re-rendering on deletion
this.model.on( 'change', function( model, options ){
if( _.isEqual( _.keys( model.changed ), [ 'deleted' ] ) ){
this.render();
}
}, this );
},

// ......................................................................... rendering
//TODO:?? possibly move to listItem
/** render a subtitle to show the user what sort of collection this is */
Expand Down
11 changes: 11 additions & 0 deletions client/galaxy/scripts/mvc/history/hdca-li.js
Expand Up @@ -18,6 +18,17 @@ var HDCAListItemView = _super.extend(

className : _super.prototype.className + " history-content",

/** event listeners */
_setUpListeners : function(){
_super.prototype._setUpListeners.call( this );
// re-rendering on deletion
this.model.on( 'change', function( model, options ){
if( _.isEqual( _.keys( model.changed ), [ 'visible' ] ) ){
this.render();
}
}, this );
},

/** Override to provide the proper collections panels as the foldout */
_getFoldoutPanelClass : function(){
switch( this.model.get( 'collection_type' ) ){
Expand Down
6 changes: 3 additions & 3 deletions client/galaxy/scripts/mvc/history/history-contents.js
Expand Up @@ -220,12 +220,12 @@ var HistoryContents = Backbone.Collection.extend( BASE_MVC.LoggableMixin ).exten
source : contentType,
type : type
})
.done( function( json ){
collection.add([ json ]);
.done( function( response ){
collection.add([ response ]);
})
.fail( function( error, status, message ){
collection.trigger( 'error', collection, xhr, {},
'Error copying contents', { type: type, id: id, source: contentType });
'Error copying contents', { type: type, id: id, source: contentType });
});
return xhr;
},
Expand Down
35 changes: 18 additions & 17 deletions lib/galaxy/managers/histories.py
Expand Up @@ -283,23 +283,24 @@ def add_serializers( self ):
deletable.PurgableSerializerMixin.add_serializers( self )

self.serializers.update({
'model_class': lambda *a: 'History',
'id': self.serialize_id,
'create_time': self.serialize_date,
'update_time': self.serialize_date,
'size': lambda t, i, k: int( i.get_disk_size() ),
'nice_size': lambda t, i, k: i.get_disk_size( nice_size=True ),
'state': lambda t, i, k: self.history_manager.get_history_state( t, i ),

'url': lambda t, i, k: self.url_for( 'history', id=t.security.encode_id( i.id ) ),
'contents_url': lambda t, i, k: self.url_for( 'history_contents', history_id=t.security.encode_id( i.id ) ),

'empty': lambda t, i, k: len( i.datasets ) <= 0,
'count': lambda trans, item, key: len( item.datasets ),
'hdas': lambda t, i, k: [ t.security.encode_id( hda.id ) for hda in i.datasets ],
'state_details': lambda t, i, k: self.history_manager.get_state_counts( t, i ),
'state_ids': lambda t, i, k: self.history_manager.get_state_ids( t, i ),
'contents': self.serialize_contents
'model_class' : lambda *a: 'History',
'id' : self.serialize_id,
'create_time' : self.serialize_date,
'update_time' : self.serialize_date,
'size' : lambda t, i, k: int( i.get_disk_size() ),
'nice_size' : lambda t, i, k: i.get_disk_size( nice_size=True ),
'state' : lambda t, i, k: self.history_manager.get_history_state( t, i ),

'url' : lambda t, i, k: self.url_for( 'history', id=t.security.encode_id( i.id ) ),
'contents_url' : lambda t, i, k: self.url_for( 'history_contents',
history_id=t.security.encode_id( i.id ) ),

'empty' : lambda t, i, k: ( len( i.datasets ) + len( i.dataset_collections ) ) <= 0,
'count' : lambda trans, item, key: len( item.datasets ),
'hdas' : lambda t, i, k: [ t.security.encode_id( hda.id ) for hda in i.datasets ],
'state_details' : lambda t, i, k: self.history_manager.get_state_counts( t, i ),
'state_ids' : lambda t, i, k: self.history_manager.get_state_ids( t, i ),
'contents' : self.serialize_contents
})

def serialize_contents( self, trans, history, *args ):
Expand Down
2 changes: 1 addition & 1 deletion static/maps/mvc/collection/collection-li.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/maps/mvc/history/hdca-li.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e36e51e

Please sign in to comment.