commit/galaxy-central: 4 new changesets
4 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/7e47493de36f/ Changeset: 7e47493de36f Branch: next-stable User: carlfeberhard Date: 2015-02-17 14:54:36+00:00 Summary: UI: Move action menu rendering into list panel, refactor history contents copying Affected #: 19 files diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 client/galaxy/scripts/mvc/history/history-contents.js --- a/client/galaxy/scripts/mvc/history/history-contents.js +++ b/client/galaxy/scripts/mvc/history/history-contents.js @@ -25,7 +25,6 @@ /** since history content is a mix, override model fn into a factory, creating based on history_content_type */ model : function( attrs, options ) { - //console.debug( 'HistoryContents.model:', attrs, options ); //TODO: can we move the type_id stuff here? //attrs.type_id = typeIdStr( attrs ); @@ -185,16 +184,36 @@ return deferred; }, + isCopyable : function( contentsJSON ){ + var copyableModelClasses = [ + 'HistoryDatasetAssociation', + 'HistoryDatasetCollectionAssociation' + ]; + return ( ( _.isObject( contentsJSON ) && contentsJSON.id ) + && ( _.contains( copyableModelClasses, contentsJSON.model_class ) ) ); + }, + /** copy an existing, accessible hda into this collection */ - copy : function( id, contentType ){ - contentType = contentType || 'hda'; - var type = ( contentType === 'hdca'? 'dataset_collection' : 'dataset' ), - collection = this; - - var xhr = jQuery.post( this.url(), { - type : type, + copy : function( json ){ + var id, type, contentType; + if( _.isString( json ) ){ + id = json; + contentType = 'hda'; + type = 'dataset'; + } else { + id = json.id; + contentType = ({ + 'HistoryDatasetAssociation' : 'hda', + 'LibraryDatasetDatasetAssociation' : 'ldda', + 'HistoryDatasetCollectionAssociation' : 'hdca' + })[ json.model_class ] || 'hda'; + type = ( contentType === 'hdca'? 'dataset_collection' : 'dataset' ); + } + var collection = this, + xhr = jQuery.post( this.url(), { + content : id, source : contentType, - content : id + type : type }) .done( function( json ){ collection.add([ json ]); diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 client/galaxy/scripts/mvc/history/history-panel-edit.js --- a/client/galaxy/scripts/mvc/history/history-panel-edit.js +++ b/client/galaxy/scripts/mvc/history/history-panel-edit.js @@ -69,8 +69,6 @@ /** is the panel currently showing the dataset selection controls? */ this.annotationEditorShown = attributes.annotationEditorShown || false; this.tagsEditorShown = attributes.tagsEditorShown || false; - - this.multiselectActions = attributes.multiselectActions || this._getActions(); }, /** Override to handle history as drag-drop target */ @@ -210,11 +208,6 @@ _super.prototype._setUpBehaviors.call( this, $where ); if( !this.model ){ return; } - // set up the pupup for actions available when multi selecting - if( this.multiselectActions.length ){ - this.actionsPopup = new PopupMenu( $where.find( '.list-action-popup-btn' ), this.multiselectActions ); - } - // anon users shouldn't have access to any of the following if( ( !Galaxy.currUser || Galaxy.currUser.isAnonymous() ) || ( Galaxy.currUser.id !== this.model.get( 'user_id' ) ) ){ @@ -245,7 +238,7 @@ /** return a new popup menu for choosing a multi selection action * ajax calls made for multiple datasets are queued */ - _getActions : function(){ + multiselectActions : function(){ var panel = this, actions = [ { html: _l( 'Hide datasets' ), func: function(){ diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 client/galaxy/scripts/mvc/history/history-panel.js --- a/client/galaxy/scripts/mvc/history/history-panel.js +++ b/client/galaxy/scripts/mvc/history/history-panel.js @@ -7,6 +7,7 @@ "mvc/collection/collection-panel", "mvc/user/user-model", "ui/fa-icon-button", + "mvc/ui/popup-menu", "mvc/base-mvc", "utils/localization", "ui/search-input" @@ -19,6 +20,7 @@ COLLECTION_PANEL, USER, faIconButton, + PopupMenu, BASE_MVC, _l ){ @@ -302,7 +304,8 @@ /** In this override, add a btn to toggle the selectors */ _buildNewRender : function(){ var $newRender = _super.prototype._buildNewRender.call( this ); - if( this.multiselectActions.length ){ + //if( this.views.length && this.multiselectActions().length ){ + if( this.multiselectActions().length ){ $newRender.find( '.controls .actions' ).prepend( this._renderSelectButton() ); } return $newRender; @@ -617,10 +620,18 @@ '<div class="actions"></div>', '<div class="messages">', - '<% if( history.deleted ){ %>', + '<% if( history.deleted && history.purged ){ %>', + '<div class="deleted-msg warningmessagesmall">', + _l( 'This history has been purged and deleted' ), + '</div>', + '<% } else if( history.deleted ){ %>', '<div class="deleted-msg warningmessagesmall">', _l( 'This history has been deleted' ), '</div>', + '<% } else if( history.purged ){ %>', + '<div class="deleted-msg warningmessagesmall">', + _l( 'This history has been purged' ), + '</div>', '<% } %>', '<% if( history.message ){ %>', @@ -646,8 +657,8 @@ '<button class="deselect-all btn btn-default"', 'data-mode="select">', _l( 'None' ), '</button>', '</div>', - '<button class="list-action-popup-btn btn btn-default">', - _l( 'For all selected' ), '...</button>', + '<div class="list-action-menu btn-group">', + '</div>', '</div>', '</div>' ], 'history' ); diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 client/galaxy/scripts/mvc/history/multi-panel.js --- a/client/galaxy/scripts/mvc/history/multi-panel.js +++ b/client/galaxy/scripts/mvc/history/multi-panel.js @@ -353,8 +353,8 @@ '</a></li>', '<% } %>', '</ul>', - '<% } %>', - '</div>', + '</div>', + '<% } %>', '</div>' ].join( '' ), { variable: 'data' }), @@ -669,11 +669,7 @@ /** set up listeners for a column and it's panel - handling: hda lazy-loading, drag and drop */ setUpColumnListeners : function setUpColumnListeners( column ){ - var multipanel = this, - modelClassToSource = { - 'HistoryDatasetAssociation' : 'hda', - 'HistoryDatasetCollectionAssociation' : 'hdca' - }; + var multipanel = this; multipanel.listenTo( column, { //'all': function(){ console.info( 'column ' + column + ':', arguments ) }, 'in-view': multipanel.queueHdaFetch @@ -691,20 +687,18 @@ multipanel.currentColumnDropTargetOff(); }, 'droptarget:drop': function( ev, data, panel ){ - //note: this will bad copy sources fail silently + //note: bad copy sources fail silently var toCopy = multipanel._dropData.filter( function( json ){ - return ( ( _.isObject( json ) && json.id ) - && ( _.contains( _.keys( modelClassToSource ), json.model_class ) ) ); + return panel.model.contents.isCopyable( json ); }); multipanel._dropData = null; var queue = new ajaxQueue.NamedAjaxQueue(); toCopy.forEach( function( content ){ - var contentType = modelClassToSource[ content.model_class ]; queue.add({ name : 'copy-' + content.id, fn : function(){ - return panel.model.contents.copy( content.id, contentType ); + return panel.model.contents.copy( content ); } }); }); @@ -714,7 +708,6 @@ }); } }); - }, /** conv. fn to count the columns in columnMap */ diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 client/galaxy/scripts/mvc/list/list-panel.js --- a/client/galaxy/scripts/mvc/list/list-panel.js +++ b/client/galaxy/scripts/mvc/list/list-panel.js @@ -46,9 +46,6 @@ /** string used for search placeholder */ searchPlaceholder : _l( 'search' ), - /** actions available for multiselected items */ - multiselectActions : [], - // ......................................................................... SET UP /** Set up the view, set up storage, bind listeners to HistoryContents events * @param {Object} attributes optional settings for the list @@ -103,11 +100,6 @@ this.title = attributes.title || ''; this.subtitle = attributes.subtitle || ''; - // allow override of multiselectActions through attributes - this.multiselectActions = attributes.multiselectActions || this.multiselectActions; - /** the popup displayed when 'for all selected...' is clicked */ - this.actionsPopup = null; - this._setUpListeners(); }, @@ -288,9 +280,45 @@ _setUpBehaviors : function( $where ){ $where = $where || this.$el; $where.find( '.controls [title]' ).tooltip({ placement: 'bottom' }); + // set up the pupup for actions available when multi selecting + this._renderMultiselectActionMenu( $where ); return this; }, + /** render a menu containing the actions available to sets of selected items */ + _renderMultiselectActionMenu : function( $where ){ + $where = $where || this.$el; + var $menu = $where.find( '.list-action-menu' ), + actions = this.multiselectActions(); + if( !actions.length ){ + return $menu.empty(); + } + + var $newMenu = $([ + '<div class="list-action-menu btn-group">', + '<button class="list-action-menu-btn btn btn-default dropdown-toggle" data-toggle="dropdown">', + _l( 'For all selected' ), '...', + '</button>', + '<ul class="dropdown-menu pull-right" role="menu">', '</ul>', + '</div>' + ].join('')); + var $actions = actions.map( function( action ){ + var html = [ '<li><a href="javascript:void(0);">', action.html, '</a></li>' ].join( '' ); + return $( html ).click( action.func ); + }); + $newMenu.find( 'ul' ).append( $actions ); + $menu.replaceWith( $newMenu ); + return $newMenu; + }, + + /** return a list of plain objects used to render multiselect actions menu. Each object should have: + * html: an html string used as the anchor contents + * func: a function called when the anchor is clicked (passed the click event) + */ + multiselectActions : function(){ + return []; + }, + // ------------------------------------------------------------------------ sub-$element shortcuts /** the scroll container for this panel - can be $el, $el.parent(), or grandparent depending on context */ $scrollContainer : function(){ @@ -790,9 +818,8 @@ '<button class="deselect-all btn btn-default"', 'data-mode="select">', _l( 'None' ), '</button>', '</div>', - //'<button class="list-action-popup-btn btn btn-default">', - // _l( 'For all selected' ), '...', - //'</button>', + '<div class="list-action-menu btn-group">', + '</div>', '</div>', '</div>' ]); @@ -929,9 +956,8 @@ '<button class="deselect-all btn btn-default"', 'data-mode="select">', _l( 'None' ), '</button>', '</div>', - //'<button class="list-action-popup-btn btn btn-default">', - // _l( 'For all selected' ), '...', - //'</button>', + '<div class="list-action-menu btn-group">', + '</div>', '</div>', '</div>' ]); diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 static/scripts/mvc/history/history-contents.js --- a/static/scripts/mvc/history/history-contents.js +++ b/static/scripts/mvc/history/history-contents.js @@ -25,7 +25,6 @@ /** since history content is a mix, override model fn into a factory, creating based on history_content_type */ model : function( attrs, options ) { - //console.debug( 'HistoryContents.model:', attrs, options ); //TODO: can we move the type_id stuff here? //attrs.type_id = typeIdStr( attrs ); @@ -185,16 +184,36 @@ return deferred; }, + isCopyable : function( contentsJSON ){ + var copyableModelClasses = [ + 'HistoryDatasetAssociation', + 'HistoryDatasetCollectionAssociation' + ]; + return ( ( _.isObject( contentsJSON ) && contentsJSON.id ) + && ( _.contains( copyableModelClasses, contentsJSON.model_class ) ) ); + }, + /** copy an existing, accessible hda into this collection */ - copy : function( id, contentType ){ - contentType = contentType || 'hda'; - var type = ( contentType === 'hdca'? 'dataset_collection' : 'dataset' ), - collection = this; - - var xhr = jQuery.post( this.url(), { - type : type, + copy : function( json ){ + var id, type, contentType; + if( _.isString( json ) ){ + id = json; + contentType = 'hda'; + type = 'dataset'; + } else { + id = json.id; + contentType = ({ + 'HistoryDatasetAssociation' : 'hda', + 'LibraryDatasetDatasetAssociation' : 'ldda', + 'HistoryDatasetCollectionAssociation' : 'hdca' + })[ json.model_class ] || 'hda'; + type = ( contentType === 'hdca'? 'dataset_collection' : 'dataset' ); + } + var collection = this, + xhr = jQuery.post( this.url(), { + content : id, source : contentType, - content : id + type : type }) .done( function( json ){ collection.add([ json ]); diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 static/scripts/mvc/history/history-panel-edit.js --- a/static/scripts/mvc/history/history-panel-edit.js +++ b/static/scripts/mvc/history/history-panel-edit.js @@ -69,8 +69,6 @@ /** is the panel currently showing the dataset selection controls? */ this.annotationEditorShown = attributes.annotationEditorShown || false; this.tagsEditorShown = attributes.tagsEditorShown || false; - - this.multiselectActions = attributes.multiselectActions || this._getActions(); }, /** Override to handle history as drag-drop target */ @@ -210,11 +208,6 @@ _super.prototype._setUpBehaviors.call( this, $where ); if( !this.model ){ return; } - // set up the pupup for actions available when multi selecting - if( this.multiselectActions.length ){ - this.actionsPopup = new PopupMenu( $where.find( '.list-action-popup-btn' ), this.multiselectActions ); - } - // anon users shouldn't have access to any of the following if( ( !Galaxy.currUser || Galaxy.currUser.isAnonymous() ) || ( Galaxy.currUser.id !== this.model.get( 'user_id' ) ) ){ @@ -245,7 +238,7 @@ /** return a new popup menu for choosing a multi selection action * ajax calls made for multiple datasets are queued */ - _getActions : function(){ + multiselectActions : function(){ var panel = this, actions = [ { html: _l( 'Hide datasets' ), func: function(){ diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 static/scripts/mvc/history/history-panel.js --- a/static/scripts/mvc/history/history-panel.js +++ b/static/scripts/mvc/history/history-panel.js @@ -7,6 +7,7 @@ "mvc/collection/collection-panel", "mvc/user/user-model", "ui/fa-icon-button", + "mvc/ui/popup-menu", "mvc/base-mvc", "utils/localization", "ui/search-input" @@ -19,6 +20,7 @@ COLLECTION_PANEL, USER, faIconButton, + PopupMenu, BASE_MVC, _l ){ @@ -302,7 +304,8 @@ /** In this override, add a btn to toggle the selectors */ _buildNewRender : function(){ var $newRender = _super.prototype._buildNewRender.call( this ); - if( this.multiselectActions.length ){ + //if( this.views.length && this.multiselectActions().length ){ + if( this.multiselectActions().length ){ $newRender.find( '.controls .actions' ).prepend( this._renderSelectButton() ); } return $newRender; @@ -617,10 +620,18 @@ '<div class="actions"></div>', '<div class="messages">', - '<% if( history.deleted ){ %>', + '<% if( history.deleted && history.purged ){ %>', + '<div class="deleted-msg warningmessagesmall">', + _l( 'This history has been purged and deleted' ), + '</div>', + '<% } else if( history.deleted ){ %>', '<div class="deleted-msg warningmessagesmall">', _l( 'This history has been deleted' ), '</div>', + '<% } else if( history.purged ){ %>', + '<div class="deleted-msg warningmessagesmall">', + _l( 'This history has been purged' ), + '</div>', '<% } %>', '<% if( history.message ){ %>', @@ -646,8 +657,8 @@ '<button class="deselect-all btn btn-default"', 'data-mode="select">', _l( 'None' ), '</button>', '</div>', - '<button class="list-action-popup-btn btn btn-default">', - _l( 'For all selected' ), '...</button>', + '<div class="list-action-menu btn-group">', + '</div>', '</div>', '</div>' ], 'history' ); diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 static/scripts/mvc/history/multi-panel.js --- a/static/scripts/mvc/history/multi-panel.js +++ b/static/scripts/mvc/history/multi-panel.js @@ -353,8 +353,8 @@ '</a></li>', '<% } %>', '</ul>', - '<% } %>', - '</div>', + '</div>', + '<% } %>', '</div>' ].join( '' ), { variable: 'data' }), @@ -669,11 +669,7 @@ /** set up listeners for a column and it's panel - handling: hda lazy-loading, drag and drop */ setUpColumnListeners : function setUpColumnListeners( column ){ - var multipanel = this, - modelClassToSource = { - 'HistoryDatasetAssociation' : 'hda', - 'HistoryDatasetCollectionAssociation' : 'hdca' - }; + var multipanel = this; multipanel.listenTo( column, { //'all': function(){ console.info( 'column ' + column + ':', arguments ) }, 'in-view': multipanel.queueHdaFetch @@ -691,20 +687,18 @@ multipanel.currentColumnDropTargetOff(); }, 'droptarget:drop': function( ev, data, panel ){ - //note: this will bad copy sources fail silently + //note: bad copy sources fail silently var toCopy = multipanel._dropData.filter( function( json ){ - return ( ( _.isObject( json ) && json.id ) - && ( _.contains( _.keys( modelClassToSource ), json.model_class ) ) ); + return panel.model.contents.isCopyable( json ); }); multipanel._dropData = null; var queue = new ajaxQueue.NamedAjaxQueue(); toCopy.forEach( function( content ){ - var contentType = modelClassToSource[ content.model_class ]; queue.add({ name : 'copy-' + content.id, fn : function(){ - return panel.model.contents.copy( content.id, contentType ); + return panel.model.contents.copy( content ); } }); }); @@ -714,7 +708,6 @@ }); } }); - }, /** conv. fn to count the columns in columnMap */ diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 static/scripts/mvc/list/list-panel.js --- a/static/scripts/mvc/list/list-panel.js +++ b/static/scripts/mvc/list/list-panel.js @@ -46,9 +46,6 @@ /** string used for search placeholder */ searchPlaceholder : _l( 'search' ), - /** actions available for multiselected items */ - multiselectActions : [], - // ......................................................................... SET UP /** Set up the view, set up storage, bind listeners to HistoryContents events * @param {Object} attributes optional settings for the list @@ -103,11 +100,6 @@ this.title = attributes.title || ''; this.subtitle = attributes.subtitle || ''; - // allow override of multiselectActions through attributes - this.multiselectActions = attributes.multiselectActions || this.multiselectActions; - /** the popup displayed when 'for all selected...' is clicked */ - this.actionsPopup = null; - this._setUpListeners(); }, @@ -288,9 +280,45 @@ _setUpBehaviors : function( $where ){ $where = $where || this.$el; $where.find( '.controls [title]' ).tooltip({ placement: 'bottom' }); + // set up the pupup for actions available when multi selecting + this._renderMultiselectActionMenu( $where ); return this; }, + /** render a menu containing the actions available to sets of selected items */ + _renderMultiselectActionMenu : function( $where ){ + $where = $where || this.$el; + var $menu = $where.find( '.list-action-menu' ), + actions = this.multiselectActions(); + if( !actions.length ){ + return $menu.empty(); + } + + var $newMenu = $([ + '<div class="list-action-menu btn-group">', + '<button class="list-action-menu-btn btn btn-default dropdown-toggle" data-toggle="dropdown">', + _l( 'For all selected' ), '...', + '</button>', + '<ul class="dropdown-menu pull-right" role="menu">', '</ul>', + '</div>' + ].join('')); + var $actions = actions.map( function( action ){ + var html = [ '<li><a href="javascript:void(0);">', action.html, '</a></li>' ].join( '' ); + return $( html ).click( action.func ); + }); + $newMenu.find( 'ul' ).append( $actions ); + $menu.replaceWith( $newMenu ); + return $newMenu; + }, + + /** return a list of plain objects used to render multiselect actions menu. Each object should have: + * html: an html string used as the anchor contents + * func: a function called when the anchor is clicked (passed the click event) + */ + multiselectActions : function(){ + return []; + }, + // ------------------------------------------------------------------------ sub-$element shortcuts /** the scroll container for this panel - can be $el, $el.parent(), or grandparent depending on context */ $scrollContainer : function(){ @@ -790,9 +818,8 @@ '<button class="deselect-all btn btn-default"', 'data-mode="select">', _l( 'None' ), '</button>', '</div>', - //'<button class="list-action-popup-btn btn btn-default">', - // _l( 'For all selected' ), '...', - //'</button>', + '<div class="list-action-menu btn-group">', + '</div>', '</div>', '</div>' ]); @@ -929,9 +956,8 @@ '<button class="deselect-all btn btn-default"', 'data-mode="select">', _l( 'None' ), '</button>', '</div>', - //'<button class="list-action-popup-btn btn btn-default">', - // _l( 'For all selected' ), '...', - //'</button>', + '<div class="list-action-menu btn-group">', + '</div>', '</div>', '</div>' ]); diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 static/scripts/packed/mvc/history/history-contents.js --- a/static/scripts/packed/mvc/history/history-contents.js +++ b/static/scripts/packed/mvc/history/history-contents.js @@ -1,1 +1,1 @@ -define(["mvc/history/history-content-model","mvc/history/hda-model","mvc/history/hdca-model","mvc/base-mvc","utils/localization"],function(g,e,b,a,c){var f=Backbone.Collection.extend(a.LoggableMixin).extend({model:function(i,h){if(i.history_content_type==="dataset"){return new e.HistoryDatasetAssociation(i,h)}else{if(i.history_content_type==="dataset_collection"){switch(i.collection_type){case"list":return new b.HistoryListDatasetCollection(i,h);case"paired":return new b.HistoryPairDatasetCollection(i,h);case"list:paired":return new b.HistoryListPairedDatasetCollection(i,h)}throw new TypeError("Unknown collection_type: "+i.collection_type)}}throw new TypeError("Unknown history_content_type: "+i.history_content_type)},initialize:function(i,h){h=h||{};this.historyId=h.historyId;this.on("all",function(){this.debug(this+".event:",arguments)})},urlRoot:galaxy_config.root+"api/histories",url:function(){return this.urlRoot+"/"+this.historyId+"/contents"},ids:function(){return this.map(function(h){return h.get("id")})},notReady:function(){return this.filter(function(h){return !h.inReadyState()})},running:function(){var h=[];this.each(function(j){var i=!j.inReadyState();if(i){h.push(j.get("id"))}});return h},getByHid:function(h){return _.first(this.filter(function(i){return i.get("hid")===h}))},getVisible:function(h,k,j){j=j||[];this.debug("checking isVisible");var i=new f(this.filter(function(l){return l.isVisible(h,k)}));_.each(j,function(l){if(!_.isFunction(l)){return}i=new f(i.filter(l))});return i},haveDetails:function(){return this.all(function(h){return h.hasDetails()})},fetchAllDetails:function(i){i=i||{};var h={details:"all"};i.data=(i.data)?(_.extend(i.data,h)):(h);return this.fetch(i)},ajaxQueue:function(m,j){var i=jQuery.Deferred(),h=this.length,l=[];if(!h){i.resolve([]);return i}var k=this.chain().reverse().map(function(o,n){return function(){var p=m.call(o,j);p.done(function(q){i.notify({curr:n,total:h,response:q,model:o})});p.always(function(q){l.push(q);if(k.length){k.shift()()}else{i.resolve(l)}})}}).value();k.shift()();return i},copy:function(l,k){k=k||"hda";var h=(k==="hdca"?"dataset_collection":"dataset"),j=this;var i=jQuery.post(this.url(),{type:h,source:k,content:l}).done(function(m){j.add([m])}).fail(function(n,m,o){j.trigger("error",j,i,{},"Error copying contents",{type:h,id:l,source:k})});return i},matches:function(h){return this.filter(function(i){return i.matches(h)})},set:function(j,h){this.debug("set:",j);var i=this;j=_.map(j,function(m){var l=m.attributes||m,n=g.typeIdStr(l.history_content_type,l.id),o=i.get(n);if(!o){return m}var k=_.clone(o.attributes);_.extend(k,m);return k});Backbone.Collection.prototype.set.call(this,j,h)},promoteToHistoryDatasetCollection:function d(m,k,i){i=i||{};i.url=this.url();i.type="POST";var o=k;var l=[],h=null;if(k==="list"){this.chain().each(function(r){var p=r.attributes.name;var s=r.get("id");var q=r.attributes.history_content_type;if(q==="dataset"){if(o!=="list"){this.log("Invalid collection type")}l.push({name:p,src:"hda",id:s})}else{if(o==="list"){o="list:"+r.attributes.collection_type}else{if(o!=="list:"+r.attributes.collection_type){this.log("Invalid collection type")}}l.push({name:p,src:"hdca",id:s})}});h="New Dataset List"}else{if(k==="paired"){var j=this.ids();if(j.length!==2){}l.push({name:"forward",src:"hda",id:j[0]});l.push({name:"reverse",src:"hda",id:j[1]});h="New Dataset Pair"}}i.data={type:"dataset_collection",name:h,collection_type:o,element_identifiers:JSON.stringify(l)};var n=jQuery.ajax(i);n.done(function(r,p,q){m.refresh()});n.fail(function(r,p,q){if(r.responseJSON&&r.responseJSON.error){error=r.responseJSON.error}else{error=r.responseJSON}r.responseText=error});return n},clone:function(){var h=Backbone.Collection.prototype.clone.call(this);h.historyId=this.historyId;return h},print:function(){var h=this;h.each(function(i){h.debug(i);if(i.elements){h.debug("\t elements:",i.elements)}})},toString:function(){return(["HistoryContents(",[this.historyId,this.length].join(),")"].join(""))}});return{HistoryContents:f}}); \ No newline at end of file +define(["mvc/history/history-content-model","mvc/history/hda-model","mvc/history/hdca-model","mvc/base-mvc","utils/localization"],function(g,e,b,a,c){var f=Backbone.Collection.extend(a.LoggableMixin).extend({model:function(i,h){if(i.history_content_type==="dataset"){return new e.HistoryDatasetAssociation(i,h)}else{if(i.history_content_type==="dataset_collection"){switch(i.collection_type){case"list":return new b.HistoryListDatasetCollection(i,h);case"paired":return new b.HistoryPairDatasetCollection(i,h);case"list:paired":return new b.HistoryListPairedDatasetCollection(i,h)}throw new TypeError("Unknown collection_type: "+i.collection_type)}}throw new TypeError("Unknown history_content_type: "+i.history_content_type)},initialize:function(i,h){h=h||{};this.historyId=h.historyId;this.on("all",function(){this.debug(this+".event:",arguments)})},urlRoot:galaxy_config.root+"api/histories",url:function(){return this.urlRoot+"/"+this.historyId+"/contents"},ids:function(){return this.map(function(h){return h.get("id")})},notReady:function(){return this.filter(function(h){return !h.inReadyState()})},running:function(){var h=[];this.each(function(j){var i=!j.inReadyState();if(i){h.push(j.get("id"))}});return h},getByHid:function(h){return _.first(this.filter(function(i){return i.get("hid")===h}))},getVisible:function(h,k,j){j=j||[];this.debug("checking isVisible");var i=new f(this.filter(function(l){return l.isVisible(h,k)}));_.each(j,function(l){if(!_.isFunction(l)){return}i=new f(i.filter(l))});return i},haveDetails:function(){return this.all(function(h){return h.hasDetails()})},fetchAllDetails:function(i){i=i||{};var h={details:"all"};i.data=(i.data)?(_.extend(i.data,h)):(h);return this.fetch(i)},ajaxQueue:function(m,j){var i=jQuery.Deferred(),h=this.length,l=[];if(!h){i.resolve([]);return i}var k=this.chain().reverse().map(function(o,n){return function(){var p=m.call(o,j);p.done(function(q){i.notify({curr:n,total:h,response:q,model:o})});p.always(function(q){l.push(q);if(k.length){k.shift()()}else{i.resolve(l)}})}}).value();k.shift()();return i},isCopyable:function(i){var h=["HistoryDatasetAssociation","HistoryDatasetCollectionAssociation"];return((_.isObject(i)&&i.id)&&(_.contains(h,i.model_class)))},copy:function(h){var m,i,l;if(_.isString(h)){m=h;l="hda";i="dataset"}else{m=h.id;l=({HistoryDatasetAssociation:"hda",LibraryDatasetDatasetAssociation:"ldda",HistoryDatasetCollectionAssociation:"hdca"})[h.model_class]||"hda";i=(l==="hdca"?"dataset_collection":"dataset")}var k=this,j=jQuery.post(this.url(),{content:m,source:l,type:i}).done(function(n){k.add([n])}).fail(function(o,n,p){k.trigger("error",k,j,{},"Error copying contents",{type:i,id:m,source:l})});return j},matches:function(h){return this.filter(function(i){return i.matches(h)})},set:function(j,h){this.debug("set:",j);var i=this;j=_.map(j,function(m){var l=m.attributes||m,n=g.typeIdStr(l.history_content_type,l.id),o=i.get(n);if(!o){return m}var k=_.clone(o.attributes);_.extend(k,m);return k});Backbone.Collection.prototype.set.call(this,j,h)},promoteToHistoryDatasetCollection:function d(m,k,i){i=i||{};i.url=this.url();i.type="POST";var o=k;var l=[],h=null;if(k==="list"){this.chain().each(function(r){var p=r.attributes.name;var s=r.get("id");var q=r.attributes.history_content_type;if(q==="dataset"){if(o!=="list"){this.log("Invalid collection type")}l.push({name:p,src:"hda",id:s})}else{if(o==="list"){o="list:"+r.attributes.collection_type}else{if(o!=="list:"+r.attributes.collection_type){this.log("Invalid collection type")}}l.push({name:p,src:"hdca",id:s})}});h="New Dataset List"}else{if(k==="paired"){var j=this.ids();if(j.length!==2){}l.push({name:"forward",src:"hda",id:j[0]});l.push({name:"reverse",src:"hda",id:j[1]});h="New Dataset Pair"}}i.data={type:"dataset_collection",name:h,collection_type:o,element_identifiers:JSON.stringify(l)};var n=jQuery.ajax(i);n.done(function(r,p,q){m.refresh()});n.fail(function(r,p,q){if(r.responseJSON&&r.responseJSON.error){error=r.responseJSON.error}else{error=r.responseJSON}r.responseText=error});return n},clone:function(){var h=Backbone.Collection.prototype.clone.call(this);h.historyId=this.historyId;return h},print:function(){var h=this;h.each(function(i){h.debug(i);if(i.elements){h.debug("\t elements:",i.elements)}})},toString:function(){return(["HistoryContents(",[this.historyId,this.length].join(),")"].join(""))}});return{HistoryContents:f}}); \ No newline at end of file diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 static/scripts/packed/mvc/history/history-panel-edit.js --- a/static/scripts/packed/mvc/history/history-panel-edit.js +++ b/static/scripts/packed/mvc/history/history-panel-edit.js @@ -1,1 +1,1 @@ -define(["mvc/history/history-panel","mvc/history/history-contents","mvc/dataset/states","mvc/history/hda-model","mvc/history/hda-li-edit","mvc/history/hdca-li-edit","mvc/tags","mvc/annotations","ui/fa-icon-button","mvc/ui/popup-menu","utils/localization"],function(h,j,m,f,e,i,l,c,b,a,d){var k=h.HistoryPanel;var g=k.extend({HDAViewClass:e.HDAListItemEdit,HDCAViewClass:i.HDCAListItemEdit,initialize:function(n){n=n||{};k.prototype.initialize.call(this,n);this.tagsEditor=null;this.annotationEditor=null;this.purgeAllowed=n.purgeAllowed||false;this.annotationEditorShown=n.annotationEditorShown||false;this.tagsEditorShown=n.tagsEditorShown||false;this.multiselectActions=n.multiselectActions||this._getActions()},_setUpListeners:function(){var n=this;k.prototype._setUpListeners.call(n);n.on("drop",function(o,p){n.dataDropped(p);n.dropTargetOff()});n.on("view:attached view:removed",function(){n._renderCounts()},n)},_setUpCollectionListeners:function(){k.prototype._setUpCollectionListeners.call(this);this.collection.on("change:deleted",this._handleHdaDeletionChange,this);this.collection.on("change:visible",this._handleHdaVisibleChange,this);this.collection.on("change:purged",function(n){this.model.fetch()},this);return this},_setUpModelListeners:function(){k.prototype._setUpModelListeners.call(this);this.model.on("change:nice_size",this.updateHistoryDiskSize,this);return this},_buildNewRender:function(){var n=k.prototype._buildNewRender.call(this);if(!this.model){return n}if(Galaxy&&Galaxy.currUser&&Galaxy.currUser.id&&Galaxy.currUser.id===this.model.get("user_id")){this._renderTags(n);this._renderAnnotation(n)}return n},renderItems:function(o){var n=k.prototype.renderItems.call(this,o);this._renderCounts(o);return n},_renderCounts:function(p){function o(s,t){return['<a class="',s,'" href="javascript:void(0);">',t,"</a>"].join("")}p=p||this.$el;var n=this.collection.where({deleted:true}),r=this.collection.where({visible:false}),q=[];if(this.views.length){q.push([this.views.length,d("shown")].join(" "))}if(n.length){q.push((!this.showDeleted)?([n.length,o("toggle-deleted-link",d("deleted"))].join(" ")):(o("toggle-deleted-link",d("hide deleted"))))}if(r.length){q.push((!this.showHidden)?([r.length,o("toggle-hidden-link",d("hidden"))].join(" ")):(o("toggle-hidden-link",d("hide hidden"))))}return p.find("> .controls .subtitle").html(q.join(", "))},_renderTags:function(n){var o=this;this.tagsEditor=new l.TagsEditor({model:this.model,el:n.find(".controls .tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){o.toggleHDATagEditors(true,o.fxSpeed)},onhide:function(){o.toggleHDATagEditors(false,o.fxSpeed)},$activator:b({title:d("Edit history tags"),classes:"history-tag-btn",faIcon:"fa-tags"}).appendTo(n.find(".controls .actions"))})},_renderAnnotation:function(n){var o=this;this.annotationEditor=new c.AnnotationEditor({model:this.model,el:n.find(".controls .annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){o.toggleHDAAnnotationEditors(true,o.fxSpeed)},onhide:function(){o.toggleHDAAnnotationEditors(false,o.fxSpeed)},$activator:b({title:d("Edit history annotation"),classes:"history-annotate-btn",faIcon:"fa-comment"}).appendTo(n.find(".controls .actions"))})},_setUpBehaviors:function(n){n=n||this.$el;k.prototype._setUpBehaviors.call(this,n);if(!this.model){return}if(this.multiselectActions.length){this.actionsPopup=new a(n.find(".list-action-popup-btn"),this.multiselectActions)}if((!Galaxy.currUser||Galaxy.currUser.isAnonymous())||(Galaxy.currUser.id!==this.model.get("user_id"))){return}var o=this,p=".controls .name";n.find(p).attr("title",d("Click to rename history")).tooltip({placement:"bottom"}).make_text_editable({on_finish:function(q){var r=o.model.get("name");if(q&&q!==r){o.$el.find(p).text(q);o.model.save({name:q}).fail(function(){o.$el.find(p).text(o.model.previous("name"))})}else{o.$el.find(p).text(r)}}})},_getActions:function(){var n=this,o=[{html:d("Hide datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype.hide;n.getSelectedModels().ajaxQueue(p)}},{html:d("Unhide datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype.unhide;n.getSelectedModels().ajaxQueue(p)}},{html:d("Delete datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype["delete"];n.getSelectedModels().ajaxQueue(p)}},{html:d("Undelete datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype.undelete;n.getSelectedModels().ajaxQueue(p)}}];if(n.purgeAllowed){o.push({html:d("Permanently delete datasets"),func:function(){if(confirm(d("This will permanently remove the data in your datasets. Are you sure?"))){var p=f.HistoryDatasetAssociation.prototype.purge;n.getSelectedModels().ajaxQueue(p)}}})}o.push({html:d("Build Dataset List"),func:function(){n.getSelectedModels().promoteToHistoryDatasetCollection(n.model,"list")}});o.push({html:d("Build Dataset Pair"),func:function(){n.getSelectedModels().promoteToHistoryDatasetCollection(n.model,"paired")}});o.push({html:d("Build List of Dataset Pairs"),func:_.bind(n._showPairedCollectionModal,n)});return o},_showPairedCollectionModal:function(){var n=this,o=n.getSelectedModels().toJSON().filter(function(p){return p.history_content_type==="dataset"&&p.state===m.OK});if(o.length){require(["mvc/collection/paired-collection-creator"],function(p){window.creator=p.pairedCollectionCreatorModal(o,{historyId:n.model.id})})}else{Galaxy.modal.show({title:d("No valid datasets were selected"),body:d(["Use the checkboxes at the left of the dataset names to select them.","Selected datasets should be error-free and should have completed running."].join(" ")),buttons:{Ok:function(){Galaxy.modal.hide()}},closing_events:true})}},_attachItems:function(n){this.$list(n).append(this.views.reverse().map(function(o){return o.$el}));return this},_attachView:function(o){var n=this;n.views.unshift(o);n.$list().prepend(o.render(0).$el.hide());n.trigger("view:attached",o);o.$el.slideDown(n.fxSpeed,function(){n.trigger("view:attached:rendered")})},_getItemViewOptions:function(o){var n=k.prototype._getItemViewOptions.call(this,o);_.extend(n,{purgeAllowed:this.purgeAllowed,tagsEditorShown:(this.tagsEditor&&!this.tagsEditor.hidden),annotationEditorShown:(this.annotationEditor&&!this.annotationEditor.hidden)});return n},_handleHdaDeletionChange:function(n){if(n.get("deleted")&&!this.showDeleted){this.removeItemView(n)}this._renderCounts()},_handleHdaVisibleChange:function(n){if(n.hidden()&&!this.storage.showHidden){this.removeItemView(n)}this._renderCounts()},toggleHDATagEditors:function(n){var o=Array.prototype.slice.call(arguments,1);_.each(this.views,function(p){if(p.tagsEditor){p.tagsEditor.toggle.apply(p.tagsEditor,o)}})},toggleHDAAnnotationEditors:function(n){var o=Array.prototype.slice.call(arguments,1);_.each(this.views,function(p){if(p.annotationEditor){p.annotationEditor.toggle.apply(p.annotationEditor,o)}})},events:_.extend(_.clone(k.prototype.events),{"click .show-selectors-btn":"toggleSelectors","click .toggle-deleted-link":function(n){this.toggleShowDeleted()},"click .toggle-hidden-link":function(n){this.toggleShowHidden()}}),updateHistoryDiskSize:function(){this.$el.find(".history-size").text(this.model.get("nice_size"))},dropTargetOn:function(){if(this.dropTarget){return this}this.dropTarget=true;var o={dragenter:_.bind(this.dragenter,this),dragover:_.bind(this.dragover,this),dragleave:_.bind(this.dragleave,this),drop:_.bind(this.drop,this)};var p=this._renderDropTarget();this.$list().before([this._renderDropTargetHelp(),p]);for(var n in o){if(o.hasOwnProperty(n)){p.on(n,o[n])}}return this},_renderDropTarget:function(){this.$(".history-drop-target").remove();return $("<div/>").addClass("history-drop-target").css({height:"64px",margin:"0px 10px 10px 10px",border:"1px dashed black","border-radius":"3px"})},_renderDropTargetHelp:function(){this.$(".history-drop-target-help").remove();return $("<div/>").addClass("history-drop-target-help").css({margin:"10px 10px 4px 10px",color:"grey","font-size":"80%","font-style":"italic"}).text(d("Drag datasets here to copy them to the current history"))},dropTargetOff:function(){if(!this.dropTarget){return this}this.dropTarget=false;var o=this.$(".history-drop-target").get(0);for(var n in this._dropHandlers){if(this._dropHandlers.hasOwnProperty(n)){console.debug(n,this._dropHandlers[n]);o.off(n,this._dropHandlers[n])}}this.$(".history-drop-target").remove();this.$(".history-drop-target-help").remove();return this},dropTargetToggle:function(){if(this.dropTarget){this.dropTargetOff()}else{this.dropTargetOn()}return this},dragenter:function(n){n.preventDefault();n.stopPropagation();this.$(".history-drop-target").css("border","2px solid black")},dragover:function(n){n.preventDefault();n.stopPropagation()},dragleave:function(n){n.preventDefault();n.stopPropagation();this.$(".history-drop-target").css("border","1px dashed black")},drop:function(p){p.preventDefault();p.dataTransfer.dropEffect="move";var n=this,q=p.dataTransfer.getData("text");try{q=JSON.parse(q)}catch(o){this.warn("error parsing JSON from drop:",q)}this.trigger("droptarget:drop",p,q,n);return false},dataDropped:function(o){var n=this;if(_.isObject(o)&&o.model_class==="HistoryDatasetAssociation"&&o.id){return n.model.contents.copy(o.id)}return jQuery.when()},toString:function(){return"HistoryPanelEdit("+((this.model)?(this.model.get("name")):(""))+")"}});return{HistoryPanelEdit:g}}); \ No newline at end of file +define(["mvc/history/history-panel","mvc/history/history-contents","mvc/dataset/states","mvc/history/hda-model","mvc/history/hda-li-edit","mvc/history/hdca-li-edit","mvc/tags","mvc/annotations","ui/fa-icon-button","mvc/ui/popup-menu","utils/localization"],function(h,j,m,f,e,i,l,c,b,a,d){var k=h.HistoryPanel;var g=k.extend({HDAViewClass:e.HDAListItemEdit,HDCAViewClass:i.HDCAListItemEdit,initialize:function(n){n=n||{};k.prototype.initialize.call(this,n);this.tagsEditor=null;this.annotationEditor=null;this.purgeAllowed=n.purgeAllowed||false;this.annotationEditorShown=n.annotationEditorShown||false;this.tagsEditorShown=n.tagsEditorShown||false},_setUpListeners:function(){var n=this;k.prototype._setUpListeners.call(n);n.on("drop",function(o,p){n.dataDropped(p);n.dropTargetOff()});n.on("view:attached view:removed",function(){n._renderCounts()},n)},_setUpCollectionListeners:function(){k.prototype._setUpCollectionListeners.call(this);this.collection.on("change:deleted",this._handleHdaDeletionChange,this);this.collection.on("change:visible",this._handleHdaVisibleChange,this);this.collection.on("change:purged",function(n){this.model.fetch()},this);return this},_setUpModelListeners:function(){k.prototype._setUpModelListeners.call(this);this.model.on("change:nice_size",this.updateHistoryDiskSize,this);return this},_buildNewRender:function(){var n=k.prototype._buildNewRender.call(this);if(!this.model){return n}if(Galaxy&&Galaxy.currUser&&Galaxy.currUser.id&&Galaxy.currUser.id===this.model.get("user_id")){this._renderTags(n);this._renderAnnotation(n)}return n},renderItems:function(o){var n=k.prototype.renderItems.call(this,o);this._renderCounts(o);return n},_renderCounts:function(p){function o(s,t){return['<a class="',s,'" href="javascript:void(0);">',t,"</a>"].join("")}p=p||this.$el;var n=this.collection.where({deleted:true}),r=this.collection.where({visible:false}),q=[];if(this.views.length){q.push([this.views.length,d("shown")].join(" "))}if(n.length){q.push((!this.showDeleted)?([n.length,o("toggle-deleted-link",d("deleted"))].join(" ")):(o("toggle-deleted-link",d("hide deleted"))))}if(r.length){q.push((!this.showHidden)?([r.length,o("toggle-hidden-link",d("hidden"))].join(" ")):(o("toggle-hidden-link",d("hide hidden"))))}return p.find("> .controls .subtitle").html(q.join(", "))},_renderTags:function(n){var o=this;this.tagsEditor=new l.TagsEditor({model:this.model,el:n.find(".controls .tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){o.toggleHDATagEditors(true,o.fxSpeed)},onhide:function(){o.toggleHDATagEditors(false,o.fxSpeed)},$activator:b({title:d("Edit history tags"),classes:"history-tag-btn",faIcon:"fa-tags"}).appendTo(n.find(".controls .actions"))})},_renderAnnotation:function(n){var o=this;this.annotationEditor=new c.AnnotationEditor({model:this.model,el:n.find(".controls .annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){o.toggleHDAAnnotationEditors(true,o.fxSpeed)},onhide:function(){o.toggleHDAAnnotationEditors(false,o.fxSpeed)},$activator:b({title:d("Edit history annotation"),classes:"history-annotate-btn",faIcon:"fa-comment"}).appendTo(n.find(".controls .actions"))})},_setUpBehaviors:function(n){n=n||this.$el;k.prototype._setUpBehaviors.call(this,n);if(!this.model){return}if((!Galaxy.currUser||Galaxy.currUser.isAnonymous())||(Galaxy.currUser.id!==this.model.get("user_id"))){return}var o=this,p=".controls .name";n.find(p).attr("title",d("Click to rename history")).tooltip({placement:"bottom"}).make_text_editable({on_finish:function(q){var r=o.model.get("name");if(q&&q!==r){o.$el.find(p).text(q);o.model.save({name:q}).fail(function(){o.$el.find(p).text(o.model.previous("name"))})}else{o.$el.find(p).text(r)}}})},multiselectActions:function(){var n=this,o=[{html:d("Hide datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype.hide;n.getSelectedModels().ajaxQueue(p)}},{html:d("Unhide datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype.unhide;n.getSelectedModels().ajaxQueue(p)}},{html:d("Delete datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype["delete"];n.getSelectedModels().ajaxQueue(p)}},{html:d("Undelete datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype.undelete;n.getSelectedModels().ajaxQueue(p)}}];if(n.purgeAllowed){o.push({html:d("Permanently delete datasets"),func:function(){if(confirm(d("This will permanently remove the data in your datasets. Are you sure?"))){var p=f.HistoryDatasetAssociation.prototype.purge;n.getSelectedModels().ajaxQueue(p)}}})}o.push({html:d("Build Dataset List"),func:function(){n.getSelectedModels().promoteToHistoryDatasetCollection(n.model,"list")}});o.push({html:d("Build Dataset Pair"),func:function(){n.getSelectedModels().promoteToHistoryDatasetCollection(n.model,"paired")}});o.push({html:d("Build List of Dataset Pairs"),func:_.bind(n._showPairedCollectionModal,n)});return o},_showPairedCollectionModal:function(){var n=this,o=n.getSelectedModels().toJSON().filter(function(p){return p.history_content_type==="dataset"&&p.state===m.OK});if(o.length){require(["mvc/collection/paired-collection-creator"],function(p){window.creator=p.pairedCollectionCreatorModal(o,{historyId:n.model.id})})}else{Galaxy.modal.show({title:d("No valid datasets were selected"),body:d(["Use the checkboxes at the left of the dataset names to select them.","Selected datasets should be error-free and should have completed running."].join(" ")),buttons:{Ok:function(){Galaxy.modal.hide()}},closing_events:true})}},_attachItems:function(n){this.$list(n).append(this.views.reverse().map(function(o){return o.$el}));return this},_attachView:function(o){var n=this;n.views.unshift(o);n.$list().prepend(o.render(0).$el.hide());n.trigger("view:attached",o);o.$el.slideDown(n.fxSpeed,function(){n.trigger("view:attached:rendered")})},_getItemViewOptions:function(o){var n=k.prototype._getItemViewOptions.call(this,o);_.extend(n,{purgeAllowed:this.purgeAllowed,tagsEditorShown:(this.tagsEditor&&!this.tagsEditor.hidden),annotationEditorShown:(this.annotationEditor&&!this.annotationEditor.hidden)});return n},_handleHdaDeletionChange:function(n){if(n.get("deleted")&&!this.showDeleted){this.removeItemView(n)}this._renderCounts()},_handleHdaVisibleChange:function(n){if(n.hidden()&&!this.storage.showHidden){this.removeItemView(n)}this._renderCounts()},toggleHDATagEditors:function(n){var o=Array.prototype.slice.call(arguments,1);_.each(this.views,function(p){if(p.tagsEditor){p.tagsEditor.toggle.apply(p.tagsEditor,o)}})},toggleHDAAnnotationEditors:function(n){var o=Array.prototype.slice.call(arguments,1);_.each(this.views,function(p){if(p.annotationEditor){p.annotationEditor.toggle.apply(p.annotationEditor,o)}})},events:_.extend(_.clone(k.prototype.events),{"click .show-selectors-btn":"toggleSelectors","click .toggle-deleted-link":function(n){this.toggleShowDeleted()},"click .toggle-hidden-link":function(n){this.toggleShowHidden()}}),updateHistoryDiskSize:function(){this.$el.find(".history-size").text(this.model.get("nice_size"))},dropTargetOn:function(){if(this.dropTarget){return this}this.dropTarget=true;var o={dragenter:_.bind(this.dragenter,this),dragover:_.bind(this.dragover,this),dragleave:_.bind(this.dragleave,this),drop:_.bind(this.drop,this)};var p=this._renderDropTarget();this.$list().before([this._renderDropTargetHelp(),p]);for(var n in o){if(o.hasOwnProperty(n)){p.on(n,o[n])}}return this},_renderDropTarget:function(){this.$(".history-drop-target").remove();return $("<div/>").addClass("history-drop-target").css({height:"64px",margin:"0px 10px 10px 10px",border:"1px dashed black","border-radius":"3px"})},_renderDropTargetHelp:function(){this.$(".history-drop-target-help").remove();return $("<div/>").addClass("history-drop-target-help").css({margin:"10px 10px 4px 10px",color:"grey","font-size":"80%","font-style":"italic"}).text(d("Drag datasets here to copy them to the current history"))},dropTargetOff:function(){if(!this.dropTarget){return this}this.dropTarget=false;var o=this.$(".history-drop-target").get(0);for(var n in this._dropHandlers){if(this._dropHandlers.hasOwnProperty(n)){console.debug(n,this._dropHandlers[n]);o.off(n,this._dropHandlers[n])}}this.$(".history-drop-target").remove();this.$(".history-drop-target-help").remove();return this},dropTargetToggle:function(){if(this.dropTarget){this.dropTargetOff()}else{this.dropTargetOn()}return this},dragenter:function(n){n.preventDefault();n.stopPropagation();this.$(".history-drop-target").css("border","2px solid black")},dragover:function(n){n.preventDefault();n.stopPropagation()},dragleave:function(n){n.preventDefault();n.stopPropagation();this.$(".history-drop-target").css("border","1px dashed black")},drop:function(p){p.preventDefault();p.dataTransfer.dropEffect="move";var n=this,q=p.dataTransfer.getData("text");try{q=JSON.parse(q)}catch(o){this.warn("error parsing JSON from drop:",q)}this.trigger("droptarget:drop",p,q,n);return false},dataDropped:function(o){var n=this;if(_.isObject(o)&&o.model_class==="HistoryDatasetAssociation"&&o.id){return n.model.contents.copy(o.id)}return jQuery.when()},toString:function(){return"HistoryPanelEdit("+((this.model)?(this.model.get("name")):(""))+")"}});return{HistoryPanelEdit:g}}); \ No newline at end of file diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 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/list/list-panel","mvc/history/history-model","mvc/history/history-contents","mvc/history/hda-li","mvc/history/hdca-li","mvc/collection/collection-panel","mvc/user/user-model","ui/fa-icon-button","mvc/base-mvc","utils/localization","ui/search-input"],function(e,g,m,c,a,n,h,b,p,f){var k=p.SessionStorageModel.extend({defaults:{expandedIds:{},show_deleted:false,show_hidden:false},addExpanded:function(q){var r="expandedIds";this.save(r,_.extend(this.get(r),_.object([q.id],[q.get("id")])))},removeExpanded:function(q){var r="expandedIds";this.save(r,_.omit(this.get(r),q.id))},toString:function(){return"HistoryPrefs("+this.id+")"}});k.storageKeyPrefix="history:";k.historyStorageKey=function i(q){if(!q){throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+q)}return(k.storageKeyPrefix+q)};k.get=function d(q){return new k({id:k.historyStorageKey(q)})};k.clearAll=function j(r){for(var q in sessionStorage){if(q.indexOf(k.storageKeyPrefix)===0){sessionStorage.removeItem(q)}}};var o=e.ModelListPanel;var l=o.extend({HDAViewClass:c.HDAListItemView,HDCAViewClass:a.HDCAListItemView,collectionClass:m.HistoryContents,modelCollectionKey:"contents",tagName:"div",className:o.prototype.className+" history-panel",emptyMsg:f("This history is empty"),noneFoundMsg:f("No matching datasets found"),searchPlaceholder:f("search datasets"),initialize:function(q){o.prototype.initialize.call(this,q);this.linkTarget=q.linkTarget||"_blank"},freeModel:function(){o.prototype.freeModel.call(this);if(this.model){this.model.clearUpdateTimeout()}return this},_setUpListeners:function(){o.prototype._setUpListeners.call(this);this.on("error",function(r,u,q,t,s){this.errorHandler(r,u,q,t,s)});this.on("loading-done",function(){if(!this.views.length){this.trigger("empty-history",this)}})},loadHistoryWithDetails:function(t,s,r,u){this.info("loadHistoryWithDetails:",t,s,r,u);var q=function(v){return _.values(k.get(v.id).get("expandedIds"))};return this.loadHistory(t,s,r,u,q)},loadHistory:function(u,t,s,v,q){this.info("loadHistory:",u,t,s,v,q);var r=this;t=t||{};r.trigger("loading",r);var w=g.History.getHistoryData(u,{historyFn:s,contentsFn:v,detailIdsFn:t.initiallyExpanded||q});return r._loadHistoryFromXHR(w,t).fail(function(z,x,y){r.trigger("error",r,z,t,f("An error was encountered while "+x),{historyId:u,history:y||{}})}).always(function(){r.trigger("loading-done",r)})},_loadHistoryFromXHR:function(s,r){var q=this;s.then(function(t,u){q.JSONToModel(t,u,r);q.render()});s.fail(function(u,t){q.render()});return s},refreshContents:function(r,q){if(this.model){return this.model.refresh(r,q)}return $.when()},JSONToModel:function(t,q,r){this.log("JSONToModel:",t,q,r);r=r||{};var s=new g.History(t,q,r);this.setModel(s);return s},setModel:function(r,q){q=q||{};o.prototype.setModel.call(this,r,q);if(this.model){this._setUpWebStorage(q.initiallyExpanded,q.show_deleted,q.show_hidden)}},_setUpWebStorage:function(r,q,s){if(this.storage){this.stopListening(this.storage)}this.storage=new k({id:k.historyStorageKey(this.model.get("id"))});if(_.isObject(r)){this.storage.set("expandedIds",r)}if(_.isBoolean(q)){this.storage.set("show_deleted",q)}if(_.isBoolean(s)){this.storage.set("show_hidden",s)}this.trigger("new-storage",this.storage,this);this.log(this+" (init'd) storage:",this.storage.get());this.listenTo(this.storage,{"change:show_deleted":function(t,u){this.showDeleted=u},"change:show_hidden":function(t,u){this.showHidden=u}},this);this.showDeleted=(q!==undefined)?q:this.storage.get("show_deleted");this.showHidden=(s!==undefined)?s:this.storage.get("show_hidden");return this},_buildNewRender:function(){var q=o.prototype._buildNewRender.call(this);if(this.multiselectActions.length){q.find(".controls .actions").prepend(this._renderSelectButton())}return q},_renderSelectButton:function(q){return b({title:f("Operations on multiple datasets"),classes:"show-selectors-btn",faIcon:"fa-check-square-o"})},_getItemViewClass:function(q){var r=q.get("history_content_type");switch(r){case"dataset":return this.HDAViewClass;case"dataset_collection":return this.HDCAViewClass}throw new TypeError("Unknown history_content_type: "+r)},_filterItem:function(r){var q=this;return(o.prototype._filterItem.call(q,r)&&(!r.hidden()||q.showHidden)&&(!r.isDeletedOrPurged()||q.showDeleted))},_getItemViewOptions:function(r){var q=o.prototype._getItemViewOptions.call(this,r);return _.extend(q,{linkTarget:this.linkTarget,expanded:!!this.storage.get("expandedIds")[r.id],hasUser:this.model.ownedByCurrUser()})},_setUpItemViewListeners:function(r){var q=this;o.prototype._setUpItemViewListeners.call(q,r);r.on("expanded",function(s){q.storage.addExpanded(s.model)});r.on("collapsed",function(s){q.storage.removeExpanded(s.model)});return this},getSelectedModels:function(){var q=o.prototype.getSelectedModels.call(this);q.historyId=this.collection.historyId;return q},events:_.extend(_.clone(o.prototype.events),{"click .show-selectors-btn":"toggleSelectors"}),toggleShowDeleted:function(q,r){q=(q!==undefined)?(q):(!this.showDeleted);r=(r!==undefined)?(r):(true);this.showDeleted=q;if(r){this.storage.set("show_deleted",q)}this.trigger("show-hidden",q);this.renderItems();return this.showDeleted},toggleShowHidden:function(q,r){q=(q!==undefined)?(q):(!this.showHidden);r=(r!==undefined)?(r):(true);this.showHidden=q;if(r){this.storage.set("show_hidden",q)}this.trigger("show-hidden",q);this.renderItems();return this.showHidden},_firstSearch:function(q){var r=this,s=".history-search-input";this.log("onFirstSearch",q);if(r.model.contents.haveDetails()){r.searchItems(q);return}r.$el.find(s).searchInput("toggle-loading");r.model.contents.fetchAllDetails({silent:true}).always(function(){r.$el.find(s).searchInput("toggle-loading")}).done(function(){r.searchItems(q)})},errorHandler:function(s,v,r,u,t){this.error(s,v,r,u,t);if(v&&v.status===0&&v.readyState===0){}else{if(v&&v.status===502){}else{var q=this._parseErrorMessage(s,v,r,u,t);if(!this.$messages().is(":visible")){this.once("rendered",function(){this.displayMessage("error",q.message,q.details)})}else{this.displayMessage("error",q.message,q.details)}}}},_parseErrorMessage:function(u,x,y,s,q,v){var t=Galaxy.currUser,w={message:this._bePolite(s),details:{message:s,raven:(window.Raven&&_.isFunction(Raven.lastEventId))?(Raven.lastEventId()):(undefined),agent:navigator.userAgent,url:(window.Galaxy)?(Galaxy.lastAjax.url):(undefined),data:(window.Galaxy)?(Galaxy.lastAjax.data):(undefined),options:(x)?(_.omit(y,"xhr")):(y),xhr:x,source:(_.isFunction(u.toJSON))?(u.toJSON()):(u+""),user:(t instanceof h.User)?(t.toJSON()):(t+"")}};_.extend(w.details,q||{});if(x&&_.isFunction(x.getAllResponseHeaders)){var r=x.getAllResponseHeaders();r=_.compact(r.split("\n"));r=_.map(r,function(z){return z.split(": ")});w.details.xhr.responseHeaders=_.object(r)}return w},_bePolite:function(q){q=q||f("An error occurred while getting updates from the server");return q+". "+f("Please contact a Galaxy administrator if the problem persists")+"."},displayMessage:function(v,w,u){var s=this;this.scrollToTop();var t=this.$messages(),q=$("<div/>").addClass(v+"message").html(w);if(!_.isEmpty(u)){var r=$('<a href="javascript:void(0)">Details</a>').click(function(){Galaxy.modal.show(s._messageToModalOptions(v,w,u));return false});q.append(" ",r)}return t.html(q)},_messageToModalOptions:function(t,w,s){var q=this,r={title:"Details"};if(_.isObject(s)){s=_.omit(s,_.functions(s));var v=JSON.stringify(s,null," "),u=$("<pre/>").text(v);r.body=$("<div/>").append(u)}else{r.body=$("<div/>").html(s)}r.buttons={Ok:function(){Galaxy.modal.hide();q.clearMessages()}};return r},clearMessages:function(q){$(q.currentTarget).fadeOut(this.fxSpeed,function(){$(this).remove()});return this},scrollToHid:function(q){return this.scrollToItem(_.first(this.viewsWhereModel({hid:q})))},toString:function(){return"HistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});l.prototype.templates=(function(){var q=p.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= history.name %></div>',"</div>",'<div class="subtitle"></div>','<div class="history-size"><%= history.nice_size %></div>','<div class="actions"></div>','<div class="messages">',"<% if( history.deleted ){ %>",'<div class="deleted-msg warningmessagesmall">',f("This history has been deleted"),"</div>","<% } %>","<% if( history.message ){ %>",'<div class="<%= history.message.level || "info" %>messagesmall">',"<%= history.message.text %>","</div>","<% } %>","</div>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',f("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',f("None"),"</button>","</div>",'<button class="list-action-popup-btn btn btn-default">',f("For all selected"),"...</button>","</div>","</div>"],"history");return _.extend(_.clone(o.prototype.templates),{controls:q})}());return{HistoryPanel:l}}); \ No newline at end of file +define(["mvc/list/list-panel","mvc/history/history-model","mvc/history/history-contents","mvc/history/hda-li","mvc/history/hdca-li","mvc/collection/collection-panel","mvc/user/user-model","ui/fa-icon-button","mvc/ui/popup-menu","mvc/base-mvc","utils/localization","ui/search-input"],function(f,h,n,d,b,o,i,c,a,q,g){var l=q.SessionStorageModel.extend({defaults:{expandedIds:{},show_deleted:false,show_hidden:false},addExpanded:function(r){var s="expandedIds";this.save(s,_.extend(this.get(s),_.object([r.id],[r.get("id")])))},removeExpanded:function(r){var s="expandedIds";this.save(s,_.omit(this.get(s),r.id))},toString:function(){return"HistoryPrefs("+this.id+")"}});l.storageKeyPrefix="history:";l.historyStorageKey=function j(r){if(!r){throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+r)}return(l.storageKeyPrefix+r)};l.get=function e(r){return new l({id:l.historyStorageKey(r)})};l.clearAll=function k(s){for(var r in sessionStorage){if(r.indexOf(l.storageKeyPrefix)===0){sessionStorage.removeItem(r)}}};var p=f.ModelListPanel;var m=p.extend({HDAViewClass:d.HDAListItemView,HDCAViewClass:b.HDCAListItemView,collectionClass:n.HistoryContents,modelCollectionKey:"contents",tagName:"div",className:p.prototype.className+" history-panel",emptyMsg:g("This history is empty"),noneFoundMsg:g("No matching datasets found"),searchPlaceholder:g("search datasets"),initialize:function(r){p.prototype.initialize.call(this,r);this.linkTarget=r.linkTarget||"_blank"},freeModel:function(){p.prototype.freeModel.call(this);if(this.model){this.model.clearUpdateTimeout()}return this},_setUpListeners:function(){p.prototype._setUpListeners.call(this);this.on("error",function(s,v,r,u,t){this.errorHandler(s,v,r,u,t)});this.on("loading-done",function(){if(!this.views.length){this.trigger("empty-history",this)}})},loadHistoryWithDetails:function(u,t,s,v){this.info("loadHistoryWithDetails:",u,t,s,v);var r=function(w){return _.values(l.get(w.id).get("expandedIds"))};return this.loadHistory(u,t,s,v,r)},loadHistory:function(v,u,t,w,r){this.info("loadHistory:",v,u,t,w,r);var s=this;u=u||{};s.trigger("loading",s);var x=h.History.getHistoryData(v,{historyFn:t,contentsFn:w,detailIdsFn:u.initiallyExpanded||r});return s._loadHistoryFromXHR(x,u).fail(function(A,y,z){s.trigger("error",s,A,u,g("An error was encountered while "+y),{historyId:v,history:z||{}})}).always(function(){s.trigger("loading-done",s)})},_loadHistoryFromXHR:function(t,s){var r=this;t.then(function(u,v){r.JSONToModel(u,v,s);r.render()});t.fail(function(v,u){r.render()});return t},refreshContents:function(s,r){if(this.model){return this.model.refresh(s,r)}return $.when()},JSONToModel:function(u,r,s){this.log("JSONToModel:",u,r,s);s=s||{};var t=new h.History(u,r,s);this.setModel(t);return t},setModel:function(s,r){r=r||{};p.prototype.setModel.call(this,s,r);if(this.model){this._setUpWebStorage(r.initiallyExpanded,r.show_deleted,r.show_hidden)}},_setUpWebStorage:function(s,r,t){if(this.storage){this.stopListening(this.storage)}this.storage=new l({id:l.historyStorageKey(this.model.get("id"))});if(_.isObject(s)){this.storage.set("expandedIds",s)}if(_.isBoolean(r)){this.storage.set("show_deleted",r)}if(_.isBoolean(t)){this.storage.set("show_hidden",t)}this.trigger("new-storage",this.storage,this);this.log(this+" (init'd) storage:",this.storage.get());this.listenTo(this.storage,{"change:show_deleted":function(u,v){this.showDeleted=v},"change:show_hidden":function(u,v){this.showHidden=v}},this);this.showDeleted=(r!==undefined)?r:this.storage.get("show_deleted");this.showHidden=(t!==undefined)?t:this.storage.get("show_hidden");return this},_buildNewRender:function(){var r=p.prototype._buildNewRender.call(this);if(this.multiselectActions().length){r.find(".controls .actions").prepend(this._renderSelectButton())}return r},_renderSelectButton:function(r){return c({title:g("Operations on multiple datasets"),classes:"show-selectors-btn",faIcon:"fa-check-square-o"})},_getItemViewClass:function(r){var s=r.get("history_content_type");switch(s){case"dataset":return this.HDAViewClass;case"dataset_collection":return this.HDCAViewClass}throw new TypeError("Unknown history_content_type: "+s)},_filterItem:function(s){var r=this;return(p.prototype._filterItem.call(r,s)&&(!s.hidden()||r.showHidden)&&(!s.isDeletedOrPurged()||r.showDeleted))},_getItemViewOptions:function(s){var r=p.prototype._getItemViewOptions.call(this,s);return _.extend(r,{linkTarget:this.linkTarget,expanded:!!this.storage.get("expandedIds")[s.id],hasUser:this.model.ownedByCurrUser()})},_setUpItemViewListeners:function(s){var r=this;p.prototype._setUpItemViewListeners.call(r,s);s.on("expanded",function(t){r.storage.addExpanded(t.model)});s.on("collapsed",function(t){r.storage.removeExpanded(t.model)});return this},getSelectedModels:function(){var r=p.prototype.getSelectedModels.call(this);r.historyId=this.collection.historyId;return r},events:_.extend(_.clone(p.prototype.events),{"click .show-selectors-btn":"toggleSelectors"}),toggleShowDeleted:function(r,s){r=(r!==undefined)?(r):(!this.showDeleted);s=(s!==undefined)?(s):(true);this.showDeleted=r;if(s){this.storage.set("show_deleted",r)}this.trigger("show-hidden",r);this.renderItems();return this.showDeleted},toggleShowHidden:function(r,s){r=(r!==undefined)?(r):(!this.showHidden);s=(s!==undefined)?(s):(true);this.showHidden=r;if(s){this.storage.set("show_hidden",r)}this.trigger("show-hidden",r);this.renderItems();return this.showHidden},_firstSearch:function(r){var s=this,t=".history-search-input";this.log("onFirstSearch",r);if(s.model.contents.haveDetails()){s.searchItems(r);return}s.$el.find(t).searchInput("toggle-loading");s.model.contents.fetchAllDetails({silent:true}).always(function(){s.$el.find(t).searchInput("toggle-loading")}).done(function(){s.searchItems(r)})},errorHandler:function(t,w,s,v,u){this.error(t,w,s,v,u);if(w&&w.status===0&&w.readyState===0){}else{if(w&&w.status===502){}else{var r=this._parseErrorMessage(t,w,s,v,u);if(!this.$messages().is(":visible")){this.once("rendered",function(){this.displayMessage("error",r.message,r.details)})}else{this.displayMessage("error",r.message,r.details)}}}},_parseErrorMessage:function(v,y,z,t,r,w){var u=Galaxy.currUser,x={message:this._bePolite(t),details:{message:t,raven:(window.Raven&&_.isFunction(Raven.lastEventId))?(Raven.lastEventId()):(undefined),agent:navigator.userAgent,url:(window.Galaxy)?(Galaxy.lastAjax.url):(undefined),data:(window.Galaxy)?(Galaxy.lastAjax.data):(undefined),options:(y)?(_.omit(z,"xhr")):(z),xhr:y,source:(_.isFunction(v.toJSON))?(v.toJSON()):(v+""),user:(u instanceof i.User)?(u.toJSON()):(u+"")}};_.extend(x.details,r||{});if(y&&_.isFunction(y.getAllResponseHeaders)){var s=y.getAllResponseHeaders();s=_.compact(s.split("\n"));s=_.map(s,function(A){return A.split(": ")});x.details.xhr.responseHeaders=_.object(s)}return x},_bePolite:function(r){r=r||g("An error occurred while getting updates from the server");return r+". "+g("Please contact a Galaxy administrator if the problem persists")+"."},displayMessage:function(w,x,v){var t=this;this.scrollToTop();var u=this.$messages(),r=$("<div/>").addClass(w+"message").html(x);if(!_.isEmpty(v)){var s=$('<a href="javascript:void(0)">Details</a>').click(function(){Galaxy.modal.show(t._messageToModalOptions(w,x,v));return false});r.append(" ",s)}return u.html(r)},_messageToModalOptions:function(u,x,t){var r=this,s={title:"Details"};if(_.isObject(t)){t=_.omit(t,_.functions(t));var w=JSON.stringify(t,null," "),v=$("<pre/>").text(w);s.body=$("<div/>").append(v)}else{s.body=$("<div/>").html(t)}s.buttons={Ok:function(){Galaxy.modal.hide();r.clearMessages()}};return s},clearMessages:function(r){$(r.currentTarget).fadeOut(this.fxSpeed,function(){$(this).remove()});return this},scrollToHid:function(r){return this.scrollToItem(_.first(this.viewsWhereModel({hid:r})))},toString:function(){return"HistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});m.prototype.templates=(function(){var r=q.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= history.name %></div>',"</div>",'<div class="subtitle"></div>','<div class="history-size"><%= history.nice_size %></div>','<div class="actions"></div>','<div class="messages">',"<% if( history.deleted && history.purged ){ %>",'<div class="deleted-msg warningmessagesmall">',g("This history has been purged and deleted"),"</div>","<% } else if( history.deleted ){ %>",'<div class="deleted-msg warningmessagesmall">',g("This history has been deleted"),"</div>","<% } else if( history.purged ){ %>",'<div class="deleted-msg warningmessagesmall">',g("This history has been purged"),"</div>","<% } %>","<% if( history.message ){ %>",'<div class="<%= history.message.level || "info" %>messagesmall">',"<%= history.message.text %>","</div>","<% } %>","</div>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',g("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',g("None"),"</button>","</div>",'<div class="list-action-menu btn-group">',"</div>","</div>","</div>"],"history");return _.extend(_.clone(p.prototype.templates),{controls:r})}());return{HistoryPanel:m}}); \ No newline at end of file diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 static/scripts/packed/mvc/history/multi-panel.js --- a/static/scripts/packed/mvc/history/multi-panel.js +++ b/static/scripts/packed/mvc/history/multi-panel.js @@ -1,1 +1,1 @@ -define(["mvc/history/history-model","mvc/history/history-panel-edit","mvc/base-mvc","utils/ajax-queue","ui/mode-button","ui/search-input"],function(d,l,z,a){function g(I,E){E=E||{};if(!(Galaxy&&Galaxy.modal)){return I.copy()}var F=I.get("name"),C="Copy of '"+F+"'";function D(K){if(!K){if(!Galaxy.modal.$("#invalid-title").size()){var J=$("<p/>").attr("id","invalid-title").css({color:"red","margin-top":"8px"}).addClass("bg-danger").text(_l("Please enter a valid history title"));Galaxy.modal.$(".modal-body").append(J)}return false}return K}function G(J){var K=$('<p><span class="fa fa-spinner fa-spin"></span> Copying history...</p>').css("margin-top","8px");Galaxy.modal.$(".modal-body").append(K);I.copy(true,J).fail(function(){alert(_l("History could not be copied. Please contact a Galaxy administrator"))}).always(function(){Galaxy.modal.hide()})}function H(){var J=Galaxy.modal.$("#copy-modal-title").val();if(!D(J)){return}G(J)}Galaxy.modal.show(_.extend({title:_l("Copying history")+' "'+F+'"',body:$(['<label for="copy-modal-title">',_l("Enter a title for the copied history"),":","</label><br />",'<input id="copy-modal-title" class="form-control" style="width: 100%" value="',C,'" />'].join("")),buttons:{Cancel:function(){Galaxy.modal.hide()},Copy:H}},E));$("#copy-modal-title").focus().select();$("#copy-modal-title").on("keydown",function(J){if(J.keyCode===13){H()}})}var B=Backbone.View.extend(z.LoggableMixin).extend({tagName:"div",className:"history-column flex-column flex-row-container",id:function q(){if(!this.model){return""}return"history-column-"+this.model.get("id")},initialize:function c(C){C=C||{};this.purgeAllowed=!_.isUndefined(C.purgeAllowed)?C.purgeAllowed:false;this.panel=C.panel||this.createPanel(C);this.setUpListeners()},createPanel:function u(D){D=_.extend({model:this.model,purgeAllowed:this.purgeAllowed,dragItems:true},D);var C=new l.HistoryPanelEdit(D);C._renderEmptyMessage=this.__patch_renderEmptyMessage;return C},__patch_renderEmptyMessage:function(E){var D=this,F=_.chain(this.model.get("state_ids")).values().flatten().value().length,C=D.$emptyMessage(E);if(!_.isEmpty(D.hdaViews)){C.hide()}else{if(F&&!this.model.contents.length){C.empty().append($('<span class="fa fa-spinner fa-spin"></span><i>loading datasets...</i>')).show()}else{if(D.searchFor){C.text(D.noneFoundMsg).show()}else{C.text(D.emptyMsg).show()}}}return C},setUpListeners:function f(){var C=this;this.once("rendered",function(){C.trigger("rendered:initial",C)});this.setUpPanelListeners()},setUpPanelListeners:function k(){var C=this;this.listenTo(this.panel,{rendered:function(){C.trigger("rendered",C)}},this)},inView:function(C,D){var F=this.$el.offset().left,E=F+this.$el.width();if(E<C){return false}if(F>D){return false}return true},$panel:function e(){return this.$(".history-panel")},render:function A(D){D=(D!==undefined)?(D):("fast");var C=this.model?this.model.toJSON():{};this.$el.html(this.template(C));this.renderPanel(D);this.setUpBehaviors();return this},setUpBehaviors:function v(){},template:function w(C){C=_.extend(C||{},{isCurrentHistory:this.currentHistory});return $(['<div class="panel-controls clear flex-row">',this.controlsLeftTemplate({history:C,view:this}),this.controlsRightTemplate({history:C,view:this}),"</div>",'<div class="inner flex-row flex-column-container">','<div id="history-',C.id,'" class="history-column history-panel flex-column"></div>',"</div>"].join(""))},renderPanel:function h(C){C=(C!==undefined)?(C):("fast");this.panel.setElement(this.$panel()).render(C);if(this.currentHistory){this.panel.$list().before(this.panel._renderDropTargetHelp())}return this},events:{"click .switch-to.btn":function(){this.model.setAsCurrent()},"click .delete-history":function(){var C=this;this.model._delete().fail(function(F,D,E){alert(_l("Could not delete the history")+":\n"+E)}).done(function(D){C.render()})},"click .undelete-history":function(){var C=this;this.model.undelete().fail(function(F,D,E){alert(_l("Could not undelete the history")+":\n"+E)}).done(function(D){C.render()})},"click .purge-history":function(){if(confirm(_l("This will permanently remove the data. Are you sure?"))){var C=this;this.model.purge().fail(function(F,D,E){alert(_l("Could not purge the history")+":\n"+E)}).done(function(D){C.render()})}},"click .copy-history":"copy"},copy:function s(){g(this.model)},controlsLeftTemplate:_.template(['<div class="pull-left">',"<% if( data.history.isCurrentHistory ){ %>",'<strong class="current-label">',_l("Current History"),"</strong>","<% } else { %>",'<button class="switch-to btn btn-default">',_l("Switch to"),"</button>","<% } %>","</div>"].join(""),{variable:"data"}),controlsRightTemplate:_.template(['<div class="pull-right">',"<% if( !data.history.purged ){ %>",'<div class="panel-menu btn-group">','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">','<span class="caret"></span>',"</button>",'<ul class="dropdown-menu pull-right" role="menu">',"<% if( !data.history.deleted ){ %>",'<li><a href="javascript:void(0);" class="copy-history">',_l("Copy"),"</a></li>",'<li><a href="javascript:void(0);" class="delete-history">',_l("Delete"),"</a></li>","<% } else /* if is deleted */ { %>",'<li><a href="javascript:void(0);" class="undelete-history">',_l("Undelete"),"</a></li>","<% } %>","<% if( data.view.purgeAllowed ){ %>",'<li><a href="javascript:void(0);" class="purge-history">',_l("Purge"),"</a></li>","<% } %>","</ul>","<% } %>","</div>","</div>"].join(""),{variable:"data"}),toString:function(){return"HistoryPanelColumn("+(this.panel?this.panel:"")+")"}});var m=Backbone.View.extend(z.LoggableMixin).extend({className:"multi-panel-history",initialize:function c(C){C=C||{};this.log(this+".init",C);this.$el.addClass(this.className);if(!C.currentHistoryId){throw new Error(this+" requires a currentHistoryId in the options")}this.currentHistoryId=C.currentHistoryId;this.options={columnWidth:312,borderWidth:1,columnGap:8,headerHeight:29,footerHeight:0,controlsHeight:20};this.order=C.order||"update";this._initSortOrders();this.hdaQueue=new a.NamedAjaxQueue([],false);this.collection=null;this.setCollection(C.histories||[]);this.columnMap={};this.createColumns(C.columnOptions);this.setUpListeners()},_initSortOrders:function(){function C(D,E){return function F(H,G,I){if(H.id===I){return -1}if(G.id===I){return 1}H=D(H);G=D(G);return E.asc?((H===G)?(0):(H>G?1:-1)):((H===G)?(0):(H>G?-1:1))}}this.sortOrders={update:{text:_l("most recent first"),fn:C(function(D){return Date(D.get("update_time"))},{asc:false})},name:{text:_l("name, a to z"),fn:C(function(D){return D.get("name")},{asc:true})},"name-dsc":{text:_l("name, z to a"),fn:C(function(D){return D.get("name")},{asc:false})},size:{text:_l("size, large to small"),fn:C(function(D){return D.get("size")},{asc:false})},"size-dsc":{text:_l("size, small to large"),fn:C(function(D){return D.get("size")},{asc:true})}};return this.sortOrders},setUpListeners:function f(){},setCollection:function y(D){var C=this;C.stopListening(C.collection);C.collection=D;C.sortCollection(C.order,{silent:true});C.setUpCollectionListeners();C.trigger("new-collection",C);return C},setUpCollectionListeners:function(){var C=this,D=C.collection;C.listenTo(D,{add:C.addAsCurrentColumn,"set-as-current":C.setCurrentHistory,"change:deleted change:purged":C.handleDeletedHistory,sort:function(){C.renderColumns(0)}})},setCurrentHistory:function p(D){var C=this.columnMap[this.currentHistoryId];if(C){C.currentHistory=false;C.$el.height("")}this.currentHistoryId=D.id;var E=this.columnMap[this.currentHistoryId];E.currentHistory=true;this.sortCollection();multipanel._recalcFirstColumnHeight();return E},handleDeletedHistory:function b(D){if(D.get("deleted")||D.get("purged")){this.log("handleDeletedHistory",this.collection.includeDeleted,D);var C=this;column=C.columnMap[D.id];if(!column){return}if(column.model.id===this.currentHistoryId){}else{if(!C.collection.includeDeleted){C.removeColumn(column)}}}},sortCollection:function(C,D){if(!(C in this.sortOrders)){C="update"}this.order=C;var G=this.currentHistoryId,F=this.sortOrders[C];this.collection.comparator=function E(I,H){return F.fn(I,H,G)};this.$(".current-order").text(F.text);if(this.$(".more-options").is(":visible")){this.$(".open-more-options.btn").popover("show")}this.collection.sort(D);return this.collection},create:function(C){return this.collection.create({current:true})},createColumns:function r(D){D=D||{};var C=this;this.columnMap={};C.collection.each(function(E,F){var G=C.createColumn(E,D);C.columnMap[E.id]=G})},createColumn:function t(E,C){C=_.extend({},C,{model:E,purgeAllowed:Galaxy.config.allow_user_dataset_purge});var D=new B(C);if(E.id===this.currentHistoryId){D.currentHistory=true}this.setUpColumnListeners(D);return D},sortedFilteredColumns:function(C){C=C||this.filters;if(!C||!C.length){return this.sortedColumns()}var D=this;return D.sortedColumns().filter(function(G,F){var E=G.currentHistory||_.every(C.map(function(H){return H.call(G)}));return E})},sortedColumns:function(){var D=this;var C=this.collection.map(function(F,E){return D.columnMap[F.id]});return C},addColumn:function o(E,C){C=C!==undefined?C:true;var D=this.createColumn(E);this.columnMap[E.id]=D;if(C){this.renderColumns()}return D},addAsCurrentColumn:function o(E){var D=this,C=this.addColumn(E,false);this.setCurrentHistory(E);C.once("rendered",function(){D.queueHdaFetch(C)});return C},removeColumn:function x(E,D){D=D!==undefined?D:true;this.log("removeColumn",E);if(!E){return}var F=this,C=this.options.columnWidth+this.options.columnGap;E.$el.fadeOut("fast",function(){if(D){$(this).remove();F.$(".middle").width(F.$(".middle").width()-C);F.checkColumnsInView();F._recalcFirstColumnHeight()}F.stopListening(E.panel);F.stopListening(E);delete F.columnMap[E.model.id];E.remove()})},setUpColumnListeners:function n(D){var E=this,C={HistoryDatasetAssociation:"hda",HistoryDatasetCollectionAssociation:"hdca"};E.listenTo(D,{"in-view":E.queueHdaFetch});E.listenTo(D.panel,{"view:draggable:dragstart":function(I,G,F,H){E._dropData=JSON.parse(I.dataTransfer.getData("text"));E.currentColumnDropTargetOn()},"view:draggable:dragend":function(I,G,F,H){E._dropData=null;E.currentColumnDropTargetOff()},"droptarget:drop":function(H,I,G){var J=E._dropData.filter(function(K){return((_.isObject(K)&&K.id)&&(_.contains(_.keys(C),K.model_class)))});E._dropData=null;var F=new a.NamedAjaxQueue();J.forEach(function(K){var L=C[K.model_class];F.add({name:"copy-"+K.id,fn:function(){return G.model.contents.copy(K.id,L)}})});F.start();F.done(function(K){G.model.fetch()})}})},columnMapLength:function(){return Object.keys(this.columnMap).length},render:function A(D){D=D!==undefined?D:this.fxSpeed;var C=this;C.log(C+".render");C.$el.html(C.mainTemplate(C));C.renderColumns(D);C.setUpBehaviors();C.trigger("rendered",C);return C},renderColumns:function j(F){F=F!==undefined?F:this.fxSpeed;var E=this,C=E.sortedFilteredColumns();E.$(".middle").width(C.length*(this.options.columnWidth+this.options.columnGap)+this.options.columnGap+16);var D=E.$(".middle");D.empty();C.forEach(function(H,G){H.$el.appendTo(D);H.delegateEvents();E.renderColumn(H,F)});if(this.searchFor&&C.length<=1){}else{E.checkColumnsInView();this._recalcFirstColumnHeight()}return C},renderColumn:function(C,D){D=D!==undefined?D:this.fxSpeed;return C.render(D)},queueHdaFetch:function i(E){if(E.model.contents.length===0&&!E.model.get("empty")){var C={},D=_.values(E.panel.storage.get("expandedIds")).join();if(D){C.dataset_details=D}this.hdaQueue.add({name:E.model.id,fn:function(){var F=E.model.contents.fetch({data:C,silent:true});return F.done(function(G){E.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},queueHdaFetchDetails:function(C){if((C.model.contents.length===0&&!C.model.get("empty"))||(!C.model.contents.haveDetails())){this.hdaQueue.add({name:C.model.id,fn:function(){var D=C.model.contents.fetch({data:{details:"all"},silent:true});return D.done(function(E){C.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},renderInfo:function(C){return this.$(".header .header-info").text(C)},events:{"click .done.btn":"close","click .create-new.btn":"create","click #include-deleted":"_clickToggleDeletedHistories","click .order .set-order":"_chooseOrder","click #toggle-deleted":"_clickToggleDeletedDatasets","click #toggle-hidden":"_clickToggleHiddenDatasets"},close:function(D){var C="/";if(Galaxy&&Galaxy.options&&Galaxy.options.root){C=Galaxy.options.root}else{if(galaxy_config&&galaxy_config.root){C=galaxy_config.root}}window.location=C},_clickToggleDeletedHistories:function(C){return this.toggleDeletedHistories($(C.currentTarget).is(":checked"))},toggleDeletedHistories:function(C){if(C){window.location=Galaxy.options.root+"history/view_multiple?include_deleted_histories=True"}else{window.location=Galaxy.options.root+"history/view_multiple"}},_clickToggleDeletedDatasets:function(C){return this.toggleDeletedDatasets($(C.currentTarget).is(":checked"))},toggleDeletedDatasets:function(C){C=C!==undefined?C:false;var D=this;D.sortedFilteredColumns().forEach(function(F,E){_.delay(function(){F.panel.toggleShowDeleted(C,false)},E*200)})},_clickToggleHiddenDatasets:function(C){return this.toggleHiddenDatasets($(C.currentTarget).is(":checked"))},toggleHiddenDatasets:function(C){C=C!==undefined?C:false;var D=this;D.sortedFilteredColumns().forEach(function(F,E){_.delay(function(){F.panel.toggleShowHidden(C,false)},E*200)})},_chooseOrder:function(D){var C=$(D.currentTarget).data("order");this.sortCollection(C)},setUpBehaviors:function(){var D=this;D._moreOptionsPopover();D.$("#search-histories").searchInput({name:"search-histories",placeholder:_l("search histories"),onsearch:function(E){D.searchFor=E;D.filters=[function(){return this.model.matchesAll(D.searchFor)}];D.renderColumns(0)},onclear:function(E){D.searchFor=null;D.filters=[];D.renderColumns(0)}});D.$("#search-datasets").searchInput({name:"search-datasets",placeholder:_l("search all datasets"),onfirstsearch:function(E){D.hdaQueue.clear();D.$("#search-datasets").searchInput("toggle-loading");D.searchFor=E;D.sortedFilteredColumns().forEach(function(F){F.panel.searchItems(E);D.queueHdaFetchDetails(F)});D.hdaQueue.progress(function(F){D.renderInfo([_l("searching"),(F.curr+1),_l("of"),F.total].join(" "))});D.hdaQueue.deferred.done(function(){D.renderInfo("");D.$("#search-datasets").searchInput("toggle-loading")})},onsearch:function(E){D.searchFor=E;D.sortedFilteredColumns().forEach(function(F){F.panel.searchItems(E)})},onclear:function(E){D.searchFor=null;D.sortedFilteredColumns().forEach(function(F){F.panel.clearSearch()})}});$(window).resize(function(){D._recalcFirstColumnHeight()});var C=_.debounce(_.bind(this.checkColumnsInView,this),100);this.$(".middle").parent().scroll(C)},_moreOptionsPopover:function(){return this.$(".open-more-options.btn").popover({container:".header",placement:"bottom",html:true,content:$(this.optionsPopoverTemplate(this))})},_recalcFirstColumnHeight:function(){var C=this.$(".history-column").first(),E=this.$(".middle").height(),D=C.find(".panel-controls").height();C.height(E).find(".inner").height(E-D)},_viewport:function(){var C=this.$(".middle").parent().offset().left;return{left:C,right:C+this.$(".middle").parent().width()}},columnsInView:function(){var C=this._viewport();return this.sortedFilteredColumns().filter(function(D){return D.currentHistory||D.inView(C.left,C.right)})},checkColumnsInView:function(){this.columnsInView().forEach(function(C){C.trigger("in-view",C)})},currentColumnDropTargetOn:function(){var C=this.columnMap[this.currentHistoryId];if(!C){return}C.panel.dataDropped=function(D){};C.panel.dropTargetOn()},currentColumnDropTargetOff:function(){var C=this.columnMap[this.currentHistoryId];if(!C){return}C.panel.dataDropped=l.HistoryPanelEdit.prototype.dataDrop;C.panel.dropTarget=false;C.panel.$(".history-drop-target").remove()},toString:function(){return"MultiPanelColumns("+(this.columns?this.columns.length:0)+")"},mainTemplate:_.template(['<div class="header flex-column-container">','<div class="control-column control-column-left flex-column">','<button class="create-new btn btn-default" tabindex="4">',_l("Create new"),"</button> ",'<div id="search-histories" class="search-control"></div>','<div id="search-datasets" class="search-control"></div>','<a class="open-more-options btn btn-default" tabindex="3">','<span class="fa fa-ellipsis-h"></span>',"</a>","</div>",'<div class="control-column control-column-center flex-column">','<div class="header-info">',"</div>","</div>",'<div class="control-column control-column-right flex-column">','<button class="done btn btn-default" tabindex="1">',_l("Done"),"</button>","</div>","</div>",'<div class="outer-middle flex-row flex-row-container">','<div class="middle flex-column-container flex-row"></div>',"</div>",'<div class="footer flex-column-container">',"</div>"].join(""),{variable:"view"}),optionsPopoverTemplate:_.template(['<div class="more-options">','<div class="order btn-group">','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">',_l("Order histories by")+" ",'<span class="current-order"><%= view.sortOrders[ view.order ].text %></span> ','<span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">',"<% _.each( view.sortOrders, function( order, key ){ %>",'<li><a href="javascript:void(0);" class="set-order" data-order="<%= key %>">',"<%= order.text %>","</a></li>","<% }); %>","</ul>","</div>",'<div class="checkbox"><label><input id="include-deleted" type="checkbox"','<%= view.collection.includeDeleted? " checked" : "" %>>',_l("Include deleted histories"),"</label></div>","<hr />",'<div class="checkbox"><label><input id="toggle-deleted" type="checkbox">',_l("Include deleted datasets"),"</label></div>",'<div class="checkbox"><label><input id="toggle-hidden" type="checkbox">',_l("Include hidden datasets"),"</label></div>","</div>"].join(""),{variable:"view"})});return{MultiPanelColumns:m}}); \ No newline at end of file +define(["mvc/history/history-model","mvc/history/history-panel-edit","mvc/base-mvc","utils/ajax-queue","ui/mode-button","ui/search-input"],function(d,l,z,a){function g(I,E){E=E||{};if(!(Galaxy&&Galaxy.modal)){return I.copy()}var F=I.get("name"),C="Copy of '"+F+"'";function D(K){if(!K){if(!Galaxy.modal.$("#invalid-title").size()){var J=$("<p/>").attr("id","invalid-title").css({color:"red","margin-top":"8px"}).addClass("bg-danger").text(_l("Please enter a valid history title"));Galaxy.modal.$(".modal-body").append(J)}return false}return K}function G(J){var K=$('<p><span class="fa fa-spinner fa-spin"></span> Copying history...</p>').css("margin-top","8px");Galaxy.modal.$(".modal-body").append(K);I.copy(true,J).fail(function(){alert(_l("History could not be copied. Please contact a Galaxy administrator"))}).always(function(){Galaxy.modal.hide()})}function H(){var J=Galaxy.modal.$("#copy-modal-title").val();if(!D(J)){return}G(J)}Galaxy.modal.show(_.extend({title:_l("Copying history")+' "'+F+'"',body:$(['<label for="copy-modal-title">',_l("Enter a title for the copied history"),":","</label><br />",'<input id="copy-modal-title" class="form-control" style="width: 100%" value="',C,'" />'].join("")),buttons:{Cancel:function(){Galaxy.modal.hide()},Copy:H}},E));$("#copy-modal-title").focus().select();$("#copy-modal-title").on("keydown",function(J){if(J.keyCode===13){H()}})}var B=Backbone.View.extend(z.LoggableMixin).extend({tagName:"div",className:"history-column flex-column flex-row-container",id:function q(){if(!this.model){return""}return"history-column-"+this.model.get("id")},initialize:function c(C){C=C||{};this.purgeAllowed=!_.isUndefined(C.purgeAllowed)?C.purgeAllowed:false;this.panel=C.panel||this.createPanel(C);this.setUpListeners()},createPanel:function u(D){D=_.extend({model:this.model,purgeAllowed:this.purgeAllowed,dragItems:true},D);var C=new l.HistoryPanelEdit(D);C._renderEmptyMessage=this.__patch_renderEmptyMessage;return C},__patch_renderEmptyMessage:function(E){var D=this,F=_.chain(this.model.get("state_ids")).values().flatten().value().length,C=D.$emptyMessage(E);if(!_.isEmpty(D.hdaViews)){C.hide()}else{if(F&&!this.model.contents.length){C.empty().append($('<span class="fa fa-spinner fa-spin"></span><i>loading datasets...</i>')).show()}else{if(D.searchFor){C.text(D.noneFoundMsg).show()}else{C.text(D.emptyMsg).show()}}}return C},setUpListeners:function f(){var C=this;this.once("rendered",function(){C.trigger("rendered:initial",C)});this.setUpPanelListeners()},setUpPanelListeners:function k(){var C=this;this.listenTo(this.panel,{rendered:function(){C.trigger("rendered",C)}},this)},inView:function(C,D){var F=this.$el.offset().left,E=F+this.$el.width();if(E<C){return false}if(F>D){return false}return true},$panel:function e(){return this.$(".history-panel")},render:function A(D){D=(D!==undefined)?(D):("fast");var C=this.model?this.model.toJSON():{};this.$el.html(this.template(C));this.renderPanel(D);this.setUpBehaviors();return this},setUpBehaviors:function v(){},template:function w(C){C=_.extend(C||{},{isCurrentHistory:this.currentHistory});return $(['<div class="panel-controls clear flex-row">',this.controlsLeftTemplate({history:C,view:this}),this.controlsRightTemplate({history:C,view:this}),"</div>",'<div class="inner flex-row flex-column-container">','<div id="history-',C.id,'" class="history-column history-panel flex-column"></div>',"</div>"].join(""))},renderPanel:function h(C){C=(C!==undefined)?(C):("fast");this.panel.setElement(this.$panel()).render(C);if(this.currentHistory){this.panel.$list().before(this.panel._renderDropTargetHelp())}return this},events:{"click .switch-to.btn":function(){this.model.setAsCurrent()},"click .delete-history":function(){var C=this;this.model._delete().fail(function(F,D,E){alert(_l("Could not delete the history")+":\n"+E)}).done(function(D){C.render()})},"click .undelete-history":function(){var C=this;this.model.undelete().fail(function(F,D,E){alert(_l("Could not undelete the history")+":\n"+E)}).done(function(D){C.render()})},"click .purge-history":function(){if(confirm(_l("This will permanently remove the data. Are you sure?"))){var C=this;this.model.purge().fail(function(F,D,E){alert(_l("Could not purge the history")+":\n"+E)}).done(function(D){C.render()})}},"click .copy-history":"copy"},copy:function s(){g(this.model)},controlsLeftTemplate:_.template(['<div class="pull-left">',"<% if( data.history.isCurrentHistory ){ %>",'<strong class="current-label">',_l("Current History"),"</strong>","<% } else { %>",'<button class="switch-to btn btn-default">',_l("Switch to"),"</button>","<% } %>","</div>"].join(""),{variable:"data"}),controlsRightTemplate:_.template(['<div class="pull-right">',"<% if( !data.history.purged ){ %>",'<div class="panel-menu btn-group">','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">','<span class="caret"></span>',"</button>",'<ul class="dropdown-menu pull-right" role="menu">',"<% if( !data.history.deleted ){ %>",'<li><a href="javascript:void(0);" class="copy-history">',_l("Copy"),"</a></li>",'<li><a href="javascript:void(0);" class="delete-history">',_l("Delete"),"</a></li>","<% } else /* if is deleted */ { %>",'<li><a href="javascript:void(0);" class="undelete-history">',_l("Undelete"),"</a></li>","<% } %>","<% if( data.view.purgeAllowed ){ %>",'<li><a href="javascript:void(0);" class="purge-history">',_l("Purge"),"</a></li>","<% } %>","</ul>","</div>","<% } %>","</div>"].join(""),{variable:"data"}),toString:function(){return"HistoryPanelColumn("+(this.panel?this.panel:"")+")"}});var m=Backbone.View.extend(z.LoggableMixin).extend({className:"multi-panel-history",initialize:function c(C){C=C||{};this.log(this+".init",C);this.$el.addClass(this.className);if(!C.currentHistoryId){throw new Error(this+" requires a currentHistoryId in the options")}this.currentHistoryId=C.currentHistoryId;this.options={columnWidth:312,borderWidth:1,columnGap:8,headerHeight:29,footerHeight:0,controlsHeight:20};this.order=C.order||"update";this._initSortOrders();this.hdaQueue=new a.NamedAjaxQueue([],false);this.collection=null;this.setCollection(C.histories||[]);this.columnMap={};this.createColumns(C.columnOptions);this.setUpListeners()},_initSortOrders:function(){function C(D,E){return function F(H,G,I){if(H.id===I){return -1}if(G.id===I){return 1}H=D(H);G=D(G);return E.asc?((H===G)?(0):(H>G?1:-1)):((H===G)?(0):(H>G?-1:1))}}this.sortOrders={update:{text:_l("most recent first"),fn:C(function(D){return Date(D.get("update_time"))},{asc:false})},name:{text:_l("name, a to z"),fn:C(function(D){return D.get("name")},{asc:true})},"name-dsc":{text:_l("name, z to a"),fn:C(function(D){return D.get("name")},{asc:false})},size:{text:_l("size, large to small"),fn:C(function(D){return D.get("size")},{asc:false})},"size-dsc":{text:_l("size, small to large"),fn:C(function(D){return D.get("size")},{asc:true})}};return this.sortOrders},setUpListeners:function f(){},setCollection:function y(D){var C=this;C.stopListening(C.collection);C.collection=D;C.sortCollection(C.order,{silent:true});C.setUpCollectionListeners();C.trigger("new-collection",C);return C},setUpCollectionListeners:function(){var C=this,D=C.collection;C.listenTo(D,{add:C.addAsCurrentColumn,"set-as-current":C.setCurrentHistory,"change:deleted change:purged":C.handleDeletedHistory,sort:function(){C.renderColumns(0)}})},setCurrentHistory:function p(D){var C=this.columnMap[this.currentHistoryId];if(C){C.currentHistory=false;C.$el.height("")}this.currentHistoryId=D.id;var E=this.columnMap[this.currentHistoryId];E.currentHistory=true;this.sortCollection();multipanel._recalcFirstColumnHeight();return E},handleDeletedHistory:function b(D){if(D.get("deleted")||D.get("purged")){this.log("handleDeletedHistory",this.collection.includeDeleted,D);var C=this;column=C.columnMap[D.id];if(!column){return}if(column.model.id===this.currentHistoryId){}else{if(!C.collection.includeDeleted){C.removeColumn(column)}}}},sortCollection:function(C,D){if(!(C in this.sortOrders)){C="update"}this.order=C;var G=this.currentHistoryId,F=this.sortOrders[C];this.collection.comparator=function E(I,H){return F.fn(I,H,G)};this.$(".current-order").text(F.text);if(this.$(".more-options").is(":visible")){this.$(".open-more-options.btn").popover("show")}this.collection.sort(D);return this.collection},create:function(C){return this.collection.create({current:true})},createColumns:function r(D){D=D||{};var C=this;this.columnMap={};C.collection.each(function(E,F){var G=C.createColumn(E,D);C.columnMap[E.id]=G})},createColumn:function t(E,C){C=_.extend({},C,{model:E,purgeAllowed:Galaxy.config.allow_user_dataset_purge});var D=new B(C);if(E.id===this.currentHistoryId){D.currentHistory=true}this.setUpColumnListeners(D);return D},sortedFilteredColumns:function(C){C=C||this.filters;if(!C||!C.length){return this.sortedColumns()}var D=this;return D.sortedColumns().filter(function(G,F){var E=G.currentHistory||_.every(C.map(function(H){return H.call(G)}));return E})},sortedColumns:function(){var D=this;var C=this.collection.map(function(F,E){return D.columnMap[F.id]});return C},addColumn:function o(E,C){C=C!==undefined?C:true;var D=this.createColumn(E);this.columnMap[E.id]=D;if(C){this.renderColumns()}return D},addAsCurrentColumn:function o(E){var D=this,C=this.addColumn(E,false);this.setCurrentHistory(E);C.once("rendered",function(){D.queueHdaFetch(C)});return C},removeColumn:function x(E,D){D=D!==undefined?D:true;this.log("removeColumn",E);if(!E){return}var F=this,C=this.options.columnWidth+this.options.columnGap;E.$el.fadeOut("fast",function(){if(D){$(this).remove();F.$(".middle").width(F.$(".middle").width()-C);F.checkColumnsInView();F._recalcFirstColumnHeight()}F.stopListening(E.panel);F.stopListening(E);delete F.columnMap[E.model.id];E.remove()})},setUpColumnListeners:function n(C){var D=this;D.listenTo(C,{"in-view":D.queueHdaFetch});D.listenTo(C.panel,{"view:draggable:dragstart":function(H,F,E,G){D._dropData=JSON.parse(H.dataTransfer.getData("text"));D.currentColumnDropTargetOn()},"view:draggable:dragend":function(H,F,E,G){D._dropData=null;D.currentColumnDropTargetOff()},"droptarget:drop":function(G,H,F){var I=D._dropData.filter(function(J){return F.model.contents.isCopyable(J)});D._dropData=null;var E=new a.NamedAjaxQueue();I.forEach(function(J){E.add({name:"copy-"+J.id,fn:function(){return F.model.contents.copy(J)}})});E.start();E.done(function(J){F.model.fetch()})}})},columnMapLength:function(){return Object.keys(this.columnMap).length},render:function A(D){D=D!==undefined?D:this.fxSpeed;var C=this;C.log(C+".render");C.$el.html(C.mainTemplate(C));C.renderColumns(D);C.setUpBehaviors();C.trigger("rendered",C);return C},renderColumns:function j(F){F=F!==undefined?F:this.fxSpeed;var E=this,C=E.sortedFilteredColumns();E.$(".middle").width(C.length*(this.options.columnWidth+this.options.columnGap)+this.options.columnGap+16);var D=E.$(".middle");D.empty();C.forEach(function(H,G){H.$el.appendTo(D);H.delegateEvents();E.renderColumn(H,F)});if(this.searchFor&&C.length<=1){}else{E.checkColumnsInView();this._recalcFirstColumnHeight()}return C},renderColumn:function(C,D){D=D!==undefined?D:this.fxSpeed;return C.render(D)},queueHdaFetch:function i(E){if(E.model.contents.length===0&&!E.model.get("empty")){var C={},D=_.values(E.panel.storage.get("expandedIds")).join();if(D){C.dataset_details=D}this.hdaQueue.add({name:E.model.id,fn:function(){var F=E.model.contents.fetch({data:C,silent:true});return F.done(function(G){E.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},queueHdaFetchDetails:function(C){if((C.model.contents.length===0&&!C.model.get("empty"))||(!C.model.contents.haveDetails())){this.hdaQueue.add({name:C.model.id,fn:function(){var D=C.model.contents.fetch({data:{details:"all"},silent:true});return D.done(function(E){C.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},renderInfo:function(C){return this.$(".header .header-info").text(C)},events:{"click .done.btn":"close","click .create-new.btn":"create","click #include-deleted":"_clickToggleDeletedHistories","click .order .set-order":"_chooseOrder","click #toggle-deleted":"_clickToggleDeletedDatasets","click #toggle-hidden":"_clickToggleHiddenDatasets"},close:function(D){var C="/";if(Galaxy&&Galaxy.options&&Galaxy.options.root){C=Galaxy.options.root}else{if(galaxy_config&&galaxy_config.root){C=galaxy_config.root}}window.location=C},_clickToggleDeletedHistories:function(C){return this.toggleDeletedHistories($(C.currentTarget).is(":checked"))},toggleDeletedHistories:function(C){if(C){window.location=Galaxy.options.root+"history/view_multiple?include_deleted_histories=True"}else{window.location=Galaxy.options.root+"history/view_multiple"}},_clickToggleDeletedDatasets:function(C){return this.toggleDeletedDatasets($(C.currentTarget).is(":checked"))},toggleDeletedDatasets:function(C){C=C!==undefined?C:false;var D=this;D.sortedFilteredColumns().forEach(function(F,E){_.delay(function(){F.panel.toggleShowDeleted(C,false)},E*200)})},_clickToggleHiddenDatasets:function(C){return this.toggleHiddenDatasets($(C.currentTarget).is(":checked"))},toggleHiddenDatasets:function(C){C=C!==undefined?C:false;var D=this;D.sortedFilteredColumns().forEach(function(F,E){_.delay(function(){F.panel.toggleShowHidden(C,false)},E*200)})},_chooseOrder:function(D){var C=$(D.currentTarget).data("order");this.sortCollection(C)},setUpBehaviors:function(){var D=this;D._moreOptionsPopover();D.$("#search-histories").searchInput({name:"search-histories",placeholder:_l("search histories"),onsearch:function(E){D.searchFor=E;D.filters=[function(){return this.model.matchesAll(D.searchFor)}];D.renderColumns(0)},onclear:function(E){D.searchFor=null;D.filters=[];D.renderColumns(0)}});D.$("#search-datasets").searchInput({name:"search-datasets",placeholder:_l("search all datasets"),onfirstsearch:function(E){D.hdaQueue.clear();D.$("#search-datasets").searchInput("toggle-loading");D.searchFor=E;D.sortedFilteredColumns().forEach(function(F){F.panel.searchItems(E);D.queueHdaFetchDetails(F)});D.hdaQueue.progress(function(F){D.renderInfo([_l("searching"),(F.curr+1),_l("of"),F.total].join(" "))});D.hdaQueue.deferred.done(function(){D.renderInfo("");D.$("#search-datasets").searchInput("toggle-loading")})},onsearch:function(E){D.searchFor=E;D.sortedFilteredColumns().forEach(function(F){F.panel.searchItems(E)})},onclear:function(E){D.searchFor=null;D.sortedFilteredColumns().forEach(function(F){F.panel.clearSearch()})}});$(window).resize(function(){D._recalcFirstColumnHeight()});var C=_.debounce(_.bind(this.checkColumnsInView,this),100);this.$(".middle").parent().scroll(C)},_moreOptionsPopover:function(){return this.$(".open-more-options.btn").popover({container:".header",placement:"bottom",html:true,content:$(this.optionsPopoverTemplate(this))})},_recalcFirstColumnHeight:function(){var C=this.$(".history-column").first(),E=this.$(".middle").height(),D=C.find(".panel-controls").height();C.height(E).find(".inner").height(E-D)},_viewport:function(){var C=this.$(".middle").parent().offset().left;return{left:C,right:C+this.$(".middle").parent().width()}},columnsInView:function(){var C=this._viewport();return this.sortedFilteredColumns().filter(function(D){return D.currentHistory||D.inView(C.left,C.right)})},checkColumnsInView:function(){this.columnsInView().forEach(function(C){C.trigger("in-view",C)})},currentColumnDropTargetOn:function(){var C=this.columnMap[this.currentHistoryId];if(!C){return}C.panel.dataDropped=function(D){};C.panel.dropTargetOn()},currentColumnDropTargetOff:function(){var C=this.columnMap[this.currentHistoryId];if(!C){return}C.panel.dataDropped=l.HistoryPanelEdit.prototype.dataDrop;C.panel.dropTarget=false;C.panel.$(".history-drop-target").remove()},toString:function(){return"MultiPanelColumns("+(this.columns?this.columns.length:0)+")"},mainTemplate:_.template(['<div class="header flex-column-container">','<div class="control-column control-column-left flex-column">','<button class="create-new btn btn-default" tabindex="4">',_l("Create new"),"</button> ",'<div id="search-histories" class="search-control"></div>','<div id="search-datasets" class="search-control"></div>','<a class="open-more-options btn btn-default" tabindex="3">','<span class="fa fa-ellipsis-h"></span>',"</a>","</div>",'<div class="control-column control-column-center flex-column">','<div class="header-info">',"</div>","</div>",'<div class="control-column control-column-right flex-column">','<button class="done btn btn-default" tabindex="1">',_l("Done"),"</button>","</div>","</div>",'<div class="outer-middle flex-row flex-row-container">','<div class="middle flex-column-container flex-row"></div>',"</div>",'<div class="footer flex-column-container">',"</div>"].join(""),{variable:"view"}),optionsPopoverTemplate:_.template(['<div class="more-options">','<div class="order btn-group">','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">',_l("Order histories by")+" ",'<span class="current-order"><%= view.sortOrders[ view.order ].text %></span> ','<span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">',"<% _.each( view.sortOrders, function( order, key ){ %>",'<li><a href="javascript:void(0);" class="set-order" data-order="<%= key %>">',"<%= order.text %>","</a></li>","<% }); %>","</ul>","</div>",'<div class="checkbox"><label><input id="include-deleted" type="checkbox"','<%= view.collection.includeDeleted? " checked" : "" %>>',_l("Include deleted histories"),"</label></div>","<hr />",'<div class="checkbox"><label><input id="toggle-deleted" type="checkbox">',_l("Include deleted datasets"),"</label></div>",'<div class="checkbox"><label><input id="toggle-hidden" type="checkbox">',_l("Include hidden datasets"),"</label></div>","</div>"].join(""),{variable:"view"})});return{MultiPanelColumns:m}}); \ No newline at end of file diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 static/scripts/packed/mvc/list/list-panel.js --- a/static/scripts/packed/mvc/list/list-panel.js +++ b/static/scripts/packed/mvc/list/list-panel.js @@ -1,1 +1,1 @@ -define(["mvc/list/list-item","ui/loading-indicator","mvc/base-mvc","utils/localization","ui/search-input"],function(d,f,b,c){var e=Backbone.View.extend(b.LoggableMixin).extend({viewClass:d.ListItemView,collectionClass:Backbone.Collection,tagName:"div",className:"list-panel",fxSpeed:"fast",emptyMsg:c("This list is empty"),noneFoundMsg:c("No matching items found"),searchPlaceholder:c("search"),multiselectActions:[],initialize:function(g,h){g=g||{};if(g.logger){this.logger=g.logger}this.log(this+".initialize:",g);this.fxSpeed=_.has(g,"fxSpeed")?(g.fxSpeed):(this.fxSpeed);this.filters=[];this.searchFor=g.searchFor||"";this.indicator=new f(this.$el);this.selecting=(g.selecting!==undefined)?g.selecting:true;this.selected=g.selected||[];this.lastSelected=null;this.dragItems=g.dragItems||false;this.viewClass=g.viewClass||this.viewClass;this.views=[];this.collection=g.collection||(new this.collectionClass([]));this.filters=g.filters||[];this.$scrollContainer=g.$scrollContainer||this.$scrollContainer;this.title=g.title||"";this.subtitle=g.subtitle||"";this.multiselectActions=g.multiselectActions||this.multiselectActions;this.actionsPopup=null;this._setUpListeners()},freeViews:function(){_.each(this.views,function(g){g.off()});this.views=[];return this},_setUpListeners:function(){this.off();this.on("error",function(h,k,g,j,i){console.error(h,k,g,j,i)},this);this.on("loading",function(){this._showLoadingIndicator("loading...",40)},this);this.on("loading-done",function(){this._hideLoadingIndicator(40)},this);this.once("rendered",function(){this.trigger("rendered:initial",this)},this);if(this.logger){this.on("all",function(g){this.log(this+"",arguments)},this)}this._setUpCollectionListeners();this._setUpViewListeners();return this},_setUpCollectionListeners:function(){this.log(this+"._setUpCollectionListeners",this.collection);this.collection.off();this.collection.on("error",function(h,k,g,j,i){this.trigger("error",h,k,g,j,i)},this);this.collection.on("reset",function(){this.renderItems()},this);this.collection.on("add",this.addItemView,this);this.collection.on("remove",this.removeItemView,this);if(this.logger){this.collection.on("all",function(g){this.info(this+"(collection)",arguments)},this)}return this},_setUpViewListeners:function(){this.log(this+"._setUpViewListeners");this.on("view:selected",function(g,h){if(h&&h.shiftKey&&this.lastSelected){var i=this.viewFromModelId(this.lastSelected);if(i){this.selectRange(g,i)}}else{if(h&&h.altKey&&!this.selecting){this.showSelectors()}}this.selected.push(g.model.id);this.lastSelected=g.model.id},this);this.on("view:de-selected",function(g,h){this.selected=_.without(this.selected,g.model.id)},this)},render:function(h){this.log(this+".render",h);var g=this._buildNewRender();this._setUpBehaviors(g);this._queueNewRender(g,h);return this},_buildNewRender:function(){this.debug(this+"(ListPanel)._buildNewRender");var g=$(this.templates.el({},this));this._renderControls(g);this._renderTitle(g);this._renderSubtitle(g);this._renderSearch(g);this.renderItems(g);return g},_renderControls:function(h){this.debug(this+"(ListPanel)._renderControls");var g=$(this.templates.controls({},this));h.find(".controls").replaceWith(g);return g},_renderTitle:function(g){},_renderSubtitle:function(g){},_queueNewRender:function(h,i){i=(i===undefined)?(this.fxSpeed):(i);var g=this;g.log("_queueNewRender:",h,i);$(g).queue("fx",[function(j){this.$el.fadeOut(i,j)},function(j){g._swapNewRender(h);j()},function(j){this.$el.fadeIn(i,j)},function(j){g.trigger("rendered",g);j()}])},_swapNewRender:function(g){this.$el.empty().attr("class",this.className).append(g.children());if(this.selecting){this.showSelectors(0)}return this},_setUpBehaviors:function(g){g=g||this.$el;g.find(".controls [title]").tooltip({placement:"bottom"});return this},$scrollContainer:function(){return this.$el.parent().parent()},$list:function(g){return(g||this.$el).find("> .list-items")},$messages:function(g){return(g||this.$el).find("> .controls .messages")},$emptyMessage:function(g){return(g||this.$el).find("> .empty-message")},renderItems:function(i){i=i||this.$el;var g=this;g.log(this+".renderItems",i);var h=g.$list(i);g.views=g._filterCollection().map(function(j){return g._createItemView(j).render(0)});h.empty();if(g.views.length){g._attachItems(i);g.$emptyMessage(i).hide()}else{g._renderEmptyMessage(i).show()}return g.views},_filterCollection:function(){var g=this;return g.collection.filter(_.bind(g._filterItem,g))},_filterItem:function(h){var g=this;return(_.every(g.filters.map(function(i){return i.call(h)})))&&(!g.searchFor||h.matchesAll(g.searchFor))},_createItemView:function(i){var j=this._getItemViewClass(i),h=_.extend(this._getItemViewOptions(i),{model:i}),g=new j(h);this._setUpItemViewListeners(g);return g},_getItemViewClass:function(g){return this.viewClass},_getItemViewOptions:function(g){return{fxSpeed:this.fxSpeed,expanded:false,selectable:this.selecting,selected:_.contains(this.selected,g.id),draggable:this.dragItems}},_setUpItemViewListeners:function(h){var g=this;h.on("all",function(){var i=Array.prototype.slice.call(arguments,0);i[0]="view:"+i[0];g.trigger.apply(g,i)});h.on("draggable:dragstart",function(l,i){var j={},k=this.getSelectedModels();if(k.length){j=k.toJSON()}else{j=[i.model.toJSON()]}l.dataTransfer.setData("text",JSON.stringify(j))},this);return g},_attachItems:function(g){this.$list(g).append(this.views.map(function(h){return h.$el}));return this},_renderEmptyMessage:function(g){this.debug("_renderEmptyMessage",g,this.searchFor);var h=this.searchFor?this.noneFoundMsg:this.emptyMsg;return this.$emptyMessage(g).text(h)},expandAll:function(){_.each(this.views,function(g){g.expand()})},collapseAll:function(){_.each(this.views,function(g){g.collapse()})},addItemView:function(j,k,i){this.log(this+".addItemView:",j);var h=this;if(!h._filterItem(j)){return undefined}var g=h._createItemView(j);$(g).queue("fx",[function(l){h.$emptyMessage().fadeOut(h.fxSpeed,l)},function(l){h._attachView(g);l()}]);return g},_attachView:function(h){var g=this;g.views.push(h);g.$list().append(h.render(0).$el.hide());g.trigger("view:attached",h);h.$el.slideDown(g.fxSpeed,function(){g.trigger("view:attached:rendered")})},removeItemView:function(j,k,i){this.log(this+".removeItemView:",j);var h=this,g=h.viewFromModel(j);if(!g){return undefined}h.views=_.without(h.views,g);h.trigger("view:removed",g);$({}).queue("fx",[function(l){g.$el.fadeOut(h.fxSpeed,l)},function(l){g.remove();h.trigger("view:removed:rendered");if(!h.views.length){h._renderEmptyMessage().fadeIn(h.fxSpeed,l)}else{l()}}]);return g},viewFromModelId:function(h){for(var g=0;g<this.views.length;g++){if(this.views[g].model.id===h){return this.views[g]}}return undefined},viewFromModel:function(g){if(!g){return undefined}return this.viewFromModelId(g.id)},viewsWhereModel:function(g){return this.views.filter(function(h){var j=h.model.toJSON();for(var i in g){if(g.hasOwnProperty(i)){if(j[i]!==h.model.get(i)){return false}}}return true})},viewRange:function(j,i){if(j===i){return(j)?([j]):([])}var h=this.views.indexOf(j),g=this.views.indexOf(i);if(h===-1||g===-1){if(h===g){return[]}return(h===-1)?([i]):([j])}return(h<g)?this.views.slice(h,g+1):this.views.slice(g,h+1)},_renderSearch:function(g){g.find(".controls .search-input").searchInput({placeholder:this.searchPlaceholder,initialVal:this.searchFor,onfirstsearch:_.bind(this._firstSearch,this),onsearch:_.bind(this.searchItems,this),onclear:_.bind(this.clearSearch,this)});return g},_firstSearch:function(g){this.log("onFirstSearch",g);return this.searchItems(g)},searchItems:function(g){this.searchFor=g;this.trigger("search:searching",g,this);this.renderItems();this.$("> .controls .search-query").val(g);return this},clearSearch:function(g){this.searchFor="";this.trigger("search:clear",this);this.renderItems();this.$("> .controls .search-query").val("");return this},showSelectors:function(g){g=(g!==undefined)?(g):(this.fxSpeed);this.selecting=true;this.$(".list-actions").slideDown(g);_.each(this.views,function(h){h.showSelector(g)})},hideSelectors:function(g){g=(g!==undefined)?(g):(this.fxSpeed);this.selecting=false;this.$(".list-actions").slideUp(g);_.each(this.views,function(h){h.hideSelector(g)});this.selected=[];this.lastSelected=null},toggleSelectors:function(){if(!this.selecting){this.showSelectors()}else{this.hideSelectors()}},selectAll:function(g){_.each(this.views,function(h){h.select(g)})},deselectAll:function(g){this.lastSelected=null;_.each(this.views,function(h){h.deselect(g)})},selectRange:function(i,h){var g=this.viewRange(i,h);_.each(g,function(j){j.select()});return g},getSelectedViews:function(){return _.filter(this.views,function(g){return g.selected})},getSelectedModels:function(){return new this.collection.constructor(_.map(this.getSelectedViews(),function(g){return g.model}))},_showLoadingIndicator:function(h,g,i){this.debug("_showLoadingIndicator",this.indicator,h,g,i);g=(g!==undefined)?(g):(this.fxSpeed);if(!this.indicator){this.indicator=new f(this.$el,this.$el.parent());this.debug("\t created",this.indicator)}if(!this.$el.is(":visible")){this.indicator.show(0,i)}else{this.$el.fadeOut(g);this.indicator.show(h,g,i)}},_hideLoadingIndicator:function(g,h){this.debug("_hideLoadingIndicator",this.indicator,g,h);g=(g!==undefined)?(g):(this.fxSpeed);if(this.indicator){this.indicator.hide(g,h)}},scrollPosition:function(){return this.$scrollContainer().scrollTop()},scrollTo:function(h,g){g=g||0;this.$scrollContainer().animate({scrollTop:h},g);return this},scrollToTop:function(g){return this.scrollTo(0,g)},scrollToItem:function(g,i){if(!g){return this}var h=g.$el.position().top;return this.scrollTo(h,i)},scrollToId:function(h,g){return this.scrollToItem(this.viewFromModelId(h),g)},events:{"click .select-all":"selectAll","click .deselect-all":"deselectAll"},toString:function(){return"ListPanel("+this.collection+")"}});e.prototype.templates=(function(){var h=b.wrapTemplate(["<div>",'<div class="controls"></div>','<div class="list-items"></div>','<div class="empty-message infomessagesmall"></div>',"</div>"]);var g=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= view.title %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>","</div>","</div>"]);return{el:h,controls:g}}());var a=e.extend({modelCollectionKey:"contents",initialize:function(g){e.prototype.initialize.call(this,g);this.selecting=(g.selecting!==undefined)?g.selecting:false;this.setModel(this.model,g)},setModel:function(h,g){g=g||{};this.debug(this+".setModel:",h,g);this.freeModel();this.freeViews();if(h){var i=this.model?this.model.get("id"):null;this.model=h;if(this.logger){this.model.logger=this.logger}this._setUpModelListeners();this.collection.off();this.collection=(this.model[this.modelCollectionKey])?this.model[this.modelCollectionKey]:(g.collection||(new this.collectionClass([])));this._setUpCollectionListeners();if(i&&h.get("id")!==i){this.trigger("new-model",this)}}return this},freeModel:function(){if(this.model){this.stopListening(this.model)}return this},_setUpModelListeners:function(){this.log(this+"._setUpModelListeners",this.model);this.model.on("error",function(){var g=Array.prototype.slice.call(arguments,0);g.unshift("error");this.trigger.apply(this,g)},this);return this},_renderControls:function(h){this.debug(this+"(ListPanel)._renderControls");var i=this.model?this.model.toJSON():{},g=$(this.templates.controls(i,this));h.find(".controls").replaceWith(g);return g},toString:function(){return"ModelListPanel("+this.model+")"}});a.prototype.templates=(function(){var g=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= model.name %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>","</div>","</div>"]);return _.extend(_.clone(e.prototype.templates),{controls:g})}());return{ListPanel:e,ModelListPanel:a}}); \ No newline at end of file +define(["mvc/list/list-item","ui/loading-indicator","mvc/base-mvc","utils/localization","ui/search-input"],function(d,f,b,c){var e=Backbone.View.extend(b.LoggableMixin).extend({viewClass:d.ListItemView,collectionClass:Backbone.Collection,tagName:"div",className:"list-panel",fxSpeed:"fast",emptyMsg:c("This list is empty"),noneFoundMsg:c("No matching items found"),searchPlaceholder:c("search"),initialize:function(g,h){g=g||{};if(g.logger){this.logger=g.logger}this.log(this+".initialize:",g);this.fxSpeed=_.has(g,"fxSpeed")?(g.fxSpeed):(this.fxSpeed);this.filters=[];this.searchFor=g.searchFor||"";this.indicator=new f(this.$el);this.selecting=(g.selecting!==undefined)?g.selecting:true;this.selected=g.selected||[];this.lastSelected=null;this.dragItems=g.dragItems||false;this.viewClass=g.viewClass||this.viewClass;this.views=[];this.collection=g.collection||(new this.collectionClass([]));this.filters=g.filters||[];this.$scrollContainer=g.$scrollContainer||this.$scrollContainer;this.title=g.title||"";this.subtitle=g.subtitle||"";this._setUpListeners()},freeViews:function(){_.each(this.views,function(g){g.off()});this.views=[];return this},_setUpListeners:function(){this.off();this.on("error",function(h,k,g,j,i){console.error(h,k,g,j,i)},this);this.on("loading",function(){this._showLoadingIndicator("loading...",40)},this);this.on("loading-done",function(){this._hideLoadingIndicator(40)},this);this.once("rendered",function(){this.trigger("rendered:initial",this)},this);if(this.logger){this.on("all",function(g){this.log(this+"",arguments)},this)}this._setUpCollectionListeners();this._setUpViewListeners();return this},_setUpCollectionListeners:function(){this.log(this+"._setUpCollectionListeners",this.collection);this.collection.off();this.collection.on("error",function(h,k,g,j,i){this.trigger("error",h,k,g,j,i)},this);this.collection.on("reset",function(){this.renderItems()},this);this.collection.on("add",this.addItemView,this);this.collection.on("remove",this.removeItemView,this);if(this.logger){this.collection.on("all",function(g){this.info(this+"(collection)",arguments)},this)}return this},_setUpViewListeners:function(){this.log(this+"._setUpViewListeners");this.on("view:selected",function(g,h){if(h&&h.shiftKey&&this.lastSelected){var i=this.viewFromModelId(this.lastSelected);if(i){this.selectRange(g,i)}}else{if(h&&h.altKey&&!this.selecting){this.showSelectors()}}this.selected.push(g.model.id);this.lastSelected=g.model.id},this);this.on("view:de-selected",function(g,h){this.selected=_.without(this.selected,g.model.id)},this)},render:function(h){this.log(this+".render",h);var g=this._buildNewRender();this._setUpBehaviors(g);this._queueNewRender(g,h);return this},_buildNewRender:function(){this.debug(this+"(ListPanel)._buildNewRender");var g=$(this.templates.el({},this));this._renderControls(g);this._renderTitle(g);this._renderSubtitle(g);this._renderSearch(g);this.renderItems(g);return g},_renderControls:function(h){this.debug(this+"(ListPanel)._renderControls");var g=$(this.templates.controls({},this));h.find(".controls").replaceWith(g);return g},_renderTitle:function(g){},_renderSubtitle:function(g){},_queueNewRender:function(h,i){i=(i===undefined)?(this.fxSpeed):(i);var g=this;g.log("_queueNewRender:",h,i);$(g).queue("fx",[function(j){this.$el.fadeOut(i,j)},function(j){g._swapNewRender(h);j()},function(j){this.$el.fadeIn(i,j)},function(j){g.trigger("rendered",g);j()}])},_swapNewRender:function(g){this.$el.empty().attr("class",this.className).append(g.children());if(this.selecting){this.showSelectors(0)}return this},_setUpBehaviors:function(g){g=g||this.$el;g.find(".controls [title]").tooltip({placement:"bottom"});this._renderMultiselectActionMenu(g);return this},_renderMultiselectActionMenu:function(g){g=g||this.$el;var h=g.find(".list-action-menu"),k=this.multiselectActions();if(!k.length){return h.empty()}var j=$(['<div class="list-action-menu btn-group">','<button class="list-action-menu-btn btn btn-default dropdown-toggle" data-toggle="dropdown">',c("For all selected"),"...","</button>",'<ul class="dropdown-menu pull-right" role="menu">',"</ul>","</div>"].join(""));var i=k.map(function(m){var l=['<li><a href="javascript:void(0);">',m.html,"</a></li>"].join("");return $(l).click(m.func)});j.find("ul").append(i);h.replaceWith(j);return j},multiselectActions:function(){return[]},$scrollContainer:function(){return this.$el.parent().parent()},$list:function(g){return(g||this.$el).find("> .list-items")},$messages:function(g){return(g||this.$el).find("> .controls .messages")},$emptyMessage:function(g){return(g||this.$el).find("> .empty-message")},renderItems:function(i){i=i||this.$el;var g=this;g.log(this+".renderItems",i);var h=g.$list(i);g.views=g._filterCollection().map(function(j){return g._createItemView(j).render(0)});h.empty();if(g.views.length){g._attachItems(i);g.$emptyMessage(i).hide()}else{g._renderEmptyMessage(i).show()}return g.views},_filterCollection:function(){var g=this;return g.collection.filter(_.bind(g._filterItem,g))},_filterItem:function(h){var g=this;return(_.every(g.filters.map(function(i){return i.call(h)})))&&(!g.searchFor||h.matchesAll(g.searchFor))},_createItemView:function(i){var j=this._getItemViewClass(i),h=_.extend(this._getItemViewOptions(i),{model:i}),g=new j(h);this._setUpItemViewListeners(g);return g},_getItemViewClass:function(g){return this.viewClass},_getItemViewOptions:function(g){return{fxSpeed:this.fxSpeed,expanded:false,selectable:this.selecting,selected:_.contains(this.selected,g.id),draggable:this.dragItems}},_setUpItemViewListeners:function(h){var g=this;h.on("all",function(){var i=Array.prototype.slice.call(arguments,0);i[0]="view:"+i[0];g.trigger.apply(g,i)});h.on("draggable:dragstart",function(l,i){var j={},k=this.getSelectedModels();if(k.length){j=k.toJSON()}else{j=[i.model.toJSON()]}l.dataTransfer.setData("text",JSON.stringify(j))},this);return g},_attachItems:function(g){this.$list(g).append(this.views.map(function(h){return h.$el}));return this},_renderEmptyMessage:function(g){this.debug("_renderEmptyMessage",g,this.searchFor);var h=this.searchFor?this.noneFoundMsg:this.emptyMsg;return this.$emptyMessage(g).text(h)},expandAll:function(){_.each(this.views,function(g){g.expand()})},collapseAll:function(){_.each(this.views,function(g){g.collapse()})},addItemView:function(j,k,i){this.log(this+".addItemView:",j);var h=this;if(!h._filterItem(j)){return undefined}var g=h._createItemView(j);$(g).queue("fx",[function(l){h.$emptyMessage().fadeOut(h.fxSpeed,l)},function(l){h._attachView(g);l()}]);return g},_attachView:function(h){var g=this;g.views.push(h);g.$list().append(h.render(0).$el.hide());g.trigger("view:attached",h);h.$el.slideDown(g.fxSpeed,function(){g.trigger("view:attached:rendered")})},removeItemView:function(j,k,i){this.log(this+".removeItemView:",j);var h=this,g=h.viewFromModel(j);if(!g){return undefined}h.views=_.without(h.views,g);h.trigger("view:removed",g);$({}).queue("fx",[function(l){g.$el.fadeOut(h.fxSpeed,l)},function(l){g.remove();h.trigger("view:removed:rendered");if(!h.views.length){h._renderEmptyMessage().fadeIn(h.fxSpeed,l)}else{l()}}]);return g},viewFromModelId:function(h){for(var g=0;g<this.views.length;g++){if(this.views[g].model.id===h){return this.views[g]}}return undefined},viewFromModel:function(g){if(!g){return undefined}return this.viewFromModelId(g.id)},viewsWhereModel:function(g){return this.views.filter(function(h){var j=h.model.toJSON();for(var i in g){if(g.hasOwnProperty(i)){if(j[i]!==h.model.get(i)){return false}}}return true})},viewRange:function(j,i){if(j===i){return(j)?([j]):([])}var h=this.views.indexOf(j),g=this.views.indexOf(i);if(h===-1||g===-1){if(h===g){return[]}return(h===-1)?([i]):([j])}return(h<g)?this.views.slice(h,g+1):this.views.slice(g,h+1)},_renderSearch:function(g){g.find(".controls .search-input").searchInput({placeholder:this.searchPlaceholder,initialVal:this.searchFor,onfirstsearch:_.bind(this._firstSearch,this),onsearch:_.bind(this.searchItems,this),onclear:_.bind(this.clearSearch,this)});return g},_firstSearch:function(g){this.log("onFirstSearch",g);return this.searchItems(g)},searchItems:function(g){this.searchFor=g;this.trigger("search:searching",g,this);this.renderItems();this.$("> .controls .search-query").val(g);return this},clearSearch:function(g){this.searchFor="";this.trigger("search:clear",this);this.renderItems();this.$("> .controls .search-query").val("");return this},showSelectors:function(g){g=(g!==undefined)?(g):(this.fxSpeed);this.selecting=true;this.$(".list-actions").slideDown(g);_.each(this.views,function(h){h.showSelector(g)})},hideSelectors:function(g){g=(g!==undefined)?(g):(this.fxSpeed);this.selecting=false;this.$(".list-actions").slideUp(g);_.each(this.views,function(h){h.hideSelector(g)});this.selected=[];this.lastSelected=null},toggleSelectors:function(){if(!this.selecting){this.showSelectors()}else{this.hideSelectors()}},selectAll:function(g){_.each(this.views,function(h){h.select(g)})},deselectAll:function(g){this.lastSelected=null;_.each(this.views,function(h){h.deselect(g)})},selectRange:function(i,h){var g=this.viewRange(i,h);_.each(g,function(j){j.select()});return g},getSelectedViews:function(){return _.filter(this.views,function(g){return g.selected})},getSelectedModels:function(){return new this.collection.constructor(_.map(this.getSelectedViews(),function(g){return g.model}))},_showLoadingIndicator:function(h,g,i){this.debug("_showLoadingIndicator",this.indicator,h,g,i);g=(g!==undefined)?(g):(this.fxSpeed);if(!this.indicator){this.indicator=new f(this.$el,this.$el.parent());this.debug("\t created",this.indicator)}if(!this.$el.is(":visible")){this.indicator.show(0,i)}else{this.$el.fadeOut(g);this.indicator.show(h,g,i)}},_hideLoadingIndicator:function(g,h){this.debug("_hideLoadingIndicator",this.indicator,g,h);g=(g!==undefined)?(g):(this.fxSpeed);if(this.indicator){this.indicator.hide(g,h)}},scrollPosition:function(){return this.$scrollContainer().scrollTop()},scrollTo:function(h,g){g=g||0;this.$scrollContainer().animate({scrollTop:h},g);return this},scrollToTop:function(g){return this.scrollTo(0,g)},scrollToItem:function(g,i){if(!g){return this}var h=g.$el.position().top;return this.scrollTo(h,i)},scrollToId:function(h,g){return this.scrollToItem(this.viewFromModelId(h),g)},events:{"click .select-all":"selectAll","click .deselect-all":"deselectAll"},toString:function(){return"ListPanel("+this.collection+")"}});e.prototype.templates=(function(){var h=b.wrapTemplate(["<div>",'<div class="controls"></div>','<div class="list-items"></div>','<div class="empty-message infomessagesmall"></div>',"</div>"]);var g=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= view.title %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>",'<div class="list-action-menu btn-group">',"</div>","</div>","</div>"]);return{el:h,controls:g}}());var a=e.extend({modelCollectionKey:"contents",initialize:function(g){e.prototype.initialize.call(this,g);this.selecting=(g.selecting!==undefined)?g.selecting:false;this.setModel(this.model,g)},setModel:function(h,g){g=g||{};this.debug(this+".setModel:",h,g);this.freeModel();this.freeViews();if(h){var i=this.model?this.model.get("id"):null;this.model=h;if(this.logger){this.model.logger=this.logger}this._setUpModelListeners();this.collection.off();this.collection=(this.model[this.modelCollectionKey])?this.model[this.modelCollectionKey]:(g.collection||(new this.collectionClass([])));this._setUpCollectionListeners();if(i&&h.get("id")!==i){this.trigger("new-model",this)}}return this},freeModel:function(){if(this.model){this.stopListening(this.model)}return this},_setUpModelListeners:function(){this.log(this+"._setUpModelListeners",this.model);this.model.on("error",function(){var g=Array.prototype.slice.call(arguments,0);g.unshift("error");this.trigger.apply(this,g)},this);return this},_renderControls:function(h){this.debug(this+"(ListPanel)._renderControls");var i=this.model?this.model.toJSON():{},g=$(this.templates.controls(i,this));h.find(".controls").replaceWith(g);return g},toString:function(){return"ModelListPanel("+this.model+")"}});a.prototype.templates=(function(){var g=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= model.name %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>",'<div class="list-action-menu btn-group">',"</div>","</div>","</div>"]);return _.extend(_.clone(e.prototype.templates),{controls:g})}());return{ListPanel:e,ModelListPanel:a}}); \ No newline at end of file diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 static/style/blue/base.css --- a/static/style/blue/base.css +++ b/static/style/blue/base.css @@ -2007,7 +2007,8 @@ .list-panel .controls .list-actions:after{clear:both} .list-panel .controls .list-actions:before,.list-panel .controls .list-actions:after{content:" ";display:table;} .list-panel .controls .list-actions:after{clear:both} -.list-panel .controls .list-actions .btn{padding-top:2px;padding-bottom:2px;font-size:90%} +.list-panel .controls .list-actions .btn{padding-top:2px;padding-bottom:2px;font-size:90%;z-index:inherit} +.list-panel .controls .list-actions .list-action-menu{float:right}.list-panel .controls .list-actions .list-action-menu .dropdown-menu{z-index:inherit} .list-panel .list-items .list-item:not(:last-child){border-bottom-width:0px} .list-panel .empty-message{display:none;margin:0px} .list-item .details .list-panel{margin-top:8px;border-radius:3px;background:white;padding:4px}.list-item .details .list-panel .list-items{border:1px solid #bfbfbf;border-radius:3px}.list-item .details .list-panel .list-items .list-item:first-child{border-top-width:0px;border-radius:3px 3px 0px 0px} @@ -2078,7 +2079,6 @@ .history-panel .controls .annotation-display .annotation{border-radius:3px;border:1px solid rgba(153,153,153,0.5);padding:4px;white-space:pre-wrap;overflow:auto} .history-panel .controls .annotation-display .annotation:empty:after{position:relative;top:-4px;font-size:10px;font-style:italic;color:grey;content:'Click here to edit annotation'} .history-panel .controls .annotation-display textarea{margin:0px 0px 2px 0px;border-radius:3px;width:100%} -.history-panel .controls .list-actions .list-action-popup-btn{float:right} .history-panel .list-item.history-content{border-width:1px 0px 0px 0px}.history-panel .list-item.history-content:last-child{border-width:1px 0px 1px 0px} .history-panel .empty-message{margin:0px 10px 0px 10px} .history-panel .dataset-collection .subtitle{margin-top:2px} diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 static/style/src/less/history.less --- a/static/style/src/less/history.less +++ b/static/style/src/less/history.less @@ -449,12 +449,6 @@ width: 100%; } } - - .list-actions { - .list-action-popup-btn { - float: right; - } - } } // display only a top border on all diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 static/style/src/less/list-item.less --- a/static/style/src/less/list-item.less +++ b/static/style/src/less/list-item.less @@ -167,6 +167,13 @@ padding-top: 2px; padding-bottom: 2px; font-size: 90%; + z-index: inherit; + } + .list-action-menu { + float: right; + .dropdown-menu { + z-index: inherit; + } } } } diff -r 9bb938ddd02e88abce8570049049982acc934690 -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 templates/webapps/galaxy/history/view_multiple.mako --- a/templates/webapps/galaxy/history/view_multiple.mako +++ b/templates/webapps/galaxy/history/view_multiple.mako @@ -43,7 +43,6 @@ multipanel = new MULTI_PANEL.MultiPanelColumns({ el : $( '#center' ).get(0), histories : histories, - //historiesJSON : historiesJSON, order : bootstrapped.order, currentHistoryId : '${current_history_id}' }).render( 0 ); https://bitbucket.org/galaxy/galaxy-central/commits/316080b22578/ Changeset: 316080b22578 User: carlfeberhard Date: 2015-02-17 14:54:52+00:00 Summary: merge Affected #: 19 files diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 client/galaxy/scripts/mvc/history/history-contents.js --- a/client/galaxy/scripts/mvc/history/history-contents.js +++ b/client/galaxy/scripts/mvc/history/history-contents.js @@ -25,7 +25,6 @@ /** since history content is a mix, override model fn into a factory, creating based on history_content_type */ model : function( attrs, options ) { - //console.debug( 'HistoryContents.model:', attrs, options ); //TODO: can we move the type_id stuff here? //attrs.type_id = typeIdStr( attrs ); @@ -185,16 +184,36 @@ return deferred; }, + isCopyable : function( contentsJSON ){ + var copyableModelClasses = [ + 'HistoryDatasetAssociation', + 'HistoryDatasetCollectionAssociation' + ]; + return ( ( _.isObject( contentsJSON ) && contentsJSON.id ) + && ( _.contains( copyableModelClasses, contentsJSON.model_class ) ) ); + }, + /** copy an existing, accessible hda into this collection */ - copy : function( id, contentType ){ - contentType = contentType || 'hda'; - var type = ( contentType === 'hdca'? 'dataset_collection' : 'dataset' ), - collection = this; - - var xhr = jQuery.post( this.url(), { - type : type, + copy : function( json ){ + var id, type, contentType; + if( _.isString( json ) ){ + id = json; + contentType = 'hda'; + type = 'dataset'; + } else { + id = json.id; + contentType = ({ + 'HistoryDatasetAssociation' : 'hda', + 'LibraryDatasetDatasetAssociation' : 'ldda', + 'HistoryDatasetCollectionAssociation' : 'hdca' + })[ json.model_class ] || 'hda'; + type = ( contentType === 'hdca'? 'dataset_collection' : 'dataset' ); + } + var collection = this, + xhr = jQuery.post( this.url(), { + content : id, source : contentType, - content : id + type : type }) .done( function( json ){ collection.add([ json ]); diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 client/galaxy/scripts/mvc/history/history-panel-edit.js --- a/client/galaxy/scripts/mvc/history/history-panel-edit.js +++ b/client/galaxy/scripts/mvc/history/history-panel-edit.js @@ -69,8 +69,6 @@ /** is the panel currently showing the dataset selection controls? */ this.annotationEditorShown = attributes.annotationEditorShown || false; this.tagsEditorShown = attributes.tagsEditorShown || false; - - this.multiselectActions = attributes.multiselectActions || this._getActions(); }, /** Override to handle history as drag-drop target */ @@ -210,11 +208,6 @@ _super.prototype._setUpBehaviors.call( this, $where ); if( !this.model ){ return; } - // set up the pupup for actions available when multi selecting - if( this.multiselectActions.length ){ - this.actionsPopup = new PopupMenu( $where.find( '.list-action-popup-btn' ), this.multiselectActions ); - } - // anon users shouldn't have access to any of the following if( ( !Galaxy.currUser || Galaxy.currUser.isAnonymous() ) || ( Galaxy.currUser.id !== this.model.get( 'user_id' ) ) ){ @@ -245,7 +238,7 @@ /** return a new popup menu for choosing a multi selection action * ajax calls made for multiple datasets are queued */ - _getActions : function(){ + multiselectActions : function(){ var panel = this, actions = [ { html: _l( 'Hide datasets' ), func: function(){ diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 client/galaxy/scripts/mvc/history/history-panel.js --- a/client/galaxy/scripts/mvc/history/history-panel.js +++ b/client/galaxy/scripts/mvc/history/history-panel.js @@ -7,6 +7,7 @@ "mvc/collection/collection-panel", "mvc/user/user-model", "ui/fa-icon-button", + "mvc/ui/popup-menu", "mvc/base-mvc", "utils/localization", "ui/search-input" @@ -19,6 +20,7 @@ COLLECTION_PANEL, USER, faIconButton, + PopupMenu, BASE_MVC, _l ){ @@ -302,7 +304,8 @@ /** In this override, add a btn to toggle the selectors */ _buildNewRender : function(){ var $newRender = _super.prototype._buildNewRender.call( this ); - if( this.multiselectActions.length ){ + //if( this.views.length && this.multiselectActions().length ){ + if( this.multiselectActions().length ){ $newRender.find( '.controls .actions' ).prepend( this._renderSelectButton() ); } return $newRender; @@ -617,10 +620,18 @@ '<div class="actions"></div>', '<div class="messages">', - '<% if( history.deleted ){ %>', + '<% if( history.deleted && history.purged ){ %>', + '<div class="deleted-msg warningmessagesmall">', + _l( 'This history has been purged and deleted' ), + '</div>', + '<% } else if( history.deleted ){ %>', '<div class="deleted-msg warningmessagesmall">', _l( 'This history has been deleted' ), '</div>', + '<% } else if( history.purged ){ %>', + '<div class="deleted-msg warningmessagesmall">', + _l( 'This history has been purged' ), + '</div>', '<% } %>', '<% if( history.message ){ %>', @@ -646,8 +657,8 @@ '<button class="deselect-all btn btn-default"', 'data-mode="select">', _l( 'None' ), '</button>', '</div>', - '<button class="list-action-popup-btn btn btn-default">', - _l( 'For all selected' ), '...</button>', + '<div class="list-action-menu btn-group">', + '</div>', '</div>', '</div>' ], 'history' ); diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 client/galaxy/scripts/mvc/history/multi-panel.js --- a/client/galaxy/scripts/mvc/history/multi-panel.js +++ b/client/galaxy/scripts/mvc/history/multi-panel.js @@ -353,8 +353,8 @@ '</a></li>', '<% } %>', '</ul>', - '<% } %>', - '</div>', + '</div>', + '<% } %>', '</div>' ].join( '' ), { variable: 'data' }), @@ -669,11 +669,7 @@ /** set up listeners for a column and it's panel - handling: hda lazy-loading, drag and drop */ setUpColumnListeners : function setUpColumnListeners( column ){ - var multipanel = this, - modelClassToSource = { - 'HistoryDatasetAssociation' : 'hda', - 'HistoryDatasetCollectionAssociation' : 'hdca' - }; + var multipanel = this; multipanel.listenTo( column, { //'all': function(){ console.info( 'column ' + column + ':', arguments ) }, 'in-view': multipanel.queueHdaFetch @@ -691,20 +687,18 @@ multipanel.currentColumnDropTargetOff(); }, 'droptarget:drop': function( ev, data, panel ){ - //note: this will bad copy sources fail silently + //note: bad copy sources fail silently var toCopy = multipanel._dropData.filter( function( json ){ - return ( ( _.isObject( json ) && json.id ) - && ( _.contains( _.keys( modelClassToSource ), json.model_class ) ) ); + return panel.model.contents.isCopyable( json ); }); multipanel._dropData = null; var queue = new ajaxQueue.NamedAjaxQueue(); toCopy.forEach( function( content ){ - var contentType = modelClassToSource[ content.model_class ]; queue.add({ name : 'copy-' + content.id, fn : function(){ - return panel.model.contents.copy( content.id, contentType ); + return panel.model.contents.copy( content ); } }); }); @@ -714,7 +708,6 @@ }); } }); - }, /** conv. fn to count the columns in columnMap */ diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 client/galaxy/scripts/mvc/list/list-panel.js --- a/client/galaxy/scripts/mvc/list/list-panel.js +++ b/client/galaxy/scripts/mvc/list/list-panel.js @@ -46,9 +46,6 @@ /** string used for search placeholder */ searchPlaceholder : _l( 'search' ), - /** actions available for multiselected items */ - multiselectActions : [], - // ......................................................................... SET UP /** Set up the view, set up storage, bind listeners to HistoryContents events * @param {Object} attributes optional settings for the list @@ -103,11 +100,6 @@ this.title = attributes.title || ''; this.subtitle = attributes.subtitle || ''; - // allow override of multiselectActions through attributes - this.multiselectActions = attributes.multiselectActions || this.multiselectActions; - /** the popup displayed when 'for all selected...' is clicked */ - this.actionsPopup = null; - this._setUpListeners(); }, @@ -288,9 +280,45 @@ _setUpBehaviors : function( $where ){ $where = $where || this.$el; $where.find( '.controls [title]' ).tooltip({ placement: 'bottom' }); + // set up the pupup for actions available when multi selecting + this._renderMultiselectActionMenu( $where ); return this; }, + /** render a menu containing the actions available to sets of selected items */ + _renderMultiselectActionMenu : function( $where ){ + $where = $where || this.$el; + var $menu = $where.find( '.list-action-menu' ), + actions = this.multiselectActions(); + if( !actions.length ){ + return $menu.empty(); + } + + var $newMenu = $([ + '<div class="list-action-menu btn-group">', + '<button class="list-action-menu-btn btn btn-default dropdown-toggle" data-toggle="dropdown">', + _l( 'For all selected' ), '...', + '</button>', + '<ul class="dropdown-menu pull-right" role="menu">', '</ul>', + '</div>' + ].join('')); + var $actions = actions.map( function( action ){ + var html = [ '<li><a href="javascript:void(0);">', action.html, '</a></li>' ].join( '' ); + return $( html ).click( action.func ); + }); + $newMenu.find( 'ul' ).append( $actions ); + $menu.replaceWith( $newMenu ); + return $newMenu; + }, + + /** return a list of plain objects used to render multiselect actions menu. Each object should have: + * html: an html string used as the anchor contents + * func: a function called when the anchor is clicked (passed the click event) + */ + multiselectActions : function(){ + return []; + }, + // ------------------------------------------------------------------------ sub-$element shortcuts /** the scroll container for this panel - can be $el, $el.parent(), or grandparent depending on context */ $scrollContainer : function(){ @@ -790,9 +818,8 @@ '<button class="deselect-all btn btn-default"', 'data-mode="select">', _l( 'None' ), '</button>', '</div>', - //'<button class="list-action-popup-btn btn btn-default">', - // _l( 'For all selected' ), '...', - //'</button>', + '<div class="list-action-menu btn-group">', + '</div>', '</div>', '</div>' ]); @@ -929,9 +956,8 @@ '<button class="deselect-all btn btn-default"', 'data-mode="select">', _l( 'None' ), '</button>', '</div>', - //'<button class="list-action-popup-btn btn btn-default">', - // _l( 'For all selected' ), '...', - //'</button>', + '<div class="list-action-menu btn-group">', + '</div>', '</div>', '</div>' ]); diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 static/scripts/mvc/history/history-contents.js --- a/static/scripts/mvc/history/history-contents.js +++ b/static/scripts/mvc/history/history-contents.js @@ -25,7 +25,6 @@ /** since history content is a mix, override model fn into a factory, creating based on history_content_type */ model : function( attrs, options ) { - //console.debug( 'HistoryContents.model:', attrs, options ); //TODO: can we move the type_id stuff here? //attrs.type_id = typeIdStr( attrs ); @@ -185,16 +184,36 @@ return deferred; }, + isCopyable : function( contentsJSON ){ + var copyableModelClasses = [ + 'HistoryDatasetAssociation', + 'HistoryDatasetCollectionAssociation' + ]; + return ( ( _.isObject( contentsJSON ) && contentsJSON.id ) + && ( _.contains( copyableModelClasses, contentsJSON.model_class ) ) ); + }, + /** copy an existing, accessible hda into this collection */ - copy : function( id, contentType ){ - contentType = contentType || 'hda'; - var type = ( contentType === 'hdca'? 'dataset_collection' : 'dataset' ), - collection = this; - - var xhr = jQuery.post( this.url(), { - type : type, + copy : function( json ){ + var id, type, contentType; + if( _.isString( json ) ){ + id = json; + contentType = 'hda'; + type = 'dataset'; + } else { + id = json.id; + contentType = ({ + 'HistoryDatasetAssociation' : 'hda', + 'LibraryDatasetDatasetAssociation' : 'ldda', + 'HistoryDatasetCollectionAssociation' : 'hdca' + })[ json.model_class ] || 'hda'; + type = ( contentType === 'hdca'? 'dataset_collection' : 'dataset' ); + } + var collection = this, + xhr = jQuery.post( this.url(), { + content : id, source : contentType, - content : id + type : type }) .done( function( json ){ collection.add([ json ]); diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 static/scripts/mvc/history/history-panel-edit.js --- a/static/scripts/mvc/history/history-panel-edit.js +++ b/static/scripts/mvc/history/history-panel-edit.js @@ -69,8 +69,6 @@ /** is the panel currently showing the dataset selection controls? */ this.annotationEditorShown = attributes.annotationEditorShown || false; this.tagsEditorShown = attributes.tagsEditorShown || false; - - this.multiselectActions = attributes.multiselectActions || this._getActions(); }, /** Override to handle history as drag-drop target */ @@ -210,11 +208,6 @@ _super.prototype._setUpBehaviors.call( this, $where ); if( !this.model ){ return; } - // set up the pupup for actions available when multi selecting - if( this.multiselectActions.length ){ - this.actionsPopup = new PopupMenu( $where.find( '.list-action-popup-btn' ), this.multiselectActions ); - } - // anon users shouldn't have access to any of the following if( ( !Galaxy.currUser || Galaxy.currUser.isAnonymous() ) || ( Galaxy.currUser.id !== this.model.get( 'user_id' ) ) ){ @@ -245,7 +238,7 @@ /** return a new popup menu for choosing a multi selection action * ajax calls made for multiple datasets are queued */ - _getActions : function(){ + multiselectActions : function(){ var panel = this, actions = [ { html: _l( 'Hide datasets' ), func: function(){ diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 static/scripts/mvc/history/history-panel.js --- a/static/scripts/mvc/history/history-panel.js +++ b/static/scripts/mvc/history/history-panel.js @@ -7,6 +7,7 @@ "mvc/collection/collection-panel", "mvc/user/user-model", "ui/fa-icon-button", + "mvc/ui/popup-menu", "mvc/base-mvc", "utils/localization", "ui/search-input" @@ -19,6 +20,7 @@ COLLECTION_PANEL, USER, faIconButton, + PopupMenu, BASE_MVC, _l ){ @@ -302,7 +304,8 @@ /** In this override, add a btn to toggle the selectors */ _buildNewRender : function(){ var $newRender = _super.prototype._buildNewRender.call( this ); - if( this.multiselectActions.length ){ + //if( this.views.length && this.multiselectActions().length ){ + if( this.multiselectActions().length ){ $newRender.find( '.controls .actions' ).prepend( this._renderSelectButton() ); } return $newRender; @@ -617,10 +620,18 @@ '<div class="actions"></div>', '<div class="messages">', - '<% if( history.deleted ){ %>', + '<% if( history.deleted && history.purged ){ %>', + '<div class="deleted-msg warningmessagesmall">', + _l( 'This history has been purged and deleted' ), + '</div>', + '<% } else if( history.deleted ){ %>', '<div class="deleted-msg warningmessagesmall">', _l( 'This history has been deleted' ), '</div>', + '<% } else if( history.purged ){ %>', + '<div class="deleted-msg warningmessagesmall">', + _l( 'This history has been purged' ), + '</div>', '<% } %>', '<% if( history.message ){ %>', @@ -646,8 +657,8 @@ '<button class="deselect-all btn btn-default"', 'data-mode="select">', _l( 'None' ), '</button>', '</div>', - '<button class="list-action-popup-btn btn btn-default">', - _l( 'For all selected' ), '...</button>', + '<div class="list-action-menu btn-group">', + '</div>', '</div>', '</div>' ], 'history' ); diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 static/scripts/mvc/history/multi-panel.js --- a/static/scripts/mvc/history/multi-panel.js +++ b/static/scripts/mvc/history/multi-panel.js @@ -353,8 +353,8 @@ '</a></li>', '<% } %>', '</ul>', - '<% } %>', - '</div>', + '</div>', + '<% } %>', '</div>' ].join( '' ), { variable: 'data' }), @@ -669,11 +669,7 @@ /** set up listeners for a column and it's panel - handling: hda lazy-loading, drag and drop */ setUpColumnListeners : function setUpColumnListeners( column ){ - var multipanel = this, - modelClassToSource = { - 'HistoryDatasetAssociation' : 'hda', - 'HistoryDatasetCollectionAssociation' : 'hdca' - }; + var multipanel = this; multipanel.listenTo( column, { //'all': function(){ console.info( 'column ' + column + ':', arguments ) }, 'in-view': multipanel.queueHdaFetch @@ -691,20 +687,18 @@ multipanel.currentColumnDropTargetOff(); }, 'droptarget:drop': function( ev, data, panel ){ - //note: this will bad copy sources fail silently + //note: bad copy sources fail silently var toCopy = multipanel._dropData.filter( function( json ){ - return ( ( _.isObject( json ) && json.id ) - && ( _.contains( _.keys( modelClassToSource ), json.model_class ) ) ); + return panel.model.contents.isCopyable( json ); }); multipanel._dropData = null; var queue = new ajaxQueue.NamedAjaxQueue(); toCopy.forEach( function( content ){ - var contentType = modelClassToSource[ content.model_class ]; queue.add({ name : 'copy-' + content.id, fn : function(){ - return panel.model.contents.copy( content.id, contentType ); + return panel.model.contents.copy( content ); } }); }); @@ -714,7 +708,6 @@ }); } }); - }, /** conv. fn to count the columns in columnMap */ diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 static/scripts/mvc/list/list-panel.js --- a/static/scripts/mvc/list/list-panel.js +++ b/static/scripts/mvc/list/list-panel.js @@ -46,9 +46,6 @@ /** string used for search placeholder */ searchPlaceholder : _l( 'search' ), - /** actions available for multiselected items */ - multiselectActions : [], - // ......................................................................... SET UP /** Set up the view, set up storage, bind listeners to HistoryContents events * @param {Object} attributes optional settings for the list @@ -103,11 +100,6 @@ this.title = attributes.title || ''; this.subtitle = attributes.subtitle || ''; - // allow override of multiselectActions through attributes - this.multiselectActions = attributes.multiselectActions || this.multiselectActions; - /** the popup displayed when 'for all selected...' is clicked */ - this.actionsPopup = null; - this._setUpListeners(); }, @@ -288,9 +280,45 @@ _setUpBehaviors : function( $where ){ $where = $where || this.$el; $where.find( '.controls [title]' ).tooltip({ placement: 'bottom' }); + // set up the pupup for actions available when multi selecting + this._renderMultiselectActionMenu( $where ); return this; }, + /** render a menu containing the actions available to sets of selected items */ + _renderMultiselectActionMenu : function( $where ){ + $where = $where || this.$el; + var $menu = $where.find( '.list-action-menu' ), + actions = this.multiselectActions(); + if( !actions.length ){ + return $menu.empty(); + } + + var $newMenu = $([ + '<div class="list-action-menu btn-group">', + '<button class="list-action-menu-btn btn btn-default dropdown-toggle" data-toggle="dropdown">', + _l( 'For all selected' ), '...', + '</button>', + '<ul class="dropdown-menu pull-right" role="menu">', '</ul>', + '</div>' + ].join('')); + var $actions = actions.map( function( action ){ + var html = [ '<li><a href="javascript:void(0);">', action.html, '</a></li>' ].join( '' ); + return $( html ).click( action.func ); + }); + $newMenu.find( 'ul' ).append( $actions ); + $menu.replaceWith( $newMenu ); + return $newMenu; + }, + + /** return a list of plain objects used to render multiselect actions menu. Each object should have: + * html: an html string used as the anchor contents + * func: a function called when the anchor is clicked (passed the click event) + */ + multiselectActions : function(){ + return []; + }, + // ------------------------------------------------------------------------ sub-$element shortcuts /** the scroll container for this panel - can be $el, $el.parent(), or grandparent depending on context */ $scrollContainer : function(){ @@ -790,9 +818,8 @@ '<button class="deselect-all btn btn-default"', 'data-mode="select">', _l( 'None' ), '</button>', '</div>', - //'<button class="list-action-popup-btn btn btn-default">', - // _l( 'For all selected' ), '...', - //'</button>', + '<div class="list-action-menu btn-group">', + '</div>', '</div>', '</div>' ]); @@ -929,9 +956,8 @@ '<button class="deselect-all btn btn-default"', 'data-mode="select">', _l( 'None' ), '</button>', '</div>', - //'<button class="list-action-popup-btn btn btn-default">', - // _l( 'For all selected' ), '...', - //'</button>', + '<div class="list-action-menu btn-group">', + '</div>', '</div>', '</div>' ]); diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 static/scripts/packed/mvc/history/history-contents.js --- a/static/scripts/packed/mvc/history/history-contents.js +++ b/static/scripts/packed/mvc/history/history-contents.js @@ -1,1 +1,1 @@ -define(["mvc/history/history-content-model","mvc/history/hda-model","mvc/history/hdca-model","mvc/base-mvc","utils/localization"],function(g,e,b,a,c){var f=Backbone.Collection.extend(a.LoggableMixin).extend({model:function(i,h){if(i.history_content_type==="dataset"){return new e.HistoryDatasetAssociation(i,h)}else{if(i.history_content_type==="dataset_collection"){switch(i.collection_type){case"list":return new b.HistoryListDatasetCollection(i,h);case"paired":return new b.HistoryPairDatasetCollection(i,h);case"list:paired":return new b.HistoryListPairedDatasetCollection(i,h)}throw new TypeError("Unknown collection_type: "+i.collection_type)}}throw new TypeError("Unknown history_content_type: "+i.history_content_type)},initialize:function(i,h){h=h||{};this.historyId=h.historyId;this.on("all",function(){this.debug(this+".event:",arguments)})},urlRoot:galaxy_config.root+"api/histories",url:function(){return this.urlRoot+"/"+this.historyId+"/contents"},ids:function(){return this.map(function(h){return h.get("id")})},notReady:function(){return this.filter(function(h){return !h.inReadyState()})},running:function(){var h=[];this.each(function(j){var i=!j.inReadyState();if(i){h.push(j.get("id"))}});return h},getByHid:function(h){return _.first(this.filter(function(i){return i.get("hid")===h}))},getVisible:function(h,k,j){j=j||[];this.debug("checking isVisible");var i=new f(this.filter(function(l){return l.isVisible(h,k)}));_.each(j,function(l){if(!_.isFunction(l)){return}i=new f(i.filter(l))});return i},haveDetails:function(){return this.all(function(h){return h.hasDetails()})},fetchAllDetails:function(i){i=i||{};var h={details:"all"};i.data=(i.data)?(_.extend(i.data,h)):(h);return this.fetch(i)},ajaxQueue:function(m,j){var i=jQuery.Deferred(),h=this.length,l=[];if(!h){i.resolve([]);return i}var k=this.chain().reverse().map(function(o,n){return function(){var p=m.call(o,j);p.done(function(q){i.notify({curr:n,total:h,response:q,model:o})});p.always(function(q){l.push(q);if(k.length){k.shift()()}else{i.resolve(l)}})}}).value();k.shift()();return i},copy:function(l,k){k=k||"hda";var h=(k==="hdca"?"dataset_collection":"dataset"),j=this;var i=jQuery.post(this.url(),{type:h,source:k,content:l}).done(function(m){j.add([m])}).fail(function(n,m,o){j.trigger("error",j,i,{},"Error copying contents",{type:h,id:l,source:k})});return i},matches:function(h){return this.filter(function(i){return i.matches(h)})},set:function(j,h){this.debug("set:",j);var i=this;j=_.map(j,function(m){var l=m.attributes||m,n=g.typeIdStr(l.history_content_type,l.id),o=i.get(n);if(!o){return m}var k=_.clone(o.attributes);_.extend(k,m);return k});Backbone.Collection.prototype.set.call(this,j,h)},promoteToHistoryDatasetCollection:function d(m,k,i){i=i||{};i.url=this.url();i.type="POST";var o=k;var l=[],h=null;if(k==="list"){this.chain().each(function(r){var p=r.attributes.name;var s=r.get("id");var q=r.attributes.history_content_type;if(q==="dataset"){if(o!=="list"){this.log("Invalid collection type")}l.push({name:p,src:"hda",id:s})}else{if(o==="list"){o="list:"+r.attributes.collection_type}else{if(o!=="list:"+r.attributes.collection_type){this.log("Invalid collection type")}}l.push({name:p,src:"hdca",id:s})}});h="New Dataset List"}else{if(k==="paired"){var j=this.ids();if(j.length!==2){}l.push({name:"forward",src:"hda",id:j[0]});l.push({name:"reverse",src:"hda",id:j[1]});h="New Dataset Pair"}}i.data={type:"dataset_collection",name:h,collection_type:o,element_identifiers:JSON.stringify(l)};var n=jQuery.ajax(i);n.done(function(r,p,q){m.refresh()});n.fail(function(r,p,q){if(r.responseJSON&&r.responseJSON.error){error=r.responseJSON.error}else{error=r.responseJSON}r.responseText=error});return n},clone:function(){var h=Backbone.Collection.prototype.clone.call(this);h.historyId=this.historyId;return h},print:function(){var h=this;h.each(function(i){h.debug(i);if(i.elements){h.debug("\t elements:",i.elements)}})},toString:function(){return(["HistoryContents(",[this.historyId,this.length].join(),")"].join(""))}});return{HistoryContents:f}}); \ No newline at end of file +define(["mvc/history/history-content-model","mvc/history/hda-model","mvc/history/hdca-model","mvc/base-mvc","utils/localization"],function(g,e,b,a,c){var f=Backbone.Collection.extend(a.LoggableMixin).extend({model:function(i,h){if(i.history_content_type==="dataset"){return new e.HistoryDatasetAssociation(i,h)}else{if(i.history_content_type==="dataset_collection"){switch(i.collection_type){case"list":return new b.HistoryListDatasetCollection(i,h);case"paired":return new b.HistoryPairDatasetCollection(i,h);case"list:paired":return new b.HistoryListPairedDatasetCollection(i,h)}throw new TypeError("Unknown collection_type: "+i.collection_type)}}throw new TypeError("Unknown history_content_type: "+i.history_content_type)},initialize:function(i,h){h=h||{};this.historyId=h.historyId;this.on("all",function(){this.debug(this+".event:",arguments)})},urlRoot:galaxy_config.root+"api/histories",url:function(){return this.urlRoot+"/"+this.historyId+"/contents"},ids:function(){return this.map(function(h){return h.get("id")})},notReady:function(){return this.filter(function(h){return !h.inReadyState()})},running:function(){var h=[];this.each(function(j){var i=!j.inReadyState();if(i){h.push(j.get("id"))}});return h},getByHid:function(h){return _.first(this.filter(function(i){return i.get("hid")===h}))},getVisible:function(h,k,j){j=j||[];this.debug("checking isVisible");var i=new f(this.filter(function(l){return l.isVisible(h,k)}));_.each(j,function(l){if(!_.isFunction(l)){return}i=new f(i.filter(l))});return i},haveDetails:function(){return this.all(function(h){return h.hasDetails()})},fetchAllDetails:function(i){i=i||{};var h={details:"all"};i.data=(i.data)?(_.extend(i.data,h)):(h);return this.fetch(i)},ajaxQueue:function(m,j){var i=jQuery.Deferred(),h=this.length,l=[];if(!h){i.resolve([]);return i}var k=this.chain().reverse().map(function(o,n){return function(){var p=m.call(o,j);p.done(function(q){i.notify({curr:n,total:h,response:q,model:o})});p.always(function(q){l.push(q);if(k.length){k.shift()()}else{i.resolve(l)}})}}).value();k.shift()();return i},isCopyable:function(i){var h=["HistoryDatasetAssociation","HistoryDatasetCollectionAssociation"];return((_.isObject(i)&&i.id)&&(_.contains(h,i.model_class)))},copy:function(h){var m,i,l;if(_.isString(h)){m=h;l="hda";i="dataset"}else{m=h.id;l=({HistoryDatasetAssociation:"hda",LibraryDatasetDatasetAssociation:"ldda",HistoryDatasetCollectionAssociation:"hdca"})[h.model_class]||"hda";i=(l==="hdca"?"dataset_collection":"dataset")}var k=this,j=jQuery.post(this.url(),{content:m,source:l,type:i}).done(function(n){k.add([n])}).fail(function(o,n,p){k.trigger("error",k,j,{},"Error copying contents",{type:i,id:m,source:l})});return j},matches:function(h){return this.filter(function(i){return i.matches(h)})},set:function(j,h){this.debug("set:",j);var i=this;j=_.map(j,function(m){var l=m.attributes||m,n=g.typeIdStr(l.history_content_type,l.id),o=i.get(n);if(!o){return m}var k=_.clone(o.attributes);_.extend(k,m);return k});Backbone.Collection.prototype.set.call(this,j,h)},promoteToHistoryDatasetCollection:function d(m,k,i){i=i||{};i.url=this.url();i.type="POST";var o=k;var l=[],h=null;if(k==="list"){this.chain().each(function(r){var p=r.attributes.name;var s=r.get("id");var q=r.attributes.history_content_type;if(q==="dataset"){if(o!=="list"){this.log("Invalid collection type")}l.push({name:p,src:"hda",id:s})}else{if(o==="list"){o="list:"+r.attributes.collection_type}else{if(o!=="list:"+r.attributes.collection_type){this.log("Invalid collection type")}}l.push({name:p,src:"hdca",id:s})}});h="New Dataset List"}else{if(k==="paired"){var j=this.ids();if(j.length!==2){}l.push({name:"forward",src:"hda",id:j[0]});l.push({name:"reverse",src:"hda",id:j[1]});h="New Dataset Pair"}}i.data={type:"dataset_collection",name:h,collection_type:o,element_identifiers:JSON.stringify(l)};var n=jQuery.ajax(i);n.done(function(r,p,q){m.refresh()});n.fail(function(r,p,q){if(r.responseJSON&&r.responseJSON.error){error=r.responseJSON.error}else{error=r.responseJSON}r.responseText=error});return n},clone:function(){var h=Backbone.Collection.prototype.clone.call(this);h.historyId=this.historyId;return h},print:function(){var h=this;h.each(function(i){h.debug(i);if(i.elements){h.debug("\t elements:",i.elements)}})},toString:function(){return(["HistoryContents(",[this.historyId,this.length].join(),")"].join(""))}});return{HistoryContents:f}}); \ No newline at end of file diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 static/scripts/packed/mvc/history/history-panel-edit.js --- a/static/scripts/packed/mvc/history/history-panel-edit.js +++ b/static/scripts/packed/mvc/history/history-panel-edit.js @@ -1,1 +1,1 @@ -define(["mvc/history/history-panel","mvc/history/history-contents","mvc/dataset/states","mvc/history/hda-model","mvc/history/hda-li-edit","mvc/history/hdca-li-edit","mvc/tags","mvc/annotations","ui/fa-icon-button","mvc/ui/popup-menu","utils/localization"],function(h,j,m,f,e,i,l,c,b,a,d){var k=h.HistoryPanel;var g=k.extend({HDAViewClass:e.HDAListItemEdit,HDCAViewClass:i.HDCAListItemEdit,initialize:function(n){n=n||{};k.prototype.initialize.call(this,n);this.tagsEditor=null;this.annotationEditor=null;this.purgeAllowed=n.purgeAllowed||false;this.annotationEditorShown=n.annotationEditorShown||false;this.tagsEditorShown=n.tagsEditorShown||false;this.multiselectActions=n.multiselectActions||this._getActions()},_setUpListeners:function(){var n=this;k.prototype._setUpListeners.call(n);n.on("drop",function(o,p){n.dataDropped(p);n.dropTargetOff()});n.on("view:attached view:removed",function(){n._renderCounts()},n)},_setUpCollectionListeners:function(){k.prototype._setUpCollectionListeners.call(this);this.collection.on("change:deleted",this._handleHdaDeletionChange,this);this.collection.on("change:visible",this._handleHdaVisibleChange,this);this.collection.on("change:purged",function(n){this.model.fetch()},this);return this},_setUpModelListeners:function(){k.prototype._setUpModelListeners.call(this);this.model.on("change:nice_size",this.updateHistoryDiskSize,this);return this},_buildNewRender:function(){var n=k.prototype._buildNewRender.call(this);if(!this.model){return n}if(Galaxy&&Galaxy.currUser&&Galaxy.currUser.id&&Galaxy.currUser.id===this.model.get("user_id")){this._renderTags(n);this._renderAnnotation(n)}return n},renderItems:function(o){var n=k.prototype.renderItems.call(this,o);this._renderCounts(o);return n},_renderCounts:function(p){function o(s,t){return['<a class="',s,'" href="javascript:void(0);">',t,"</a>"].join("")}p=p||this.$el;var n=this.collection.where({deleted:true}),r=this.collection.where({visible:false}),q=[];if(this.views.length){q.push([this.views.length,d("shown")].join(" "))}if(n.length){q.push((!this.showDeleted)?([n.length,o("toggle-deleted-link",d("deleted"))].join(" ")):(o("toggle-deleted-link",d("hide deleted"))))}if(r.length){q.push((!this.showHidden)?([r.length,o("toggle-hidden-link",d("hidden"))].join(" ")):(o("toggle-hidden-link",d("hide hidden"))))}return p.find("> .controls .subtitle").html(q.join(", "))},_renderTags:function(n){var o=this;this.tagsEditor=new l.TagsEditor({model:this.model,el:n.find(".controls .tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){o.toggleHDATagEditors(true,o.fxSpeed)},onhide:function(){o.toggleHDATagEditors(false,o.fxSpeed)},$activator:b({title:d("Edit history tags"),classes:"history-tag-btn",faIcon:"fa-tags"}).appendTo(n.find(".controls .actions"))})},_renderAnnotation:function(n){var o=this;this.annotationEditor=new c.AnnotationEditor({model:this.model,el:n.find(".controls .annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){o.toggleHDAAnnotationEditors(true,o.fxSpeed)},onhide:function(){o.toggleHDAAnnotationEditors(false,o.fxSpeed)},$activator:b({title:d("Edit history annotation"),classes:"history-annotate-btn",faIcon:"fa-comment"}).appendTo(n.find(".controls .actions"))})},_setUpBehaviors:function(n){n=n||this.$el;k.prototype._setUpBehaviors.call(this,n);if(!this.model){return}if(this.multiselectActions.length){this.actionsPopup=new a(n.find(".list-action-popup-btn"),this.multiselectActions)}if((!Galaxy.currUser||Galaxy.currUser.isAnonymous())||(Galaxy.currUser.id!==this.model.get("user_id"))){return}var o=this,p=".controls .name";n.find(p).attr("title",d("Click to rename history")).tooltip({placement:"bottom"}).make_text_editable({on_finish:function(q){var r=o.model.get("name");if(q&&q!==r){o.$el.find(p).text(q);o.model.save({name:q}).fail(function(){o.$el.find(p).text(o.model.previous("name"))})}else{o.$el.find(p).text(r)}}})},_getActions:function(){var n=this,o=[{html:d("Hide datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype.hide;n.getSelectedModels().ajaxQueue(p)}},{html:d("Unhide datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype.unhide;n.getSelectedModels().ajaxQueue(p)}},{html:d("Delete datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype["delete"];n.getSelectedModels().ajaxQueue(p)}},{html:d("Undelete datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype.undelete;n.getSelectedModels().ajaxQueue(p)}}];if(n.purgeAllowed){o.push({html:d("Permanently delete datasets"),func:function(){if(confirm(d("This will permanently remove the data in your datasets. Are you sure?"))){var p=f.HistoryDatasetAssociation.prototype.purge;n.getSelectedModels().ajaxQueue(p)}}})}o.push({html:d("Build Dataset List"),func:function(){n.getSelectedModels().promoteToHistoryDatasetCollection(n.model,"list")}});o.push({html:d("Build Dataset Pair"),func:function(){n.getSelectedModels().promoteToHistoryDatasetCollection(n.model,"paired")}});o.push({html:d("Build List of Dataset Pairs"),func:_.bind(n._showPairedCollectionModal,n)});return o},_showPairedCollectionModal:function(){var n=this,o=n.getSelectedModels().toJSON().filter(function(p){return p.history_content_type==="dataset"&&p.state===m.OK});if(o.length){require(["mvc/collection/paired-collection-creator"],function(p){window.creator=p.pairedCollectionCreatorModal(o,{historyId:n.model.id})})}else{Galaxy.modal.show({title:d("No valid datasets were selected"),body:d(["Use the checkboxes at the left of the dataset names to select them.","Selected datasets should be error-free and should have completed running."].join(" ")),buttons:{Ok:function(){Galaxy.modal.hide()}},closing_events:true})}},_attachItems:function(n){this.$list(n).append(this.views.reverse().map(function(o){return o.$el}));return this},_attachView:function(o){var n=this;n.views.unshift(o);n.$list().prepend(o.render(0).$el.hide());n.trigger("view:attached",o);o.$el.slideDown(n.fxSpeed,function(){n.trigger("view:attached:rendered")})},_getItemViewOptions:function(o){var n=k.prototype._getItemViewOptions.call(this,o);_.extend(n,{purgeAllowed:this.purgeAllowed,tagsEditorShown:(this.tagsEditor&&!this.tagsEditor.hidden),annotationEditorShown:(this.annotationEditor&&!this.annotationEditor.hidden)});return n},_handleHdaDeletionChange:function(n){if(n.get("deleted")&&!this.showDeleted){this.removeItemView(n)}this._renderCounts()},_handleHdaVisibleChange:function(n){if(n.hidden()&&!this.storage.showHidden){this.removeItemView(n)}this._renderCounts()},toggleHDATagEditors:function(n){var o=Array.prototype.slice.call(arguments,1);_.each(this.views,function(p){if(p.tagsEditor){p.tagsEditor.toggle.apply(p.tagsEditor,o)}})},toggleHDAAnnotationEditors:function(n){var o=Array.prototype.slice.call(arguments,1);_.each(this.views,function(p){if(p.annotationEditor){p.annotationEditor.toggle.apply(p.annotationEditor,o)}})},events:_.extend(_.clone(k.prototype.events),{"click .show-selectors-btn":"toggleSelectors","click .toggle-deleted-link":function(n){this.toggleShowDeleted()},"click .toggle-hidden-link":function(n){this.toggleShowHidden()}}),updateHistoryDiskSize:function(){this.$el.find(".history-size").text(this.model.get("nice_size"))},dropTargetOn:function(){if(this.dropTarget){return this}this.dropTarget=true;var o={dragenter:_.bind(this.dragenter,this),dragover:_.bind(this.dragover,this),dragleave:_.bind(this.dragleave,this),drop:_.bind(this.drop,this)};var p=this._renderDropTarget();this.$list().before([this._renderDropTargetHelp(),p]);for(var n in o){if(o.hasOwnProperty(n)){p.on(n,o[n])}}return this},_renderDropTarget:function(){this.$(".history-drop-target").remove();return $("<div/>").addClass("history-drop-target").css({height:"64px",margin:"0px 10px 10px 10px",border:"1px dashed black","border-radius":"3px"})},_renderDropTargetHelp:function(){this.$(".history-drop-target-help").remove();return $("<div/>").addClass("history-drop-target-help").css({margin:"10px 10px 4px 10px",color:"grey","font-size":"80%","font-style":"italic"}).text(d("Drag datasets here to copy them to the current history"))},dropTargetOff:function(){if(!this.dropTarget){return this}this.dropTarget=false;var o=this.$(".history-drop-target").get(0);for(var n in this._dropHandlers){if(this._dropHandlers.hasOwnProperty(n)){console.debug(n,this._dropHandlers[n]);o.off(n,this._dropHandlers[n])}}this.$(".history-drop-target").remove();this.$(".history-drop-target-help").remove();return this},dropTargetToggle:function(){if(this.dropTarget){this.dropTargetOff()}else{this.dropTargetOn()}return this},dragenter:function(n){n.preventDefault();n.stopPropagation();this.$(".history-drop-target").css("border","2px solid black")},dragover:function(n){n.preventDefault();n.stopPropagation()},dragleave:function(n){n.preventDefault();n.stopPropagation();this.$(".history-drop-target").css("border","1px dashed black")},drop:function(p){p.preventDefault();p.dataTransfer.dropEffect="move";var n=this,q=p.dataTransfer.getData("text");try{q=JSON.parse(q)}catch(o){this.warn("error parsing JSON from drop:",q)}this.trigger("droptarget:drop",p,q,n);return false},dataDropped:function(o){var n=this;if(_.isObject(o)&&o.model_class==="HistoryDatasetAssociation"&&o.id){return n.model.contents.copy(o.id)}return jQuery.when()},toString:function(){return"HistoryPanelEdit("+((this.model)?(this.model.get("name")):(""))+")"}});return{HistoryPanelEdit:g}}); \ No newline at end of file +define(["mvc/history/history-panel","mvc/history/history-contents","mvc/dataset/states","mvc/history/hda-model","mvc/history/hda-li-edit","mvc/history/hdca-li-edit","mvc/tags","mvc/annotations","ui/fa-icon-button","mvc/ui/popup-menu","utils/localization"],function(h,j,m,f,e,i,l,c,b,a,d){var k=h.HistoryPanel;var g=k.extend({HDAViewClass:e.HDAListItemEdit,HDCAViewClass:i.HDCAListItemEdit,initialize:function(n){n=n||{};k.prototype.initialize.call(this,n);this.tagsEditor=null;this.annotationEditor=null;this.purgeAllowed=n.purgeAllowed||false;this.annotationEditorShown=n.annotationEditorShown||false;this.tagsEditorShown=n.tagsEditorShown||false},_setUpListeners:function(){var n=this;k.prototype._setUpListeners.call(n);n.on("drop",function(o,p){n.dataDropped(p);n.dropTargetOff()});n.on("view:attached view:removed",function(){n._renderCounts()},n)},_setUpCollectionListeners:function(){k.prototype._setUpCollectionListeners.call(this);this.collection.on("change:deleted",this._handleHdaDeletionChange,this);this.collection.on("change:visible",this._handleHdaVisibleChange,this);this.collection.on("change:purged",function(n){this.model.fetch()},this);return this},_setUpModelListeners:function(){k.prototype._setUpModelListeners.call(this);this.model.on("change:nice_size",this.updateHistoryDiskSize,this);return this},_buildNewRender:function(){var n=k.prototype._buildNewRender.call(this);if(!this.model){return n}if(Galaxy&&Galaxy.currUser&&Galaxy.currUser.id&&Galaxy.currUser.id===this.model.get("user_id")){this._renderTags(n);this._renderAnnotation(n)}return n},renderItems:function(o){var n=k.prototype.renderItems.call(this,o);this._renderCounts(o);return n},_renderCounts:function(p){function o(s,t){return['<a class="',s,'" href="javascript:void(0);">',t,"</a>"].join("")}p=p||this.$el;var n=this.collection.where({deleted:true}),r=this.collection.where({visible:false}),q=[];if(this.views.length){q.push([this.views.length,d("shown")].join(" "))}if(n.length){q.push((!this.showDeleted)?([n.length,o("toggle-deleted-link",d("deleted"))].join(" ")):(o("toggle-deleted-link",d("hide deleted"))))}if(r.length){q.push((!this.showHidden)?([r.length,o("toggle-hidden-link",d("hidden"))].join(" ")):(o("toggle-hidden-link",d("hide hidden"))))}return p.find("> .controls .subtitle").html(q.join(", "))},_renderTags:function(n){var o=this;this.tagsEditor=new l.TagsEditor({model:this.model,el:n.find(".controls .tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){o.toggleHDATagEditors(true,o.fxSpeed)},onhide:function(){o.toggleHDATagEditors(false,o.fxSpeed)},$activator:b({title:d("Edit history tags"),classes:"history-tag-btn",faIcon:"fa-tags"}).appendTo(n.find(".controls .actions"))})},_renderAnnotation:function(n){var o=this;this.annotationEditor=new c.AnnotationEditor({model:this.model,el:n.find(".controls .annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){o.toggleHDAAnnotationEditors(true,o.fxSpeed)},onhide:function(){o.toggleHDAAnnotationEditors(false,o.fxSpeed)},$activator:b({title:d("Edit history annotation"),classes:"history-annotate-btn",faIcon:"fa-comment"}).appendTo(n.find(".controls .actions"))})},_setUpBehaviors:function(n){n=n||this.$el;k.prototype._setUpBehaviors.call(this,n);if(!this.model){return}if((!Galaxy.currUser||Galaxy.currUser.isAnonymous())||(Galaxy.currUser.id!==this.model.get("user_id"))){return}var o=this,p=".controls .name";n.find(p).attr("title",d("Click to rename history")).tooltip({placement:"bottom"}).make_text_editable({on_finish:function(q){var r=o.model.get("name");if(q&&q!==r){o.$el.find(p).text(q);o.model.save({name:q}).fail(function(){o.$el.find(p).text(o.model.previous("name"))})}else{o.$el.find(p).text(r)}}})},multiselectActions:function(){var n=this,o=[{html:d("Hide datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype.hide;n.getSelectedModels().ajaxQueue(p)}},{html:d("Unhide datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype.unhide;n.getSelectedModels().ajaxQueue(p)}},{html:d("Delete datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype["delete"];n.getSelectedModels().ajaxQueue(p)}},{html:d("Undelete datasets"),func:function(){var p=f.HistoryDatasetAssociation.prototype.undelete;n.getSelectedModels().ajaxQueue(p)}}];if(n.purgeAllowed){o.push({html:d("Permanently delete datasets"),func:function(){if(confirm(d("This will permanently remove the data in your datasets. Are you sure?"))){var p=f.HistoryDatasetAssociation.prototype.purge;n.getSelectedModels().ajaxQueue(p)}}})}o.push({html:d("Build Dataset List"),func:function(){n.getSelectedModels().promoteToHistoryDatasetCollection(n.model,"list")}});o.push({html:d("Build Dataset Pair"),func:function(){n.getSelectedModels().promoteToHistoryDatasetCollection(n.model,"paired")}});o.push({html:d("Build List of Dataset Pairs"),func:_.bind(n._showPairedCollectionModal,n)});return o},_showPairedCollectionModal:function(){var n=this,o=n.getSelectedModels().toJSON().filter(function(p){return p.history_content_type==="dataset"&&p.state===m.OK});if(o.length){require(["mvc/collection/paired-collection-creator"],function(p){window.creator=p.pairedCollectionCreatorModal(o,{historyId:n.model.id})})}else{Galaxy.modal.show({title:d("No valid datasets were selected"),body:d(["Use the checkboxes at the left of the dataset names to select them.","Selected datasets should be error-free and should have completed running."].join(" ")),buttons:{Ok:function(){Galaxy.modal.hide()}},closing_events:true})}},_attachItems:function(n){this.$list(n).append(this.views.reverse().map(function(o){return o.$el}));return this},_attachView:function(o){var n=this;n.views.unshift(o);n.$list().prepend(o.render(0).$el.hide());n.trigger("view:attached",o);o.$el.slideDown(n.fxSpeed,function(){n.trigger("view:attached:rendered")})},_getItemViewOptions:function(o){var n=k.prototype._getItemViewOptions.call(this,o);_.extend(n,{purgeAllowed:this.purgeAllowed,tagsEditorShown:(this.tagsEditor&&!this.tagsEditor.hidden),annotationEditorShown:(this.annotationEditor&&!this.annotationEditor.hidden)});return n},_handleHdaDeletionChange:function(n){if(n.get("deleted")&&!this.showDeleted){this.removeItemView(n)}this._renderCounts()},_handleHdaVisibleChange:function(n){if(n.hidden()&&!this.storage.showHidden){this.removeItemView(n)}this._renderCounts()},toggleHDATagEditors:function(n){var o=Array.prototype.slice.call(arguments,1);_.each(this.views,function(p){if(p.tagsEditor){p.tagsEditor.toggle.apply(p.tagsEditor,o)}})},toggleHDAAnnotationEditors:function(n){var o=Array.prototype.slice.call(arguments,1);_.each(this.views,function(p){if(p.annotationEditor){p.annotationEditor.toggle.apply(p.annotationEditor,o)}})},events:_.extend(_.clone(k.prototype.events),{"click .show-selectors-btn":"toggleSelectors","click .toggle-deleted-link":function(n){this.toggleShowDeleted()},"click .toggle-hidden-link":function(n){this.toggleShowHidden()}}),updateHistoryDiskSize:function(){this.$el.find(".history-size").text(this.model.get("nice_size"))},dropTargetOn:function(){if(this.dropTarget){return this}this.dropTarget=true;var o={dragenter:_.bind(this.dragenter,this),dragover:_.bind(this.dragover,this),dragleave:_.bind(this.dragleave,this),drop:_.bind(this.drop,this)};var p=this._renderDropTarget();this.$list().before([this._renderDropTargetHelp(),p]);for(var n in o){if(o.hasOwnProperty(n)){p.on(n,o[n])}}return this},_renderDropTarget:function(){this.$(".history-drop-target").remove();return $("<div/>").addClass("history-drop-target").css({height:"64px",margin:"0px 10px 10px 10px",border:"1px dashed black","border-radius":"3px"})},_renderDropTargetHelp:function(){this.$(".history-drop-target-help").remove();return $("<div/>").addClass("history-drop-target-help").css({margin:"10px 10px 4px 10px",color:"grey","font-size":"80%","font-style":"italic"}).text(d("Drag datasets here to copy them to the current history"))},dropTargetOff:function(){if(!this.dropTarget){return this}this.dropTarget=false;var o=this.$(".history-drop-target").get(0);for(var n in this._dropHandlers){if(this._dropHandlers.hasOwnProperty(n)){console.debug(n,this._dropHandlers[n]);o.off(n,this._dropHandlers[n])}}this.$(".history-drop-target").remove();this.$(".history-drop-target-help").remove();return this},dropTargetToggle:function(){if(this.dropTarget){this.dropTargetOff()}else{this.dropTargetOn()}return this},dragenter:function(n){n.preventDefault();n.stopPropagation();this.$(".history-drop-target").css("border","2px solid black")},dragover:function(n){n.preventDefault();n.stopPropagation()},dragleave:function(n){n.preventDefault();n.stopPropagation();this.$(".history-drop-target").css("border","1px dashed black")},drop:function(p){p.preventDefault();p.dataTransfer.dropEffect="move";var n=this,q=p.dataTransfer.getData("text");try{q=JSON.parse(q)}catch(o){this.warn("error parsing JSON from drop:",q)}this.trigger("droptarget:drop",p,q,n);return false},dataDropped:function(o){var n=this;if(_.isObject(o)&&o.model_class==="HistoryDatasetAssociation"&&o.id){return n.model.contents.copy(o.id)}return jQuery.when()},toString:function(){return"HistoryPanelEdit("+((this.model)?(this.model.get("name")):(""))+")"}});return{HistoryPanelEdit:g}}); \ No newline at end of file diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 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/list/list-panel","mvc/history/history-model","mvc/history/history-contents","mvc/history/hda-li","mvc/history/hdca-li","mvc/collection/collection-panel","mvc/user/user-model","ui/fa-icon-button","mvc/base-mvc","utils/localization","ui/search-input"],function(e,g,m,c,a,n,h,b,p,f){var k=p.SessionStorageModel.extend({defaults:{expandedIds:{},show_deleted:false,show_hidden:false},addExpanded:function(q){var r="expandedIds";this.save(r,_.extend(this.get(r),_.object([q.id],[q.get("id")])))},removeExpanded:function(q){var r="expandedIds";this.save(r,_.omit(this.get(r),q.id))},toString:function(){return"HistoryPrefs("+this.id+")"}});k.storageKeyPrefix="history:";k.historyStorageKey=function i(q){if(!q){throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+q)}return(k.storageKeyPrefix+q)};k.get=function d(q){return new k({id:k.historyStorageKey(q)})};k.clearAll=function j(r){for(var q in sessionStorage){if(q.indexOf(k.storageKeyPrefix)===0){sessionStorage.removeItem(q)}}};var o=e.ModelListPanel;var l=o.extend({HDAViewClass:c.HDAListItemView,HDCAViewClass:a.HDCAListItemView,collectionClass:m.HistoryContents,modelCollectionKey:"contents",tagName:"div",className:o.prototype.className+" history-panel",emptyMsg:f("This history is empty"),noneFoundMsg:f("No matching datasets found"),searchPlaceholder:f("search datasets"),initialize:function(q){o.prototype.initialize.call(this,q);this.linkTarget=q.linkTarget||"_blank"},freeModel:function(){o.prototype.freeModel.call(this);if(this.model){this.model.clearUpdateTimeout()}return this},_setUpListeners:function(){o.prototype._setUpListeners.call(this);this.on("error",function(r,u,q,t,s){this.errorHandler(r,u,q,t,s)});this.on("loading-done",function(){if(!this.views.length){this.trigger("empty-history",this)}})},loadHistoryWithDetails:function(t,s,r,u){this.info("loadHistoryWithDetails:",t,s,r,u);var q=function(v){return _.values(k.get(v.id).get("expandedIds"))};return this.loadHistory(t,s,r,u,q)},loadHistory:function(u,t,s,v,q){this.info("loadHistory:",u,t,s,v,q);var r=this;t=t||{};r.trigger("loading",r);var w=g.History.getHistoryData(u,{historyFn:s,contentsFn:v,detailIdsFn:t.initiallyExpanded||q});return r._loadHistoryFromXHR(w,t).fail(function(z,x,y){r.trigger("error",r,z,t,f("An error was encountered while "+x),{historyId:u,history:y||{}})}).always(function(){r.trigger("loading-done",r)})},_loadHistoryFromXHR:function(s,r){var q=this;s.then(function(t,u){q.JSONToModel(t,u,r);q.render()});s.fail(function(u,t){q.render()});return s},refreshContents:function(r,q){if(this.model){return this.model.refresh(r,q)}return $.when()},JSONToModel:function(t,q,r){this.log("JSONToModel:",t,q,r);r=r||{};var s=new g.History(t,q,r);this.setModel(s);return s},setModel:function(r,q){q=q||{};o.prototype.setModel.call(this,r,q);if(this.model){this._setUpWebStorage(q.initiallyExpanded,q.show_deleted,q.show_hidden)}},_setUpWebStorage:function(r,q,s){if(this.storage){this.stopListening(this.storage)}this.storage=new k({id:k.historyStorageKey(this.model.get("id"))});if(_.isObject(r)){this.storage.set("expandedIds",r)}if(_.isBoolean(q)){this.storage.set("show_deleted",q)}if(_.isBoolean(s)){this.storage.set("show_hidden",s)}this.trigger("new-storage",this.storage,this);this.log(this+" (init'd) storage:",this.storage.get());this.listenTo(this.storage,{"change:show_deleted":function(t,u){this.showDeleted=u},"change:show_hidden":function(t,u){this.showHidden=u}},this);this.showDeleted=(q!==undefined)?q:this.storage.get("show_deleted");this.showHidden=(s!==undefined)?s:this.storage.get("show_hidden");return this},_buildNewRender:function(){var q=o.prototype._buildNewRender.call(this);if(this.multiselectActions.length){q.find(".controls .actions").prepend(this._renderSelectButton())}return q},_renderSelectButton:function(q){return b({title:f("Operations on multiple datasets"),classes:"show-selectors-btn",faIcon:"fa-check-square-o"})},_getItemViewClass:function(q){var r=q.get("history_content_type");switch(r){case"dataset":return this.HDAViewClass;case"dataset_collection":return this.HDCAViewClass}throw new TypeError("Unknown history_content_type: "+r)},_filterItem:function(r){var q=this;return(o.prototype._filterItem.call(q,r)&&(!r.hidden()||q.showHidden)&&(!r.isDeletedOrPurged()||q.showDeleted))},_getItemViewOptions:function(r){var q=o.prototype._getItemViewOptions.call(this,r);return _.extend(q,{linkTarget:this.linkTarget,expanded:!!this.storage.get("expandedIds")[r.id],hasUser:this.model.ownedByCurrUser()})},_setUpItemViewListeners:function(r){var q=this;o.prototype._setUpItemViewListeners.call(q,r);r.on("expanded",function(s){q.storage.addExpanded(s.model)});r.on("collapsed",function(s){q.storage.removeExpanded(s.model)});return this},getSelectedModels:function(){var q=o.prototype.getSelectedModels.call(this);q.historyId=this.collection.historyId;return q},events:_.extend(_.clone(o.prototype.events),{"click .show-selectors-btn":"toggleSelectors"}),toggleShowDeleted:function(q,r){q=(q!==undefined)?(q):(!this.showDeleted);r=(r!==undefined)?(r):(true);this.showDeleted=q;if(r){this.storage.set("show_deleted",q)}this.trigger("show-hidden",q);this.renderItems();return this.showDeleted},toggleShowHidden:function(q,r){q=(q!==undefined)?(q):(!this.showHidden);r=(r!==undefined)?(r):(true);this.showHidden=q;if(r){this.storage.set("show_hidden",q)}this.trigger("show-hidden",q);this.renderItems();return this.showHidden},_firstSearch:function(q){var r=this,s=".history-search-input";this.log("onFirstSearch",q);if(r.model.contents.haveDetails()){r.searchItems(q);return}r.$el.find(s).searchInput("toggle-loading");r.model.contents.fetchAllDetails({silent:true}).always(function(){r.$el.find(s).searchInput("toggle-loading")}).done(function(){r.searchItems(q)})},errorHandler:function(s,v,r,u,t){this.error(s,v,r,u,t);if(v&&v.status===0&&v.readyState===0){}else{if(v&&v.status===502){}else{var q=this._parseErrorMessage(s,v,r,u,t);if(!this.$messages().is(":visible")){this.once("rendered",function(){this.displayMessage("error",q.message,q.details)})}else{this.displayMessage("error",q.message,q.details)}}}},_parseErrorMessage:function(u,x,y,s,q,v){var t=Galaxy.currUser,w={message:this._bePolite(s),details:{message:s,raven:(window.Raven&&_.isFunction(Raven.lastEventId))?(Raven.lastEventId()):(undefined),agent:navigator.userAgent,url:(window.Galaxy)?(Galaxy.lastAjax.url):(undefined),data:(window.Galaxy)?(Galaxy.lastAjax.data):(undefined),options:(x)?(_.omit(y,"xhr")):(y),xhr:x,source:(_.isFunction(u.toJSON))?(u.toJSON()):(u+""),user:(t instanceof h.User)?(t.toJSON()):(t+"")}};_.extend(w.details,q||{});if(x&&_.isFunction(x.getAllResponseHeaders)){var r=x.getAllResponseHeaders();r=_.compact(r.split("\n"));r=_.map(r,function(z){return z.split(": ")});w.details.xhr.responseHeaders=_.object(r)}return w},_bePolite:function(q){q=q||f("An error occurred while getting updates from the server");return q+". "+f("Please contact a Galaxy administrator if the problem persists")+"."},displayMessage:function(v,w,u){var s=this;this.scrollToTop();var t=this.$messages(),q=$("<div/>").addClass(v+"message").html(w);if(!_.isEmpty(u)){var r=$('<a href="javascript:void(0)">Details</a>').click(function(){Galaxy.modal.show(s._messageToModalOptions(v,w,u));return false});q.append(" ",r)}return t.html(q)},_messageToModalOptions:function(t,w,s){var q=this,r={title:"Details"};if(_.isObject(s)){s=_.omit(s,_.functions(s));var v=JSON.stringify(s,null," "),u=$("<pre/>").text(v);r.body=$("<div/>").append(u)}else{r.body=$("<div/>").html(s)}r.buttons={Ok:function(){Galaxy.modal.hide();q.clearMessages()}};return r},clearMessages:function(q){$(q.currentTarget).fadeOut(this.fxSpeed,function(){$(this).remove()});return this},scrollToHid:function(q){return this.scrollToItem(_.first(this.viewsWhereModel({hid:q})))},toString:function(){return"HistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});l.prototype.templates=(function(){var q=p.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= history.name %></div>',"</div>",'<div class="subtitle"></div>','<div class="history-size"><%= history.nice_size %></div>','<div class="actions"></div>','<div class="messages">',"<% if( history.deleted ){ %>",'<div class="deleted-msg warningmessagesmall">',f("This history has been deleted"),"</div>","<% } %>","<% if( history.message ){ %>",'<div class="<%= history.message.level || "info" %>messagesmall">',"<%= history.message.text %>","</div>","<% } %>","</div>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',f("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',f("None"),"</button>","</div>",'<button class="list-action-popup-btn btn btn-default">',f("For all selected"),"...</button>","</div>","</div>"],"history");return _.extend(_.clone(o.prototype.templates),{controls:q})}());return{HistoryPanel:l}}); \ No newline at end of file +define(["mvc/list/list-panel","mvc/history/history-model","mvc/history/history-contents","mvc/history/hda-li","mvc/history/hdca-li","mvc/collection/collection-panel","mvc/user/user-model","ui/fa-icon-button","mvc/ui/popup-menu","mvc/base-mvc","utils/localization","ui/search-input"],function(f,h,n,d,b,o,i,c,a,q,g){var l=q.SessionStorageModel.extend({defaults:{expandedIds:{},show_deleted:false,show_hidden:false},addExpanded:function(r){var s="expandedIds";this.save(s,_.extend(this.get(s),_.object([r.id],[r.get("id")])))},removeExpanded:function(r){var s="expandedIds";this.save(s,_.omit(this.get(s),r.id))},toString:function(){return"HistoryPrefs("+this.id+")"}});l.storageKeyPrefix="history:";l.historyStorageKey=function j(r){if(!r){throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+r)}return(l.storageKeyPrefix+r)};l.get=function e(r){return new l({id:l.historyStorageKey(r)})};l.clearAll=function k(s){for(var r in sessionStorage){if(r.indexOf(l.storageKeyPrefix)===0){sessionStorage.removeItem(r)}}};var p=f.ModelListPanel;var m=p.extend({HDAViewClass:d.HDAListItemView,HDCAViewClass:b.HDCAListItemView,collectionClass:n.HistoryContents,modelCollectionKey:"contents",tagName:"div",className:p.prototype.className+" history-panel",emptyMsg:g("This history is empty"),noneFoundMsg:g("No matching datasets found"),searchPlaceholder:g("search datasets"),initialize:function(r){p.prototype.initialize.call(this,r);this.linkTarget=r.linkTarget||"_blank"},freeModel:function(){p.prototype.freeModel.call(this);if(this.model){this.model.clearUpdateTimeout()}return this},_setUpListeners:function(){p.prototype._setUpListeners.call(this);this.on("error",function(s,v,r,u,t){this.errorHandler(s,v,r,u,t)});this.on("loading-done",function(){if(!this.views.length){this.trigger("empty-history",this)}})},loadHistoryWithDetails:function(u,t,s,v){this.info("loadHistoryWithDetails:",u,t,s,v);var r=function(w){return _.values(l.get(w.id).get("expandedIds"))};return this.loadHistory(u,t,s,v,r)},loadHistory:function(v,u,t,w,r){this.info("loadHistory:",v,u,t,w,r);var s=this;u=u||{};s.trigger("loading",s);var x=h.History.getHistoryData(v,{historyFn:t,contentsFn:w,detailIdsFn:u.initiallyExpanded||r});return s._loadHistoryFromXHR(x,u).fail(function(A,y,z){s.trigger("error",s,A,u,g("An error was encountered while "+y),{historyId:v,history:z||{}})}).always(function(){s.trigger("loading-done",s)})},_loadHistoryFromXHR:function(t,s){var r=this;t.then(function(u,v){r.JSONToModel(u,v,s);r.render()});t.fail(function(v,u){r.render()});return t},refreshContents:function(s,r){if(this.model){return this.model.refresh(s,r)}return $.when()},JSONToModel:function(u,r,s){this.log("JSONToModel:",u,r,s);s=s||{};var t=new h.History(u,r,s);this.setModel(t);return t},setModel:function(s,r){r=r||{};p.prototype.setModel.call(this,s,r);if(this.model){this._setUpWebStorage(r.initiallyExpanded,r.show_deleted,r.show_hidden)}},_setUpWebStorage:function(s,r,t){if(this.storage){this.stopListening(this.storage)}this.storage=new l({id:l.historyStorageKey(this.model.get("id"))});if(_.isObject(s)){this.storage.set("expandedIds",s)}if(_.isBoolean(r)){this.storage.set("show_deleted",r)}if(_.isBoolean(t)){this.storage.set("show_hidden",t)}this.trigger("new-storage",this.storage,this);this.log(this+" (init'd) storage:",this.storage.get());this.listenTo(this.storage,{"change:show_deleted":function(u,v){this.showDeleted=v},"change:show_hidden":function(u,v){this.showHidden=v}},this);this.showDeleted=(r!==undefined)?r:this.storage.get("show_deleted");this.showHidden=(t!==undefined)?t:this.storage.get("show_hidden");return this},_buildNewRender:function(){var r=p.prototype._buildNewRender.call(this);if(this.multiselectActions().length){r.find(".controls .actions").prepend(this._renderSelectButton())}return r},_renderSelectButton:function(r){return c({title:g("Operations on multiple datasets"),classes:"show-selectors-btn",faIcon:"fa-check-square-o"})},_getItemViewClass:function(r){var s=r.get("history_content_type");switch(s){case"dataset":return this.HDAViewClass;case"dataset_collection":return this.HDCAViewClass}throw new TypeError("Unknown history_content_type: "+s)},_filterItem:function(s){var r=this;return(p.prototype._filterItem.call(r,s)&&(!s.hidden()||r.showHidden)&&(!s.isDeletedOrPurged()||r.showDeleted))},_getItemViewOptions:function(s){var r=p.prototype._getItemViewOptions.call(this,s);return _.extend(r,{linkTarget:this.linkTarget,expanded:!!this.storage.get("expandedIds")[s.id],hasUser:this.model.ownedByCurrUser()})},_setUpItemViewListeners:function(s){var r=this;p.prototype._setUpItemViewListeners.call(r,s);s.on("expanded",function(t){r.storage.addExpanded(t.model)});s.on("collapsed",function(t){r.storage.removeExpanded(t.model)});return this},getSelectedModels:function(){var r=p.prototype.getSelectedModels.call(this);r.historyId=this.collection.historyId;return r},events:_.extend(_.clone(p.prototype.events),{"click .show-selectors-btn":"toggleSelectors"}),toggleShowDeleted:function(r,s){r=(r!==undefined)?(r):(!this.showDeleted);s=(s!==undefined)?(s):(true);this.showDeleted=r;if(s){this.storage.set("show_deleted",r)}this.trigger("show-hidden",r);this.renderItems();return this.showDeleted},toggleShowHidden:function(r,s){r=(r!==undefined)?(r):(!this.showHidden);s=(s!==undefined)?(s):(true);this.showHidden=r;if(s){this.storage.set("show_hidden",r)}this.trigger("show-hidden",r);this.renderItems();return this.showHidden},_firstSearch:function(r){var s=this,t=".history-search-input";this.log("onFirstSearch",r);if(s.model.contents.haveDetails()){s.searchItems(r);return}s.$el.find(t).searchInput("toggle-loading");s.model.contents.fetchAllDetails({silent:true}).always(function(){s.$el.find(t).searchInput("toggle-loading")}).done(function(){s.searchItems(r)})},errorHandler:function(t,w,s,v,u){this.error(t,w,s,v,u);if(w&&w.status===0&&w.readyState===0){}else{if(w&&w.status===502){}else{var r=this._parseErrorMessage(t,w,s,v,u);if(!this.$messages().is(":visible")){this.once("rendered",function(){this.displayMessage("error",r.message,r.details)})}else{this.displayMessage("error",r.message,r.details)}}}},_parseErrorMessage:function(v,y,z,t,r,w){var u=Galaxy.currUser,x={message:this._bePolite(t),details:{message:t,raven:(window.Raven&&_.isFunction(Raven.lastEventId))?(Raven.lastEventId()):(undefined),agent:navigator.userAgent,url:(window.Galaxy)?(Galaxy.lastAjax.url):(undefined),data:(window.Galaxy)?(Galaxy.lastAjax.data):(undefined),options:(y)?(_.omit(z,"xhr")):(z),xhr:y,source:(_.isFunction(v.toJSON))?(v.toJSON()):(v+""),user:(u instanceof i.User)?(u.toJSON()):(u+"")}};_.extend(x.details,r||{});if(y&&_.isFunction(y.getAllResponseHeaders)){var s=y.getAllResponseHeaders();s=_.compact(s.split("\n"));s=_.map(s,function(A){return A.split(": ")});x.details.xhr.responseHeaders=_.object(s)}return x},_bePolite:function(r){r=r||g("An error occurred while getting updates from the server");return r+". "+g("Please contact a Galaxy administrator if the problem persists")+"."},displayMessage:function(w,x,v){var t=this;this.scrollToTop();var u=this.$messages(),r=$("<div/>").addClass(w+"message").html(x);if(!_.isEmpty(v)){var s=$('<a href="javascript:void(0)">Details</a>').click(function(){Galaxy.modal.show(t._messageToModalOptions(w,x,v));return false});r.append(" ",s)}return u.html(r)},_messageToModalOptions:function(u,x,t){var r=this,s={title:"Details"};if(_.isObject(t)){t=_.omit(t,_.functions(t));var w=JSON.stringify(t,null," "),v=$("<pre/>").text(w);s.body=$("<div/>").append(v)}else{s.body=$("<div/>").html(t)}s.buttons={Ok:function(){Galaxy.modal.hide();r.clearMessages()}};return s},clearMessages:function(r){$(r.currentTarget).fadeOut(this.fxSpeed,function(){$(this).remove()});return this},scrollToHid:function(r){return this.scrollToItem(_.first(this.viewsWhereModel({hid:r})))},toString:function(){return"HistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});m.prototype.templates=(function(){var r=q.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= history.name %></div>',"</div>",'<div class="subtitle"></div>','<div class="history-size"><%= history.nice_size %></div>','<div class="actions"></div>','<div class="messages">',"<% if( history.deleted && history.purged ){ %>",'<div class="deleted-msg warningmessagesmall">',g("This history has been purged and deleted"),"</div>","<% } else if( history.deleted ){ %>",'<div class="deleted-msg warningmessagesmall">',g("This history has been deleted"),"</div>","<% } else if( history.purged ){ %>",'<div class="deleted-msg warningmessagesmall">',g("This history has been purged"),"</div>","<% } %>","<% if( history.message ){ %>",'<div class="<%= history.message.level || "info" %>messagesmall">',"<%= history.message.text %>","</div>","<% } %>","</div>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',g("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',g("None"),"</button>","</div>",'<div class="list-action-menu btn-group">',"</div>","</div>","</div>"],"history");return _.extend(_.clone(p.prototype.templates),{controls:r})}());return{HistoryPanel:m}}); \ No newline at end of file diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 static/scripts/packed/mvc/history/multi-panel.js --- a/static/scripts/packed/mvc/history/multi-panel.js +++ b/static/scripts/packed/mvc/history/multi-panel.js @@ -1,1 +1,1 @@ -define(["mvc/history/history-model","mvc/history/history-panel-edit","mvc/base-mvc","utils/ajax-queue","ui/mode-button","ui/search-input"],function(d,l,z,a){function g(I,E){E=E||{};if(!(Galaxy&&Galaxy.modal)){return I.copy()}var F=I.get("name"),C="Copy of '"+F+"'";function D(K){if(!K){if(!Galaxy.modal.$("#invalid-title").size()){var J=$("<p/>").attr("id","invalid-title").css({color:"red","margin-top":"8px"}).addClass("bg-danger").text(_l("Please enter a valid history title"));Galaxy.modal.$(".modal-body").append(J)}return false}return K}function G(J){var K=$('<p><span class="fa fa-spinner fa-spin"></span> Copying history...</p>').css("margin-top","8px");Galaxy.modal.$(".modal-body").append(K);I.copy(true,J).fail(function(){alert(_l("History could not be copied. Please contact a Galaxy administrator"))}).always(function(){Galaxy.modal.hide()})}function H(){var J=Galaxy.modal.$("#copy-modal-title").val();if(!D(J)){return}G(J)}Galaxy.modal.show(_.extend({title:_l("Copying history")+' "'+F+'"',body:$(['<label for="copy-modal-title">',_l("Enter a title for the copied history"),":","</label><br />",'<input id="copy-modal-title" class="form-control" style="width: 100%" value="',C,'" />'].join("")),buttons:{Cancel:function(){Galaxy.modal.hide()},Copy:H}},E));$("#copy-modal-title").focus().select();$("#copy-modal-title").on("keydown",function(J){if(J.keyCode===13){H()}})}var B=Backbone.View.extend(z.LoggableMixin).extend({tagName:"div",className:"history-column flex-column flex-row-container",id:function q(){if(!this.model){return""}return"history-column-"+this.model.get("id")},initialize:function c(C){C=C||{};this.purgeAllowed=!_.isUndefined(C.purgeAllowed)?C.purgeAllowed:false;this.panel=C.panel||this.createPanel(C);this.setUpListeners()},createPanel:function u(D){D=_.extend({model:this.model,purgeAllowed:this.purgeAllowed,dragItems:true},D);var C=new l.HistoryPanelEdit(D);C._renderEmptyMessage=this.__patch_renderEmptyMessage;return C},__patch_renderEmptyMessage:function(E){var D=this,F=_.chain(this.model.get("state_ids")).values().flatten().value().length,C=D.$emptyMessage(E);if(!_.isEmpty(D.hdaViews)){C.hide()}else{if(F&&!this.model.contents.length){C.empty().append($('<span class="fa fa-spinner fa-spin"></span><i>loading datasets...</i>')).show()}else{if(D.searchFor){C.text(D.noneFoundMsg).show()}else{C.text(D.emptyMsg).show()}}}return C},setUpListeners:function f(){var C=this;this.once("rendered",function(){C.trigger("rendered:initial",C)});this.setUpPanelListeners()},setUpPanelListeners:function k(){var C=this;this.listenTo(this.panel,{rendered:function(){C.trigger("rendered",C)}},this)},inView:function(C,D){var F=this.$el.offset().left,E=F+this.$el.width();if(E<C){return false}if(F>D){return false}return true},$panel:function e(){return this.$(".history-panel")},render:function A(D){D=(D!==undefined)?(D):("fast");var C=this.model?this.model.toJSON():{};this.$el.html(this.template(C));this.renderPanel(D);this.setUpBehaviors();return this},setUpBehaviors:function v(){},template:function w(C){C=_.extend(C||{},{isCurrentHistory:this.currentHistory});return $(['<div class="panel-controls clear flex-row">',this.controlsLeftTemplate({history:C,view:this}),this.controlsRightTemplate({history:C,view:this}),"</div>",'<div class="inner flex-row flex-column-container">','<div id="history-',C.id,'" class="history-column history-panel flex-column"></div>',"</div>"].join(""))},renderPanel:function h(C){C=(C!==undefined)?(C):("fast");this.panel.setElement(this.$panel()).render(C);if(this.currentHistory){this.panel.$list().before(this.panel._renderDropTargetHelp())}return this},events:{"click .switch-to.btn":function(){this.model.setAsCurrent()},"click .delete-history":function(){var C=this;this.model._delete().fail(function(F,D,E){alert(_l("Could not delete the history")+":\n"+E)}).done(function(D){C.render()})},"click .undelete-history":function(){var C=this;this.model.undelete().fail(function(F,D,E){alert(_l("Could not undelete the history")+":\n"+E)}).done(function(D){C.render()})},"click .purge-history":function(){if(confirm(_l("This will permanently remove the data. Are you sure?"))){var C=this;this.model.purge().fail(function(F,D,E){alert(_l("Could not purge the history")+":\n"+E)}).done(function(D){C.render()})}},"click .copy-history":"copy"},copy:function s(){g(this.model)},controlsLeftTemplate:_.template(['<div class="pull-left">',"<% if( data.history.isCurrentHistory ){ %>",'<strong class="current-label">',_l("Current History"),"</strong>","<% } else { %>",'<button class="switch-to btn btn-default">',_l("Switch to"),"</button>","<% } %>","</div>"].join(""),{variable:"data"}),controlsRightTemplate:_.template(['<div class="pull-right">',"<% if( !data.history.purged ){ %>",'<div class="panel-menu btn-group">','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">','<span class="caret"></span>',"</button>",'<ul class="dropdown-menu pull-right" role="menu">',"<% if( !data.history.deleted ){ %>",'<li><a href="javascript:void(0);" class="copy-history">',_l("Copy"),"</a></li>",'<li><a href="javascript:void(0);" class="delete-history">',_l("Delete"),"</a></li>","<% } else /* if is deleted */ { %>",'<li><a href="javascript:void(0);" class="undelete-history">',_l("Undelete"),"</a></li>","<% } %>","<% if( data.view.purgeAllowed ){ %>",'<li><a href="javascript:void(0);" class="purge-history">',_l("Purge"),"</a></li>","<% } %>","</ul>","<% } %>","</div>","</div>"].join(""),{variable:"data"}),toString:function(){return"HistoryPanelColumn("+(this.panel?this.panel:"")+")"}});var m=Backbone.View.extend(z.LoggableMixin).extend({className:"multi-panel-history",initialize:function c(C){C=C||{};this.log(this+".init",C);this.$el.addClass(this.className);if(!C.currentHistoryId){throw new Error(this+" requires a currentHistoryId in the options")}this.currentHistoryId=C.currentHistoryId;this.options={columnWidth:312,borderWidth:1,columnGap:8,headerHeight:29,footerHeight:0,controlsHeight:20};this.order=C.order||"update";this._initSortOrders();this.hdaQueue=new a.NamedAjaxQueue([],false);this.collection=null;this.setCollection(C.histories||[]);this.columnMap={};this.createColumns(C.columnOptions);this.setUpListeners()},_initSortOrders:function(){function C(D,E){return function F(H,G,I){if(H.id===I){return -1}if(G.id===I){return 1}H=D(H);G=D(G);return E.asc?((H===G)?(0):(H>G?1:-1)):((H===G)?(0):(H>G?-1:1))}}this.sortOrders={update:{text:_l("most recent first"),fn:C(function(D){return Date(D.get("update_time"))},{asc:false})},name:{text:_l("name, a to z"),fn:C(function(D){return D.get("name")},{asc:true})},"name-dsc":{text:_l("name, z to a"),fn:C(function(D){return D.get("name")},{asc:false})},size:{text:_l("size, large to small"),fn:C(function(D){return D.get("size")},{asc:false})},"size-dsc":{text:_l("size, small to large"),fn:C(function(D){return D.get("size")},{asc:true})}};return this.sortOrders},setUpListeners:function f(){},setCollection:function y(D){var C=this;C.stopListening(C.collection);C.collection=D;C.sortCollection(C.order,{silent:true});C.setUpCollectionListeners();C.trigger("new-collection",C);return C},setUpCollectionListeners:function(){var C=this,D=C.collection;C.listenTo(D,{add:C.addAsCurrentColumn,"set-as-current":C.setCurrentHistory,"change:deleted change:purged":C.handleDeletedHistory,sort:function(){C.renderColumns(0)}})},setCurrentHistory:function p(D){var C=this.columnMap[this.currentHistoryId];if(C){C.currentHistory=false;C.$el.height("")}this.currentHistoryId=D.id;var E=this.columnMap[this.currentHistoryId];E.currentHistory=true;this.sortCollection();multipanel._recalcFirstColumnHeight();return E},handleDeletedHistory:function b(D){if(D.get("deleted")||D.get("purged")){this.log("handleDeletedHistory",this.collection.includeDeleted,D);var C=this;column=C.columnMap[D.id];if(!column){return}if(column.model.id===this.currentHistoryId){}else{if(!C.collection.includeDeleted){C.removeColumn(column)}}}},sortCollection:function(C,D){if(!(C in this.sortOrders)){C="update"}this.order=C;var G=this.currentHistoryId,F=this.sortOrders[C];this.collection.comparator=function E(I,H){return F.fn(I,H,G)};this.$(".current-order").text(F.text);if(this.$(".more-options").is(":visible")){this.$(".open-more-options.btn").popover("show")}this.collection.sort(D);return this.collection},create:function(C){return this.collection.create({current:true})},createColumns:function r(D){D=D||{};var C=this;this.columnMap={};C.collection.each(function(E,F){var G=C.createColumn(E,D);C.columnMap[E.id]=G})},createColumn:function t(E,C){C=_.extend({},C,{model:E,purgeAllowed:Galaxy.config.allow_user_dataset_purge});var D=new B(C);if(E.id===this.currentHistoryId){D.currentHistory=true}this.setUpColumnListeners(D);return D},sortedFilteredColumns:function(C){C=C||this.filters;if(!C||!C.length){return this.sortedColumns()}var D=this;return D.sortedColumns().filter(function(G,F){var E=G.currentHistory||_.every(C.map(function(H){return H.call(G)}));return E})},sortedColumns:function(){var D=this;var C=this.collection.map(function(F,E){return D.columnMap[F.id]});return C},addColumn:function o(E,C){C=C!==undefined?C:true;var D=this.createColumn(E);this.columnMap[E.id]=D;if(C){this.renderColumns()}return D},addAsCurrentColumn:function o(E){var D=this,C=this.addColumn(E,false);this.setCurrentHistory(E);C.once("rendered",function(){D.queueHdaFetch(C)});return C},removeColumn:function x(E,D){D=D!==undefined?D:true;this.log("removeColumn",E);if(!E){return}var F=this,C=this.options.columnWidth+this.options.columnGap;E.$el.fadeOut("fast",function(){if(D){$(this).remove();F.$(".middle").width(F.$(".middle").width()-C);F.checkColumnsInView();F._recalcFirstColumnHeight()}F.stopListening(E.panel);F.stopListening(E);delete F.columnMap[E.model.id];E.remove()})},setUpColumnListeners:function n(D){var E=this,C={HistoryDatasetAssociation:"hda",HistoryDatasetCollectionAssociation:"hdca"};E.listenTo(D,{"in-view":E.queueHdaFetch});E.listenTo(D.panel,{"view:draggable:dragstart":function(I,G,F,H){E._dropData=JSON.parse(I.dataTransfer.getData("text"));E.currentColumnDropTargetOn()},"view:draggable:dragend":function(I,G,F,H){E._dropData=null;E.currentColumnDropTargetOff()},"droptarget:drop":function(H,I,G){var J=E._dropData.filter(function(K){return((_.isObject(K)&&K.id)&&(_.contains(_.keys(C),K.model_class)))});E._dropData=null;var F=new a.NamedAjaxQueue();J.forEach(function(K){var L=C[K.model_class];F.add({name:"copy-"+K.id,fn:function(){return G.model.contents.copy(K.id,L)}})});F.start();F.done(function(K){G.model.fetch()})}})},columnMapLength:function(){return Object.keys(this.columnMap).length},render:function A(D){D=D!==undefined?D:this.fxSpeed;var C=this;C.log(C+".render");C.$el.html(C.mainTemplate(C));C.renderColumns(D);C.setUpBehaviors();C.trigger("rendered",C);return C},renderColumns:function j(F){F=F!==undefined?F:this.fxSpeed;var E=this,C=E.sortedFilteredColumns();E.$(".middle").width(C.length*(this.options.columnWidth+this.options.columnGap)+this.options.columnGap+16);var D=E.$(".middle");D.empty();C.forEach(function(H,G){H.$el.appendTo(D);H.delegateEvents();E.renderColumn(H,F)});if(this.searchFor&&C.length<=1){}else{E.checkColumnsInView();this._recalcFirstColumnHeight()}return C},renderColumn:function(C,D){D=D!==undefined?D:this.fxSpeed;return C.render(D)},queueHdaFetch:function i(E){if(E.model.contents.length===0&&!E.model.get("empty")){var C={},D=_.values(E.panel.storage.get("expandedIds")).join();if(D){C.dataset_details=D}this.hdaQueue.add({name:E.model.id,fn:function(){var F=E.model.contents.fetch({data:C,silent:true});return F.done(function(G){E.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},queueHdaFetchDetails:function(C){if((C.model.contents.length===0&&!C.model.get("empty"))||(!C.model.contents.haveDetails())){this.hdaQueue.add({name:C.model.id,fn:function(){var D=C.model.contents.fetch({data:{details:"all"},silent:true});return D.done(function(E){C.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},renderInfo:function(C){return this.$(".header .header-info").text(C)},events:{"click .done.btn":"close","click .create-new.btn":"create","click #include-deleted":"_clickToggleDeletedHistories","click .order .set-order":"_chooseOrder","click #toggle-deleted":"_clickToggleDeletedDatasets","click #toggle-hidden":"_clickToggleHiddenDatasets"},close:function(D){var C="/";if(Galaxy&&Galaxy.options&&Galaxy.options.root){C=Galaxy.options.root}else{if(galaxy_config&&galaxy_config.root){C=galaxy_config.root}}window.location=C},_clickToggleDeletedHistories:function(C){return this.toggleDeletedHistories($(C.currentTarget).is(":checked"))},toggleDeletedHistories:function(C){if(C){window.location=Galaxy.options.root+"history/view_multiple?include_deleted_histories=True"}else{window.location=Galaxy.options.root+"history/view_multiple"}},_clickToggleDeletedDatasets:function(C){return this.toggleDeletedDatasets($(C.currentTarget).is(":checked"))},toggleDeletedDatasets:function(C){C=C!==undefined?C:false;var D=this;D.sortedFilteredColumns().forEach(function(F,E){_.delay(function(){F.panel.toggleShowDeleted(C,false)},E*200)})},_clickToggleHiddenDatasets:function(C){return this.toggleHiddenDatasets($(C.currentTarget).is(":checked"))},toggleHiddenDatasets:function(C){C=C!==undefined?C:false;var D=this;D.sortedFilteredColumns().forEach(function(F,E){_.delay(function(){F.panel.toggleShowHidden(C,false)},E*200)})},_chooseOrder:function(D){var C=$(D.currentTarget).data("order");this.sortCollection(C)},setUpBehaviors:function(){var D=this;D._moreOptionsPopover();D.$("#search-histories").searchInput({name:"search-histories",placeholder:_l("search histories"),onsearch:function(E){D.searchFor=E;D.filters=[function(){return this.model.matchesAll(D.searchFor)}];D.renderColumns(0)},onclear:function(E){D.searchFor=null;D.filters=[];D.renderColumns(0)}});D.$("#search-datasets").searchInput({name:"search-datasets",placeholder:_l("search all datasets"),onfirstsearch:function(E){D.hdaQueue.clear();D.$("#search-datasets").searchInput("toggle-loading");D.searchFor=E;D.sortedFilteredColumns().forEach(function(F){F.panel.searchItems(E);D.queueHdaFetchDetails(F)});D.hdaQueue.progress(function(F){D.renderInfo([_l("searching"),(F.curr+1),_l("of"),F.total].join(" "))});D.hdaQueue.deferred.done(function(){D.renderInfo("");D.$("#search-datasets").searchInput("toggle-loading")})},onsearch:function(E){D.searchFor=E;D.sortedFilteredColumns().forEach(function(F){F.panel.searchItems(E)})},onclear:function(E){D.searchFor=null;D.sortedFilteredColumns().forEach(function(F){F.panel.clearSearch()})}});$(window).resize(function(){D._recalcFirstColumnHeight()});var C=_.debounce(_.bind(this.checkColumnsInView,this),100);this.$(".middle").parent().scroll(C)},_moreOptionsPopover:function(){return this.$(".open-more-options.btn").popover({container:".header",placement:"bottom",html:true,content:$(this.optionsPopoverTemplate(this))})},_recalcFirstColumnHeight:function(){var C=this.$(".history-column").first(),E=this.$(".middle").height(),D=C.find(".panel-controls").height();C.height(E).find(".inner").height(E-D)},_viewport:function(){var C=this.$(".middle").parent().offset().left;return{left:C,right:C+this.$(".middle").parent().width()}},columnsInView:function(){var C=this._viewport();return this.sortedFilteredColumns().filter(function(D){return D.currentHistory||D.inView(C.left,C.right)})},checkColumnsInView:function(){this.columnsInView().forEach(function(C){C.trigger("in-view",C)})},currentColumnDropTargetOn:function(){var C=this.columnMap[this.currentHistoryId];if(!C){return}C.panel.dataDropped=function(D){};C.panel.dropTargetOn()},currentColumnDropTargetOff:function(){var C=this.columnMap[this.currentHistoryId];if(!C){return}C.panel.dataDropped=l.HistoryPanelEdit.prototype.dataDrop;C.panel.dropTarget=false;C.panel.$(".history-drop-target").remove()},toString:function(){return"MultiPanelColumns("+(this.columns?this.columns.length:0)+")"},mainTemplate:_.template(['<div class="header flex-column-container">','<div class="control-column control-column-left flex-column">','<button class="create-new btn btn-default" tabindex="4">',_l("Create new"),"</button> ",'<div id="search-histories" class="search-control"></div>','<div id="search-datasets" class="search-control"></div>','<a class="open-more-options btn btn-default" tabindex="3">','<span class="fa fa-ellipsis-h"></span>',"</a>","</div>",'<div class="control-column control-column-center flex-column">','<div class="header-info">',"</div>","</div>",'<div class="control-column control-column-right flex-column">','<button class="done btn btn-default" tabindex="1">',_l("Done"),"</button>","</div>","</div>",'<div class="outer-middle flex-row flex-row-container">','<div class="middle flex-column-container flex-row"></div>',"</div>",'<div class="footer flex-column-container">',"</div>"].join(""),{variable:"view"}),optionsPopoverTemplate:_.template(['<div class="more-options">','<div class="order btn-group">','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">',_l("Order histories by")+" ",'<span class="current-order"><%= view.sortOrders[ view.order ].text %></span> ','<span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">',"<% _.each( view.sortOrders, function( order, key ){ %>",'<li><a href="javascript:void(0);" class="set-order" data-order="<%= key %>">',"<%= order.text %>","</a></li>","<% }); %>","</ul>","</div>",'<div class="checkbox"><label><input id="include-deleted" type="checkbox"','<%= view.collection.includeDeleted? " checked" : "" %>>',_l("Include deleted histories"),"</label></div>","<hr />",'<div class="checkbox"><label><input id="toggle-deleted" type="checkbox">',_l("Include deleted datasets"),"</label></div>",'<div class="checkbox"><label><input id="toggle-hidden" type="checkbox">',_l("Include hidden datasets"),"</label></div>","</div>"].join(""),{variable:"view"})});return{MultiPanelColumns:m}}); \ No newline at end of file +define(["mvc/history/history-model","mvc/history/history-panel-edit","mvc/base-mvc","utils/ajax-queue","ui/mode-button","ui/search-input"],function(d,l,z,a){function g(I,E){E=E||{};if(!(Galaxy&&Galaxy.modal)){return I.copy()}var F=I.get("name"),C="Copy of '"+F+"'";function D(K){if(!K){if(!Galaxy.modal.$("#invalid-title").size()){var J=$("<p/>").attr("id","invalid-title").css({color:"red","margin-top":"8px"}).addClass("bg-danger").text(_l("Please enter a valid history title"));Galaxy.modal.$(".modal-body").append(J)}return false}return K}function G(J){var K=$('<p><span class="fa fa-spinner fa-spin"></span> Copying history...</p>').css("margin-top","8px");Galaxy.modal.$(".modal-body").append(K);I.copy(true,J).fail(function(){alert(_l("History could not be copied. Please contact a Galaxy administrator"))}).always(function(){Galaxy.modal.hide()})}function H(){var J=Galaxy.modal.$("#copy-modal-title").val();if(!D(J)){return}G(J)}Galaxy.modal.show(_.extend({title:_l("Copying history")+' "'+F+'"',body:$(['<label for="copy-modal-title">',_l("Enter a title for the copied history"),":","</label><br />",'<input id="copy-modal-title" class="form-control" style="width: 100%" value="',C,'" />'].join("")),buttons:{Cancel:function(){Galaxy.modal.hide()},Copy:H}},E));$("#copy-modal-title").focus().select();$("#copy-modal-title").on("keydown",function(J){if(J.keyCode===13){H()}})}var B=Backbone.View.extend(z.LoggableMixin).extend({tagName:"div",className:"history-column flex-column flex-row-container",id:function q(){if(!this.model){return""}return"history-column-"+this.model.get("id")},initialize:function c(C){C=C||{};this.purgeAllowed=!_.isUndefined(C.purgeAllowed)?C.purgeAllowed:false;this.panel=C.panel||this.createPanel(C);this.setUpListeners()},createPanel:function u(D){D=_.extend({model:this.model,purgeAllowed:this.purgeAllowed,dragItems:true},D);var C=new l.HistoryPanelEdit(D);C._renderEmptyMessage=this.__patch_renderEmptyMessage;return C},__patch_renderEmptyMessage:function(E){var D=this,F=_.chain(this.model.get("state_ids")).values().flatten().value().length,C=D.$emptyMessage(E);if(!_.isEmpty(D.hdaViews)){C.hide()}else{if(F&&!this.model.contents.length){C.empty().append($('<span class="fa fa-spinner fa-spin"></span><i>loading datasets...</i>')).show()}else{if(D.searchFor){C.text(D.noneFoundMsg).show()}else{C.text(D.emptyMsg).show()}}}return C},setUpListeners:function f(){var C=this;this.once("rendered",function(){C.trigger("rendered:initial",C)});this.setUpPanelListeners()},setUpPanelListeners:function k(){var C=this;this.listenTo(this.panel,{rendered:function(){C.trigger("rendered",C)}},this)},inView:function(C,D){var F=this.$el.offset().left,E=F+this.$el.width();if(E<C){return false}if(F>D){return false}return true},$panel:function e(){return this.$(".history-panel")},render:function A(D){D=(D!==undefined)?(D):("fast");var C=this.model?this.model.toJSON():{};this.$el.html(this.template(C));this.renderPanel(D);this.setUpBehaviors();return this},setUpBehaviors:function v(){},template:function w(C){C=_.extend(C||{},{isCurrentHistory:this.currentHistory});return $(['<div class="panel-controls clear flex-row">',this.controlsLeftTemplate({history:C,view:this}),this.controlsRightTemplate({history:C,view:this}),"</div>",'<div class="inner flex-row flex-column-container">','<div id="history-',C.id,'" class="history-column history-panel flex-column"></div>',"</div>"].join(""))},renderPanel:function h(C){C=(C!==undefined)?(C):("fast");this.panel.setElement(this.$panel()).render(C);if(this.currentHistory){this.panel.$list().before(this.panel._renderDropTargetHelp())}return this},events:{"click .switch-to.btn":function(){this.model.setAsCurrent()},"click .delete-history":function(){var C=this;this.model._delete().fail(function(F,D,E){alert(_l("Could not delete the history")+":\n"+E)}).done(function(D){C.render()})},"click .undelete-history":function(){var C=this;this.model.undelete().fail(function(F,D,E){alert(_l("Could not undelete the history")+":\n"+E)}).done(function(D){C.render()})},"click .purge-history":function(){if(confirm(_l("This will permanently remove the data. Are you sure?"))){var C=this;this.model.purge().fail(function(F,D,E){alert(_l("Could not purge the history")+":\n"+E)}).done(function(D){C.render()})}},"click .copy-history":"copy"},copy:function s(){g(this.model)},controlsLeftTemplate:_.template(['<div class="pull-left">',"<% if( data.history.isCurrentHistory ){ %>",'<strong class="current-label">',_l("Current History"),"</strong>","<% } else { %>",'<button class="switch-to btn btn-default">',_l("Switch to"),"</button>","<% } %>","</div>"].join(""),{variable:"data"}),controlsRightTemplate:_.template(['<div class="pull-right">',"<% if( !data.history.purged ){ %>",'<div class="panel-menu btn-group">','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">','<span class="caret"></span>',"</button>",'<ul class="dropdown-menu pull-right" role="menu">',"<% if( !data.history.deleted ){ %>",'<li><a href="javascript:void(0);" class="copy-history">',_l("Copy"),"</a></li>",'<li><a href="javascript:void(0);" class="delete-history">',_l("Delete"),"</a></li>","<% } else /* if is deleted */ { %>",'<li><a href="javascript:void(0);" class="undelete-history">',_l("Undelete"),"</a></li>","<% } %>","<% if( data.view.purgeAllowed ){ %>",'<li><a href="javascript:void(0);" class="purge-history">',_l("Purge"),"</a></li>","<% } %>","</ul>","</div>","<% } %>","</div>"].join(""),{variable:"data"}),toString:function(){return"HistoryPanelColumn("+(this.panel?this.panel:"")+")"}});var m=Backbone.View.extend(z.LoggableMixin).extend({className:"multi-panel-history",initialize:function c(C){C=C||{};this.log(this+".init",C);this.$el.addClass(this.className);if(!C.currentHistoryId){throw new Error(this+" requires a currentHistoryId in the options")}this.currentHistoryId=C.currentHistoryId;this.options={columnWidth:312,borderWidth:1,columnGap:8,headerHeight:29,footerHeight:0,controlsHeight:20};this.order=C.order||"update";this._initSortOrders();this.hdaQueue=new a.NamedAjaxQueue([],false);this.collection=null;this.setCollection(C.histories||[]);this.columnMap={};this.createColumns(C.columnOptions);this.setUpListeners()},_initSortOrders:function(){function C(D,E){return function F(H,G,I){if(H.id===I){return -1}if(G.id===I){return 1}H=D(H);G=D(G);return E.asc?((H===G)?(0):(H>G?1:-1)):((H===G)?(0):(H>G?-1:1))}}this.sortOrders={update:{text:_l("most recent first"),fn:C(function(D){return Date(D.get("update_time"))},{asc:false})},name:{text:_l("name, a to z"),fn:C(function(D){return D.get("name")},{asc:true})},"name-dsc":{text:_l("name, z to a"),fn:C(function(D){return D.get("name")},{asc:false})},size:{text:_l("size, large to small"),fn:C(function(D){return D.get("size")},{asc:false})},"size-dsc":{text:_l("size, small to large"),fn:C(function(D){return D.get("size")},{asc:true})}};return this.sortOrders},setUpListeners:function f(){},setCollection:function y(D){var C=this;C.stopListening(C.collection);C.collection=D;C.sortCollection(C.order,{silent:true});C.setUpCollectionListeners();C.trigger("new-collection",C);return C},setUpCollectionListeners:function(){var C=this,D=C.collection;C.listenTo(D,{add:C.addAsCurrentColumn,"set-as-current":C.setCurrentHistory,"change:deleted change:purged":C.handleDeletedHistory,sort:function(){C.renderColumns(0)}})},setCurrentHistory:function p(D){var C=this.columnMap[this.currentHistoryId];if(C){C.currentHistory=false;C.$el.height("")}this.currentHistoryId=D.id;var E=this.columnMap[this.currentHistoryId];E.currentHistory=true;this.sortCollection();multipanel._recalcFirstColumnHeight();return E},handleDeletedHistory:function b(D){if(D.get("deleted")||D.get("purged")){this.log("handleDeletedHistory",this.collection.includeDeleted,D);var C=this;column=C.columnMap[D.id];if(!column){return}if(column.model.id===this.currentHistoryId){}else{if(!C.collection.includeDeleted){C.removeColumn(column)}}}},sortCollection:function(C,D){if(!(C in this.sortOrders)){C="update"}this.order=C;var G=this.currentHistoryId,F=this.sortOrders[C];this.collection.comparator=function E(I,H){return F.fn(I,H,G)};this.$(".current-order").text(F.text);if(this.$(".more-options").is(":visible")){this.$(".open-more-options.btn").popover("show")}this.collection.sort(D);return this.collection},create:function(C){return this.collection.create({current:true})},createColumns:function r(D){D=D||{};var C=this;this.columnMap={};C.collection.each(function(E,F){var G=C.createColumn(E,D);C.columnMap[E.id]=G})},createColumn:function t(E,C){C=_.extend({},C,{model:E,purgeAllowed:Galaxy.config.allow_user_dataset_purge});var D=new B(C);if(E.id===this.currentHistoryId){D.currentHistory=true}this.setUpColumnListeners(D);return D},sortedFilteredColumns:function(C){C=C||this.filters;if(!C||!C.length){return this.sortedColumns()}var D=this;return D.sortedColumns().filter(function(G,F){var E=G.currentHistory||_.every(C.map(function(H){return H.call(G)}));return E})},sortedColumns:function(){var D=this;var C=this.collection.map(function(F,E){return D.columnMap[F.id]});return C},addColumn:function o(E,C){C=C!==undefined?C:true;var D=this.createColumn(E);this.columnMap[E.id]=D;if(C){this.renderColumns()}return D},addAsCurrentColumn:function o(E){var D=this,C=this.addColumn(E,false);this.setCurrentHistory(E);C.once("rendered",function(){D.queueHdaFetch(C)});return C},removeColumn:function x(E,D){D=D!==undefined?D:true;this.log("removeColumn",E);if(!E){return}var F=this,C=this.options.columnWidth+this.options.columnGap;E.$el.fadeOut("fast",function(){if(D){$(this).remove();F.$(".middle").width(F.$(".middle").width()-C);F.checkColumnsInView();F._recalcFirstColumnHeight()}F.stopListening(E.panel);F.stopListening(E);delete F.columnMap[E.model.id];E.remove()})},setUpColumnListeners:function n(C){var D=this;D.listenTo(C,{"in-view":D.queueHdaFetch});D.listenTo(C.panel,{"view:draggable:dragstart":function(H,F,E,G){D._dropData=JSON.parse(H.dataTransfer.getData("text"));D.currentColumnDropTargetOn()},"view:draggable:dragend":function(H,F,E,G){D._dropData=null;D.currentColumnDropTargetOff()},"droptarget:drop":function(G,H,F){var I=D._dropData.filter(function(J){return F.model.contents.isCopyable(J)});D._dropData=null;var E=new a.NamedAjaxQueue();I.forEach(function(J){E.add({name:"copy-"+J.id,fn:function(){return F.model.contents.copy(J)}})});E.start();E.done(function(J){F.model.fetch()})}})},columnMapLength:function(){return Object.keys(this.columnMap).length},render:function A(D){D=D!==undefined?D:this.fxSpeed;var C=this;C.log(C+".render");C.$el.html(C.mainTemplate(C));C.renderColumns(D);C.setUpBehaviors();C.trigger("rendered",C);return C},renderColumns:function j(F){F=F!==undefined?F:this.fxSpeed;var E=this,C=E.sortedFilteredColumns();E.$(".middle").width(C.length*(this.options.columnWidth+this.options.columnGap)+this.options.columnGap+16);var D=E.$(".middle");D.empty();C.forEach(function(H,G){H.$el.appendTo(D);H.delegateEvents();E.renderColumn(H,F)});if(this.searchFor&&C.length<=1){}else{E.checkColumnsInView();this._recalcFirstColumnHeight()}return C},renderColumn:function(C,D){D=D!==undefined?D:this.fxSpeed;return C.render(D)},queueHdaFetch:function i(E){if(E.model.contents.length===0&&!E.model.get("empty")){var C={},D=_.values(E.panel.storage.get("expandedIds")).join();if(D){C.dataset_details=D}this.hdaQueue.add({name:E.model.id,fn:function(){var F=E.model.contents.fetch({data:C,silent:true});return F.done(function(G){E.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},queueHdaFetchDetails:function(C){if((C.model.contents.length===0&&!C.model.get("empty"))||(!C.model.contents.haveDetails())){this.hdaQueue.add({name:C.model.id,fn:function(){var D=C.model.contents.fetch({data:{details:"all"},silent:true});return D.done(function(E){C.panel.renderItems()})}});if(!this.hdaQueue.running){this.hdaQueue.start()}}},renderInfo:function(C){return this.$(".header .header-info").text(C)},events:{"click .done.btn":"close","click .create-new.btn":"create","click #include-deleted":"_clickToggleDeletedHistories","click .order .set-order":"_chooseOrder","click #toggle-deleted":"_clickToggleDeletedDatasets","click #toggle-hidden":"_clickToggleHiddenDatasets"},close:function(D){var C="/";if(Galaxy&&Galaxy.options&&Galaxy.options.root){C=Galaxy.options.root}else{if(galaxy_config&&galaxy_config.root){C=galaxy_config.root}}window.location=C},_clickToggleDeletedHistories:function(C){return this.toggleDeletedHistories($(C.currentTarget).is(":checked"))},toggleDeletedHistories:function(C){if(C){window.location=Galaxy.options.root+"history/view_multiple?include_deleted_histories=True"}else{window.location=Galaxy.options.root+"history/view_multiple"}},_clickToggleDeletedDatasets:function(C){return this.toggleDeletedDatasets($(C.currentTarget).is(":checked"))},toggleDeletedDatasets:function(C){C=C!==undefined?C:false;var D=this;D.sortedFilteredColumns().forEach(function(F,E){_.delay(function(){F.panel.toggleShowDeleted(C,false)},E*200)})},_clickToggleHiddenDatasets:function(C){return this.toggleHiddenDatasets($(C.currentTarget).is(":checked"))},toggleHiddenDatasets:function(C){C=C!==undefined?C:false;var D=this;D.sortedFilteredColumns().forEach(function(F,E){_.delay(function(){F.panel.toggleShowHidden(C,false)},E*200)})},_chooseOrder:function(D){var C=$(D.currentTarget).data("order");this.sortCollection(C)},setUpBehaviors:function(){var D=this;D._moreOptionsPopover();D.$("#search-histories").searchInput({name:"search-histories",placeholder:_l("search histories"),onsearch:function(E){D.searchFor=E;D.filters=[function(){return this.model.matchesAll(D.searchFor)}];D.renderColumns(0)},onclear:function(E){D.searchFor=null;D.filters=[];D.renderColumns(0)}});D.$("#search-datasets").searchInput({name:"search-datasets",placeholder:_l("search all datasets"),onfirstsearch:function(E){D.hdaQueue.clear();D.$("#search-datasets").searchInput("toggle-loading");D.searchFor=E;D.sortedFilteredColumns().forEach(function(F){F.panel.searchItems(E);D.queueHdaFetchDetails(F)});D.hdaQueue.progress(function(F){D.renderInfo([_l("searching"),(F.curr+1),_l("of"),F.total].join(" "))});D.hdaQueue.deferred.done(function(){D.renderInfo("");D.$("#search-datasets").searchInput("toggle-loading")})},onsearch:function(E){D.searchFor=E;D.sortedFilteredColumns().forEach(function(F){F.panel.searchItems(E)})},onclear:function(E){D.searchFor=null;D.sortedFilteredColumns().forEach(function(F){F.panel.clearSearch()})}});$(window).resize(function(){D._recalcFirstColumnHeight()});var C=_.debounce(_.bind(this.checkColumnsInView,this),100);this.$(".middle").parent().scroll(C)},_moreOptionsPopover:function(){return this.$(".open-more-options.btn").popover({container:".header",placement:"bottom",html:true,content:$(this.optionsPopoverTemplate(this))})},_recalcFirstColumnHeight:function(){var C=this.$(".history-column").first(),E=this.$(".middle").height(),D=C.find(".panel-controls").height();C.height(E).find(".inner").height(E-D)},_viewport:function(){var C=this.$(".middle").parent().offset().left;return{left:C,right:C+this.$(".middle").parent().width()}},columnsInView:function(){var C=this._viewport();return this.sortedFilteredColumns().filter(function(D){return D.currentHistory||D.inView(C.left,C.right)})},checkColumnsInView:function(){this.columnsInView().forEach(function(C){C.trigger("in-view",C)})},currentColumnDropTargetOn:function(){var C=this.columnMap[this.currentHistoryId];if(!C){return}C.panel.dataDropped=function(D){};C.panel.dropTargetOn()},currentColumnDropTargetOff:function(){var C=this.columnMap[this.currentHistoryId];if(!C){return}C.panel.dataDropped=l.HistoryPanelEdit.prototype.dataDrop;C.panel.dropTarget=false;C.panel.$(".history-drop-target").remove()},toString:function(){return"MultiPanelColumns("+(this.columns?this.columns.length:0)+")"},mainTemplate:_.template(['<div class="header flex-column-container">','<div class="control-column control-column-left flex-column">','<button class="create-new btn btn-default" tabindex="4">',_l("Create new"),"</button> ",'<div id="search-histories" class="search-control"></div>','<div id="search-datasets" class="search-control"></div>','<a class="open-more-options btn btn-default" tabindex="3">','<span class="fa fa-ellipsis-h"></span>',"</a>","</div>",'<div class="control-column control-column-center flex-column">','<div class="header-info">',"</div>","</div>",'<div class="control-column control-column-right flex-column">','<button class="done btn btn-default" tabindex="1">',_l("Done"),"</button>","</div>","</div>",'<div class="outer-middle flex-row flex-row-container">','<div class="middle flex-column-container flex-row"></div>',"</div>",'<div class="footer flex-column-container">',"</div>"].join(""),{variable:"view"}),optionsPopoverTemplate:_.template(['<div class="more-options">','<div class="order btn-group">','<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">',_l("Order histories by")+" ",'<span class="current-order"><%= view.sortOrders[ view.order ].text %></span> ','<span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">',"<% _.each( view.sortOrders, function( order, key ){ %>",'<li><a href="javascript:void(0);" class="set-order" data-order="<%= key %>">',"<%= order.text %>","</a></li>","<% }); %>","</ul>","</div>",'<div class="checkbox"><label><input id="include-deleted" type="checkbox"','<%= view.collection.includeDeleted? " checked" : "" %>>',_l("Include deleted histories"),"</label></div>","<hr />",'<div class="checkbox"><label><input id="toggle-deleted" type="checkbox">',_l("Include deleted datasets"),"</label></div>",'<div class="checkbox"><label><input id="toggle-hidden" type="checkbox">',_l("Include hidden datasets"),"</label></div>","</div>"].join(""),{variable:"view"})});return{MultiPanelColumns:m}}); \ No newline at end of file diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 static/scripts/packed/mvc/list/list-panel.js --- a/static/scripts/packed/mvc/list/list-panel.js +++ b/static/scripts/packed/mvc/list/list-panel.js @@ -1,1 +1,1 @@ -define(["mvc/list/list-item","ui/loading-indicator","mvc/base-mvc","utils/localization","ui/search-input"],function(d,f,b,c){var e=Backbone.View.extend(b.LoggableMixin).extend({viewClass:d.ListItemView,collectionClass:Backbone.Collection,tagName:"div",className:"list-panel",fxSpeed:"fast",emptyMsg:c("This list is empty"),noneFoundMsg:c("No matching items found"),searchPlaceholder:c("search"),multiselectActions:[],initialize:function(g,h){g=g||{};if(g.logger){this.logger=g.logger}this.log(this+".initialize:",g);this.fxSpeed=_.has(g,"fxSpeed")?(g.fxSpeed):(this.fxSpeed);this.filters=[];this.searchFor=g.searchFor||"";this.indicator=new f(this.$el);this.selecting=(g.selecting!==undefined)?g.selecting:true;this.selected=g.selected||[];this.lastSelected=null;this.dragItems=g.dragItems||false;this.viewClass=g.viewClass||this.viewClass;this.views=[];this.collection=g.collection||(new this.collectionClass([]));this.filters=g.filters||[];this.$scrollContainer=g.$scrollContainer||this.$scrollContainer;this.title=g.title||"";this.subtitle=g.subtitle||"";this.multiselectActions=g.multiselectActions||this.multiselectActions;this.actionsPopup=null;this._setUpListeners()},freeViews:function(){_.each(this.views,function(g){g.off()});this.views=[];return this},_setUpListeners:function(){this.off();this.on("error",function(h,k,g,j,i){console.error(h,k,g,j,i)},this);this.on("loading",function(){this._showLoadingIndicator("loading...",40)},this);this.on("loading-done",function(){this._hideLoadingIndicator(40)},this);this.once("rendered",function(){this.trigger("rendered:initial",this)},this);if(this.logger){this.on("all",function(g){this.log(this+"",arguments)},this)}this._setUpCollectionListeners();this._setUpViewListeners();return this},_setUpCollectionListeners:function(){this.log(this+"._setUpCollectionListeners",this.collection);this.collection.off();this.collection.on("error",function(h,k,g,j,i){this.trigger("error",h,k,g,j,i)},this);this.collection.on("reset",function(){this.renderItems()},this);this.collection.on("add",this.addItemView,this);this.collection.on("remove",this.removeItemView,this);if(this.logger){this.collection.on("all",function(g){this.info(this+"(collection)",arguments)},this)}return this},_setUpViewListeners:function(){this.log(this+"._setUpViewListeners");this.on("view:selected",function(g,h){if(h&&h.shiftKey&&this.lastSelected){var i=this.viewFromModelId(this.lastSelected);if(i){this.selectRange(g,i)}}else{if(h&&h.altKey&&!this.selecting){this.showSelectors()}}this.selected.push(g.model.id);this.lastSelected=g.model.id},this);this.on("view:de-selected",function(g,h){this.selected=_.without(this.selected,g.model.id)},this)},render:function(h){this.log(this+".render",h);var g=this._buildNewRender();this._setUpBehaviors(g);this._queueNewRender(g,h);return this},_buildNewRender:function(){this.debug(this+"(ListPanel)._buildNewRender");var g=$(this.templates.el({},this));this._renderControls(g);this._renderTitle(g);this._renderSubtitle(g);this._renderSearch(g);this.renderItems(g);return g},_renderControls:function(h){this.debug(this+"(ListPanel)._renderControls");var g=$(this.templates.controls({},this));h.find(".controls").replaceWith(g);return g},_renderTitle:function(g){},_renderSubtitle:function(g){},_queueNewRender:function(h,i){i=(i===undefined)?(this.fxSpeed):(i);var g=this;g.log("_queueNewRender:",h,i);$(g).queue("fx",[function(j){this.$el.fadeOut(i,j)},function(j){g._swapNewRender(h);j()},function(j){this.$el.fadeIn(i,j)},function(j){g.trigger("rendered",g);j()}])},_swapNewRender:function(g){this.$el.empty().attr("class",this.className).append(g.children());if(this.selecting){this.showSelectors(0)}return this},_setUpBehaviors:function(g){g=g||this.$el;g.find(".controls [title]").tooltip({placement:"bottom"});return this},$scrollContainer:function(){return this.$el.parent().parent()},$list:function(g){return(g||this.$el).find("> .list-items")},$messages:function(g){return(g||this.$el).find("> .controls .messages")},$emptyMessage:function(g){return(g||this.$el).find("> .empty-message")},renderItems:function(i){i=i||this.$el;var g=this;g.log(this+".renderItems",i);var h=g.$list(i);g.views=g._filterCollection().map(function(j){return g._createItemView(j).render(0)});h.empty();if(g.views.length){g._attachItems(i);g.$emptyMessage(i).hide()}else{g._renderEmptyMessage(i).show()}return g.views},_filterCollection:function(){var g=this;return g.collection.filter(_.bind(g._filterItem,g))},_filterItem:function(h){var g=this;return(_.every(g.filters.map(function(i){return i.call(h)})))&&(!g.searchFor||h.matchesAll(g.searchFor))},_createItemView:function(i){var j=this._getItemViewClass(i),h=_.extend(this._getItemViewOptions(i),{model:i}),g=new j(h);this._setUpItemViewListeners(g);return g},_getItemViewClass:function(g){return this.viewClass},_getItemViewOptions:function(g){return{fxSpeed:this.fxSpeed,expanded:false,selectable:this.selecting,selected:_.contains(this.selected,g.id),draggable:this.dragItems}},_setUpItemViewListeners:function(h){var g=this;h.on("all",function(){var i=Array.prototype.slice.call(arguments,0);i[0]="view:"+i[0];g.trigger.apply(g,i)});h.on("draggable:dragstart",function(l,i){var j={},k=this.getSelectedModels();if(k.length){j=k.toJSON()}else{j=[i.model.toJSON()]}l.dataTransfer.setData("text",JSON.stringify(j))},this);return g},_attachItems:function(g){this.$list(g).append(this.views.map(function(h){return h.$el}));return this},_renderEmptyMessage:function(g){this.debug("_renderEmptyMessage",g,this.searchFor);var h=this.searchFor?this.noneFoundMsg:this.emptyMsg;return this.$emptyMessage(g).text(h)},expandAll:function(){_.each(this.views,function(g){g.expand()})},collapseAll:function(){_.each(this.views,function(g){g.collapse()})},addItemView:function(j,k,i){this.log(this+".addItemView:",j);var h=this;if(!h._filterItem(j)){return undefined}var g=h._createItemView(j);$(g).queue("fx",[function(l){h.$emptyMessage().fadeOut(h.fxSpeed,l)},function(l){h._attachView(g);l()}]);return g},_attachView:function(h){var g=this;g.views.push(h);g.$list().append(h.render(0).$el.hide());g.trigger("view:attached",h);h.$el.slideDown(g.fxSpeed,function(){g.trigger("view:attached:rendered")})},removeItemView:function(j,k,i){this.log(this+".removeItemView:",j);var h=this,g=h.viewFromModel(j);if(!g){return undefined}h.views=_.without(h.views,g);h.trigger("view:removed",g);$({}).queue("fx",[function(l){g.$el.fadeOut(h.fxSpeed,l)},function(l){g.remove();h.trigger("view:removed:rendered");if(!h.views.length){h._renderEmptyMessage().fadeIn(h.fxSpeed,l)}else{l()}}]);return g},viewFromModelId:function(h){for(var g=0;g<this.views.length;g++){if(this.views[g].model.id===h){return this.views[g]}}return undefined},viewFromModel:function(g){if(!g){return undefined}return this.viewFromModelId(g.id)},viewsWhereModel:function(g){return this.views.filter(function(h){var j=h.model.toJSON();for(var i in g){if(g.hasOwnProperty(i)){if(j[i]!==h.model.get(i)){return false}}}return true})},viewRange:function(j,i){if(j===i){return(j)?([j]):([])}var h=this.views.indexOf(j),g=this.views.indexOf(i);if(h===-1||g===-1){if(h===g){return[]}return(h===-1)?([i]):([j])}return(h<g)?this.views.slice(h,g+1):this.views.slice(g,h+1)},_renderSearch:function(g){g.find(".controls .search-input").searchInput({placeholder:this.searchPlaceholder,initialVal:this.searchFor,onfirstsearch:_.bind(this._firstSearch,this),onsearch:_.bind(this.searchItems,this),onclear:_.bind(this.clearSearch,this)});return g},_firstSearch:function(g){this.log("onFirstSearch",g);return this.searchItems(g)},searchItems:function(g){this.searchFor=g;this.trigger("search:searching",g,this);this.renderItems();this.$("> .controls .search-query").val(g);return this},clearSearch:function(g){this.searchFor="";this.trigger("search:clear",this);this.renderItems();this.$("> .controls .search-query").val("");return this},showSelectors:function(g){g=(g!==undefined)?(g):(this.fxSpeed);this.selecting=true;this.$(".list-actions").slideDown(g);_.each(this.views,function(h){h.showSelector(g)})},hideSelectors:function(g){g=(g!==undefined)?(g):(this.fxSpeed);this.selecting=false;this.$(".list-actions").slideUp(g);_.each(this.views,function(h){h.hideSelector(g)});this.selected=[];this.lastSelected=null},toggleSelectors:function(){if(!this.selecting){this.showSelectors()}else{this.hideSelectors()}},selectAll:function(g){_.each(this.views,function(h){h.select(g)})},deselectAll:function(g){this.lastSelected=null;_.each(this.views,function(h){h.deselect(g)})},selectRange:function(i,h){var g=this.viewRange(i,h);_.each(g,function(j){j.select()});return g},getSelectedViews:function(){return _.filter(this.views,function(g){return g.selected})},getSelectedModels:function(){return new this.collection.constructor(_.map(this.getSelectedViews(),function(g){return g.model}))},_showLoadingIndicator:function(h,g,i){this.debug("_showLoadingIndicator",this.indicator,h,g,i);g=(g!==undefined)?(g):(this.fxSpeed);if(!this.indicator){this.indicator=new f(this.$el,this.$el.parent());this.debug("\t created",this.indicator)}if(!this.$el.is(":visible")){this.indicator.show(0,i)}else{this.$el.fadeOut(g);this.indicator.show(h,g,i)}},_hideLoadingIndicator:function(g,h){this.debug("_hideLoadingIndicator",this.indicator,g,h);g=(g!==undefined)?(g):(this.fxSpeed);if(this.indicator){this.indicator.hide(g,h)}},scrollPosition:function(){return this.$scrollContainer().scrollTop()},scrollTo:function(h,g){g=g||0;this.$scrollContainer().animate({scrollTop:h},g);return this},scrollToTop:function(g){return this.scrollTo(0,g)},scrollToItem:function(g,i){if(!g){return this}var h=g.$el.position().top;return this.scrollTo(h,i)},scrollToId:function(h,g){return this.scrollToItem(this.viewFromModelId(h),g)},events:{"click .select-all":"selectAll","click .deselect-all":"deselectAll"},toString:function(){return"ListPanel("+this.collection+")"}});e.prototype.templates=(function(){var h=b.wrapTemplate(["<div>",'<div class="controls"></div>','<div class="list-items"></div>','<div class="empty-message infomessagesmall"></div>',"</div>"]);var g=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= view.title %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>","</div>","</div>"]);return{el:h,controls:g}}());var a=e.extend({modelCollectionKey:"contents",initialize:function(g){e.prototype.initialize.call(this,g);this.selecting=(g.selecting!==undefined)?g.selecting:false;this.setModel(this.model,g)},setModel:function(h,g){g=g||{};this.debug(this+".setModel:",h,g);this.freeModel();this.freeViews();if(h){var i=this.model?this.model.get("id"):null;this.model=h;if(this.logger){this.model.logger=this.logger}this._setUpModelListeners();this.collection.off();this.collection=(this.model[this.modelCollectionKey])?this.model[this.modelCollectionKey]:(g.collection||(new this.collectionClass([])));this._setUpCollectionListeners();if(i&&h.get("id")!==i){this.trigger("new-model",this)}}return this},freeModel:function(){if(this.model){this.stopListening(this.model)}return this},_setUpModelListeners:function(){this.log(this+"._setUpModelListeners",this.model);this.model.on("error",function(){var g=Array.prototype.slice.call(arguments,0);g.unshift("error");this.trigger.apply(this,g)},this);return this},_renderControls:function(h){this.debug(this+"(ListPanel)._renderControls");var i=this.model?this.model.toJSON():{},g=$(this.templates.controls(i,this));h.find(".controls").replaceWith(g);return g},toString:function(){return"ModelListPanel("+this.model+")"}});a.prototype.templates=(function(){var g=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= model.name %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>","</div>","</div>"]);return _.extend(_.clone(e.prototype.templates),{controls:g})}());return{ListPanel:e,ModelListPanel:a}}); \ No newline at end of file +define(["mvc/list/list-item","ui/loading-indicator","mvc/base-mvc","utils/localization","ui/search-input"],function(d,f,b,c){var e=Backbone.View.extend(b.LoggableMixin).extend({viewClass:d.ListItemView,collectionClass:Backbone.Collection,tagName:"div",className:"list-panel",fxSpeed:"fast",emptyMsg:c("This list is empty"),noneFoundMsg:c("No matching items found"),searchPlaceholder:c("search"),initialize:function(g,h){g=g||{};if(g.logger){this.logger=g.logger}this.log(this+".initialize:",g);this.fxSpeed=_.has(g,"fxSpeed")?(g.fxSpeed):(this.fxSpeed);this.filters=[];this.searchFor=g.searchFor||"";this.indicator=new f(this.$el);this.selecting=(g.selecting!==undefined)?g.selecting:true;this.selected=g.selected||[];this.lastSelected=null;this.dragItems=g.dragItems||false;this.viewClass=g.viewClass||this.viewClass;this.views=[];this.collection=g.collection||(new this.collectionClass([]));this.filters=g.filters||[];this.$scrollContainer=g.$scrollContainer||this.$scrollContainer;this.title=g.title||"";this.subtitle=g.subtitle||"";this._setUpListeners()},freeViews:function(){_.each(this.views,function(g){g.off()});this.views=[];return this},_setUpListeners:function(){this.off();this.on("error",function(h,k,g,j,i){console.error(h,k,g,j,i)},this);this.on("loading",function(){this._showLoadingIndicator("loading...",40)},this);this.on("loading-done",function(){this._hideLoadingIndicator(40)},this);this.once("rendered",function(){this.trigger("rendered:initial",this)},this);if(this.logger){this.on("all",function(g){this.log(this+"",arguments)},this)}this._setUpCollectionListeners();this._setUpViewListeners();return this},_setUpCollectionListeners:function(){this.log(this+"._setUpCollectionListeners",this.collection);this.collection.off();this.collection.on("error",function(h,k,g,j,i){this.trigger("error",h,k,g,j,i)},this);this.collection.on("reset",function(){this.renderItems()},this);this.collection.on("add",this.addItemView,this);this.collection.on("remove",this.removeItemView,this);if(this.logger){this.collection.on("all",function(g){this.info(this+"(collection)",arguments)},this)}return this},_setUpViewListeners:function(){this.log(this+"._setUpViewListeners");this.on("view:selected",function(g,h){if(h&&h.shiftKey&&this.lastSelected){var i=this.viewFromModelId(this.lastSelected);if(i){this.selectRange(g,i)}}else{if(h&&h.altKey&&!this.selecting){this.showSelectors()}}this.selected.push(g.model.id);this.lastSelected=g.model.id},this);this.on("view:de-selected",function(g,h){this.selected=_.without(this.selected,g.model.id)},this)},render:function(h){this.log(this+".render",h);var g=this._buildNewRender();this._setUpBehaviors(g);this._queueNewRender(g,h);return this},_buildNewRender:function(){this.debug(this+"(ListPanel)._buildNewRender");var g=$(this.templates.el({},this));this._renderControls(g);this._renderTitle(g);this._renderSubtitle(g);this._renderSearch(g);this.renderItems(g);return g},_renderControls:function(h){this.debug(this+"(ListPanel)._renderControls");var g=$(this.templates.controls({},this));h.find(".controls").replaceWith(g);return g},_renderTitle:function(g){},_renderSubtitle:function(g){},_queueNewRender:function(h,i){i=(i===undefined)?(this.fxSpeed):(i);var g=this;g.log("_queueNewRender:",h,i);$(g).queue("fx",[function(j){this.$el.fadeOut(i,j)},function(j){g._swapNewRender(h);j()},function(j){this.$el.fadeIn(i,j)},function(j){g.trigger("rendered",g);j()}])},_swapNewRender:function(g){this.$el.empty().attr("class",this.className).append(g.children());if(this.selecting){this.showSelectors(0)}return this},_setUpBehaviors:function(g){g=g||this.$el;g.find(".controls [title]").tooltip({placement:"bottom"});this._renderMultiselectActionMenu(g);return this},_renderMultiselectActionMenu:function(g){g=g||this.$el;var h=g.find(".list-action-menu"),k=this.multiselectActions();if(!k.length){return h.empty()}var j=$(['<div class="list-action-menu btn-group">','<button class="list-action-menu-btn btn btn-default dropdown-toggle" data-toggle="dropdown">',c("For all selected"),"...","</button>",'<ul class="dropdown-menu pull-right" role="menu">',"</ul>","</div>"].join(""));var i=k.map(function(m){var l=['<li><a href="javascript:void(0);">',m.html,"</a></li>"].join("");return $(l).click(m.func)});j.find("ul").append(i);h.replaceWith(j);return j},multiselectActions:function(){return[]},$scrollContainer:function(){return this.$el.parent().parent()},$list:function(g){return(g||this.$el).find("> .list-items")},$messages:function(g){return(g||this.$el).find("> .controls .messages")},$emptyMessage:function(g){return(g||this.$el).find("> .empty-message")},renderItems:function(i){i=i||this.$el;var g=this;g.log(this+".renderItems",i);var h=g.$list(i);g.views=g._filterCollection().map(function(j){return g._createItemView(j).render(0)});h.empty();if(g.views.length){g._attachItems(i);g.$emptyMessage(i).hide()}else{g._renderEmptyMessage(i).show()}return g.views},_filterCollection:function(){var g=this;return g.collection.filter(_.bind(g._filterItem,g))},_filterItem:function(h){var g=this;return(_.every(g.filters.map(function(i){return i.call(h)})))&&(!g.searchFor||h.matchesAll(g.searchFor))},_createItemView:function(i){var j=this._getItemViewClass(i),h=_.extend(this._getItemViewOptions(i),{model:i}),g=new j(h);this._setUpItemViewListeners(g);return g},_getItemViewClass:function(g){return this.viewClass},_getItemViewOptions:function(g){return{fxSpeed:this.fxSpeed,expanded:false,selectable:this.selecting,selected:_.contains(this.selected,g.id),draggable:this.dragItems}},_setUpItemViewListeners:function(h){var g=this;h.on("all",function(){var i=Array.prototype.slice.call(arguments,0);i[0]="view:"+i[0];g.trigger.apply(g,i)});h.on("draggable:dragstart",function(l,i){var j={},k=this.getSelectedModels();if(k.length){j=k.toJSON()}else{j=[i.model.toJSON()]}l.dataTransfer.setData("text",JSON.stringify(j))},this);return g},_attachItems:function(g){this.$list(g).append(this.views.map(function(h){return h.$el}));return this},_renderEmptyMessage:function(g){this.debug("_renderEmptyMessage",g,this.searchFor);var h=this.searchFor?this.noneFoundMsg:this.emptyMsg;return this.$emptyMessage(g).text(h)},expandAll:function(){_.each(this.views,function(g){g.expand()})},collapseAll:function(){_.each(this.views,function(g){g.collapse()})},addItemView:function(j,k,i){this.log(this+".addItemView:",j);var h=this;if(!h._filterItem(j)){return undefined}var g=h._createItemView(j);$(g).queue("fx",[function(l){h.$emptyMessage().fadeOut(h.fxSpeed,l)},function(l){h._attachView(g);l()}]);return g},_attachView:function(h){var g=this;g.views.push(h);g.$list().append(h.render(0).$el.hide());g.trigger("view:attached",h);h.$el.slideDown(g.fxSpeed,function(){g.trigger("view:attached:rendered")})},removeItemView:function(j,k,i){this.log(this+".removeItemView:",j);var h=this,g=h.viewFromModel(j);if(!g){return undefined}h.views=_.without(h.views,g);h.trigger("view:removed",g);$({}).queue("fx",[function(l){g.$el.fadeOut(h.fxSpeed,l)},function(l){g.remove();h.trigger("view:removed:rendered");if(!h.views.length){h._renderEmptyMessage().fadeIn(h.fxSpeed,l)}else{l()}}]);return g},viewFromModelId:function(h){for(var g=0;g<this.views.length;g++){if(this.views[g].model.id===h){return this.views[g]}}return undefined},viewFromModel:function(g){if(!g){return undefined}return this.viewFromModelId(g.id)},viewsWhereModel:function(g){return this.views.filter(function(h){var j=h.model.toJSON();for(var i in g){if(g.hasOwnProperty(i)){if(j[i]!==h.model.get(i)){return false}}}return true})},viewRange:function(j,i){if(j===i){return(j)?([j]):([])}var h=this.views.indexOf(j),g=this.views.indexOf(i);if(h===-1||g===-1){if(h===g){return[]}return(h===-1)?([i]):([j])}return(h<g)?this.views.slice(h,g+1):this.views.slice(g,h+1)},_renderSearch:function(g){g.find(".controls .search-input").searchInput({placeholder:this.searchPlaceholder,initialVal:this.searchFor,onfirstsearch:_.bind(this._firstSearch,this),onsearch:_.bind(this.searchItems,this),onclear:_.bind(this.clearSearch,this)});return g},_firstSearch:function(g){this.log("onFirstSearch",g);return this.searchItems(g)},searchItems:function(g){this.searchFor=g;this.trigger("search:searching",g,this);this.renderItems();this.$("> .controls .search-query").val(g);return this},clearSearch:function(g){this.searchFor="";this.trigger("search:clear",this);this.renderItems();this.$("> .controls .search-query").val("");return this},showSelectors:function(g){g=(g!==undefined)?(g):(this.fxSpeed);this.selecting=true;this.$(".list-actions").slideDown(g);_.each(this.views,function(h){h.showSelector(g)})},hideSelectors:function(g){g=(g!==undefined)?(g):(this.fxSpeed);this.selecting=false;this.$(".list-actions").slideUp(g);_.each(this.views,function(h){h.hideSelector(g)});this.selected=[];this.lastSelected=null},toggleSelectors:function(){if(!this.selecting){this.showSelectors()}else{this.hideSelectors()}},selectAll:function(g){_.each(this.views,function(h){h.select(g)})},deselectAll:function(g){this.lastSelected=null;_.each(this.views,function(h){h.deselect(g)})},selectRange:function(i,h){var g=this.viewRange(i,h);_.each(g,function(j){j.select()});return g},getSelectedViews:function(){return _.filter(this.views,function(g){return g.selected})},getSelectedModels:function(){return new this.collection.constructor(_.map(this.getSelectedViews(),function(g){return g.model}))},_showLoadingIndicator:function(h,g,i){this.debug("_showLoadingIndicator",this.indicator,h,g,i);g=(g!==undefined)?(g):(this.fxSpeed);if(!this.indicator){this.indicator=new f(this.$el,this.$el.parent());this.debug("\t created",this.indicator)}if(!this.$el.is(":visible")){this.indicator.show(0,i)}else{this.$el.fadeOut(g);this.indicator.show(h,g,i)}},_hideLoadingIndicator:function(g,h){this.debug("_hideLoadingIndicator",this.indicator,g,h);g=(g!==undefined)?(g):(this.fxSpeed);if(this.indicator){this.indicator.hide(g,h)}},scrollPosition:function(){return this.$scrollContainer().scrollTop()},scrollTo:function(h,g){g=g||0;this.$scrollContainer().animate({scrollTop:h},g);return this},scrollToTop:function(g){return this.scrollTo(0,g)},scrollToItem:function(g,i){if(!g){return this}var h=g.$el.position().top;return this.scrollTo(h,i)},scrollToId:function(h,g){return this.scrollToItem(this.viewFromModelId(h),g)},events:{"click .select-all":"selectAll","click .deselect-all":"deselectAll"},toString:function(){return"ListPanel("+this.collection+")"}});e.prototype.templates=(function(){var h=b.wrapTemplate(["<div>",'<div class="controls"></div>','<div class="list-items"></div>','<div class="empty-message infomessagesmall"></div>',"</div>"]);var g=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= view.title %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>",'<div class="list-action-menu btn-group">',"</div>","</div>","</div>"]);return{el:h,controls:g}}());var a=e.extend({modelCollectionKey:"contents",initialize:function(g){e.prototype.initialize.call(this,g);this.selecting=(g.selecting!==undefined)?g.selecting:false;this.setModel(this.model,g)},setModel:function(h,g){g=g||{};this.debug(this+".setModel:",h,g);this.freeModel();this.freeViews();if(h){var i=this.model?this.model.get("id"):null;this.model=h;if(this.logger){this.model.logger=this.logger}this._setUpModelListeners();this.collection.off();this.collection=(this.model[this.modelCollectionKey])?this.model[this.modelCollectionKey]:(g.collection||(new this.collectionClass([])));this._setUpCollectionListeners();if(i&&h.get("id")!==i){this.trigger("new-model",this)}}return this},freeModel:function(){if(this.model){this.stopListening(this.model)}return this},_setUpModelListeners:function(){this.log(this+"._setUpModelListeners",this.model);this.model.on("error",function(){var g=Array.prototype.slice.call(arguments,0);g.unshift("error");this.trigger.apply(this,g)},this);return this},_renderControls:function(h){this.debug(this+"(ListPanel)._renderControls");var i=this.model?this.model.toJSON():{},g=$(this.templates.controls(i,this));h.find(".controls").replaceWith(g);return g},toString:function(){return"ModelListPanel("+this.model+")"}});a.prototype.templates=(function(){var g=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= model.name %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>",'<div class="list-action-menu btn-group">',"</div>","</div>","</div>"]);return _.extend(_.clone(e.prototype.templates),{controls:g})}());return{ListPanel:e,ModelListPanel:a}}); \ No newline at end of file diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 static/style/blue/base.css --- a/static/style/blue/base.css +++ b/static/style/blue/base.css @@ -2007,7 +2007,8 @@ .list-panel .controls .list-actions:after{clear:both} .list-panel .controls .list-actions:before,.list-panel .controls .list-actions:after{content:" ";display:table;} .list-panel .controls .list-actions:after{clear:both} -.list-panel .controls .list-actions .btn{padding-top:2px;padding-bottom:2px;font-size:90%} +.list-panel .controls .list-actions .btn{padding-top:2px;padding-bottom:2px;font-size:90%;z-index:inherit} +.list-panel .controls .list-actions .list-action-menu{float:right}.list-panel .controls .list-actions .list-action-menu .dropdown-menu{z-index:inherit} .list-panel .list-items .list-item:not(:last-child){border-bottom-width:0px} .list-panel .empty-message{display:none;margin:0px} .list-item .details .list-panel{margin-top:8px;border-radius:3px;background:white;padding:4px}.list-item .details .list-panel .list-items{border:1px solid #bfbfbf;border-radius:3px}.list-item .details .list-panel .list-items .list-item:first-child{border-top-width:0px;border-radius:3px 3px 0px 0px} @@ -2078,7 +2079,6 @@ .history-panel .controls .annotation-display .annotation{border-radius:3px;border:1px solid rgba(153,153,153,0.5);padding:4px;white-space:pre-wrap;overflow:auto} .history-panel .controls .annotation-display .annotation:empty:after{position:relative;top:-4px;font-size:10px;font-style:italic;color:grey;content:'Click here to edit annotation'} .history-panel .controls .annotation-display textarea{margin:0px 0px 2px 0px;border-radius:3px;width:100%} -.history-panel .controls .list-actions .list-action-popup-btn{float:right} .history-panel .list-item.history-content{border-width:1px 0px 0px 0px}.history-panel .list-item.history-content:last-child{border-width:1px 0px 1px 0px} .history-panel .empty-message{margin:0px 10px 0px 10px} .history-panel .dataset-collection .subtitle{margin-top:2px} diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 static/style/src/less/history.less --- a/static/style/src/less/history.less +++ b/static/style/src/less/history.less @@ -449,12 +449,6 @@ width: 100%; } } - - .list-actions { - .list-action-popup-btn { - float: right; - } - } } // display only a top border on all diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 static/style/src/less/list-item.less --- a/static/style/src/less/list-item.less +++ b/static/style/src/less/list-item.less @@ -167,6 +167,13 @@ padding-top: 2px; padding-bottom: 2px; font-size: 90%; + z-index: inherit; + } + .list-action-menu { + float: right; + .dropdown-menu { + z-index: inherit; + } } } } diff -r 8519e2f351f82229ccec63f5b33ff719b8837fd5 -r 316080b22578989fc473e101641c2118a73f6693 templates/webapps/galaxy/history/view_multiple.mako --- a/templates/webapps/galaxy/history/view_multiple.mako +++ b/templates/webapps/galaxy/history/view_multiple.mako @@ -43,7 +43,6 @@ multipanel = new MULTI_PANEL.MultiPanelColumns({ el : $( '#center' ).get(0), histories : histories, - //historiesJSON : historiesJSON, order : bootstrapped.order, currentHistoryId : '${current_history_id}' }).render( 0 ); https://bitbucket.org/galaxy/galaxy-central/commits/df939bc2b7fe/ Changeset: df939bc2b7fe Branch: next-stable User: carlfeberhard Date: 2015-02-17 14:57:18+00:00 Summary: merge Affected #: 5 files diff -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 -r df939bc2b7fe0ac410e227acd6e32535a0ad7817 config/galaxy.ini.sample --- a/config/galaxy.ini.sample +++ b/config/galaxy.ini.sample @@ -786,6 +786,14 @@ # public. #new_user_dataset_access_role_default_private = False +# Expose user list. Setting this to true will expose the user list to authenticated users. This +# makes sharing datasets in smaller galaxy instances much easier as they can type a name/email and +# have the correct user show up. This makes less sense on large public galaxy instances where +# that data shouldn't be exposed. For semi-public galaxies, it may make sense to expose just the +# username and not email, or vice versa. +#expose_user_name = False +#expose_user_email = False + # -- Beta features # Use new tool form diff -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 -r df939bc2b7fe0ac410e227acd6e32535a0ad7817 lib/galaxy/config.py --- a/lib/galaxy/config.py +++ b/lib/galaxy/config.py @@ -106,6 +106,9 @@ self.user_label_filters = listify( kwargs.get( "user_tool_label_filters", [] ), do_strip=True ) self.user_section_filters = listify( kwargs.get( "user_tool_section_filters", [] ), do_strip=True ) + self.expose_user_name = kwargs.get( "expose_user_name", False ) + self.expose_user_email = kwargs.get( "expose_user_email", False ) + # Check for tools defined in the above non-shed tool configs (i.e., tool_conf.xml) tht have # been migrated from the Galaxy code distribution to the Tool Shed. self.check_migrate_tools = string_as_bool( kwargs.get( 'check_migrate_tools', True ) ) diff -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 -r df939bc2b7fe0ac410e227acd6e32535a0ad7817 lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -131,7 +131,7 @@ histories, credentials, and roles. """ # attributes that will be accessed and returned when calling to_dict( view='collection' ) - dict_collection_visible_keys = ( 'id', 'email' ) + dict_collection_visible_keys = ( 'id', 'email', 'username' ) # attributes that will be accessed and returned when calling to_dict( view='element' ) dict_element_visible_keys = ( 'id', 'email', 'username', 'total_disk_usage', 'nice_total_disk_usage' ) diff -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 -r df939bc2b7fe0ac410e227acd6e32535a0ad7817 lib/galaxy/webapps/galaxy/api/users.py --- a/lib/galaxy/webapps/galaxy/api/users.py +++ b/lib/galaxy/webapps/galaxy/api/users.py @@ -43,11 +43,19 @@ else: query = query.filter( trans.app.model.User.table.c.deleted == False ) # noqa # special case: user can see only their own user - if not trans.user_is_admin(): + # special case2: if the galaxy admin has specified that other user email/names are + # exposed, we don't want special case #1 + if not trans.user_is_admin() and not trans.app.config.expose_user_name and not trans.app.config.expose_user_email: item = trans.user.to_dict( value_mapper={ 'id': trans.security.encode_id } ) return [item] for user in query: item = user.to_dict( value_mapper={ 'id': trans.security.encode_id } ) + # If NOT configured to expose_email, do not expose email UNLESS the user is self, or + # the user is an admin + if not trans.app.config.expose_user_name and user is not trans.user and not trans.user_is_admin(): + del item['username'] + if not trans.app.config.expose_user_email and user is not trans.user and not trans.user_is_admin(): + del item['email'] # TODO: move into api_values rval.append( item ) return rval diff -r 7e47493de36fa37e0fe2e2a29d777cc4356bd6e5 -r df939bc2b7fe0ac410e227acd6e32535a0ad7817 templates/webapps/galaxy/history/share.mako --- a/templates/webapps/galaxy/history/share.mako +++ b/templates/webapps/galaxy/history/share.mako @@ -36,10 +36,10 @@ </div><div style="clear: both"></div><div class="form-row"> + <% existing_emails = ','.join([ d.user.email for d in history.users_shared_with ]) %><label>Galaxy user emails with which to share histories</label> - <div style="float: left; width: 250px; margin-right: 10px;"> - <input type="text" name="email" value="${email}" size="40"> - </div> + <input type="hidden" id="email_select" name="email" value="${ existing_emails }" style="float: left; width: 250px; margin-right: 10px;"> + </input><div class="toolParamHelp" style="clear: both;"> Enter a Galaxy user email address or a comma-separated list of addresses if sharing with multiple users </div> @@ -55,6 +55,94 @@ <input type="submit" name="share_button" value="Submit"></div></form> + <script type="text/javascript"> + // stolen from templates/admin/impersonate.mako + /* This should be ripped out and made generic at some point for the + * various API bindings available, and once the API can filter list + * queries (term, below) */ + + var user_id = "${trans.security.encode_id(trans.user.id)}"; + var history_id = "${trans.security.encode_id( history.id )}"; + + function item_to_label(item){ + var text = ""; + if(typeof(item.username) === "string" && typeof(item.email) === "string"){ + text = item.username + " <" + item.email + ">"; + }else if(typeof(item.username) === "string"){ + text = item.username; + }else{ + text = item.email; + } + return text; + //return "id:" + item.id + "|e:" + item.email + "|u:" + item.username; + } + + $("#email_select").select2({ + placeholder: "Select a user", + multiple: true, + initSelection: function(element, callback) { + var data = [ + // Must be here to loop across the users that this has been shared with. + %for i, association in enumerate( history.users_shared_with ): + <% shared_with = association.user %> + { + email: "${ shared_with.email }", + id: "${trans.security.encode_id(shared_with.id)}", + text: item_to_label({"email": "${ shared_with.email }", "username": "${ shared_with.username }" }) + }, + %endfor + ]; + callback(data); + }, + tokenSeparators: [',', ' '], + // Required for initSelection + id: function(object) { + return object.id; + }, + ajax: { + url: "${h.url_for(controller="/api/users", action="index")}", + data: function (term) { + return { + f_email: term + }; + }, + dataType: 'json', + quietMillis: 250, + results: function (data) { + var results = []; + // For every user returned by the API call, + $.each(data, function(index, item){ + // If they aren't the requesting user, add to the + // list that will populate the select + if(item.id != "${trans.security.encode_id(trans.user.id)}"){ + results.push({ + id: item.id, + name: item.username, + text: item_to_label(item), + }); + } + }); + return { + results: results + }; + } + }, + createSearchChoice: function(term, data) { + // Check for a user with a matching email. + var matches = _.filter(data, function(user){ + return user.text.indexOf(term) > -1; + }); + // If there aren't any users with matching object labels, then + // display a "default" entry with whatever text they're entering. + // id is set to term as that will be used in + if(matches.length == 0){ + return {id: term, text:term}; + }else{ + // No extra needed + } + } + }); + </script> %else: ## We are sharing restricted histories %if no_change_needed or can_change: https://bitbucket.org/galaxy/galaxy-central/commits/df4ab158d14e/ Changeset: df4ab158d14e User: carlfeberhard Date: 2015-02-17 14:57:34+00:00 Summary: merge Affected #: 0 files 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.
participants (1)
-
commits-noreply@bitbucket.org