details: http://www.bx.psu.edu/hg/galaxy/rev/14e178f656ba changeset: 2953:14e178f656ba user: jeremy goecks <jeremy.goecks@emory.edu> date: Tue Nov 03 16:53:14 2009 -0500 description: Added 'History' column to HDA grid. diffstat: lib/galaxy/web/controllers/dataset.py | 26 +++++++++++++++++++------- templates/dataset/grid.mako | 11 ++++++++--- templates/root/history_common.mako | 2 +- 3 files changed, 28 insertions(+), 11 deletions(-) diffs (116 lines): diff -r 6491acd0bef2 -r 14e178f656ba lib/galaxy/web/controllers/dataset.py --- a/lib/galaxy/web/controllers/dataset.py Tue Nov 03 15:39:51 2009 -0500 +++ b/lib/galaxy/web/controllers/dataset.py Tue Nov 03 16:53:14 2009 -0500 @@ -45,6 +45,11 @@ """ class HistoryDatasetAssociationListGrid( grids.Grid ): + # Custom columns for grid. + class HistoryColumn( grids.GridColumn ): + def get_value( self, trans, grid, hda): + return hda.history.name + class StatusColumn( grids.GridColumn ): def get_value( self, trans, grid, hda ): if hda.deleted: @@ -52,6 +57,7 @@ return "" def get_link( self, trans, grid, hda ): return None + class TagsColumn( grids.GridColumn ): def __init__(self, col_name, key, filterable): grids.GridColumn.__init__(self, col_name, key=key, filterable=filterable) @@ -107,14 +113,16 @@ return accepted_filters # Grid definition - title = "Stored Datasets" + title = "Saved Datasets" model_class = model.HistoryDatasetAssociation template='/dataset/grid.mako' default_sort_key = "-create_time" columns = [ - grids.GridColumn( "Name", key="name", - # Link name to dataset's history. + grids.GridColumn( "Name", key="name", + # Link name to dataset's history. link=( lambda item: iff( item.history.deleted, None, dict( operation="switch", id=item.id ) ) ) ), + HistoryColumn( "History", key="history", + link=( lambda item: iff( item.history.deleted, None, dict( operation="switch_history", id=item.id ) ) ) ), TagsColumn( "Tags", key="tags", filterable=True ), StatusColumn( "Status", key="deleted", attach_popup=False ), grids.GridColumn( "Created", key="create_time", format=time_ago ), @@ -285,8 +293,9 @@ log.warn( "Invalid history_dataset_association id '%r' passed to list", hda_id ) if hdas: - - if operation == "switch": + if operation == "switch" or operation == "switch_history": + # Switch to a history that the HDA resides in. + # Convert hda to histories. histories = [] for hda in hdas: @@ -295,8 +304,11 @@ # Use history controller to switch the history. TODO: is this reasonable? status, message = trans.webapp.controllers['history']._list_switch( trans, histories ) - # Current history changed, refresh history frame - trans.template_context['refresh_frames'] = ['history'] + # Current history changed, refresh history frame; if switching to a dataset, set hda seek. + trans.template_context['refresh_frames'] = ['history'] + if operation == "switch": + hda_ids = [ trans.security.encode_id( hda.id ) for hda in hdas ] + trans.template_context[ 'seek_hda_ids' ] = hda_ids # Render the list view return self.stored_list_grid( trans, status=status, message=message, **kwargs ) diff -r 6491acd0bef2 -r 14e178f656ba templates/dataset/grid.mako --- a/templates/dataset/grid.mako Tue Nov 03 15:39:51 2009 -0500 +++ b/templates/dataset/grid.mako Tue Nov 03 16:53:14 2009 -0500 @@ -92,8 +92,6 @@ t.autocomplete("${h.url_for( controller='tag', action='tag_autocomplete_data', item_class='HistoryDatasetAssociation' )}", autocomplete_options); - //t.addClass("tag-input"); - return t; }); ## Can this be moved into base.mako? @@ -110,7 +108,14 @@ %endif %if 'history' in refresh_frames: if ( parent.frames && parent.frames.galaxy_history ) { - parent.frames.galaxy_history.location.href="${h.url_for( controller='root', action='history', hda_id=str(ids) )}"; + ## If available, include HDA ids to seek to in history request. + <% + hda_id = None + if seek_hda_ids: + hda_id = str( seek_hda_ids[0] ) # Use only the first id. + print hda_id + %> + parent.frames.galaxy_history.location.href="${h.url_for( controller='root', action='history', hda_id=hda_id )}"; if ( parent.force_right_panel ) { parent.force_right_panel( 'show' ); } diff -r 6491acd0bef2 -r 14e178f656ba templates/root/history_common.mako --- a/templates/root/history_common.mako Tue Nov 03 15:39:51 2009 -0500 +++ b/templates/root/history_common.mako Tue Nov 03 16:53:14 2009 -0500 @@ -1,6 +1,7 @@ <% _=n_ %> ## Render the dataset `data` as history item, using `hid` as the displayed id <%def name="render_dataset( data, hid, show_deleted_on_refresh = False, user_owns_dataset = True )"> + <a name="${trans.security.encode_id( data.id )}"></a> <% if data.state in ['no state','',None]: data_state = "queued" @@ -21,7 +22,6 @@ %endif ## Header row for history items (name, state, action buttons) - <a name="${trans.security.encode_id(data.id)}"></a> <div style="overflow: hidden;" class="historyItemTitleBar"> <div class="historyItemButtons"> %if data_state == "upload":