mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
UI, history: minor cleanup
This commit is contained in:
@@ -565,12 +565,13 @@ function wrapTemplate( template, jsonNamespace ){
|
||||
|
||||
//==============================================================================
|
||||
/** Return a comparator function for sorted Collections */
|
||||
function buildComparator( attribute_name, isAsc ){
|
||||
isAsc = isAsc? 1 : -1;
|
||||
function buildComparator( attribute_name, options ){
|
||||
options = options || {};
|
||||
var ascending = options.ascending? 1 : -1;
|
||||
return function __comparator( a, b ){
|
||||
a = a.get( attribute_name );
|
||||
b = b.get( attribute_name );
|
||||
return ( a < b? -1 : ( a > b? 1 : 0 ) ) * isAsc;
|
||||
return ( a < b? -1 : ( a > b? 1 : 0 ) ) * ascending;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@ var HistoryContents = _super.extend( BASE_MVC.LoggableMixin ).extend({
|
||||
this.includeDeleted = options.includeDeleted || false;
|
||||
/** @type {Boolean} does this collection contain and fetch non-visible elements */
|
||||
this.includeHidden = options.includeHidden || false;
|
||||
|
||||
this.on( 'all', function(){ console.debug( arguments ); });
|
||||
},
|
||||
|
||||
/** root api url */
|
||||
@@ -72,16 +74,8 @@ var HistoryContents = _super.extend( BASE_MVC.LoggableMixin ).extend({
|
||||
/** @type {String} order used here and when fetching from server */
|
||||
order : 'create_time',
|
||||
|
||||
//TODO: generalize
|
||||
/** local comparator */
|
||||
comparator : function _create_timeDsc( a, b ){
|
||||
var createTimeA = a.get( 'create_time' );
|
||||
var createTimeB = b.get( 'create_time' );
|
||||
// console.log( 'comparator', createTimeA, createTimeB );
|
||||
if( createTimeA > createTimeB ){ return 1; }
|
||||
if( createTimeA < createTimeB ){ return -1; }
|
||||
return 0;
|
||||
},
|
||||
comparator : BASE_MVC.buildComparator( 'create_time', { ascending: false }),
|
||||
|
||||
// ........................................................................ common queries
|
||||
/** Get the id of every model in this collection not in a 'ready' state (running).
|
||||
|
||||
@@ -153,6 +153,7 @@ var History = Backbone.Model
|
||||
|
||||
/** */
|
||||
refresh : function( options ){
|
||||
// console.log( this + '.refresh' );
|
||||
options = options || {};
|
||||
var self = this;
|
||||
|
||||
@@ -168,9 +169,11 @@ var History = Backbone.Model
|
||||
|
||||
/** */
|
||||
checkForUpdates : function( options ){
|
||||
// console.log( this + '.checkForUpdates' );
|
||||
options = options || {};
|
||||
var delay = this.UPDATE_DELAY;
|
||||
var self = this;
|
||||
if( !self.id ){ return; }
|
||||
|
||||
function _delayThenUpdate(){
|
||||
// prevent buildup of updater timeouts by clearing previous if any, then set new and cache id
|
||||
@@ -225,8 +228,10 @@ var History = Backbone.Model
|
||||
|
||||
/** */
|
||||
fetchWithContents : function( options, contentsOptions ){
|
||||
console.log( this + '.fetchWithContents' );
|
||||
// TODO: push down to a base class
|
||||
options = options || {};
|
||||
contentsOptions = contentsOptions || {};
|
||||
options.view = 'current';
|
||||
|
||||
var self = this;
|
||||
@@ -235,7 +240,12 @@ var History = Backbone.Model
|
||||
self.contents.historyId = history.id;
|
||||
// reset the update time
|
||||
self.lastUpdateTime = new Date();
|
||||
|
||||
contentsOptions.reset = true;
|
||||
contentsOptions.silent = true;
|
||||
return self.contents.fetch( contentsOptions );
|
||||
|
||||
// return self.contents.fetchFirst( contentsOptions );
|
||||
});
|
||||
},
|
||||
|
||||
@@ -390,10 +400,10 @@ var HistoryCollection = _collectionSuper.extend( BASE_MVC.LoggableMixin ).extend
|
||||
|
||||
/** @type {Object} map of collection available sorting orders containing comparator fns */
|
||||
comparators : _.extend( _.clone( _collectionSuper.prototype.comparators ), {
|
||||
'name' : BASE_MVC.buildComparator( 'name', true ),
|
||||
'name-dsc' : BASE_MVC.buildComparator( 'name', false ),
|
||||
'size' : BASE_MVC.buildComparator( 'size', false ),
|
||||
'size-asc' : BASE_MVC.buildComparator( 'size', true ),
|
||||
'name' : BASE_MVC.buildComparator( 'name', { ascending: true }),
|
||||
'name-dsc' : BASE_MVC.buildComparator( 'name', { ascending: false }),
|
||||
'size' : BASE_MVC.buildComparator( 'size', { ascending: false }),
|
||||
'size-asc' : BASE_MVC.buildComparator( 'size', { ascending: true }),
|
||||
}),
|
||||
|
||||
/** override to always have the current history first */
|
||||
|
||||
@@ -123,7 +123,7 @@ var CurrentHistoryView = _super.extend(
|
||||
/** release/free/shutdown old models and set up panel for new models */
|
||||
setModel : function( model, attributes, render ){
|
||||
_super.prototype.setModel.call( this, model, attributes, render );
|
||||
if( this.model ){
|
||||
if( this.model && this.model.id ){
|
||||
this.log( 'checking for updates' );
|
||||
this.model.checkForUpdates();
|
||||
}
|
||||
@@ -149,11 +149,13 @@ var CurrentHistoryView = _super.extend(
|
||||
/** listening for history events */
|
||||
_setUpModelListeners : function(){
|
||||
_super.prototype._setUpModelListeners.call( this );
|
||||
// ---- history
|
||||
// re-broadcast any model change events so that listeners don't have to re-bind to each history
|
||||
this.listenTo( this.model, 'change:nice_size change:size', function(){
|
||||
this.trigger( 'history-size-change', this, this.model, arguments );
|
||||
}, this );
|
||||
return this.listenTo( this.model, {
|
||||
'change:nice_size change:size' : function(){
|
||||
this.trigger( 'history-size-change', this, this.model, arguments );
|
||||
},
|
||||
'change:id' : function(){ this.model.checkForUpdates(); }
|
||||
});
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------ panel rendering
|
||||
|
||||
@@ -294,45 +294,24 @@ var HistoryViewEdit = _super.extend(
|
||||
return [
|
||||
{ html: _l( 'Build Dataset List' ), func: function() {
|
||||
LIST_COLLECTION_CREATOR.createListCollection( panel.getSelectedModels() )
|
||||
.done( function(){ panel.model.refresh() });
|
||||
.done( function(){ panel.model.refresh(); });
|
||||
}
|
||||
},
|
||||
// TODO: Only show quick pair if two things selected.
|
||||
{ html: _l( 'Build Dataset Pair' ), func: function() {
|
||||
PAIR_COLLECTION_CREATOR.createPairCollection( panel.getSelectedModels() )
|
||||
.done( function(){ panel.model.refresh() });
|
||||
.done( function(){ panel.model.refresh(); });
|
||||
}
|
||||
},
|
||||
{ html: _l( 'Build List of Dataset Pairs' ), func: function() {
|
||||
LIST_OF_PAIRS_COLLECTION_CREATOR.createListOfPairsCollection( panel.getSelectedModels() )
|
||||
.done( function(){ panel.model.refresh() });
|
||||
.done( function(){ panel.model.refresh(); });
|
||||
}
|
||||
},
|
||||
];
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------ sub-views
|
||||
// reverse HID order
|
||||
/** Override to reverse order of views - newest contents on top */
|
||||
_attachItems : function( $whereTo ){
|
||||
this.$list( $whereTo ).append( this.views.reverse().map( function( view ){
|
||||
return view.$el;
|
||||
}));
|
||||
return this;
|
||||
},
|
||||
|
||||
/** Override to add new contents at the top */
|
||||
_attachView : function( view ){
|
||||
var panel = this;
|
||||
// override to control where the view is added, how/whether it's rendered
|
||||
panel.views.unshift( view );
|
||||
panel.$list().prepend( view.render( 0 ).$el.hide() );
|
||||
panel.trigger( 'view:attached', view );
|
||||
view.$el.slideDown( panel.fxSpeed, function(){
|
||||
panel.trigger( 'view:attached:rendered' );
|
||||
});
|
||||
},
|
||||
|
||||
/** In this override, add purgeAllowed and whether tags/annotation editors should be shown */
|
||||
_getItemViewOptions : function( model ){
|
||||
var options = _super.prototype._getItemViewOptions.call( this, model );
|
||||
@@ -403,7 +382,7 @@ var HistoryViewEdit = _super.extend(
|
||||
/** Update the history size display (curr. upper right of panel).
|
||||
*/
|
||||
updateHistoryDiskSize : function(){
|
||||
this.$el.find( '.history-size' ).text( this.model.get( 'nice_size' ) );
|
||||
this.$( '.history-size' ).text( this.model.get( 'nice_size' ) );
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------ as drop target
|
||||
|
||||
@@ -97,8 +97,9 @@ var ListPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend(/** @lends
|
||||
/** override $scrollContainer fn via attributes - fn should return jq for elem to call scrollTo on */
|
||||
this.$scrollContainer = attributes.$scrollContainer || this.$scrollContainer;
|
||||
|
||||
//TODO: remove
|
||||
/** @type {String} generic title */
|
||||
this.title = attributes.title || '';
|
||||
/** @type {String} generic subtitle */
|
||||
this.subtitle = attributes.subtitle || '';
|
||||
|
||||
this._setUpListeners();
|
||||
@@ -106,12 +107,13 @@ var ListPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend(/** @lends
|
||||
|
||||
/** free any sub-views the list has */
|
||||
freeViews : function(){
|
||||
//TODO: stopListening? remove?
|
||||
_.each( this.views, function( view ){
|
||||
var self = this;
|
||||
_.each( self.views, function( view ){
|
||||
self.stopListening( view );
|
||||
view.off();
|
||||
});
|
||||
this.views = [];
|
||||
return this;
|
||||
self.views = [];
|
||||
return self;
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------ listeners
|
||||
@@ -167,8 +169,23 @@ var ListPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend(/** @lends
|
||||
this.renderItems();
|
||||
},
|
||||
add : this.addItemView,
|
||||
remove : this.removeItemView
|
||||
remove : this.removeItemView,
|
||||
});
|
||||
// //TODO: when backbone > 1.2 : use 'update' for batch addition of model views
|
||||
// // experimental 'addMany'
|
||||
// this.listenTo( this.collection, {
|
||||
// add : function( model, collection, options ){
|
||||
// if( !this._bulkAdd ){ this._bulkAdd = []; }
|
||||
// this._bulkAdd.push( model.id );
|
||||
// console.log( 'add another:', model.id );
|
||||
|
||||
// var self = this;
|
||||
// _.debounce( function(){
|
||||
// console.log( 'bulkAdd:', self._bulkAdd );
|
||||
// delete self._bulkAdd;
|
||||
// }, 80 );
|
||||
// }
|
||||
// });
|
||||
|
||||
// debugging
|
||||
if( this.logger ){
|
||||
@@ -354,15 +371,15 @@ var ListPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend(/** @lends
|
||||
* @returns the visible item views
|
||||
*/
|
||||
renderItems : function( $whereTo ){
|
||||
console.log( '------------------------------------------------- renderItems' );
|
||||
$whereTo = $whereTo || this.$el;
|
||||
var panel = this;
|
||||
panel.log( this + '.renderItems', $whereTo );
|
||||
|
||||
var $list = panel.$list( $whereTo );
|
||||
//TODO: free prev. views?
|
||||
panel.freeViews();
|
||||
//TODO:? cache and re-use views?
|
||||
panel.views = panel._filterCollection().map( function( itemModel ){
|
||||
//TODO: creates views each time - not neccessarily good
|
||||
//TODO: pass speed here
|
||||
return panel._createItemView( itemModel ).render( 0 );
|
||||
});
|
||||
//panel.debug( item$els );
|
||||
@@ -452,12 +469,6 @@ var ListPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend(/** @lends
|
||||
//ev.dataTransfer.setDragImage( v.el, 60, 60 );
|
||||
}, this );
|
||||
|
||||
// debugging
|
||||
//if( this.logger ){
|
||||
// view.on( 'all', function( event ){
|
||||
// this.log( this + '(view)', arguments );
|
||||
// }, this );
|
||||
//}
|
||||
return panel;
|
||||
},
|
||||
|
||||
@@ -496,27 +507,40 @@ var ListPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend(/** @lends
|
||||
addItemView : function( model, collection, options ){
|
||||
this.log( this + '.addItemView:', model );
|
||||
var panel = this;
|
||||
if( !panel._filterItem( model ) ){ return undefined; }
|
||||
|
||||
// get the index of the model in the list of filtered models shown by this list
|
||||
// in order to insert the view in the proper place
|
||||
//TODO:? potentially expensive
|
||||
var modelIndex = panel._filterCollection().indexOf( model );
|
||||
if( modelIndex === -1 ){ return undefined; }
|
||||
var view = panel._createItemView( model );
|
||||
// hide the empty message if only view
|
||||
$( view ).queue( 'fx', [
|
||||
//TODO:? could poss. pubsub this
|
||||
function( next ){ panel.$emptyMessage().fadeOut( panel.fxSpeed, next ); },
|
||||
function( next ){
|
||||
panel._attachView( view );
|
||||
next();
|
||||
}
|
||||
]);
|
||||
|
||||
if( panel.$emptyMessage().is( ':visible' ) && panel.views.length === 1 ){
|
||||
// hide the empty message if only view
|
||||
$( view ).queue( 'fx', [
|
||||
function( next ){ panel.$emptyMessage().fadeOut( panel.fxSpeed, next ); },
|
||||
function( next ){
|
||||
panel._attachView( view, modelIndex );
|
||||
next();
|
||||
}
|
||||
]);
|
||||
}
|
||||
return view;
|
||||
},
|
||||
|
||||
/** internal fn to add view (to both panel.views and panel.$list) */
|
||||
_attachView : function( view ){
|
||||
_attachView : function( view, modelIndex ){
|
||||
modelIndex = modelIndex || 0;
|
||||
var panel = this;
|
||||
// override to control where the view is added, how/whether it's rendered
|
||||
panel.views.push( view );
|
||||
panel.$list().append( view.render( 0 ).$el.hide() );
|
||||
|
||||
// use the modelIndex to splice into views and insert at the proper index in the DOM
|
||||
panel.views.splice( modelIndex, 0, view );
|
||||
if( modelIndex === 0 ){
|
||||
panel.$list().prepend( view.render( 0 ).$el.hide() );
|
||||
} else {
|
||||
var $placedAfterThis = panel.$list().children().eq( modelIndex - 1 );
|
||||
$placedAfterThis.after( view.render( 0 ).$el.hide() );
|
||||
}
|
||||
|
||||
panel.trigger( 'view:attached', view );
|
||||
view.$el.slideDown( panel.fxSpeed, function(){
|
||||
panel.trigger( 'view:attached:rendered' );
|
||||
@@ -568,17 +592,7 @@ var ListPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend(/** @lends
|
||||
/** get views based on model properties */
|
||||
viewsWhereModel : function( properties ){
|
||||
return this.views.filter( function( view ){
|
||||
//return view.model.matches( properties );
|
||||
//TODO: replace with _.matches (underscore 1.6.0)
|
||||
var json = view.model.toJSON();
|
||||
for( var key in properties ){
|
||||
if( properties.hasOwnProperty( key ) ){
|
||||
if( json[ key ] !== properties[ key ] ){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return view.model.matches( properties );
|
||||
});
|
||||
},
|
||||
|
||||
@@ -648,14 +662,14 @@ var ListPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend(/** @lends
|
||||
|
||||
// ------------------------------------------------------------------------ selection
|
||||
/** @type Integer when the number of list item views is >= to this, don't animate selectors */
|
||||
THROTTLE_SELECTORS_AT : 20,
|
||||
THROTTLE_SELECTOR_FX_AT : 20,
|
||||
|
||||
/** show selectors on all visible itemViews and associated controls */
|
||||
showSelectors : function( speed ){
|
||||
speed = ( speed !== undefined )?( speed ):( this.fxSpeed );
|
||||
this.selecting = true;
|
||||
this.$( '.list-actions' ).slideDown( speed );
|
||||
speed = this.views.length >= this.THROTTLE_SELECTORS_AT? 0 : speed;
|
||||
speed = this.views.length >= this.THROTTLE_SELECTOR_FX_AT? 0 : speed;
|
||||
_.each( this.views, function( view ){
|
||||
view.showSelector( speed );
|
||||
});
|
||||
@@ -668,7 +682,7 @@ var ListPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend(/** @lends
|
||||
speed = ( speed !== undefined )?( speed ):( this.fxSpeed );
|
||||
this.selecting = false;
|
||||
this.$( '.list-actions' ).slideUp( speed );
|
||||
speed = this.views.length >= this.THROTTLE_SELECTORS_AT? 0 : speed;
|
||||
speed = this.views.length >= this.THROTTLE_SELECTOR_FX_AT? 0 : speed;
|
||||
_.each( this.views, function( view ){
|
||||
view.hideSelector( speed );
|
||||
});
|
||||
@@ -724,7 +738,6 @@ var ListPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend(/** @lends
|
||||
},
|
||||
|
||||
// ------------------------------------------------------------------------ loading indicator
|
||||
//TODO: questionable
|
||||
/** hide the $el and display a loading indicator (in the $el's parent) when loading new data */
|
||||
_showLoadingIndicator : function( msg, speed, callback ){
|
||||
this.debug( '_showLoadingIndicator', this.indicator, msg, speed, callback );
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
||||
define(["mvc/history/history-content-model","mvc/base/controlled-fetch-collection","mvc/history/hda-model","mvc/history/hdca-model","mvc/history/history-preferences","mvc/base-mvc"],function(a,b,c,d,e,f){"use strict";var g=b.ControlledFetchCollection,h=g.extend(f.LoggableMixin).extend({_logNamespace:"history",model:function(a,b){if("dataset"===a.history_content_type)return new c.HistoryDatasetAssociation(a,b);if("dataset_collection"===a.history_content_type){switch(a.collection_type){case"list":return new d.HistoryListDatasetCollection(a,b);case"paired":return new d.HistoryPairDatasetCollection(a,b);case"list:paired":return new d.HistoryListPairedDatasetCollection(a,b)}return{validationError:"Unknown collection_type: "+a.history_content_type}}return{validationError:"Unknown history_content_type: "+a.history_content_type}},initialize:function(a,b){b=b||{},this.historyId=b.historyId||null,this.model.prototype.idAttribute="type_id",this.includeDeleted=b.includeDeleted||!1,this.includeHidden=b.includeHidden||!1},urlRoot:Galaxy.root+"api/histories",url:function(){return this.urlRoot+"/"+this.historyId+"/contents"},order:"create_time",comparator:function(a,b){var c=a.get("create_time"),d=b.get("create_time");return c>d?1:d>c?-1:0},running:function(){function a(a){return!a.inReadyState()}return new h(this.filter(a))},getByHid:function(a){return _.first(this.filter(function(b){return b.get("hid")===a}))},haveDetails:function(){return this.all(function(a){return a.hasDetails()})},hidden:function(){function a(a){return a.hidden()}return new h(this.filter(a))},deleted:function(){function a(a){return a.get("deleted")}return new h(this.filter(a))},visibleAndUndeleted:function(){function a(a){return a.get("visible")&&!a.get("deleted")}return new h(this.filter(a))},setIncludeDeleted:function(a){_.isBoolean(a)&&a!==this.includeDeleted&&(this.includeDeleted=a,this.trigger("change:include-deleted",a,this))},setIncludeHidden:function(a){_.isBoolean(a)&&a!==this.includeHidden&&(this.includeHidden=a,this.trigger("change:include-hidden",a,this))},fetch:function(a){if(a=a||{},this.historyId&&!a.details){var b=e.HistoryPrefs.get(this.historyId).get("expandedIds");a.details=_.values(b).join(",")}return g.prototype.fetch.call(this,a)},fetchUpdated:function(a,b){return a&&(b=b||{filters:{}},b.filters={"update_time-ge":a.toISOString()}),console.log("fetching updated:",this.historyId),this.fetch(b)},_buildFetchData:function(a){return _.extend(g.prototype._buildFetchData.call(this,a),{v:"dev"})},_fetchParams:g.prototype._fetchParams.concat(["v","details"]),_buildFetchFilters:function(a){var b={};return this.includeDeleted||(b.deleted=!1,b.purged=!1),this.includeHidden||(b.visible=!0),_.defaults(g.prototype._buildFetchFilters(this,a),b)},fetchAllDetails:function(a){a=a||{};var b={details:"all"};return a.data=_.extend(a.data||{},b),this.fetch(a)},ajaxQueue:function(a,b){var c=jQuery.Deferred(),d=this.length,e=[];if(!d)return c.resolve([]),c;var f=this.chain().reverse().map(function(g,h){return function(){var i=a.call(g,b);i.done(function(a){c.notify({curr:h,total:d,response:a,model:g})}),i.always(function(a){e.push(a),f.length?f.shift()():c.resolve(e)})}}).value();return f.shift()(),c},isCopyable:function(a){var b=["HistoryDatasetAssociation","HistoryDatasetCollectionAssociation"];return _.isObject(a)&&a.id&&_.contains(b,a.model_class)},copy:function(a){var b,c,d;_.isString(a)?(b=a,d="hda",c="dataset"):(b=a.id,d={HistoryDatasetAssociation:"hda",LibraryDatasetDatasetAssociation:"ldda",HistoryDatasetCollectionAssociation:"hdca"}[a.model_class]||"hda",c="hdca"===d?"dataset_collection":"dataset");var e=this,f=jQuery.post(this.url(),{content:b,source:d,type:c}).done(function(a){e.add([a])}).fail(function(){e.trigger("error",e,f,{},"Error copying contents",{type:c,id:b,source:d})});return f},createHDCA:function(a,b,c){var e=this,f={list:d.HistoryListDatasetCollection,paired:d.HistoryPairDatasetCollection},g=new f[b]({history_id:this.historyId,name:c,element_identifiers:a});return g.save().done(function(){e.add(g)}).fail(function(a,b,c){e.trigger("error",a,b,c)})},matches:function(a){return this.filter(function(b){return b.matches(a)})},set:function(b,c){b=_.isArray(b)?b:[b],_.each(b,function(b){b.type_id&&b.get&&b.get("type_id")||(b.type_id=a.typeIdStr(b.history_content_type,b.id))}),Backbone.Collection.prototype.set.call(this,b,c)},clone:function(){var a=Backbone.Collection.prototype.clone.call(this);return a.historyId=this.historyId,a},toString:function(){return["HistoryContents(",[this.historyId,this.length].join(),")"].join("")}});return window.HistoryContents=h,{HistoryContents:h}});
|
||||
define(["mvc/history/history-content-model","mvc/base/controlled-fetch-collection","mvc/history/hda-model","mvc/history/hdca-model","mvc/history/history-preferences","mvc/base-mvc"],function(a,b,c,d,e,f){"use strict";var g=b.ControlledFetchCollection,h=g.extend(f.LoggableMixin).extend({_logNamespace:"history",model:function(a,b){if("dataset"===a.history_content_type)return new c.HistoryDatasetAssociation(a,b);if("dataset_collection"===a.history_content_type){switch(a.collection_type){case"list":return new d.HistoryListDatasetCollection(a,b);case"paired":return new d.HistoryPairDatasetCollection(a,b);case"list:paired":return new d.HistoryListPairedDatasetCollection(a,b)}return{validationError:"Unknown collection_type: "+a.history_content_type}}return{validationError:"Unknown history_content_type: "+a.history_content_type}},initialize:function(a,b){b=b||{},this.historyId=b.historyId||null,this.model.prototype.idAttribute="type_id",this.includeDeleted=b.includeDeleted||!1,this.includeHidden=b.includeHidden||!1,this.on("all",function(){console.debug(arguments)})},urlRoot:Galaxy.root+"api/histories",url:function(){return this.urlRoot+"/"+this.historyId+"/contents"},order:"create_time",comparator:f.buildComparator("create_time",{ascending:!1}),running:function(){function a(a){return!a.inReadyState()}return new h(this.filter(a))},getByHid:function(a){return _.first(this.filter(function(b){return b.get("hid")===a}))},haveDetails:function(){return this.all(function(a){return a.hasDetails()})},hidden:function(){function a(a){return a.hidden()}return new h(this.filter(a))},deleted:function(){function a(a){return a.get("deleted")}return new h(this.filter(a))},visibleAndUndeleted:function(){function a(a){return a.get("visible")&&!a.get("deleted")}return new h(this.filter(a))},setIncludeDeleted:function(a){_.isBoolean(a)&&a!==this.includeDeleted&&(this.includeDeleted=a,this.trigger("change:include-deleted",a,this))},setIncludeHidden:function(a){_.isBoolean(a)&&a!==this.includeHidden&&(this.includeHidden=a,this.trigger("change:include-hidden",a,this))},fetch:function(a){if(a=a||{},this.historyId&&!a.details){var b=e.HistoryPrefs.get(this.historyId).get("expandedIds");a.details=_.values(b).join(",")}return g.prototype.fetch.call(this,a)},fetchUpdated:function(a,b){return a&&(b=b||{filters:{}},b.filters={"update_time-ge":a.toISOString()}),console.log("fetching updated:",this.historyId),this.fetch(b)},_buildFetchData:function(a){return _.extend(g.prototype._buildFetchData.call(this,a),{v:"dev"})},_fetchParams:g.prototype._fetchParams.concat(["v","details"]),_buildFetchFilters:function(a){var b={};return this.includeDeleted||(b.deleted=!1,b.purged=!1),this.includeHidden||(b.visible=!0),_.defaults(g.prototype._buildFetchFilters(this,a),b)},fetchAllDetails:function(a){a=a||{};var b={details:"all"};return a.data=_.extend(a.data||{},b),this.fetch(a)},ajaxQueue:function(a,b){var c=jQuery.Deferred(),d=this.length,e=[];if(!d)return c.resolve([]),c;var f=this.chain().reverse().map(function(g,h){return function(){var i=a.call(g,b);i.done(function(a){c.notify({curr:h,total:d,response:a,model:g})}),i.always(function(a){e.push(a),f.length?f.shift()():c.resolve(e)})}}).value();return f.shift()(),c},isCopyable:function(a){var b=["HistoryDatasetAssociation","HistoryDatasetCollectionAssociation"];return _.isObject(a)&&a.id&&_.contains(b,a.model_class)},copy:function(a){var b,c,d;_.isString(a)?(b=a,d="hda",c="dataset"):(b=a.id,d={HistoryDatasetAssociation:"hda",LibraryDatasetDatasetAssociation:"ldda",HistoryDatasetCollectionAssociation:"hdca"}[a.model_class]||"hda",c="hdca"===d?"dataset_collection":"dataset");var e=this,f=jQuery.post(this.url(),{content:b,source:d,type:c}).done(function(a){e.add([a])}).fail(function(){e.trigger("error",e,f,{},"Error copying contents",{type:c,id:b,source:d})});return f},createHDCA:function(a,b,c){var e=this,f={list:d.HistoryListDatasetCollection,paired:d.HistoryPairDatasetCollection},g=new f[b]({history_id:this.historyId,name:c,element_identifiers:a});return g.save().done(function(){e.add(g)}).fail(function(a,b,c){e.trigger("error",a,b,c)})},matches:function(a){return this.filter(function(b){return b.matches(a)})},set:function(b,c){b=_.isArray(b)?b:[b],_.each(b,function(b){b.type_id&&b.get&&b.get("type_id")||(b.type_id=a.typeIdStr(b.history_content_type,b.id))}),Backbone.Collection.prototype.set.call(this,b,c)},clone:function(){var a=Backbone.Collection.prototype.clone.call(this);return a.historyId=this.historyId,a},toString:function(){return["HistoryContents(",[this.historyId,this.length].join(),")"].join("")}});return window.HistoryContents=h,{HistoryContents:h}});
|
||||
//# sourceMappingURL=../../../maps/mvc/history/history-contents.js.map
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user