2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/0c0517794198/ Changeset: 0c0517794198 User: jmchilton Date: 2014-06-16 20:08:37 Summary: Redo 74826a5: Attempt fix of UI problems when collections & datasets in same history have same id. Approach outlined by Carl, introduces separation between Backbone model id and underlying Galaxy id. Backbone id now includes type in the id. Lots of switching around which id is used where - probably introduces some bugs if I failed to update which id is to be used or switched to wrong one. Affected #: 6 files diff -r 1b2fdf69104d821fa3a52e04321d5795d6f4c6d0 -r 0c0517794198ec32fedc0bb022fe375e9f2e11e7 static/scripts/mvc/collection/dataset-collection-base.js --- a/static/scripts/mvc/collection/dataset-collection-base.js +++ b/static/scripts/mvc/collection/dataset-collection-base.js @@ -144,7 +144,7 @@ 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.get( 'id' ) ); + contentView.trigger( 'body-expanded', contentView.model ); }); } // TODO: Fetch more details like HDA view... @@ -158,7 +158,7 @@ var hdaView = this; this.$el.children( '.dataset-body' ).slideUp( hdaView.fxSpeed, function(){ hdaView.expanded = false; - hdaView.trigger( 'body-collapsed', hdaView.model.get( 'id' ) ); + hdaView.trigger( 'body-collapsed', hdaView.model.id ); }); }, diff -r 1b2fdf69104d821fa3a52e04321d5795d6f4c6d0 -r 0c0517794198ec32fedc0bb022fe375e9f2e11e7 static/scripts/mvc/dataset/hda-base.js --- a/static/scripts/mvc/dataset/hda-base.js +++ b/static/scripts/mvc/dataset/hda-base.js @@ -319,7 +319,7 @@ title : "Data Viewer: " + self.model.get('name'), type : "other", content : function(parent_elt) { - var new_dataset = new dataset.TabularDataset({id: self.model.id}); + var new_dataset = new dataset.TabularDataset({id: self.model.get('id')}); $.when(new_dataset.fetch()).then(function() { dataset.createTabularDatasetChunkedView({ model: new_dataset, @@ -568,7 +568,7 @@ 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.get( 'id' ) ); + hdaView.trigger( 'body-expanded', hdaView.model ); }); //hdaView.render( false ).$el.children( '.dataset-body' ).slideDown( hdaView.fxSpeed, function(){ @@ -595,7 +595,7 @@ var hdaView = this; this.$el.children( '.dataset-body' ).slideUp( hdaView.fxSpeed, function(){ hdaView.expanded = false; - hdaView.trigger( 'body-collapsed', hdaView.model.get( 'id' ) ); + hdaView.trigger( 'body-collapsed', hdaView.model.id ); }); }, diff -r 1b2fdf69104d821fa3a52e04321d5795d6f4c6d0 -r 0c0517794198ec32fedc0bb022fe375e9f2e11e7 static/scripts/mvc/dataset/hda-model.js --- a/static/scripts/mvc/dataset/hda-model.js +++ b/static/scripts/mvc/dataset/hda-model.js @@ -12,9 +12,22 @@ * @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.history_content_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' ); @@ -138,10 +151,19 @@ term = term.replace( /"/g, '' ); return model.matches( term ); }); - } + }, + + _createTypeId : function(){ + this.set( 'type_id', TypeIdModel.typeIdStr( this.get( 'history_content_type' ), this.get( 'id' ) ) ); + }, } ); +/** 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. @@ -228,7 +250,7 @@ initialize : function( data ){ this.log( this + '.initialize', this.attributes ); this.log( '\tparent history_id: ' + this.get( 'history_id' ) ); - + //!! this state is not in trans.app.model.Dataset.states - set it here - if( !this.get( 'accessible' ) ){ this.set( 'state', HistoryDatasetAssociation.STATES.NOT_VIEWABLE ); @@ -482,7 +504,7 @@ * @returns array of encoded ids */ ids : function(){ - return this.map( function( hda ){ return hda.id; }); + return this.map( function( hda ){ return hda.get('id'); }); }, /** Get hdas that are not ready @@ -614,7 +636,9 @@ // see Backbone.Collection.set and _prepareModel var collection = this; models = _.map( models, function( model ){ - var existing = collection.get( model.id ); + var attrs = model.attributes || model; // Handle raw json or Backbone model. + var typeId = HistoryContent.typeIdStr( attrs.history_content_type, attrs.id ); + var existing = collection.get( typeId ); if( !existing ){ return model; } // merge the models _BEFORE_ calling the superclass version @@ -643,7 +667,7 @@ this.chain().each( function( hda ) { // TODO: Handle duplicate names. var name = hda.attributes.name; - var id = hda.id; + var id = hda.get('id'); var content_type = hda.attributes.history_content_type; if( content_type == "dataset" ) { if( full_collection_type != "list" ) { diff -r 1b2fdf69104d821fa3a52e04321d5795d6f4c6d0 -r 0c0517794198ec32fedc0bb022fe375e9f2e11e7 static/scripts/mvc/history/history-model.js --- a/static/scripts/mvc/history/history-model.js +++ b/static/scripts/mvc/history/history-model.js @@ -236,7 +236,7 @@ // 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 -r 1b2fdf69104d821fa3a52e04321d5795d6f4c6d0 -r 0c0517794198ec32fedc0bb022fe375e9f2e11e7 static/scripts/mvc/history/history-panel.js --- a/static/scripts/mvc/history/history-panel.js +++ b/static/scripts/mvc/history/history-panel.js @@ -273,7 +273,7 @@ * @param {HistoryDatasetAssociation} hda */ _createContentView : function( hda ){ - var hdaId = hda.get( 'id' ), + var hdaId = hda.id, historyContentType = hda.get( 'history_content_type' ), hdaView = null; @@ -328,7 +328,7 @@ // only } else { - var id = hdaView.model.get( 'id' ); + var id = hdaView.model.id; historyView.lastSelectedViewId = id; //console.debug( 'lastSelectedViewId:', historyView.lastSelectedViewId ); selectedIds = [ id ]; @@ -340,7 +340,7 @@ }); hdaView.on( 'de-selected', function( hdaView, event ){ //console.debug( 'de-selected', event ); - var id = hdaView.model.get( 'id' ); + var id = hdaView.model.id; historyView.selectedHdaIds = _.without( historyView.selectedHdaIds, id ); //console.debug( 'de-selected', historyView.selectedHdaIds ); }); diff -r 1b2fdf69104d821fa3a52e04321d5795d6f4c6d0 -r 0c0517794198ec32fedc0bb022fe375e9f2e11e7 static/scripts/mvc/history/readonly-history-panel.js --- a/static/scripts/mvc/history/readonly-history-panel.js +++ b/static/scripts/mvc/history/readonly-history-panel.js @@ -18,9 +18,9 @@ //TODO: add scroll position? }, /** add an hda id to the hash of expanded hdas */ - addExpandedHda : function( id ){ + addExpandedHda : function( model ){ var key = 'expandedHdas'; - this.save( key, _.extend( this.get( key ), _.object([ id ], [ true ]) ) ); + this.save( key, _.extend( this.get( key ), _.object([ model.id ], [ model.get( 'id' ) ]) ) ); }, /** remove an hda id from the hash of expanded hdas */ removeExpandedHda : function( id ){ @@ -264,7 +264,7 @@ 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 _.keys( HistoryPrefs.get( historyData.id ).get( 'expandedHdas' ) ); + return _.values( HistoryPrefs.get( historyData.id ).get( 'expandedHdas' ) ); }; return this.loadHistory( historyId, attributes, historyFn, hdaFn, hdaDetailIds ); }, @@ -591,7 +591,7 @@ if( visibleHdas.length ){ visibleHdas.each( function( hda ){ // render it (NOTE: reverse order, newest on top (prepend)) - var hdaId = hda.get( 'id' ), + var hdaId = hda.id, hdaView = panel._createContentView( hda ); newHdaViews[ hdaId ] = hdaView; // persist selection @@ -610,7 +610,7 @@ * @param {HistoryDatasetAssociation} hda */ _createContentView : function( hda ){ - var hdaId = hda.get( 'id' ), + var hdaId = hda.id, historyContentType = hda.get( "history_content_type" ), hdaView = null; if( historyContentType === "dataset" ){ @@ -646,8 +646,8 @@ panel.errorHandler( model, xhr, options, msg ); }); // maintain a list of hdas whose bodies are expanded - hdaView.on( 'body-expanded', function( id ){ - panel.storage.addExpandedHda( id ); + hdaView.on( 'body-expanded', function( model ){ + panel.storage.addExpandedHda( model ); }); hdaView.on( 'body-collapsed', function( id ){ panel.storage.removeExpandedHda( id ); https://bitbucket.org/galaxy/galaxy-central/commits/7f506e778275/ Changeset: 7f506e778275 User: jmchilton Date: 2014-06-16 20:09:54 Summary: Pack scripts. Affected #: 5 files diff -r 0c0517794198ec32fedc0bb022fe375e9f2e11e7 -r 7f506e778275715639d8f5d37041712be9662b39 static/scripts/packed/mvc/collection/dataset-collection-base.js --- a/static/scripts/packed/mvc/collection/dataset-collection-base.js +++ b/static/scripts/packed/mvc/collection/dataset-collection-base.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/hda-model","mvc/dataset/hda-base"],function(b,a){var c=a.HistoryContentBaseView.extend({className:"dataset hda history-panel-hda",id:function(){return"hdca-"+this.model.get("id")},initialize:function(d){if(d.logger){this.logger=this.model.logger=d.logger}this.log(this+".initialize:",d);this.selectable=d.selectable||false;this.selected=d.selected||false;this.expanded=d.expanded||false},render:function(e){var d=this._buildNewRender();this._queueNewRender(d,e);return this},templateSkeleton:function(){return['<div class="dataset hda">','<div class="dataset-warnings">',"<% if ( deleted ) { %>",'<div class="dataset-deleted-msg warningmessagesmall"><strong>',_l("This dataset has been deleted."),"</div>","<% } %>","<% if ( ! visible ) { %>",'<div class="dataset-hidden-msg warningmessagesmall"><strong>',_l("This dataset has been hidden."),"</div>","<% } %>","</div>",'<div class="dataset-selector"><span class="fa fa-2x fa-square-o"></span></div>','<div class="dataset-primary-actions"></div>','<div class="dataset-title-bar clear" tabindex="0">','<span class="dataset-state-icon state-icon"></span>','<div class="dataset-title">','<span class="hda-hid"><%= hid %></span> ','<span class="dataset-name"><%= name %></span>',"</div>","</div>",'<div class="dataset-body"></div>',"</div>"].join("")},templateBody:function(){return['<div class="dataset-body">','<div class="dataset-summary">',"A dataset collection.","</div>"].join("")},_buildNewRender:function(){var d=$(_.template(this.templateSkeleton(),this.model.toJSON()));d.find(".dataset-primary-actions").append(this._render_titleButtons());d.children(".dataset-body").replaceWith(this._render_body());this._setUpBehaviors(d);return d},_render_titleButtons:function(){return[]},_render_body:function(){var e=$('<div>Error: unknown state "'+this.model.get("state")+'".</div>'),d=this["_render_body_"+this.model.get("state")];if(_.isFunction(d)){e=d.call(this)}this._setUpBehaviors(e);if(this.expanded){e.show()}return e},_setUpBehaviors:function(d){d=d||this.$el;make_popup_menus(d);d.find("[title]").tooltip({placement:"bottom"})},events:{"click .dataset-title-bar":"toggleBodyVisibility","keydown .dataset-title-bar":"toggleBodyVisibility","click .dataset-selector":"toggleSelect"},expandBody:function(){var d=this;function e(){d.$el.children(".dataset-body").replaceWith(d._render_body());d.$el.children(".dataset-body").slideDown(d.fxSpeed,function(){d.expanded=true;d.trigger("body-expanded",d.model.get("id"))})}e()},collapseBody:function(){var d=this;this.$el.children(".dataset-body").slideUp(d.fxSpeed,function(){d.expanded=false;d.trigger("body-collapsed",d.model.get("id"))})},_render_body_ok:function(){var d=$(_.template(this.templateBody(),this.model.toJSON()));if(this.model.get("deleted")){return d}return d}});return{DatasetCollectionBaseView:c}}); \ No newline at end of file +define(["mvc/dataset/hda-model","mvc/dataset/hda-base"],function(b,a){var c=a.HistoryContentBaseView.extend({className:"dataset hda history-panel-hda",id:function(){return"hdca-"+this.model.get("id")},initialize:function(d){if(d.logger){this.logger=this.model.logger=d.logger}this.log(this+".initialize:",d);this.selectable=d.selectable||false;this.selected=d.selected||false;this.expanded=d.expanded||false},render:function(e){var d=this._buildNewRender();this._queueNewRender(d,e);return this},templateSkeleton:function(){return['<div class="dataset hda">','<div class="dataset-warnings">',"<% if ( deleted ) { %>",'<div class="dataset-deleted-msg warningmessagesmall"><strong>',_l("This dataset has been deleted."),"</div>","<% } %>","<% if ( ! visible ) { %>",'<div class="dataset-hidden-msg warningmessagesmall"><strong>',_l("This dataset has been hidden."),"</div>","<% } %>","</div>",'<div class="dataset-selector"><span class="fa fa-2x fa-square-o"></span></div>','<div class="dataset-primary-actions"></div>','<div class="dataset-title-bar clear" tabindex="0">','<span class="dataset-state-icon state-icon"></span>','<div class="dataset-title">','<span class="hda-hid"><%= hid %></span> ','<span class="dataset-name"><%= name %></span>',"</div>","</div>",'<div class="dataset-body"></div>',"</div>"].join("")},templateBody:function(){return['<div class="dataset-body">','<div class="dataset-summary">',"A dataset collection.","</div>"].join("")},_buildNewRender:function(){var d=$(_.template(this.templateSkeleton(),this.model.toJSON()));d.find(".dataset-primary-actions").append(this._render_titleButtons());d.children(".dataset-body").replaceWith(this._render_body());this._setUpBehaviors(d);return d},_render_titleButtons:function(){return[]},_render_body:function(){var e=$('<div>Error: unknown state "'+this.model.get("state")+'".</div>'),d=this["_render_body_"+this.model.get("state")];if(_.isFunction(d)){e=d.call(this)}this._setUpBehaviors(e);if(this.expanded){e.show()}return e},_setUpBehaviors:function(d){d=d||this.$el;make_popup_menus(d);d.find("[title]").tooltip({placement:"bottom"})},events:{"click .dataset-title-bar":"toggleBodyVisibility","keydown .dataset-title-bar":"toggleBodyVisibility","click .dataset-selector":"toggleSelect"},expandBody:function(){var d=this;function e(){d.$el.children(".dataset-body").replaceWith(d._render_body());d.$el.children(".dataset-body").slideDown(d.fxSpeed,function(){d.expanded=true;d.trigger("body-expanded",d.model)})}e()},collapseBody:function(){var d=this;this.$el.children(".dataset-body").slideUp(d.fxSpeed,function(){d.expanded=false;d.trigger("body-collapsed",d.model.id)})},_render_body_ok:function(){var d=$(_.template(this.templateBody(),this.model.toJSON()));if(this.model.get("deleted")){return d}return d}});return{DatasetCollectionBaseView:c}}); \ No newline at end of file diff -r 0c0517794198ec32fedc0bb022fe375e9f2e11e7 -r 7f506e778275715639d8f5d37041712be9662b39 static/scripts/packed/mvc/dataset/hda-base.js --- a/static/scripts/packed/mvc/dataset/hda-base.js +++ b/static/scripts/packed/mvc/dataset/hda-base.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/hda-model","mvc/base-mvc","mvc/data","utils/localization"],function(e,b,g,d){var h=Backbone.View.extend(b.LoggableMixin).extend({tagName:"div",fxSpeed:"fast",_queueNewRender:function(j,k){k=(k===undefined)?(true):(k);var i=this;if(k){$(i).queue(function(l){this.$el.fadeOut(i.fxSpeed,l)})}$(i).queue(function(l){this.$el.empty().attr("class",i.className).addClass("state-"+i.model.get("state")).append(j.children());if(this.selectable){this.showSelector(0)}l()});if(k){$(i).queue(function(l){this.$el.fadeIn(i.fxSpeed,l)})}$(i).queue(function(l){this.trigger("rendered",i);if(this.model.inReadyState()){this.trigger("rendered:ready",i)}if(this.draggable){this.draggableOn()}l()})},toggleBodyVisibility:function(l,j){var i=32,k=13;if(l&&(l.type==="keydown")&&!(l.keyCode===i||l.keyCode===k)){return true}var m=this.$el.find(".dataset-body");j=(j===undefined)?(!m.is(":visible")):(j);if(j){this.expandBody()}else{this.collapseBody()}return false},showSelector:function(){if(this.selected){this.select(null,true)}this.selectable=true;this.trigger("selectable",true,this);this.$(".dataset-primary-actions").hide();this.$(".dataset-selector").show()},hideSelector:function(){this.selectable=false;this.trigger("selectable",false,this);this.$(".dataset-selector").hide();this.$(".dataset-primary-actions").show()},toggleSelector:function(){if(!this.$el.find(".dataset-selector").is(":visible")){this.showSelector()}else{this.hideSelector()}},select:function(i){this.$el.find(".dataset-selector span").removeClass("fa-square-o").addClass("fa-check-square-o");if(!this.selected){this.trigger("selected",this,i);this.selected=true}return false},deselect:function(i){this.$el.find(".dataset-selector span").removeClass("fa-check-square-o").addClass("fa-square-o");if(this.selected){this.trigger("de-selected",this,i);this.selected=false}return false},toggleSelect:function(i){if(this.selected){this.deselect(i)}else{this.select(i)}}});var c=h.extend({className:"dataset hda history-panel-hda",id:function(){return"hda-"+this.model.get("id")},initialize:function(i){if(i.logger){this.logger=this.model.logger=i.logger}this.log(this+".initialize:",i);this.defaultPrimaryActionButtonRenderers=[this._render_showParamsButton];this.linkTarget=i.linkTarget||"_blank";this.selectable=i.selectable||false;this.selected=i.selected||false;this.expanded=i.expanded||false;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(j){this.$el.find("[title]").tooltip("destroy");this.urls=this.model.urls();var i=this._buildNewRender();this._queueNewRender(i,j);return this},_buildNewRender:function(){var i=$(c.templates.skeleton(this.model.toJSON()));i.find(".dataset-primary-actions").append(this._render_titleButtons());i.children(".dataset-body").replaceWith(this._render_body());this._setUpBehaviors(i);return i},_setUpBehaviors:function(i){i=i||this.$el;make_popup_menus(i);i.find("[title]").tooltip({placement:"bottom"})},_render_titleButtons:function(){return[this._render_displayButton()]},_render_displayButton:function(){if((this.model.get("state")===e.HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(this.model.get("state")===e.HistoryDatasetAssociation.STATES.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=d("Cannot display datasets removed from disk")}else{if(this.model.get("state")===e.HistoryDatasetAssociation.STATES.UPLOAD){j.disabled=true;j.title=d("This dataset must finish uploading before it can be viewed")}else{if(this.model.get("state")===e.HistoryDatasetAssociation.STATES.NEW){j.disabled=true;j.title=d("This dataset is not yet viewable")}else{j.title=d("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 g.TabularDataset({id:i.model.id});$.when(m.fetch()).then(function(){g.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 $(['<a href="'+j.download+'" title="'+d("Download")+'" ','class="icon-btn dataset-download-btn">','<span class="fa fa-floppy-o"></span>',"</a>"].join(""))}var l="dataset-"+this.model.get("id")+"-popup",i=['<div popupmenu="'+l+'">','<a href="'+j.download+'">',d("Download dataset"),"</a>","<a>"+d("Additional files")+"</a>",_.map(k,function(m){return['<a class="action-button" href="',j.meta_download+m.file_type,'">',d("Download")," ",m.file_type,"</a>"].join("")}).join("\n"),"</div>",'<div class="icon-btn-group">','<a href="'+j.download+'" title="'+d("Download")+'" ','class="icon-btn dataset-download-btn">','<span class="fa fa-floppy-o"></span>','</a><a class="icon-btn popup" id="'+l+'">','<span class="fa fa-caret-down"></span>',"</a>","</div>"].join("\n");return $(i)},_render_showParamsButton:function(){return faIconButton({title:d("View details"),classes:"dataset-params-btn",href:this.urls.show_params,target:this.linkTarget,faIcon:"fa-info-circle"})},_render_body:function(){var j=$('<div>Error: unknown dataset state "'+this.model.get("state")+'".</div>'),i=this["_render_body_"+this.model.get("state")];if(_.isFunction(i)){j=i.call(this)}this._setUpBehaviors(j);if(this.expanded){j.show()}return j},_render_stateBodyHelper:function(i,l){l=l||[];var j=this,k=$(c.templates.body(_.extend(this.model.toJSON(),{body:i})));k.find(".dataset-actions .left").append(_.map(l,function(m){return m.call(j)}));return k},_render_body_new:function(){return this._render_stateBodyHelper("<div>"+d("This is a new dataset and not all of its data are available yet")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_noPermission:function(){return this._render_stateBodyHelper("<div>"+d("You do not have permission to view this dataset")+"</div>")},_render_body_discarded:function(){return this._render_stateBodyHelper("<div>"+d("The job creating this dataset was cancelled before completion")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_queued:function(){return this._render_stateBodyHelper("<div>"+d("This job is waiting to run")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_upload:function(){return this._render_stateBodyHelper("<div>"+d("This dataset is currently uploading")+"</div>")},_render_body_setting_metadata:function(){return this._render_stateBodyHelper("<div>"+d("Metadata is being auto-detected")+"</div>")},_render_body_running:function(){return this._render_stateBodyHelper("<div>"+d("This job is currently running")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_paused:function(){return this._render_stateBodyHelper("<div>"+d('This job is paused. Use the "Resume Paused Jobs" in the history menu to resume')+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_error:function(){var i=['<span class="help-text">',d("An error occurred with this dataset"),":</span>",'<div class="job-error-text">',$.trim(this.model.get("misc_info")),"</div>"].join("");if(!this.model.get("purged")){i="<div>"+this.model.get("misc_blurb")+"</div>"+i}return this._render_stateBodyHelper(i,[this._render_downloadButton].concat(this.defaultPrimaryActionButtonRenderers))},_render_body_empty:function(){return this._render_stateBodyHelper("<div>"+d("No data")+": <i>"+this.model.get("misc_blurb")+"</i></div>",this.defaultPrimaryActionButtonRenderers)},_render_body_failed_metadata:function(){var i=$('<div class="warningmessagesmall"></div>').append($("<strong/>").text(d("An error occurred setting the metadata for this dataset"))),j=this._render_body_ok();j.prepend(i);return j},_render_body_ok:function(){var i=this,k=$(c.templates.body(this.model.toJSON())),j=[this._render_downloadButton].concat(this.defaultPrimaryActionButtonRenderers);k.find(".dataset-actions .left").append(_.map(j,function(l){return l.call(i)}));if(this.model.isDeletedOrPurged()){return k}return k},events:{"click .dataset-title-bar":"toggleBodyVisibility","keydown .dataset-title-bar":"toggleBodyVisibility","click .dataset-selector":"toggleSelect"},expandBody:function(){var i=this;function j(){i.$el.children(".dataset-body").replaceWith(i._render_body());i.$el.children(".dataset-body").slideDown(i.fxSpeed,function(){i.expanded=true;i.trigger("body-expanded",i.model.get("id"))})}if(this.model.inReadyState()&&!this.model.hasDetails()){this.model.fetch({silent:true}).always(function(k){i.urls=i.model.urls();j()})}else{j()}},collapseBody:function(){var i=this;this.$el.children(".dataset-body").slideUp(i.fxSpeed,function(){i.expanded=false;i.trigger("body-collapsed",i.model.get("id"))})},draggableOn:function(){this.draggable=true;this.dragStartHandler=_.bind(this._dragStartHandler,this);this.dragEndHandler=_.bind(this._dragEndHandler,this);var i=this.$el.find(".dataset-title-bar").attr("draggable",true).get(0);i.addEventListener("dragstart",this.dragStartHandler,false);i.addEventListener("dragend",this.dragEndHandler,false)},draggableOff:function(){this.draggable=false;var i=this.$el.find(".dataset-title-bar").attr("draggable",false).get(0);i.removeEventListener("dragstart",this.dragStartHandler,false);i.removeEventListener("dragend",this.dragEndHandler,false)},toggleDraggable:function(){if(this.draggable){this.draggableOff()}else{this.draggableOn()}},_dragStartHandler:function(i){this.trigger("dragstart",this);i.dataTransfer.effectAllowed="move";i.dataTransfer.setData("text",JSON.stringify(this.model.toJSON()));return false},_dragEndHandler:function(i){this.trigger("dragend",this);return false},remove:function(j){var i=this;this.$el.fadeOut(i.fxSpeed,function(){i.$el.remove();i.off();if(j){j()}})},toString:function(){var i=(this.model)?(this.model+""):("(no model)");return"HDABaseView("+i+")"}});var a=_.template(['<div class="dataset hda">','<div class="dataset-warnings">',"<% if( hda.error ){ %>",'<div class="errormessagesmall">',d("There was an error getting the data for this dataset"),":<%- hda.error %>","</div>","<% } %>","<% if( hda.deleted ){ %>","<% if( hda.purged ){ %>",'<div class="dataset-purged-msg warningmessagesmall"><strong>',d("This dataset has been deleted and removed from disk")+".","</strong></div>","<% } else { %>",'<div class="dataset-deleted-msg warningmessagesmall"><strong>',d("This dataset has been deleted")+".","</strong></div>","<% } %>","<% } %>","<% if( !hda.visible ){ %>",'<div class="dataset-hidden-msg warningmessagesmall"><strong>',d("This dataset has been hidden")+".","</strong></div>","<% } %>","</div>",'<div class="dataset-selector">','<span class="fa fa-2x fa-square-o"></span>',"</div>",'<div class="dataset-primary-actions"></div>','<div class="dataset-title-bar clear" tabindex="0">','<span class="dataset-state-icon state-icon"></span>','<div class="dataset-title">','<span class="hda-hid"><%- hda.hid %></span> ','<span class="dataset-name"><%- hda.name %></span>',"</div>","</div>",'<div class="dataset-body"></div>',"</div>"].join(""));var f=_.template(['<div class="dataset-body">',"<% if( hda.body ){ %>",'<div class="dataset-summary">',"<%= hda.body %>","</div>",'<div class="dataset-actions clear">','<div class="left"></div>','<div class="right"></div>',"</div>","<% } else { %>",'<div class="dataset-summary">',"<% if( hda.misc_blurb ){ %>",'<div class="dataset-blurb">','<span class="value"><%- hda.misc_blurb %></span>',"</div>","<% } %>","<% if( hda.data_type ){ %>",'<div class="dataset-datatype">','<label class="prompt">',d("format"),"</label>",'<span class="value"><%- hda.data_type %></span>',"</div>","<% } %>","<% if( hda.metadata_dbkey ){ %>",'<div class="dataset-dbkey">','<label class="prompt">',d("database"),"</label>",'<span class="value">',"<%- hda.metadata_dbkey %>","</span>","</div>","<% } %>","<% if( hda.misc_info ){ %>",'<div class="dataset-info">','<span class="value"><%- hda.misc_info %></span>',"</div>","<% } %>","</div>",'<div class="dataset-actions clear">','<div class="left"></div>','<div class="right"></div>',"</div>","<% if( !hda.deleted ){ %>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="dataset-display-applications">',"<% _.each( hda.display_apps, function( app ){ %>",'<div class="display-application">','<span class="display-application-location"><%- app.label %></span> ','<span class="display-application-links">',"<% _.each( app.links, function( link ){ %>",'<a target="<%= link.target %>" href="<%= link.href %>">',"<% print( _l( link.text ) ); %>","</a> ","<% }); %>","</span>","</div>","<% }); %>","<% _.each( hda.display_types, function( app ){ %>",'<div class="display-application">','<span class="display-application-location"><%- app.label %></span> ','<span class="display-application-links">',"<% _.each( app.links, function( link ){ %>",'<a target="<%= link.target %>" href="<%= link.href %>">',"<% print( _l( link.text ) ); %>","</a> ","<% }); %>","</span>","</div>","<% }); %>","</div>",'<div class="dataset-peek">',"<% if( hda.peek ){ %>",'<pre class="peek"><%= hda.peek %></pre>',"<% } %>","</div>","<% } %>","<% } %>","</div>"].join(""));c.templates={skeleton:function(i){return a({_l:d,hda:i})},body:function(i){return f({_l:d,hda:i})}};return{HistoryContentBaseView:h,HDABaseView:c}}); \ No newline at end of file +define(["mvc/dataset/hda-model","mvc/base-mvc","mvc/data","utils/localization"],function(e,b,g,d){var h=Backbone.View.extend(b.LoggableMixin).extend({tagName:"div",fxSpeed:"fast",_queueNewRender:function(j,k){k=(k===undefined)?(true):(k);var i=this;if(k){$(i).queue(function(l){this.$el.fadeOut(i.fxSpeed,l)})}$(i).queue(function(l){this.$el.empty().attr("class",i.className).addClass("state-"+i.model.get("state")).append(j.children());if(this.selectable){this.showSelector(0)}l()});if(k){$(i).queue(function(l){this.$el.fadeIn(i.fxSpeed,l)})}$(i).queue(function(l){this.trigger("rendered",i);if(this.model.inReadyState()){this.trigger("rendered:ready",i)}if(this.draggable){this.draggableOn()}l()})},toggleBodyVisibility:function(l,j){var i=32,k=13;if(l&&(l.type==="keydown")&&!(l.keyCode===i||l.keyCode===k)){return true}var m=this.$el.find(".dataset-body");j=(j===undefined)?(!m.is(":visible")):(j);if(j){this.expandBody()}else{this.collapseBody()}return false},showSelector:function(){if(this.selected){this.select(null,true)}this.selectable=true;this.trigger("selectable",true,this);this.$(".dataset-primary-actions").hide();this.$(".dataset-selector").show()},hideSelector:function(){this.selectable=false;this.trigger("selectable",false,this);this.$(".dataset-selector").hide();this.$(".dataset-primary-actions").show()},toggleSelector:function(){if(!this.$el.find(".dataset-selector").is(":visible")){this.showSelector()}else{this.hideSelector()}},select:function(i){this.$el.find(".dataset-selector span").removeClass("fa-square-o").addClass("fa-check-square-o");if(!this.selected){this.trigger("selected",this,i);this.selected=true}return false},deselect:function(i){this.$el.find(".dataset-selector span").removeClass("fa-check-square-o").addClass("fa-square-o");if(this.selected){this.trigger("de-selected",this,i);this.selected=false}return false},toggleSelect:function(i){if(this.selected){this.deselect(i)}else{this.select(i)}}});var c=h.extend({className:"dataset hda history-panel-hda",id:function(){return"hda-"+this.model.get("id")},initialize:function(i){if(i.logger){this.logger=this.model.logger=i.logger}this.log(this+".initialize:",i);this.defaultPrimaryActionButtonRenderers=[this._render_showParamsButton];this.linkTarget=i.linkTarget||"_blank";this.selectable=i.selectable||false;this.selected=i.selected||false;this.expanded=i.expanded||false;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(j){this.$el.find("[title]").tooltip("destroy");this.urls=this.model.urls();var i=this._buildNewRender();this._queueNewRender(i,j);return this},_buildNewRender:function(){var i=$(c.templates.skeleton(this.model.toJSON()));i.find(".dataset-primary-actions").append(this._render_titleButtons());i.children(".dataset-body").replaceWith(this._render_body());this._setUpBehaviors(i);return i},_setUpBehaviors:function(i){i=i||this.$el;make_popup_menus(i);i.find("[title]").tooltip({placement:"bottom"})},_render_titleButtons:function(){return[this._render_displayButton()]},_render_displayButton:function(){if((this.model.get("state")===e.HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(this.model.get("state")===e.HistoryDatasetAssociation.STATES.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=d("Cannot display datasets removed from disk")}else{if(this.model.get("state")===e.HistoryDatasetAssociation.STATES.UPLOAD){j.disabled=true;j.title=d("This dataset must finish uploading before it can be viewed")}else{if(this.model.get("state")===e.HistoryDatasetAssociation.STATES.NEW){j.disabled=true;j.title=d("This dataset is not yet viewable")}else{j.title=d("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 g.TabularDataset({id:i.model.get("id")});$.when(m.fetch()).then(function(){g.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 $(['<a href="'+j.download+'" title="'+d("Download")+'" ','class="icon-btn dataset-download-btn">','<span class="fa fa-floppy-o"></span>',"</a>"].join(""))}var l="dataset-"+this.model.get("id")+"-popup",i=['<div popupmenu="'+l+'">','<a href="'+j.download+'">',d("Download dataset"),"</a>","<a>"+d("Additional files")+"</a>",_.map(k,function(m){return['<a class="action-button" href="',j.meta_download+m.file_type,'">',d("Download")," ",m.file_type,"</a>"].join("")}).join("\n"),"</div>",'<div class="icon-btn-group">','<a href="'+j.download+'" title="'+d("Download")+'" ','class="icon-btn dataset-download-btn">','<span class="fa fa-floppy-o"></span>','</a><a class="icon-btn popup" id="'+l+'">','<span class="fa fa-caret-down"></span>',"</a>","</div>"].join("\n");return $(i)},_render_showParamsButton:function(){return faIconButton({title:d("View details"),classes:"dataset-params-btn",href:this.urls.show_params,target:this.linkTarget,faIcon:"fa-info-circle"})},_render_body:function(){var j=$('<div>Error: unknown dataset state "'+this.model.get("state")+'".</div>'),i=this["_render_body_"+this.model.get("state")];if(_.isFunction(i)){j=i.call(this)}this._setUpBehaviors(j);if(this.expanded){j.show()}return j},_render_stateBodyHelper:function(i,l){l=l||[];var j=this,k=$(c.templates.body(_.extend(this.model.toJSON(),{body:i})));k.find(".dataset-actions .left").append(_.map(l,function(m){return m.call(j)}));return k},_render_body_new:function(){return this._render_stateBodyHelper("<div>"+d("This is a new dataset and not all of its data are available yet")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_noPermission:function(){return this._render_stateBodyHelper("<div>"+d("You do not have permission to view this dataset")+"</div>")},_render_body_discarded:function(){return this._render_stateBodyHelper("<div>"+d("The job creating this dataset was cancelled before completion")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_queued:function(){return this._render_stateBodyHelper("<div>"+d("This job is waiting to run")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_upload:function(){return this._render_stateBodyHelper("<div>"+d("This dataset is currently uploading")+"</div>")},_render_body_setting_metadata:function(){return this._render_stateBodyHelper("<div>"+d("Metadata is being auto-detected")+"</div>")},_render_body_running:function(){return this._render_stateBodyHelper("<div>"+d("This job is currently running")+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_paused:function(){return this._render_stateBodyHelper("<div>"+d('This job is paused. Use the "Resume Paused Jobs" in the history menu to resume')+"</div>",this.defaultPrimaryActionButtonRenderers)},_render_body_error:function(){var i=['<span class="help-text">',d("An error occurred with this dataset"),":</span>",'<div class="job-error-text">',$.trim(this.model.get("misc_info")),"</div>"].join("");if(!this.model.get("purged")){i="<div>"+this.model.get("misc_blurb")+"</div>"+i}return this._render_stateBodyHelper(i,[this._render_downloadButton].concat(this.defaultPrimaryActionButtonRenderers))},_render_body_empty:function(){return this._render_stateBodyHelper("<div>"+d("No data")+": <i>"+this.model.get("misc_blurb")+"</i></div>",this.defaultPrimaryActionButtonRenderers)},_render_body_failed_metadata:function(){var i=$('<div class="warningmessagesmall"></div>').append($("<strong/>").text(d("An error occurred setting the metadata for this dataset"))),j=this._render_body_ok();j.prepend(i);return j},_render_body_ok:function(){var i=this,k=$(c.templates.body(this.model.toJSON())),j=[this._render_downloadButton].concat(this.defaultPrimaryActionButtonRenderers);k.find(".dataset-actions .left").append(_.map(j,function(l){return l.call(i)}));if(this.model.isDeletedOrPurged()){return k}return k},events:{"click .dataset-title-bar":"toggleBodyVisibility","keydown .dataset-title-bar":"toggleBodyVisibility","click .dataset-selector":"toggleSelect"},expandBody:function(){var i=this;function j(){i.$el.children(".dataset-body").replaceWith(i._render_body());i.$el.children(".dataset-body").slideDown(i.fxSpeed,function(){i.expanded=true;i.trigger("body-expanded",i.model)})}if(this.model.inReadyState()&&!this.model.hasDetails()){this.model.fetch({silent:true}).always(function(k){i.urls=i.model.urls();j()})}else{j()}},collapseBody:function(){var i=this;this.$el.children(".dataset-body").slideUp(i.fxSpeed,function(){i.expanded=false;i.trigger("body-collapsed",i.model.id)})},draggableOn:function(){this.draggable=true;this.dragStartHandler=_.bind(this._dragStartHandler,this);this.dragEndHandler=_.bind(this._dragEndHandler,this);var i=this.$el.find(".dataset-title-bar").attr("draggable",true).get(0);i.addEventListener("dragstart",this.dragStartHandler,false);i.addEventListener("dragend",this.dragEndHandler,false)},draggableOff:function(){this.draggable=false;var i=this.$el.find(".dataset-title-bar").attr("draggable",false).get(0);i.removeEventListener("dragstart",this.dragStartHandler,false);i.removeEventListener("dragend",this.dragEndHandler,false)},toggleDraggable:function(){if(this.draggable){this.draggableOff()}else{this.draggableOn()}},_dragStartHandler:function(i){this.trigger("dragstart",this);i.dataTransfer.effectAllowed="move";i.dataTransfer.setData("text",JSON.stringify(this.model.toJSON()));return false},_dragEndHandler:function(i){this.trigger("dragend",this);return false},remove:function(j){var i=this;this.$el.fadeOut(i.fxSpeed,function(){i.$el.remove();i.off();if(j){j()}})},toString:function(){var i=(this.model)?(this.model+""):("(no model)");return"HDABaseView("+i+")"}});var a=_.template(['<div class="dataset hda">','<div class="dataset-warnings">',"<% if( hda.error ){ %>",'<div class="errormessagesmall">',d("There was an error getting the data for this dataset"),":<%- hda.error %>","</div>","<% } %>","<% if( hda.deleted ){ %>","<% if( hda.purged ){ %>",'<div class="dataset-purged-msg warningmessagesmall"><strong>',d("This dataset has been deleted and removed from disk")+".","</strong></div>","<% } else { %>",'<div class="dataset-deleted-msg warningmessagesmall"><strong>',d("This dataset has been deleted")+".","</strong></div>","<% } %>","<% } %>","<% if( !hda.visible ){ %>",'<div class="dataset-hidden-msg warningmessagesmall"><strong>',d("This dataset has been hidden")+".","</strong></div>","<% } %>","</div>",'<div class="dataset-selector">','<span class="fa fa-2x fa-square-o"></span>',"</div>",'<div class="dataset-primary-actions"></div>','<div class="dataset-title-bar clear" tabindex="0">','<span class="dataset-state-icon state-icon"></span>','<div class="dataset-title">','<span class="hda-hid"><%- hda.hid %></span> ','<span class="dataset-name"><%- hda.name %></span>',"</div>","</div>",'<div class="dataset-body"></div>',"</div>"].join(""));var f=_.template(['<div class="dataset-body">',"<% if( hda.body ){ %>",'<div class="dataset-summary">',"<%= hda.body %>","</div>",'<div class="dataset-actions clear">','<div class="left"></div>','<div class="right"></div>',"</div>","<% } else { %>",'<div class="dataset-summary">',"<% if( hda.misc_blurb ){ %>",'<div class="dataset-blurb">','<span class="value"><%- hda.misc_blurb %></span>',"</div>","<% } %>","<% if( hda.data_type ){ %>",'<div class="dataset-datatype">','<label class="prompt">',d("format"),"</label>",'<span class="value"><%- hda.data_type %></span>',"</div>","<% } %>","<% if( hda.metadata_dbkey ){ %>",'<div class="dataset-dbkey">','<label class="prompt">',d("database"),"</label>",'<span class="value">',"<%- hda.metadata_dbkey %>","</span>","</div>","<% } %>","<% if( hda.misc_info ){ %>",'<div class="dataset-info">','<span class="value"><%- hda.misc_info %></span>',"</div>","<% } %>","</div>",'<div class="dataset-actions clear">','<div class="left"></div>','<div class="right"></div>',"</div>","<% if( !hda.deleted ){ %>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="dataset-display-applications">',"<% _.each( hda.display_apps, function( app ){ %>",'<div class="display-application">','<span class="display-application-location"><%- app.label %></span> ','<span class="display-application-links">',"<% _.each( app.links, function( link ){ %>",'<a target="<%= link.target %>" href="<%= link.href %>">',"<% print( _l( link.text ) ); %>","</a> ","<% }); %>","</span>","</div>","<% }); %>","<% _.each( hda.display_types, function( app ){ %>",'<div class="display-application">','<span class="display-application-location"><%- app.label %></span> ','<span class="display-application-links">',"<% _.each( app.links, function( link ){ %>",'<a target="<%= link.target %>" href="<%= link.href %>">',"<% print( _l( link.text ) ); %>","</a> ","<% }); %>","</span>","</div>","<% }); %>","</div>",'<div class="dataset-peek">',"<% if( hda.peek ){ %>",'<pre class="peek"><%= hda.peek %></pre>',"<% } %>","</div>","<% } %>","<% } %>","</div>"].join(""));c.templates={skeleton:function(i){return a({_l:d,hda:i})},body:function(i){return f({_l:d,hda:i})}};return{HistoryContentBaseView:h,HDABaseView:c}}); \ No newline at end of file diff -r 0c0517794198ec32fedc0bb022fe375e9f2e11e7 -r 7f506e778275715639d8f5d37041712be9662b39 static/scripts/packed/mvc/dataset/hda-model.js --- a/static/scripts/packed/mvc/dataset/hda-model.js +++ b/static/scripts/packed/mvc/dataset/hda-model.js @@ -1,1 +1,1 @@ -define(["mvc/base-mvc","utils/localization"],function(e,c){var a=Backbone.Model.extend(e.LoggableMixin).extend({urlRoot:galaxy_config.root+"api/histories/",url:function(){return this.urlRoot+this.get("history_id")+"/contents/"+this.get("history_content_type")+"s/"+this.get("id")},hidden:function(){return !this.get("visible")},"delete":function f(m){if(this.get("deleted")){return jQuery.when()}return this.save({deleted:true},m)},undelete:function i(m){if(!this.get("deleted")||this.get("purged")){return jQuery.when()}return this.save({deleted:false},m)},hide:function d(m){if(!this.get("visible")){return jQuery.when()}return this.save({visible:false},m)},unhide:function h(m){if(this.get("visible")){return jQuery.when()}return this.save({visible:true},m)},isVisible:function(n,o){var m=true;if((!n)&&(this.get("deleted")||this.get("purged"))){m=false}if((!o)&&(!this.get("visible"))){m=false}return m},searchAttribute:function(o,m){var n=this.get(o);if(!m||(n===undefined||n===null)){return false}if(_.isArray(n)){return this._searchArrayAttribute(n,m)}return(n.toString().toLowerCase().indexOf(m.toLowerCase())!==-1)},_searchArrayAttribute:function(n,m){m=m.toLowerCase();return _.any(n,function(o){return(o.toString().toLowerCase().indexOf(m.toLowerCase())!==-1)})},search:function(m){var n=this;return _.filter(this.searchAttributes,function(o){return n.searchAttribute(o,m)})},matches:function(n){var p="=",m=n.split(p);if(m.length>=2){var o=m[0];o=this.searchAliases[o]||o;return this.searchAttribute(o,m[1])}return !!this.search(n).length},matchesAll:function(n){var m=this;n=n.match(/(".*"|\w*=".*"|\S*)/g).filter(function(o){return !!o});return _.all(n,function(o){o=o.replace(/"/g,"");return m.matches(o)})}});var l=a.extend({defaults:{history_id:null,model_class:"HistoryDatasetAssociation",history_content_type:"dataset",hid:0,id:null,name:"(unnamed dataset)",state:"new",deleted:false,visible:true,accessible:true,purged:false,data_type:"",file_size:0,file_ext:"",meta_files:[],misc_blurb:"",misc_info:"",tags:[],annotation:""},urls:function(){var n=this.get("id");if(!n){return{}}var m={purge:galaxy_config.root+"datasets/"+n+"/purge_async",display:galaxy_config.root+"datasets/"+n+"/display/?preview=True",edit:galaxy_config.root+"datasets/"+n+"/edit",download:galaxy_config.root+"datasets/"+n+"/display?to_ext="+this.get("file_ext"),report_error:galaxy_config.root+"dataset/errors?id="+n,rerun:galaxy_config.root+"tool_runner/rerun?id="+n,show_params:galaxy_config.root+"datasets/"+n+"/show_params",visualization:galaxy_config.root+"visualization",annotation:{get:galaxy_config.root+"dataset/get_annotation_async?id="+n,set:galaxy_config.root+"dataset/annotate_async?id="+n},meta_download:galaxy_config.root+"dataset/get_metadata_file?hda_id="+n+"&metadata_name="};return m},initialize:function(m){this.log(this+".initialize",this.attributes);this.log("\tparent history_id: "+this.get("history_id"));if(!this.get("accessible")){this.set("state",l.STATES.NOT_VIEWABLE)}this._setUpListeners()},_setUpListeners:function(){this.on("change:state",function(n,m){this.log(this+" has changed state:",n,m);if(this.inReadyState()){this.trigger("state:ready",n,m,this.previous("state"))}})},isDeletedOrPurged:function(){return(this.get("deleted")||this.get("purged"))},inReadyState:function(){var m=_.contains(l.READY_STATES,this.get("state"));return(this.isDeletedOrPurged()||m)},hasDetails:function(){return _.has(this.attributes,"genome_build")},hasData:function(){return(this.get("file_size")>0)},"delete":function f(m){if(this.get("deleted")){return jQuery.when()}return this.save({deleted:true},m)},undelete:function i(m){if(!this.get("deleted")||this.get("purged")){return jQuery.when()}return this.save({deleted:false},m)},hide:function d(m){if(!this.get("visible")){return jQuery.when()}return this.save({visible:false},m)},unhide:function h(m){if(this.get("visible")){return jQuery.when()}return this.save({visible:true},m)},purge:function g(m){if(this.get("purged")){return jQuery.when()}m=m||{};m.url=galaxy_config.root+"datasets/"+this.get("id")+"/purge_async";var n=this,o=jQuery.ajax(m);o.done(function(r,p,q){n.set({deleted:true,purged:true})});o.fail(function(t,p,s){var q=c("Unable to purge dataset");var r=("Removal of datasets by users is not allowed in this Galaxy instance");if(t.responseJSON&&t.responseJSON.error){q=t.responseJSON.error}else{if(t.responseText.indexOf(r)!==-1){q=r}}t.responseText=q;n.trigger("error",n,t,m,c(q),{error:q})});return o},searchAttributes:["name","file_ext","genome_build","misc_blurb","misc_info","annotation","tags"],searchAliases:{title:"name",format:"file_ext",database:"genome_build",blurb:"misc_blurb",description:"misc_blurb",info:"misc_info",tag:"tags"},toString:function(){var m=this.get("id")||"";if(this.get("name")){m=this.get("hid")+' :"'+this.get("name")+'",'+m}return"HDA("+m+")"}});l.STATES={UPLOAD:"upload",QUEUED:"queued",RUNNING:"running",SETTING_METADATA:"setting_metadata",NEW:"new",EMPTY:"empty",OK:"ok",PAUSED:"paused",FAILED_METADATA:"failed_metadata",NOT_VIEWABLE:"noPermission",DISCARDED:"discarded",ERROR:"error"};l.READY_STATES=[l.STATES.OK,l.STATES.EMPTY,l.STATES.PAUSED,l.STATES.FAILED_METADATA,l.STATES.NOT_VIEWABLE,l.STATES.DISCARDED,l.STATES.ERROR];l.NOT_READY_STATES=[l.STATES.UPLOAD,l.STATES.QUEUED,l.STATES.RUNNING,l.STATES.SETTING_METADATA,l.STATES.NEW];var b=Backbone.Collection.extend(e.LoggableMixin).extend({model:function(n,m){if(n.history_content_type=="dataset"){return new l(n,m)}else{if(n.history_content_type=="dataset_collection"){return new j(n,m)}else{}}},urlRoot:galaxy_config.root+"api/histories",url:function(){return this.urlRoot+"/"+this.historyId+"/contents"},initialize:function(n,m){m=m||{};this.historyId=m.historyId},ids:function(){return this.map(function(m){return m.id})},notReady:function(){return this.filter(function(m){return !m.inReadyState()})},running:function(){var m=[];this.each(function(n){if(!n.inReadyState()){m.push(n.get("id"))}});return m},getByHid:function(m){return _.first(this.filter(function(n){return n.get("hid")===m}))},getVisible:function(m,p,o){o=o||[];var n=new b(this.filter(function(q){return q.isVisible(m,p)}));_.each(o,function(q){if(!_.isFunction(q)){return}n=new b(n.filter(q))});return n},haveDetails:function(){return this.all(function(m){return m.hasDetails()})},fetchAllDetails:function(n){n=n||{};var m={details:"all"};n.data=(n.data)?(_.extend(n.data,m)):(m);return this.fetch(n)},ajaxQueue:function(p,o){var n=jQuery.Deferred(),m=this.length,r=[];if(!m){n.resolve([]);return n}var q=this.chain().reverse().map(function(t,s){return function(){var u=p.call(t,o);u.done(function(v){n.notify({curr:s,total:m,response:v,model:t})});u.always(function(v){r.push(v);if(q.length){q.shift()()}else{n.resolve(r)}})}}).value();q.shift()();return n},matches:function(m){return this.filter(function(n){return n.matches(m)})},set:function(o,m){var n=this;o=_.map(o,function(q){var r=n.get(q.id);if(!r){return q}var p=r.toJSON();_.extend(p,q);return p});Backbone.Collection.prototype.set.call(this,o,m)},promoteToHistoryDatasetCollection:function k(r,p,n){n=n||{};n.url=this.url();n.type="POST";var t=p;var q=[],m=null;if(p=="list"){this.chain().each(function(w){var u=w.attributes.name;var x=w.id;var v=w.attributes.history_content_type;if(v=="dataset"){if(t!="list"){console.log("Invalid collection type")}q.push({name:u,src:"hda",id:x})}else{if(t=="list"){t="list:"+w.attributes.collection_type}else{if(t!="list:"+w.attributes.collection_type){console.log("Invalid collection type")}}q.push({name:u,src:"hdca",id:x})}});m="New Dataset List"}else{if(p=="paired"){var o=this.ids();if(o.length!=2){}q.push({name:"forward",src:"hda",id:o[0]});q.push({name:"reverse",src:"hda",id:o[1]});m="New Dataset Pair"}}n.data={type:"dataset_collection",name:m,collection_type:t,element_identifiers:JSON.stringify(q),};var s=jQuery.ajax(n);s.done(function(w,u,v){r.refresh()});s.fail(function(w,u,v){if(w.responseJSON&&w.responseJSON.error){error=w.responseJSON.error}else{error=w.responseJSON}w.responseText=error});return s},toString:function(){return(["HDACollection(",[this.historyId,this.length].join(),")"].join(""))}});var j=a.extend({defaults:{history_id:null,model_class:"HistoryDatasetCollectionAssociation",history_content_type:"dataset_collection",hid:0,id:null,name:"(unnamed dataset collection)",state:"ok",accessible:true,deleted:false,visible:true,purged:false,tags:[],annotation:""},urls:function(){},inReadyState:function(){return true},searchAttributes:["name"],searchAliases:{title:"name"},});return{HistoryDatasetAssociation:l,HDACollection:b}}); \ No newline at end of file +define(["mvc/base-mvc","utils/localization"],function(e,c){var a=Backbone.Model.extend(e.LoggableMixin).extend({idAttribute:"type_id",urlRoot:galaxy_config.root+"api/histories/",constructor:function(o,n){o.type_id=a.typeIdStr(o.history_content_type,o.id);Backbone.Model.apply(this,arguments)},initialize:function(o,n){this.on("change:id",this._createTypeId)},url:function(){return this.urlRoot+this.get("history_id")+"/contents/"+this.get("history_content_type")+"s/"+this.get("id")},hidden:function(){return !this.get("visible")},"delete":function f(n){if(this.get("deleted")){return jQuery.when()}return this.save({deleted:true},n)},undelete:function j(n){if(!this.get("deleted")||this.get("purged")){return jQuery.when()}return this.save({deleted:false},n)},hide:function d(n){if(!this.get("visible")){return jQuery.when()}return this.save({visible:false},n)},unhide:function i(n){if(this.get("visible")){return jQuery.when()}return this.save({visible:true},n)},isVisible:function(o,p){var n=true;if((!o)&&(this.get("deleted")||this.get("purged"))){n=false}if((!p)&&(!this.get("visible"))){n=false}return n},searchAttribute:function(p,n){var o=this.get(p);if(!n||(o===undefined||o===null)){return false}if(_.isArray(o)){return this._searchArrayAttribute(o,n)}return(o.toString().toLowerCase().indexOf(n.toLowerCase())!==-1)},_searchArrayAttribute:function(o,n){n=n.toLowerCase();return _.any(o,function(p){return(p.toString().toLowerCase().indexOf(n.toLowerCase())!==-1)})},search:function(n){var o=this;return _.filter(this.searchAttributes,function(p){return o.searchAttribute(p,n)})},matches:function(o){var q="=",n=o.split(q);if(n.length>=2){var p=n[0];p=this.searchAliases[p]||p;return this.searchAttribute(p,n[1])}return !!this.search(o).length},matchesAll:function(o){var n=this;o=o.match(/(".*"|\w*=".*"|\S*)/g).filter(function(p){return !!p});return _.all(o,function(p){p=p.replace(/"/g,"");return n.matches(p)})},_createTypeId:function(){this.set("type_id",TypeIdModel.typeIdStr(this.get("history_content_type"),this.get("id")))},});a.typeIdStr=function h(n,o){return[n,o].join("-")};var m=a.extend({defaults:{history_id:null,model_class:"HistoryDatasetAssociation",history_content_type:"dataset",hid:0,id:null,name:"(unnamed dataset)",state:"new",deleted:false,visible:true,accessible:true,purged:false,data_type:"",file_size:0,file_ext:"",meta_files:[],misc_blurb:"",misc_info:"",tags:[],annotation:""},urls:function(){var o=this.get("id");if(!o){return{}}var n={purge:galaxy_config.root+"datasets/"+o+"/purge_async",display:galaxy_config.root+"datasets/"+o+"/display/?preview=True",edit:galaxy_config.root+"datasets/"+o+"/edit",download:galaxy_config.root+"datasets/"+o+"/display?to_ext="+this.get("file_ext"),report_error:galaxy_config.root+"dataset/errors?id="+o,rerun:galaxy_config.root+"tool_runner/rerun?id="+o,show_params:galaxy_config.root+"datasets/"+o+"/show_params",visualization:galaxy_config.root+"visualization",annotation:{get:galaxy_config.root+"dataset/get_annotation_async?id="+o,set:galaxy_config.root+"dataset/annotate_async?id="+o},meta_download:galaxy_config.root+"dataset/get_metadata_file?hda_id="+o+"&metadata_name="};return n},initialize:function(n){this.log(this+".initialize",this.attributes);this.log("\tparent history_id: "+this.get("history_id"));if(!this.get("accessible")){this.set("state",m.STATES.NOT_VIEWABLE)}this._setUpListeners()},_setUpListeners:function(){this.on("change:state",function(o,n){this.log(this+" has changed state:",o,n);if(this.inReadyState()){this.trigger("state:ready",o,n,this.previous("state"))}})},isDeletedOrPurged:function(){return(this.get("deleted")||this.get("purged"))},inReadyState:function(){var n=_.contains(m.READY_STATES,this.get("state"));return(this.isDeletedOrPurged()||n)},hasDetails:function(){return _.has(this.attributes,"genome_build")},hasData:function(){return(this.get("file_size")>0)},"delete":function f(n){if(this.get("deleted")){return jQuery.when()}return this.save({deleted:true},n)},undelete:function j(n){if(!this.get("deleted")||this.get("purged")){return jQuery.when()}return this.save({deleted:false},n)},hide:function d(n){if(!this.get("visible")){return jQuery.when()}return this.save({visible:false},n)},unhide:function i(n){if(this.get("visible")){return jQuery.when()}return this.save({visible:true},n)},purge:function g(n){if(this.get("purged")){return jQuery.when()}n=n||{};n.url=galaxy_config.root+"datasets/"+this.get("id")+"/purge_async";var o=this,p=jQuery.ajax(n);p.done(function(s,q,r){o.set({deleted:true,purged:true})});p.fail(function(u,q,t){var r=c("Unable to purge dataset");var s=("Removal of datasets by users is not allowed in this Galaxy instance");if(u.responseJSON&&u.responseJSON.error){r=u.responseJSON.error}else{if(u.responseText.indexOf(s)!==-1){r=s}}u.responseText=r;o.trigger("error",o,u,n,c(r),{error:r})});return p},searchAttributes:["name","file_ext","genome_build","misc_blurb","misc_info","annotation","tags"],searchAliases:{title:"name",format:"file_ext",database:"genome_build",blurb:"misc_blurb",description:"misc_blurb",info:"misc_info",tag:"tags"},toString:function(){var n=this.get("id")||"";if(this.get("name")){n=this.get("hid")+' :"'+this.get("name")+'",'+n}return"HDA("+n+")"}});m.STATES={UPLOAD:"upload",QUEUED:"queued",RUNNING:"running",SETTING_METADATA:"setting_metadata",NEW:"new",EMPTY:"empty",OK:"ok",PAUSED:"paused",FAILED_METADATA:"failed_metadata",NOT_VIEWABLE:"noPermission",DISCARDED:"discarded",ERROR:"error"};m.READY_STATES=[m.STATES.OK,m.STATES.EMPTY,m.STATES.PAUSED,m.STATES.FAILED_METADATA,m.STATES.NOT_VIEWABLE,m.STATES.DISCARDED,m.STATES.ERROR];m.NOT_READY_STATES=[m.STATES.UPLOAD,m.STATES.QUEUED,m.STATES.RUNNING,m.STATES.SETTING_METADATA,m.STATES.NEW];var b=Backbone.Collection.extend(e.LoggableMixin).extend({model:function(o,n){if(o.history_content_type=="dataset"){return new m(o,n)}else{if(o.history_content_type=="dataset_collection"){return new k(o,n)}else{}}},urlRoot:galaxy_config.root+"api/histories",url:function(){return this.urlRoot+"/"+this.historyId+"/contents"},initialize:function(o,n){n=n||{};this.historyId=n.historyId},ids:function(){return this.map(function(n){return n.get("id")})},notReady:function(){return this.filter(function(n){return !n.inReadyState()})},running:function(){var n=[];this.each(function(o){if(!o.inReadyState()){n.push(o.get("id"))}});return n},getByHid:function(n){return _.first(this.filter(function(o){return o.get("hid")===n}))},getVisible:function(n,q,p){p=p||[];var o=new b(this.filter(function(r){return r.isVisible(n,q)}));_.each(p,function(r){if(!_.isFunction(r)){return}o=new b(o.filter(r))});return o},haveDetails:function(){return this.all(function(n){return n.hasDetails()})},fetchAllDetails:function(o){o=o||{};var n={details:"all"};o.data=(o.data)?(_.extend(o.data,n)):(n);return this.fetch(o)},ajaxQueue:function(q,p){var o=jQuery.Deferred(),n=this.length,s=[];if(!n){o.resolve([]);return o}var r=this.chain().reverse().map(function(u,t){return function(){var v=q.call(u,p);v.done(function(w){o.notify({curr:t,total:n,response:w,model:u})});v.always(function(w){s.push(w);if(r.length){r.shift()()}else{o.resolve(s)}})}}).value();r.shift()();return o},matches:function(n){return this.filter(function(o){return o.matches(n)})},set:function(p,n){var o=this;p=_.map(p,function(s){var r=s.attributes||s;var t=a.typeIdStr(r.history_content_type,r.id);var u=o.get(t);if(!u){return s}var q=u.toJSON();_.extend(q,s);return q});Backbone.Collection.prototype.set.call(this,p,n)},promoteToHistoryDatasetCollection:function l(s,q,o){o=o||{};o.url=this.url();o.type="POST";var u=q;var r=[],n=null;if(q=="list"){this.chain().each(function(x){var v=x.attributes.name;var y=x.get("id");var w=x.attributes.history_content_type;if(w=="dataset"){if(u!="list"){console.log("Invalid collection type")}r.push({name:v,src:"hda",id:y})}else{if(u=="list"){u="list:"+x.attributes.collection_type}else{if(u!="list:"+x.attributes.collection_type){console.log("Invalid collection type")}}r.push({name:v,src:"hdca",id:y})}});n="New Dataset List"}else{if(q=="paired"){var p=this.ids();if(p.length!=2){}r.push({name:"forward",src:"hda",id:p[0]});r.push({name:"reverse",src:"hda",id:p[1]});n="New Dataset Pair"}}o.data={type:"dataset_collection",name:n,collection_type:u,element_identifiers:JSON.stringify(r),};var t=jQuery.ajax(o);t.done(function(x,v,w){s.refresh()});t.fail(function(x,v,w){if(x.responseJSON&&x.responseJSON.error){error=x.responseJSON.error}else{error=x.responseJSON}x.responseText=error});return t},toString:function(){return(["HDACollection(",[this.historyId,this.length].join(),")"].join(""))}});var k=a.extend({defaults:{history_id:null,model_class:"HistoryDatasetCollectionAssociation",history_content_type:"dataset_collection",hid:0,id:null,name:"(unnamed dataset collection)",state:"ok",accessible:true,deleted:false,visible:true,purged:false,tags:[],annotation:""},urls:function(){},inReadyState:function(){return true},searchAttributes:["name"],searchAliases:{title:"name"},});return{HistoryDatasetAssociation:m,HDACollection:b}}); \ No newline at end of file diff -r 0c0517794198ec32fedc0bb022fe375e9f2e11e7 -r 7f506e778275715639d8f5d37041712be9662b39 static/scripts/packed/mvc/history/history-panel.js --- a/static/scripts/packed/mvc/history/history-panel.js +++ b/static/scripts/packed/mvc/history/history-panel.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/hda-model","mvc/dataset/hda-edit","mvc/collection/dataset-collection-edit","mvc/history/readonly-history-panel","mvc/tags","mvc/annotations","utils/localization"],function(f,b,h,d,a,c,e){var g=d.ReadOnlyHistoryPanel.extend({HDAViewClass:b.HDAEditView,initialize:function(i){i=i||{};this.selectedHdaIds=[];this.lastSelectedViewId=null;this.tagsEditor=null;this.annotationEditor=null;this.purgeAllowed=i.purgeAllowed||false;this.selecting=i.selecting||false;this.annotationEditorShown=i.annotationEditorShown||false;this.tagsEditorShown=i.tagsEditorShown||false;d.ReadOnlyHistoryPanel.prototype.initialize.call(this,i)},_setUpModelEventHandlers:function(){d.ReadOnlyHistoryPanel.prototype._setUpModelEventHandlers.call(this);this.model.on("change:nice_size",this.updateHistoryDiskSize,this);this.model.hdas.on("change:deleted",this._handleHdaDeletionChange,this);this.model.hdas.on("change:visible",this._handleHdaVisibleChange,this);this.model.hdas.on("change:purged",function(i){this.model.fetch()},this)},renderModel:function(){var i=$("<div/>");i.append(g.templates.historyPanel(this.model.toJSON()));this.$emptyMessage(i).text(this.emptyMsg);if(Galaxy&&Galaxy.currUser&&Galaxy.currUser.id&&Galaxy.currUser.id===this.model.get("user_id")){this._renderTags(i);this._renderAnnotation(i)}i.find(".history-secondary-actions").prepend(this._renderSelectButton());i.find(".history-dataset-actions").toggle(this.selecting);i.find(".history-secondary-actions").prepend(this._renderSearchButton());this._setUpBehaviours(i);this.renderHdas(i);return i},_renderTags:function(i){var j=this;this.tagsEditor=new a.TagsEditor({model:this.model,el:i.find(".history-controls .tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){j.toggleHDATagEditors(true,j.fxSpeed)},onhide:function(){j.toggleHDATagEditors(false,j.fxSpeed)},$activator:faIconButton({title:e("Edit history tags"),classes:"history-tag-btn",faIcon:"fa-tags"}).appendTo(i.find(".history-secondary-actions"))})},_renderAnnotation:function(i){var j=this;this.annotationEditor=new c.AnnotationEditor({model:this.model,el:i.find(".history-controls .annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){j.toggleHDAAnnotationEditors(true,j.fxSpeed)},onhide:function(){j.toggleHDAAnnotationEditors(false,j.fxSpeed)},$activator:faIconButton({title:e("Edit history annotation"),classes:"history-annotate-btn",faIcon:"fa-comment"}).appendTo(i.find(".history-secondary-actions"))})},_renderSelectButton:function(i){return faIconButton({title:e("Operations on multiple datasets"),classes:"history-select-btn",faIcon:"fa-check-square-o"})},_setUpBehaviours:function(i){i=i||this.$el;d.ReadOnlyHistoryPanel.prototype._setUpBehaviours.call(this,i);if(!this.model){return}this._setUpDatasetActionsPopup(i);if((!Galaxy.currUser||Galaxy.currUser.isAnonymous())||(Galaxy.currUser.id!==this.model.get("user_id"))){return}var j=this;i.find(".history-name").attr("title",e("Click to rename history")).tooltip({placement:"bottom"}).make_text_editable({on_finish:function(k){var l=j.model.get("name");if(k&&k!==l){j.$el.find(".history-name").text(k);j.model.save({name:k}).fail(function(){j.$el.find(".history-name").text(j.model.previous("name"))})}else{j.$el.find(".history-name").text(l)}}})},_setUpDatasetActionsPopup:function(i){var j=this,k=[{html:e("Hide datasets"),func:function(){var l=f.HistoryDatasetAssociation.prototype.hide;j.getSelectedHdaCollection().ajaxQueue(l)}},{html:e("Unhide datasets"),func:function(){var l=f.HistoryDatasetAssociation.prototype.unhide;j.getSelectedHdaCollection().ajaxQueue(l)}},{html:e("Delete datasets"),func:function(){var l=f.HistoryDatasetAssociation.prototype["delete"];j.getSelectedHdaCollection().ajaxQueue(l)}},{html:e("Undelete datasets"),func:function(){var l=f.HistoryDatasetAssociation.prototype.undelete;j.getSelectedHdaCollection().ajaxQueue(l)}}];if(j.purgeAllowed){k.push({html:e("Permanently delete datasets"),func:function(){if(confirm(e("This will permanently remove the data in your datasets. Are you sure?"))){var l=f.HistoryDatasetAssociation.prototype.purge;j.getSelectedHdaCollection().ajaxQueue(l)}}})}k.push({html:e("Build Dataset List (Experimental)"),func:function(){j.getSelectedHdaCollection().promoteToHistoryDatasetCollection(j.model,"list")}});k.push({html:e("Build Dataset Pair (Experimental)"),func:function(){j.getSelectedHdaCollection().promoteToHistoryDatasetCollection(j.model,"paired")}});return new PopupMenu(i.find(".history-dataset-action-popup-btn"),k)},_handleHdaDeletionChange:function(i){if(i.get("deleted")&&!this.storage.get("show_deleted")){this.removeHdaView(this.hdaViews[i.id])}},_handleHdaVisibleChange:function(i){if(i.hidden()&&!this.storage.get("show_hidden")){this.removeHdaView(this.hdaViews[i.id])}},_createContentView:function(j){var i=j.get("id"),l=j.get("history_content_type"),k=null;if(l==="dataset"){k=new this.HDAViewClass({model:j,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[i],selectable:this.selecting,purgeAllowed:this.purgeAllowed,hasUser:this.model.ownedByCurrUser(),logger:this.logger,tagsEditorShown:(this.tagsEditor&&!this.tagsEditor.hidden),annotationEditorShown:(this.annotationEditor&&!this.annotationEditor.hidden)})}else{if(l==="dataset_collection"){k=new h.DatasetCollectionEditView({model:j,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[i],hasUser:this.model.ownedByCurrUser(),logger:this.logger})}}this._setUpHdaListeners(k);return k},_setUpHdaListeners:function(j){var i=this;d.ReadOnlyHistoryPanel.prototype._setUpHdaListeners.call(this,j);j.on("selected",function(m,l){if(!l){return}var k=[];if((l.shiftKey)&&(i.lastSelectedViewId&&_.has(i.hdaViews,i.lastSelectedViewId))){var o=i.hdaViews[i.lastSelectedViewId];k=i.selectDatasetRange(m,o).map(function(p){return p.model.id})}else{var n=m.model.get("id");i.lastSelectedViewId=n;k=[n]}i.selectedHdaIds=_.union(i.selectedHdaIds,k)});j.on("de-selected",function(l,k){var m=l.model.get("id");i.selectedHdaIds=_.without(i.selectedHdaIds,m)})},toggleHDATagEditors:function(i){var j=arguments;_.each(this.hdaViews,function(k){if(k.tagsEditor){k.tagsEditor.toggle.apply(k.tagsEditor,j)}})},toggleHDAAnnotationEditors:function(i){var j=arguments;_.each(this.hdaViews,function(k){if(k.annotationEditor){k.annotationEditor.toggle.apply(k.annotationEditor,j)}})},removeHdaView:function(j){if(!j){return}var i=this;j.$el.fadeOut(i.fxSpeed,function(){j.off();j.remove();delete i.hdaViews[j.model.id];if(_.isEmpty(i.hdaViews)){i.trigger("empty-history",i);i._renderEmptyMsg()}})},events:_.extend(_.clone(d.ReadOnlyHistoryPanel.prototype.events),{"click .history-select-btn":"toggleSelectors","click .history-select-all-datasets-btn":"selectAllDatasets","click .history-deselect-all-datasets-btn":"deselectAllDatasets"}),updateHistoryDiskSize:function(){this.$el.find(".history-size").text(this.model.get("nice_size"))},showSelectors:function(i){i=(i!==undefined)?(i):(this.fxSpeed);this.selecting=true;this.$(".history-dataset-actions").slideDown(i);_.each(this.hdaViews,function(j){j.showSelector()});this.selectedHdaIds=[];this.lastSelectedViewId=null},hideSelectors:function(i){i=(i!==undefined)?(i):(this.fxSpeed);this.selecting=false;this.$(".history-dataset-actions").slideUp(i);_.each(this.hdaViews,function(j){j.hideSelector()});this.selectedHdaIds=[];this.lastSelectedViewId=null},toggleSelectors:function(){if(!this.selecting){this.showSelectors()}else{this.hideSelectors()}},selectAllDatasets:function(i){_.each(this.hdaViews,function(j){j.select(i)})},deselectAllDatasets:function(i){this.lastSelectedViewId=null;_.each(this.hdaViews,function(j){j.deselect(i)})},selectDatasetRange:function(k,j){var i=this.hdaViewRange(k,j);_.each(i,function(l){l.select()});return i},getSelectedHdaViews:function(){return _.filter(this.hdaViews,function(i){return i.selected})},getSelectedHdaCollection:function(){return new f.HDACollection(_.map(this.getSelectedHdaViews(),function(i){return i.model}),{historyId:this.model.id})},toString:function(){return"HistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});return{HistoryPanel:g}}); \ No newline at end of file +define(["mvc/dataset/hda-model","mvc/dataset/hda-edit","mvc/collection/dataset-collection-edit","mvc/history/readonly-history-panel","mvc/tags","mvc/annotations","utils/localization"],function(f,b,h,d,a,c,e){var g=d.ReadOnlyHistoryPanel.extend({HDAViewClass:b.HDAEditView,initialize:function(i){i=i||{};this.selectedHdaIds=[];this.lastSelectedViewId=null;this.tagsEditor=null;this.annotationEditor=null;this.purgeAllowed=i.purgeAllowed||false;this.selecting=i.selecting||false;this.annotationEditorShown=i.annotationEditorShown||false;this.tagsEditorShown=i.tagsEditorShown||false;d.ReadOnlyHistoryPanel.prototype.initialize.call(this,i)},_setUpModelEventHandlers:function(){d.ReadOnlyHistoryPanel.prototype._setUpModelEventHandlers.call(this);this.model.on("change:nice_size",this.updateHistoryDiskSize,this);this.model.hdas.on("change:deleted",this._handleHdaDeletionChange,this);this.model.hdas.on("change:visible",this._handleHdaVisibleChange,this);this.model.hdas.on("change:purged",function(i){this.model.fetch()},this)},renderModel:function(){var i=$("<div/>");i.append(g.templates.historyPanel(this.model.toJSON()));this.$emptyMessage(i).text(this.emptyMsg);if(Galaxy&&Galaxy.currUser&&Galaxy.currUser.id&&Galaxy.currUser.id===this.model.get("user_id")){this._renderTags(i);this._renderAnnotation(i)}i.find(".history-secondary-actions").prepend(this._renderSelectButton());i.find(".history-dataset-actions").toggle(this.selecting);i.find(".history-secondary-actions").prepend(this._renderSearchButton());this._setUpBehaviours(i);this.renderHdas(i);return i},_renderTags:function(i){var j=this;this.tagsEditor=new a.TagsEditor({model:this.model,el:i.find(".history-controls .tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){j.toggleHDATagEditors(true,j.fxSpeed)},onhide:function(){j.toggleHDATagEditors(false,j.fxSpeed)},$activator:faIconButton({title:e("Edit history tags"),classes:"history-tag-btn",faIcon:"fa-tags"}).appendTo(i.find(".history-secondary-actions"))})},_renderAnnotation:function(i){var j=this;this.annotationEditor=new c.AnnotationEditor({model:this.model,el:i.find(".history-controls .annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){j.toggleHDAAnnotationEditors(true,j.fxSpeed)},onhide:function(){j.toggleHDAAnnotationEditors(false,j.fxSpeed)},$activator:faIconButton({title:e("Edit history annotation"),classes:"history-annotate-btn",faIcon:"fa-comment"}).appendTo(i.find(".history-secondary-actions"))})},_renderSelectButton:function(i){return faIconButton({title:e("Operations on multiple datasets"),classes:"history-select-btn",faIcon:"fa-check-square-o"})},_setUpBehaviours:function(i){i=i||this.$el;d.ReadOnlyHistoryPanel.prototype._setUpBehaviours.call(this,i);if(!this.model){return}this._setUpDatasetActionsPopup(i);if((!Galaxy.currUser||Galaxy.currUser.isAnonymous())||(Galaxy.currUser.id!==this.model.get("user_id"))){return}var j=this;i.find(".history-name").attr("title",e("Click to rename history")).tooltip({placement:"bottom"}).make_text_editable({on_finish:function(k){var l=j.model.get("name");if(k&&k!==l){j.$el.find(".history-name").text(k);j.model.save({name:k}).fail(function(){j.$el.find(".history-name").text(j.model.previous("name"))})}else{j.$el.find(".history-name").text(l)}}})},_setUpDatasetActionsPopup:function(i){var j=this,k=[{html:e("Hide datasets"),func:function(){var l=f.HistoryDatasetAssociation.prototype.hide;j.getSelectedHdaCollection().ajaxQueue(l)}},{html:e("Unhide datasets"),func:function(){var l=f.HistoryDatasetAssociation.prototype.unhide;j.getSelectedHdaCollection().ajaxQueue(l)}},{html:e("Delete datasets"),func:function(){var l=f.HistoryDatasetAssociation.prototype["delete"];j.getSelectedHdaCollection().ajaxQueue(l)}},{html:e("Undelete datasets"),func:function(){var l=f.HistoryDatasetAssociation.prototype.undelete;j.getSelectedHdaCollection().ajaxQueue(l)}}];if(j.purgeAllowed){k.push({html:e("Permanently delete datasets"),func:function(){if(confirm(e("This will permanently remove the data in your datasets. Are you sure?"))){var l=f.HistoryDatasetAssociation.prototype.purge;j.getSelectedHdaCollection().ajaxQueue(l)}}})}k.push({html:e("Build Dataset List (Experimental)"),func:function(){j.getSelectedHdaCollection().promoteToHistoryDatasetCollection(j.model,"list")}});k.push({html:e("Build Dataset Pair (Experimental)"),func:function(){j.getSelectedHdaCollection().promoteToHistoryDatasetCollection(j.model,"paired")}});return new PopupMenu(i.find(".history-dataset-action-popup-btn"),k)},_handleHdaDeletionChange:function(i){if(i.get("deleted")&&!this.storage.get("show_deleted")){this.removeHdaView(this.hdaViews[i.id])}},_handleHdaVisibleChange:function(i){if(i.hidden()&&!this.storage.get("show_hidden")){this.removeHdaView(this.hdaViews[i.id])}},_createContentView:function(j){var i=j.id,l=j.get("history_content_type"),k=null;if(l==="dataset"){k=new this.HDAViewClass({model:j,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[i],selectable:this.selecting,purgeAllowed:this.purgeAllowed,hasUser:this.model.ownedByCurrUser(),logger:this.logger,tagsEditorShown:(this.tagsEditor&&!this.tagsEditor.hidden),annotationEditorShown:(this.annotationEditor&&!this.annotationEditor.hidden)})}else{if(l==="dataset_collection"){k=new h.DatasetCollectionEditView({model:j,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[i],hasUser:this.model.ownedByCurrUser(),logger:this.logger})}}this._setUpHdaListeners(k);return k},_setUpHdaListeners:function(j){var i=this;d.ReadOnlyHistoryPanel.prototype._setUpHdaListeners.call(this,j);j.on("selected",function(m,l){if(!l){return}var k=[];if((l.shiftKey)&&(i.lastSelectedViewId&&_.has(i.hdaViews,i.lastSelectedViewId))){var o=i.hdaViews[i.lastSelectedViewId];k=i.selectDatasetRange(m,o).map(function(p){return p.model.id})}else{var n=m.model.id;i.lastSelectedViewId=n;k=[n]}i.selectedHdaIds=_.union(i.selectedHdaIds,k)});j.on("de-selected",function(l,k){var m=l.model.id;i.selectedHdaIds=_.without(i.selectedHdaIds,m)})},toggleHDATagEditors:function(i){var j=arguments;_.each(this.hdaViews,function(k){if(k.tagsEditor){k.tagsEditor.toggle.apply(k.tagsEditor,j)}})},toggleHDAAnnotationEditors:function(i){var j=arguments;_.each(this.hdaViews,function(k){if(k.annotationEditor){k.annotationEditor.toggle.apply(k.annotationEditor,j)}})},removeHdaView:function(j){if(!j){return}var i=this;j.$el.fadeOut(i.fxSpeed,function(){j.off();j.remove();delete i.hdaViews[j.model.id];if(_.isEmpty(i.hdaViews)){i.trigger("empty-history",i);i._renderEmptyMsg()}})},events:_.extend(_.clone(d.ReadOnlyHistoryPanel.prototype.events),{"click .history-select-btn":"toggleSelectors","click .history-select-all-datasets-btn":"selectAllDatasets","click .history-deselect-all-datasets-btn":"deselectAllDatasets"}),updateHistoryDiskSize:function(){this.$el.find(".history-size").text(this.model.get("nice_size"))},showSelectors:function(i){i=(i!==undefined)?(i):(this.fxSpeed);this.selecting=true;this.$(".history-dataset-actions").slideDown(i);_.each(this.hdaViews,function(j){j.showSelector()});this.selectedHdaIds=[];this.lastSelectedViewId=null},hideSelectors:function(i){i=(i!==undefined)?(i):(this.fxSpeed);this.selecting=false;this.$(".history-dataset-actions").slideUp(i);_.each(this.hdaViews,function(j){j.hideSelector()});this.selectedHdaIds=[];this.lastSelectedViewId=null},toggleSelectors:function(){if(!this.selecting){this.showSelectors()}else{this.hideSelectors()}},selectAllDatasets:function(i){_.each(this.hdaViews,function(j){j.select(i)})},deselectAllDatasets:function(i){this.lastSelectedViewId=null;_.each(this.hdaViews,function(j){j.deselect(i)})},selectDatasetRange:function(k,j){var i=this.hdaViewRange(k,j);_.each(i,function(l){l.select()});return i},getSelectedHdaViews:function(){return _.filter(this.hdaViews,function(i){return i.selected})},getSelectedHdaCollection:function(){return new f.HDACollection(_.map(this.getSelectedHdaViews(),function(i){return i.model}),{historyId:this.model.id})},toString:function(){return"HistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});return{HistoryPanel:g}}); \ No newline at end of file diff -r 0c0517794198ec32fedc0bb022fe375e9f2e11e7 -r 7f506e778275715639d8f5d37041712be9662b39 static/scripts/packed/mvc/history/readonly-history-panel.js --- a/static/scripts/packed/mvc/history/readonly-history-panel.js +++ b/static/scripts/packed/mvc/history/readonly-history-panel.js @@ -1,1 +1,1 @@ -define(["mvc/history/history-model","mvc/collection/dataset-collection-base","mvc/dataset/hda-base","mvc/user/user-model","mvc/base-mvc","utils/localization"],function(g,k,b,a,f,d){var i=f.SessionStorageModel.extend({defaults:{expandedHdas:{},show_deleted:false,show_hidden:false},addExpandedHda:function(n){var m="expandedHdas";this.save(m,_.extend(this.get(m),_.object([n],[true])))},removeExpandedHda:function(n){var m="expandedHdas";this.save(m,_.omit(this.get(m),n))},toString:function(){return"HistoryPrefs("+this.id+")"}});i.storageKeyPrefix="history:";i.historyStorageKey=function e(m){if(!m){throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+m)}return(i.storageKeyPrefix+m)};i.get=function c(m){return new i({id:i.historyStorageKey(m)})};i.clearAll=function h(n){for(var m in sessionStorage){if(m.indexOf(i.storageKeyPrefix)===0){sessionStorage.removeItem(m)}}};var j=Backbone.View.extend(f.LoggableMixin).extend({HDAViewClass:b.HDABaseView,tagName:"div",className:"history-panel",fxSpeed:"fast",emptyMsg:d("This history is empty"),noneFoundMsg:d("No matching datasets found"),initialize:function(m){m=m||{};if(m.logger){this.logger=m.logger}this.log(this+".initialize:",m);this.linkTarget=m.linkTarget||"_blank";this.fxSpeed=_.has(m,"fxSpeed")?(m.fxSpeed):(this.fxSpeed);this.filters=[];this.searchFor="";this.findContainerFn=m.findContainerFn;this.hdaViews={};this.indicator=new LoadingIndicator(this.$el);this._setUpListeners();var n=_.pick(m,"initiallyExpanded","show_deleted","show_hidden");this.setModel(this.model,n,false);if(m.onready){m.onready.call(this)}},_setUpListeners:function(){this.on("error",function(n,q,m,p,o){this.errorHandler(n,q,m,p,o)});this.on("loading-history",function(){this._showLoadingIndicator("loading history...",40)});this.on("loading-done",function(){this._hideLoadingIndicator(40);if(_.isEmpty(this.hdaViews)){this.trigger("empty-history",this)}});this.once("rendered",function(){this.trigger("rendered:initial",this);return false});if(this.logger){this.on("all",function(m){this.log(this+"",arguments)},this)}return this},errorHandler:function(o,r,n,q,p){console.error(o,r,n,q,p);if(r&&r.status===0&&r.readyState===0){}else{if(r&&r.status===502){}else{var m=this._parseErrorMessage(o,r,n,q,p);if(!this.$messages().is(":visible")){this.once("rendered",function(){this.displayMessage("error",m.message,m.details)})}else{this.displayMessage("error",m.message,m.details)}}}},_parseErrorMessage:function(p,t,o,s,r){var n=Galaxy.currUser,m={message:this._bePolite(s),details:{user:(n instanceof a.User)?(n.toJSON()):(n+""),source:(p instanceof Backbone.Model)?(p.toJSON()):(p+""),xhr:t,options:(t)?(_.omit(o,"xhr")):(o)}};_.extend(m.details,r||{});if(t&&_.isFunction(t.getAllResponseHeaders)){var q=t.getAllResponseHeaders();q=_.compact(q.split("\n"));q=_.map(q,function(u){return u.split(": ")});m.details.xhr.responseHeaders=_.object(q)}return m},_bePolite:function(m){m=m||d("An error occurred while getting updates from the server");return m+". "+d("Please contact a Galaxy administrator if the problem persists")+"."},loadHistoryWithHDADetails:function(o,n,m,q){var p=function(r){return _.keys(i.get(r.id).get("expandedHdas"))};return this.loadHistory(o,n,m,q,p)},loadHistory:function(p,o,n,s,q){var m=this;o=o||{};m.trigger("loading-history",m);var r=g.History.getHistoryData(p,{historyFn:n,hdaFn:s,hdaDetailIds:o.initiallyExpanded||q});return m._loadHistoryFromXHR(r,o).fail(function(v,t,u){m.trigger("error",m,v,o,d("An error was encountered while "+t),{historyId:p,history:u||{}})}).always(function(){m.trigger("loading-done",m)})},_loadHistoryFromXHR:function(o,n){var m=this;o.then(function(p,q){m.JSONToModel(p,q,n)});o.fail(function(q,p){m.render()});return o},JSONToModel:function(p,m,n){this.log("JSONToModel:",p,m,n);n=n||{};var o=new g.History(p,m,n);this.setModel(o);return this},setModel:function(n,m,o){m=m||{};o=(o!==undefined)?(o):(true);this.log("setModel:",n,m,o);this.freeModel();this.selectedHdaIds=[];if(n){this.model=n;if(this.logger){this.model.logger=this.logger}this._setUpWebStorage(m.initiallyExpanded,m.show_deleted,m.show_hidden);this._setUpModelEventHandlers();this.trigger("new-model",this)}if(o){this.render()}return this},freeModel:function(){if(this.model){this.model.clearUpdateTimeout();this.stopListening(this.model);this.stopListening(this.model.hdas)}this.freeHdaViews();return this},freeHdaViews:function(){this.hdaViews={};return this},_setUpWebStorage:function(n,m,o){this.storage=new i({id:i.historyStorageKey(this.model.get("id"))});if(_.isObject(n)){this.storage.set("exandedHdas",n)}if(_.isBoolean(m)){this.storage.set("show_deleted",m)}if(_.isBoolean(o)){this.storage.set("show_hidden",o)}this.trigger("new-storage",this.storage,this);this.log(this+" (init'd) storage:",this.storage.get());return this},_setUpModelEventHandlers:function(){this.model.hdas.on("add",this.addContentView,this);this.model.on("error error:hdas",function(n,p,m,o){this.errorHandler(n,p,m,o)},this);return this},render:function(o,p){this.log("render:",o,p);o=(o===undefined)?(this.fxSpeed):(o);var m=this,n;if(this.model){n=this.renderModel()}else{n=this.renderWithoutModel()}$(m).queue("fx",[function(q){if(o&&m.$el.is(":visible")){m.$el.fadeOut(o,q)}else{q()}},function(q){m.$el.empty();if(n){m.$el.append(n.children())}q()},function(q){if(o&&!m.$el.is(":visible")){m.$el.fadeIn(o,q)}else{q()}},function(q){if(p){p.call(this)}m.trigger("rendered",this);q()}]);return this},renderWithoutModel:function(){var m=$("<div/>"),n=$("<div/>").addClass("message-container").css({margin:"4px"});return m.append(n)},renderModel:function(){var m=$("<div/>");m.append(j.templates.historyPanel(this.model.toJSON()));this.$emptyMessage(m).text(this.emptyMsg);m.find(".history-secondary-actions").prepend(this._renderSearchButton());this._setUpBehaviours(m);this.renderHdas(m);return m},_renderEmptyMsg:function(o){var n=this,m=n.$emptyMessage(o);if(!_.isEmpty(n.hdaViews)){m.hide()}else{if(n.searchFor){m.text(n.noneFoundMsg).show()}else{m.text(n.emptyMsg).show()}}return this},_renderSearchButton:function(m){return faIconButton({title:d("Search datasets"),classes:"history-search-btn",faIcon:"fa-search"})},_setUpBehaviours:function(m){m=m||this.$el;m.find("[title]").tooltip({placement:"bottom"});this._setUpSearchInput(m.find(".history-search-controls .history-search-input"));return this},$container:function(){return(this.findContainerFn)?(this.findContainerFn.call(this)):(this.$el.parent())},$datasetsList:function(m){return(m||this.$el).find(".datasets-list")},$messages:function(m){return(m||this.$el).find(".message-container")},$emptyMessage:function(m){return(m||this.$el).find(".empty-history-message")},renderHdas:function(n){n=n||this.$el;var m=this,p={},o=this.model.hdas.getVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"),this.filters);this.$datasetsList(n).empty();if(o.length){o.each(function(r){var q=r.get("id"),s=m._createContentView(r);p[q]=s;if(_.contains(m.selectedHdaIds,q)){s.selected=true}m.attachContentView(s.render(),n)})}this.hdaViews=p;this._renderEmptyMsg(n);return this.hdaViews},_createContentView:function(n){var m=n.get("id"),p=n.get("history_content_type"),o=null;if(p==="dataset"){o=new this.HDAViewClass({model:n,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[m],hasUser:this.model.ownedByCurrUser(),logger:this.logger})}else{o=new k.DatasetCollectionBaseView({model:n,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[m],hasUser:this.model.ownedByCurrUser(),logger:this.logger})}this._setUpHdaListeners(o);return o},_setUpHdaListeners:function(n){var m=this;n.on("error",function(p,r,o,q){m.errorHandler(p,r,o,q)});n.on("body-expanded",function(o){m.storage.addExpandedHda(o)});n.on("body-collapsed",function(o){m.storage.removeExpandedHda(o)});return this},attachContentView:function(o,n){n=n||this.$el;var m=this.$datasetsList(n);m.prepend(o.$el);return this},addContentView:function(p){this.log("add."+this,p);var n=this;if(!p.isVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"))){return n}$({}).queue([function o(r){var q=n.$emptyMessage();if(q.is(":visible")){q.fadeOut(n.fxSpeed,r)}else{r()}},function m(q){var r=n._createContentView(p);n.hdaViews[p.id]=r;r.render().$el.hide();n.scrollToTop();n.attachContentView(r);r.$el.slideDown(n.fxSpeed)}]);return n},refreshContents:function(n,m){if(this.model){return this.model.refresh(n,m)}return $.when()},hdaViewRange:function(p,o){if(p===o){return[p]}var m=this,n=false,q=[];this.model.hdas.getVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"),this.filters).each(function(r){if(n){q.push(m.hdaViews[r.id]);if(r===p.model||r===o.model){n=false}}else{if(r===p.model||r===o.model){n=true;q.push(m.hdaViews[r.id])}}});return q},events:{"click .message-container":"clearMessages","click .history-search-btn":"toggleSearchControls"},collapseAllHdaBodies:function(){_.each(this.hdaViews,function(m){m.toggleBodyVisibility(null,false)});this.storage.set("expandedHdas",{});return this},toggleShowDeleted:function(m){m=(m!==undefined)?(m):(!this.storage.get("show_deleted"));this.storage.set("show_deleted",m);this.renderHdas();return this.storage.get("show_deleted")},toggleShowHidden:function(m){m=(m!==undefined)?(m):(!this.storage.get("show_hidden"));this.storage.set("show_hidden",m);this.renderHdas();return this.storage.get("show_hidden")},_setUpSearchInput:function(n){var o=this,p=".history-search-input";function m(q){if(o.model.hdas.haveDetails()){o.searchHdas(q);return}o.$el.find(p).searchInput("toggle-loading");o.model.hdas.fetchAllDetails({silent:true}).always(function(){o.$el.find(p).searchInput("toggle-loading")}).done(function(){o.searchHdas(q)})}n.searchInput({initialVal:o.searchFor,name:"history-search",placeholder:"search datasets",classes:"history-search",onfirstsearch:m,onsearch:_.bind(this.searchHdas,this),onclear:_.bind(this.clearHdaSearch,this)});return n},toggleSearchControls:function(o,m){var n=this.$el.find(".history-search-controls"),p=(jQuery.type(o)==="number")?(o):(this.fxSpeed);m=(m!==undefined)?(m):(!n.is(":visible"));if(m){n.slideDown(p,function(){$(this).find("input").focus()})}else{n.slideUp(p)}return m},searchHdas:function(m){var n=this;this.searchFor=m;this.filters=[function(o){return o.matchesAll(n.searchFor)}];this.trigger("search:searching",m,this);this.renderHdas();return this},clearHdaSearch:function(m){this.searchFor="";this.filters=[];this.trigger("search:clear",this);this.renderHdas();return this},_showLoadingIndicator:function(n,m,o){m=(m!==undefined)?(m):(this.fxSpeed);if(!this.indicator){this.indicator=new LoadingIndicator(this.$el,this.$el.parent())}if(!this.$el.is(":visible")){this.indicator.show(0,o)}else{this.$el.fadeOut(m);this.indicator.show(n,m,o)}},_hideLoadingIndicator:function(m,n){m=(m!==undefined)?(m):(this.fxSpeed);if(this.indicator){this.indicator.hide(m,n)}},displayMessage:function(r,s,q){var o=this;this.scrollToTop();var p=this.$messages(),m=$("<div/>").addClass(r+"message").html(s);if(!_.isEmpty(q)){var n=$('<a href="javascript:void(0)">Details</a>').click(function(){Galaxy.modal.show(o._messageToModalOptions(r,s,q));return false});m.append(" ",n)}return p.html(m)},_messageToModalOptions:function(q,s,p){var m=this,r=$("<div/>"),o={title:"Details"};function n(t){t=_.omit(t,_.functions(t));return["<table>",_.map(t,function(v,u){v=(_.isObject(v))?(n(v)):(v);return'<tr><td style="vertical-align: top; color: grey">'+u+'</td><td style="padding-left: 8px">'+v+"</td></tr>"}).join(""),"</table>"].join("")}if(_.isObject(p)){o.body=r.append(n(p))}else{o.body=r.html(p)}o.buttons={Ok:function(){Galaxy.modal.hide();m.clearMessages()}};return o},clearMessages:function(){this.$messages().empty();return this},scrollPosition:function(){return this.$container().scrollTop()},scrollTo:function(m){this.$container().scrollTop(m);return this},scrollToTop:function(){this.$container().scrollTop(0);return this},scrollToId:function(n){if((!n)||(!this.hdaViews[n])){return this}var m=this.hdaViews[n];this.scrollTo(m.el.offsetTop);return this},scrollToHid:function(m){var n=this.model.hdas.getByHid(m);if(!n){return this}return this.scrollToId(n.id)},toString:function(){return"ReadOnlyHistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});var l=['<div class="history-controls">','<div class="history-search-controls">','<div class="history-search-input"></div>',"</div>",'<div class="history-title">',"<% if( history.name ){ %>",'<div class="history-name"><%= history.name %></div>',"<% } %>","</div>",'<div class="history-subtitle clear">',"<% if( history.nice_size ){ %>",'<div class="history-size"><%= history.nice_size %></div>',"<% } %>",'<div class="history-secondary-actions"></div>',"</div>","<% if( history.deleted ){ %>",'<div class="warningmessagesmall"><strong>',d("You are currently viewing a deleted history!"),"</strong></div>","<% } %>",'<div class="message-container">',"<% if( history.message ){ %>",'<div class="<%= history.status %>message"><%= history.message %></div>',"<% } %>","</div>",'<div class="quota-message errormessage">',d("You are over your disk quota"),". ",d("Tool execution is on hold until your disk usage drops below your allocated quota"),".","</div>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="history-dataset-actions">','<div class="btn-group">','<button class="history-select-all-datasets-btn btn btn-default"','data-mode="select">',d("All"),"</button>",'<button class="history-deselect-all-datasets-btn btn btn-default"','data-mode="select">',d("None"),"</button>","</div>",'<button class="history-dataset-action-popup-btn btn btn-default">',d("For all selected"),"...</button>","</div>","</div>",'<div class="datasets-list"></div>','<div class="empty-history-message infomessagesmall">',d("This history is empty"),"</div>"].join("");j.templates={historyPanel:function(m){return _.template(l,m,{variable:"history"})}};return{ReadOnlyHistoryPanel:j}}); \ No newline at end of file +define(["mvc/history/history-model","mvc/collection/dataset-collection-base","mvc/dataset/hda-base","mvc/user/user-model","mvc/base-mvc","utils/localization"],function(g,k,b,a,f,d){var i=f.SessionStorageModel.extend({defaults:{expandedHdas:{},show_deleted:false,show_hidden:false},addExpandedHda:function(m){var n="expandedHdas";this.save(n,_.extend(this.get(n),_.object([m.id],[m.get("id")])))},removeExpandedHda:function(n){var m="expandedHdas";this.save(m,_.omit(this.get(m),n))},toString:function(){return"HistoryPrefs("+this.id+")"}});i.storageKeyPrefix="history:";i.historyStorageKey=function e(m){if(!m){throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+m)}return(i.storageKeyPrefix+m)};i.get=function c(m){return new i({id:i.historyStorageKey(m)})};i.clearAll=function h(n){for(var m in sessionStorage){if(m.indexOf(i.storageKeyPrefix)===0){sessionStorage.removeItem(m)}}};var j=Backbone.View.extend(f.LoggableMixin).extend({HDAViewClass:b.HDABaseView,tagName:"div",className:"history-panel",fxSpeed:"fast",emptyMsg:d("This history is empty"),noneFoundMsg:d("No matching datasets found"),initialize:function(m){m=m||{};if(m.logger){this.logger=m.logger}this.log(this+".initialize:",m);this.linkTarget=m.linkTarget||"_blank";this.fxSpeed=_.has(m,"fxSpeed")?(m.fxSpeed):(this.fxSpeed);this.filters=[];this.searchFor="";this.findContainerFn=m.findContainerFn;this.hdaViews={};this.indicator=new LoadingIndicator(this.$el);this._setUpListeners();var n=_.pick(m,"initiallyExpanded","show_deleted","show_hidden");this.setModel(this.model,n,false);if(m.onready){m.onready.call(this)}},_setUpListeners:function(){this.on("error",function(n,q,m,p,o){this.errorHandler(n,q,m,p,o)});this.on("loading-history",function(){this._showLoadingIndicator("loading history...",40)});this.on("loading-done",function(){this._hideLoadingIndicator(40);if(_.isEmpty(this.hdaViews)){this.trigger("empty-history",this)}});this.once("rendered",function(){this.trigger("rendered:initial",this);return false});if(this.logger){this.on("all",function(m){this.log(this+"",arguments)},this)}return this},errorHandler:function(o,r,n,q,p){console.error(o,r,n,q,p);if(r&&r.status===0&&r.readyState===0){}else{if(r&&r.status===502){}else{var m=this._parseErrorMessage(o,r,n,q,p);if(!this.$messages().is(":visible")){this.once("rendered",function(){this.displayMessage("error",m.message,m.details)})}else{this.displayMessage("error",m.message,m.details)}}}},_parseErrorMessage:function(p,t,o,s,r){var n=Galaxy.currUser,m={message:this._bePolite(s),details:{user:(n instanceof a.User)?(n.toJSON()):(n+""),source:(p instanceof Backbone.Model)?(p.toJSON()):(p+""),xhr:t,options:(t)?(_.omit(o,"xhr")):(o)}};_.extend(m.details,r||{});if(t&&_.isFunction(t.getAllResponseHeaders)){var q=t.getAllResponseHeaders();q=_.compact(q.split("\n"));q=_.map(q,function(u){return u.split(": ")});m.details.xhr.responseHeaders=_.object(q)}return m},_bePolite:function(m){m=m||d("An error occurred while getting updates from the server");return m+". "+d("Please contact a Galaxy administrator if the problem persists")+"."},loadHistoryWithHDADetails:function(o,n,m,q){var p=function(r){return _.values(i.get(r.id).get("expandedHdas"))};return this.loadHistory(o,n,m,q,p)},loadHistory:function(p,o,n,s,q){var m=this;o=o||{};m.trigger("loading-history",m);var r=g.History.getHistoryData(p,{historyFn:n,hdaFn:s,hdaDetailIds:o.initiallyExpanded||q});return m._loadHistoryFromXHR(r,o).fail(function(v,t,u){m.trigger("error",m,v,o,d("An error was encountered while "+t),{historyId:p,history:u||{}})}).always(function(){m.trigger("loading-done",m)})},_loadHistoryFromXHR:function(o,n){var m=this;o.then(function(p,q){m.JSONToModel(p,q,n)});o.fail(function(q,p){m.render()});return o},JSONToModel:function(p,m,n){this.log("JSONToModel:",p,m,n);n=n||{};var o=new g.History(p,m,n);this.setModel(o);return this},setModel:function(n,m,o){m=m||{};o=(o!==undefined)?(o):(true);this.log("setModel:",n,m,o);this.freeModel();this.selectedHdaIds=[];if(n){this.model=n;if(this.logger){this.model.logger=this.logger}this._setUpWebStorage(m.initiallyExpanded,m.show_deleted,m.show_hidden);this._setUpModelEventHandlers();this.trigger("new-model",this)}if(o){this.render()}return this},freeModel:function(){if(this.model){this.model.clearUpdateTimeout();this.stopListening(this.model);this.stopListening(this.model.hdas)}this.freeHdaViews();return this},freeHdaViews:function(){this.hdaViews={};return this},_setUpWebStorage:function(n,m,o){this.storage=new i({id:i.historyStorageKey(this.model.get("id"))});if(_.isObject(n)){this.storage.set("exandedHdas",n)}if(_.isBoolean(m)){this.storage.set("show_deleted",m)}if(_.isBoolean(o)){this.storage.set("show_hidden",o)}this.trigger("new-storage",this.storage,this);this.log(this+" (init'd) storage:",this.storage.get());return this},_setUpModelEventHandlers:function(){this.model.hdas.on("add",this.addContentView,this);this.model.on("error error:hdas",function(n,p,m,o){this.errorHandler(n,p,m,o)},this);return this},render:function(o,p){this.log("render:",o,p);o=(o===undefined)?(this.fxSpeed):(o);var m=this,n;if(this.model){n=this.renderModel()}else{n=this.renderWithoutModel()}$(m).queue("fx",[function(q){if(o&&m.$el.is(":visible")){m.$el.fadeOut(o,q)}else{q()}},function(q){m.$el.empty();if(n){m.$el.append(n.children())}q()},function(q){if(o&&!m.$el.is(":visible")){m.$el.fadeIn(o,q)}else{q()}},function(q){if(p){p.call(this)}m.trigger("rendered",this);q()}]);return this},renderWithoutModel:function(){var m=$("<div/>"),n=$("<div/>").addClass("message-container").css({margin:"4px"});return m.append(n)},renderModel:function(){var m=$("<div/>");m.append(j.templates.historyPanel(this.model.toJSON()));this.$emptyMessage(m).text(this.emptyMsg);m.find(".history-secondary-actions").prepend(this._renderSearchButton());this._setUpBehaviours(m);this.renderHdas(m);return m},_renderEmptyMsg:function(o){var n=this,m=n.$emptyMessage(o);if(!_.isEmpty(n.hdaViews)){m.hide()}else{if(n.searchFor){m.text(n.noneFoundMsg).show()}else{m.text(n.emptyMsg).show()}}return this},_renderSearchButton:function(m){return faIconButton({title:d("Search datasets"),classes:"history-search-btn",faIcon:"fa-search"})},_setUpBehaviours:function(m){m=m||this.$el;m.find("[title]").tooltip({placement:"bottom"});this._setUpSearchInput(m.find(".history-search-controls .history-search-input"));return this},$container:function(){return(this.findContainerFn)?(this.findContainerFn.call(this)):(this.$el.parent())},$datasetsList:function(m){return(m||this.$el).find(".datasets-list")},$messages:function(m){return(m||this.$el).find(".message-container")},$emptyMessage:function(m){return(m||this.$el).find(".empty-history-message")},renderHdas:function(n){n=n||this.$el;var m=this,p={},o=this.model.hdas.getVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"),this.filters);this.$datasetsList(n).empty();if(o.length){o.each(function(r){var q=r.id,s=m._createContentView(r);p[q]=s;if(_.contains(m.selectedHdaIds,q)){s.selected=true}m.attachContentView(s.render(),n)})}this.hdaViews=p;this._renderEmptyMsg(n);return this.hdaViews},_createContentView:function(n){var m=n.id,p=n.get("history_content_type"),o=null;if(p==="dataset"){o=new this.HDAViewClass({model:n,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[m],hasUser:this.model.ownedByCurrUser(),logger:this.logger})}else{o=new k.DatasetCollectionBaseView({model:n,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[m],hasUser:this.model.ownedByCurrUser(),logger:this.logger})}this._setUpHdaListeners(o);return o},_setUpHdaListeners:function(n){var m=this;n.on("error",function(p,r,o,q){m.errorHandler(p,r,o,q)});n.on("body-expanded",function(o){m.storage.addExpandedHda(o)});n.on("body-collapsed",function(o){m.storage.removeExpandedHda(o)});return this},attachContentView:function(o,n){n=n||this.$el;var m=this.$datasetsList(n);m.prepend(o.$el);return this},addContentView:function(p){this.log("add."+this,p);var n=this;if(!p.isVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"))){return n}$({}).queue([function o(r){var q=n.$emptyMessage();if(q.is(":visible")){q.fadeOut(n.fxSpeed,r)}else{r()}},function m(q){var r=n._createContentView(p);n.hdaViews[p.id]=r;r.render().$el.hide();n.scrollToTop();n.attachContentView(r);r.$el.slideDown(n.fxSpeed)}]);return n},refreshContents:function(n,m){if(this.model){return this.model.refresh(n,m)}return $.when()},hdaViewRange:function(p,o){if(p===o){return[p]}var m=this,n=false,q=[];this.model.hdas.getVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"),this.filters).each(function(r){if(n){q.push(m.hdaViews[r.id]);if(r===p.model||r===o.model){n=false}}else{if(r===p.model||r===o.model){n=true;q.push(m.hdaViews[r.id])}}});return q},events:{"click .message-container":"clearMessages","click .history-search-btn":"toggleSearchControls"},collapseAllHdaBodies:function(){_.each(this.hdaViews,function(m){m.toggleBodyVisibility(null,false)});this.storage.set("expandedHdas",{});return this},toggleShowDeleted:function(m){m=(m!==undefined)?(m):(!this.storage.get("show_deleted"));this.storage.set("show_deleted",m);this.renderHdas();return this.storage.get("show_deleted")},toggleShowHidden:function(m){m=(m!==undefined)?(m):(!this.storage.get("show_hidden"));this.storage.set("show_hidden",m);this.renderHdas();return this.storage.get("show_hidden")},_setUpSearchInput:function(n){var o=this,p=".history-search-input";function m(q){if(o.model.hdas.haveDetails()){o.searchHdas(q);return}o.$el.find(p).searchInput("toggle-loading");o.model.hdas.fetchAllDetails({silent:true}).always(function(){o.$el.find(p).searchInput("toggle-loading")}).done(function(){o.searchHdas(q)})}n.searchInput({initialVal:o.searchFor,name:"history-search",placeholder:"search datasets",classes:"history-search",onfirstsearch:m,onsearch:_.bind(this.searchHdas,this),onclear:_.bind(this.clearHdaSearch,this)});return n},toggleSearchControls:function(o,m){var n=this.$el.find(".history-search-controls"),p=(jQuery.type(o)==="number")?(o):(this.fxSpeed);m=(m!==undefined)?(m):(!n.is(":visible"));if(m){n.slideDown(p,function(){$(this).find("input").focus()})}else{n.slideUp(p)}return m},searchHdas:function(m){var n=this;this.searchFor=m;this.filters=[function(o){return o.matchesAll(n.searchFor)}];this.trigger("search:searching",m,this);this.renderHdas();return this},clearHdaSearch:function(m){this.searchFor="";this.filters=[];this.trigger("search:clear",this);this.renderHdas();return this},_showLoadingIndicator:function(n,m,o){m=(m!==undefined)?(m):(this.fxSpeed);if(!this.indicator){this.indicator=new LoadingIndicator(this.$el,this.$el.parent())}if(!this.$el.is(":visible")){this.indicator.show(0,o)}else{this.$el.fadeOut(m);this.indicator.show(n,m,o)}},_hideLoadingIndicator:function(m,n){m=(m!==undefined)?(m):(this.fxSpeed);if(this.indicator){this.indicator.hide(m,n)}},displayMessage:function(r,s,q){var o=this;this.scrollToTop();var p=this.$messages(),m=$("<div/>").addClass(r+"message").html(s);if(!_.isEmpty(q)){var n=$('<a href="javascript:void(0)">Details</a>').click(function(){Galaxy.modal.show(o._messageToModalOptions(r,s,q));return false});m.append(" ",n)}return p.html(m)},_messageToModalOptions:function(q,s,p){var m=this,r=$("<div/>"),o={title:"Details"};function n(t){t=_.omit(t,_.functions(t));return["<table>",_.map(t,function(v,u){v=(_.isObject(v))?(n(v)):(v);return'<tr><td style="vertical-align: top; color: grey">'+u+'</td><td style="padding-left: 8px">'+v+"</td></tr>"}).join(""),"</table>"].join("")}if(_.isObject(p)){o.body=r.append(n(p))}else{o.body=r.html(p)}o.buttons={Ok:function(){Galaxy.modal.hide();m.clearMessages()}};return o},clearMessages:function(){this.$messages().empty();return this},scrollPosition:function(){return this.$container().scrollTop()},scrollTo:function(m){this.$container().scrollTop(m);return this},scrollToTop:function(){this.$container().scrollTop(0);return this},scrollToId:function(n){if((!n)||(!this.hdaViews[n])){return this}var m=this.hdaViews[n];this.scrollTo(m.el.offsetTop);return this},scrollToHid:function(m){var n=this.model.hdas.getByHid(m);if(!n){return this}return this.scrollToId(n.id)},toString:function(){return"ReadOnlyHistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});var l=['<div class="history-controls">','<div class="history-search-controls">','<div class="history-search-input"></div>',"</div>",'<div class="history-title">',"<% if( history.name ){ %>",'<div class="history-name"><%= history.name %></div>',"<% } %>","</div>",'<div class="history-subtitle clear">',"<% if( history.nice_size ){ %>",'<div class="history-size"><%= history.nice_size %></div>',"<% } %>",'<div class="history-secondary-actions"></div>',"</div>","<% if( history.deleted ){ %>",'<div class="warningmessagesmall"><strong>',d("You are currently viewing a deleted history!"),"</strong></div>","<% } %>",'<div class="message-container">',"<% if( history.message ){ %>",'<div class="<%= history.status %>message"><%= history.message %></div>',"<% } %>","</div>",'<div class="quota-message errormessage">',d("You are over your disk quota"),". ",d("Tool execution is on hold until your disk usage drops below your allocated quota"),".","</div>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="history-dataset-actions">','<div class="btn-group">','<button class="history-select-all-datasets-btn btn btn-default"','data-mode="select">',d("All"),"</button>",'<button class="history-deselect-all-datasets-btn btn btn-default"','data-mode="select">',d("None"),"</button>","</div>",'<button class="history-dataset-action-popup-btn btn btn-default">',d("For all selected"),"...</button>","</div>","</div>",'<div class="datasets-list"></div>','<div class="empty-history-message infomessagesmall">',d("This history is empty"),"</div>"].join("");j.templates={historyPanel:function(m){return _.template(l,m,{variable:"history"})}};return{ReadOnlyHistoryPanel:j}}); \ No newline at end of file Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.