diff --git a/static/scripts/mvc/collection/dataset-collection-base.js b/static/scripts/mvc/collection/dataset-collection-base.js index b534456183c..e26c7cd7c27 100644 --- a/static/scripts/mvc/collection/dataset-collection-base.js +++ b/static/scripts/mvc/collection/dataset-collection-base.js @@ -144,7 +144,7 @@ var DatasetCollectionBaseView = hdaBase.HistoryContentBaseView.extend({ contentView.$el.children( '.dataset-body' ).replaceWith( contentView._render_body() ); contentView.$el.children( '.dataset-body' ).slideDown( contentView.fxSpeed, function(){ contentView.expanded = true; - contentView.trigger( 'body-expanded', contentView.model ); + contentView.trigger( 'body-expanded', contentView.model.get( 'id' ) ); }); } // TODO: Fetch more details like HDA view... @@ -158,7 +158,7 @@ var DatasetCollectionBaseView = hdaBase.HistoryContentBaseView.extend({ var hdaView = this; this.$el.children( '.dataset-body' ).slideUp( hdaView.fxSpeed, function(){ hdaView.expanded = false; - hdaView.trigger( 'body-collapsed', hdaView.model.id ); + hdaView.trigger( 'body-collapsed', hdaView.model.get( 'id' ) ); }); }, diff --git a/static/scripts/mvc/dataset/hda-base.js b/static/scripts/mvc/dataset/hda-base.js index c8d45a98524..0aa9b62ff72 100644 --- a/static/scripts/mvc/dataset/hda-base.js +++ b/static/scripts/mvc/dataset/hda-base.js @@ -319,7 +319,7 @@ var HDABaseView = HistoryContentBaseView.extend( title : "Data Viewer: " + self.model.get('name'), type : "other", content : function(parent_elt) { - var new_dataset = new dataset.TabularDataset({id: self.model.get('id')}); + var new_dataset = new dataset.TabularDataset({id: self.model.id}); $.when(new_dataset.fetch()).then(function() { dataset.createTabularDatasetChunkedView({ model: new_dataset, @@ -568,7 +568,7 @@ var HDABaseView = HistoryContentBaseView.extend( hdaView.$el.children( '.dataset-body' ).replaceWith( hdaView._render_body() ); hdaView.$el.children( '.dataset-body' ).slideDown( hdaView.fxSpeed, function(){ hdaView.expanded = true; - hdaView.trigger( 'body-expanded', hdaView.model ); + hdaView.trigger( 'body-expanded', hdaView.model.get( 'id' ) ); }); //hdaView.render( false ).$el.children( '.dataset-body' ).slideDown( hdaView.fxSpeed, function(){ @@ -595,7 +595,7 @@ var HDABaseView = HistoryContentBaseView.extend( var hdaView = this; this.$el.children( '.dataset-body' ).slideUp( hdaView.fxSpeed, function(){ hdaView.expanded = false; - hdaView.trigger( 'body-collapsed', hdaView.model.id ); + hdaView.trigger( 'body-collapsed', hdaView.model.get( 'id' ) ); }); }, diff --git a/static/scripts/mvc/dataset/hda-model.js b/static/scripts/mvc/dataset/hda-model.js index 6d5e2b36a83..e0d57712f7b 100644 --- a/static/scripts/mvc/dataset/hda-model.js +++ b/static/scripts/mvc/dataset/hda-model.js @@ -12,22 +12,9 @@ define([ * @constructs */ var HistoryContent = Backbone.Model.extend( baseMVC.LoggableMixin ).extend( { - idAttribute : 'type_id', /** fetch location of this HDA's history in the api */ urlRoot: galaxy_config.root + 'api/histories/', - - constructor : function( attrs, options ){ - attrs.type_id = HistoryContent.typeIdStr( attrs.type, attrs.id ); - Backbone.Model.apply( this, arguments ); - }, - - initialize : function( attrs, options ){ - // assumes type won't change - this.on( 'change:id', this._createTypeId ); - //TODO: not sure this covers all the bases... - }, - /** full url spec. for this HDA */ url : function(){ return this.urlRoot + this.get( 'history_id' ) + '/contents/' + this.get('history_content_type') + 's/' + this.get( 'id' ); @@ -151,19 +138,10 @@ var HistoryContent = Backbone.Model.extend( baseMVC.LoggableMixin ).extend( { term = term.replace( /"/g, '' ); return model.matches( term ); }); - }, - - _createTypeId : function(){ - return ( this.attributes.type_id = [ this.attributes.type, this.attributes.id ].join( '-' ) ); - }, + } } ); -/** create a type + id string for use in mixed collections */ -HistoryContent.typeIdStr = function _typeId( type, id ){ - return [ type, id ].join( '-' ); -}; - //============================================================================== /** @class (HDA) model for a Galaxy dataset * related to a history. @@ -250,10 +228,6 @@ var HistoryDatasetAssociation = HistoryContent.extend( initialize : function( data ){ this.log( this + '.initialize', this.attributes ); this.log( '\tparent history_id: ' + this.get( 'history_id' ) ); - - this._createTypeId(); - // assumes type won't change - this.on( 'change:id', this._createTypeId ); //!! this state is not in trans.app.model.Dataset.states - set it here - if( !this.get( 'accessible' ) ){ @@ -508,7 +482,7 @@ var HDACollection = Backbone.Collection.extend( baseMVC.LoggableMixin ).extend( * @returns array of encoded ids */ ids : function(){ - return this.map( function( hda ){ return hda.get('id'); }); + return this.map( function( hda ){ return hda.id; }); }, /** Get hdas that are not ready @@ -669,7 +643,7 @@ var HDACollection = Backbone.Collection.extend( baseMVC.LoggableMixin ).extend( this.chain().each( function( hda ) { // TODO: Handle duplicate names. var name = hda.attributes.name; - var id = hda.get('id'); + var id = hda.id; var content_type = hda.attributes.history_content_type; if( content_type == "dataset" ) { if( full_collection_type != "list" ) { diff --git a/static/scripts/mvc/history/history-model.js b/static/scripts/mvc/history/history-model.js index 1d1d3faf112..eaca8f7815d 100644 --- a/static/scripts/mvc/history/history-model.js +++ b/static/scripts/mvc/history/history-model.js @@ -236,7 +236,7 @@ History.getHistoryData = function getHistoryData( historyId, options ){ // for symmetry, not actually used by backend of consumed // by frontend. data[ "dataset_collection_details" ] = hdcaDetailIds.join( ',' ); - } + } return jQuery.ajax( galaxy_config.root + 'api/histories/' + historyData.id + '/contents', { data: data }); } diff --git a/static/scripts/mvc/history/history-panel.js b/static/scripts/mvc/history/history-panel.js index 4c8bd429f54..f9cb3062ffc 100644 --- a/static/scripts/mvc/history/history-panel.js +++ b/static/scripts/mvc/history/history-panel.js @@ -273,7 +273,7 @@ var HistoryPanel = readonlyPanel.ReadOnlyHistoryPanel.extend( * @param {HistoryDatasetAssociation} hda */ _createContentView : function( hda ){ - var hdaId = hda.id, + var hdaId = hda.get( 'id' ), historyContentType = hda.get( 'history_content_type' ), hdaView = null; @@ -328,7 +328,7 @@ var HistoryPanel = readonlyPanel.ReadOnlyHistoryPanel.extend( // only } else { - var id = hdaView.model.id; + var id = hdaView.model.get( 'id' ); historyView.lastSelectedViewId = id; //console.debug( 'lastSelectedViewId:', historyView.lastSelectedViewId ); selectedIds = [ id ]; @@ -340,7 +340,7 @@ var HistoryPanel = readonlyPanel.ReadOnlyHistoryPanel.extend( }); hdaView.on( 'de-selected', function( hdaView, event ){ //console.debug( 'de-selected', event ); - var id = hdaView.model.id; + var id = hdaView.model.get( 'id' ); historyView.selectedHdaIds = _.without( historyView.selectedHdaIds, id ); //console.debug( 'de-selected', historyView.selectedHdaIds ); }); diff --git a/static/scripts/mvc/history/readonly-history-panel.js b/static/scripts/mvc/history/readonly-history-panel.js index 601ef6de51f..79cd9e66fd4 100644 --- a/static/scripts/mvc/history/readonly-history-panel.js +++ b/static/scripts/mvc/history/readonly-history-panel.js @@ -18,9 +18,9 @@ var HistoryPrefs = baseMVC.SessionStorageModel.extend({ //TODO: add scroll position? }, /** add an hda id to the hash of expanded hdas */ - addExpandedHda : function( model ){ + addExpandedHda : function( id ){ var key = 'expandedHdas'; - this.save( key, _.extend( this.get( key ), _.object([ model.id ], [ model.get( 'id' ) ]) ) ); + this.save( key, _.extend( this.get( key ), _.object([ id ], [ true ]) ) ); }, /** remove an hda id from the hash of expanded hdas */ removeExpandedHda : function( id ){ @@ -264,7 +264,7 @@ var ReadOnlyHistoryPanel = Backbone.View.extend( baseMVC.LoggableMixin ).extend( var hdaDetailIds = function( historyData ){ // will be called to get hda ids that need details from the api //TODO: non-visible HDAs are getting details loaded... either stop loading them at all or filter ids thru isVisible - return _.values( HistoryPrefs.get( historyData.id ).get( 'expandedHdas' ) ); + return _.keys( HistoryPrefs.get( historyData.id ).get( 'expandedHdas' ) ); }; return this.loadHistory( historyId, attributes, historyFn, hdaFn, hdaDetailIds ); }, @@ -591,7 +591,7 @@ var ReadOnlyHistoryPanel = Backbone.View.extend( baseMVC.LoggableMixin ).extend( if( visibleHdas.length ){ visibleHdas.each( function( hda ){ // render it (NOTE: reverse order, newest on top (prepend)) - var hdaId = hda.id, + var hdaId = hda.get( 'id' ), hdaView = panel._createContentView( hda ); newHdaViews[ hdaId ] = hdaView; // persist selection @@ -610,7 +610,7 @@ var ReadOnlyHistoryPanel = Backbone.View.extend( baseMVC.LoggableMixin ).extend( * @param {HistoryDatasetAssociation} hda */ _createContentView : function( hda ){ - var hdaId = hda.id, + var hdaId = hda.get( 'id' ), historyContentType = hda.get( "history_content_type" ), hdaView = null; if( historyContentType === "dataset" ){ @@ -646,8 +646,8 @@ var ReadOnlyHistoryPanel = Backbone.View.extend( baseMVC.LoggableMixin ).extend( panel.errorHandler( model, xhr, options, msg ); }); // maintain a list of hdas whose bodies are expanded - hdaView.on( 'body-expanded', function( model ){ - panel.storage.addExpandedHda( model ); + hdaView.on( 'body-expanded', function( id ){ + panel.storage.addExpandedHda( id ); }); hdaView.on( 'body-collapsed', function( id ){ panel.storage.removeExpandedHda( id );