UI, Collections: refactor promoteToHDCA

This commit is contained in:
Carl Eberhard
2015-03-20 12:19:27 -04:00
parent 3f885ddbb5
commit 87a45aa90b
16 changed files with 156 additions and 130 deletions
@@ -87,7 +87,7 @@ var DatasetCollectionElement = Backbone.Model
.extend( BASE_MVC.LoggableMixin )
.extend( DatasetCollectionElementMixin );
//==============================================================================
/** @class Base/Abstract Backbone collection for Generic DCEs. */
var DCECollection = Backbone.Collection.extend( BASE_MVC.LoggableMixin ).extend(
@@ -359,7 +359,7 @@ var NestedDCDCE = DatasetCollection.extend( BASE_MVC.mixin( DatasetCollectionEle
this.debug( '\t NestedDCDCE.constructor:', attributes, options );
DatasetCollectionElementMixin.constructor.call( this, attributes, options );
},
/** String representation. */
toString : function(){
var objStr = ( this.object )?( '' + this.object ):( this.get( 'element_identifier' ) );
@@ -376,7 +376,7 @@ var NestedDCDCECollection = DCECollection.extend(
/** logger used to record this.log messages, commonly set to console */
//logger : console,
/** This is a collection of nested collections */
model: NestedDCDCE,
@@ -17,6 +17,21 @@ var hcontentMixin = HISTORY_CONTENT.HistoryContentMixin,
PairDC = DC_MODEL.PairDatasetCollection,
ListPairedDC = DC_MODEL.ListPairedDatasetCollection;
//==============================================================================
/** Override to post to contents route w/o id. */
function buildHDCASave( _super ){
return function _save( attributes, options ){
if( this.isNew() ){
options = options || {};
options.url = this.urlRoot + this.get( 'history_id' ) + '/contents';
attributes = attributes || {};
attributes.type = 'dataset_collection';
}
return _super.call( this, attributes, options );
};
}
//==============================================================================
/** @class Backbone model for List Dataset Collection within a History.
*/
@@ -24,7 +39,9 @@ var HistoryListDatasetCollection = ListDC.extend( hcontentMixin ).extend(
/** @lends HistoryListDatasetCollection.prototype */{
defaults : _.extend( _.clone( ListDC.prototype.defaults ), {
model_class : 'HistoryDatasetCollectionAssociation'
history_content_type: 'dataset_collection',
collection_type : 'list',
model_class : 'HistoryDatasetCollectionAssociation'
}),
initialize : function( model, options ){
@@ -32,6 +49,9 @@ var HistoryListDatasetCollection = ListDC.extend( hcontentMixin ).extend(
hcontentMixin.initialize.call( this, model, options );
},
/** Override to post to contents route w/o id. */
save : buildHDCASave( ListDC.prototype.save ),
/** String representation. */
toString : function(){
return ([ 'HistoryListDatasetCollection(', this.get( 'name' ), ')' ].join( '' ));
@@ -47,7 +67,9 @@ var HistoryPairDatasetCollection = PairDC.extend( hcontentMixin ).extend(
/** @lends HistoryPairDatasetCollection.prototype */{
defaults : _.extend( _.clone( PairDC.prototype.defaults ), {
model_class : 'HistoryDatasetCollectionAssociation'
history_content_type: 'dataset_collection',
collection_type : 'paired',
model_class : 'HistoryDatasetCollectionAssociation'
}),
initialize : function( model, options ){
@@ -55,6 +77,9 @@ var HistoryPairDatasetCollection = PairDC.extend( hcontentMixin ).extend(
hcontentMixin.initialize.call( this, model, options );
},
/** Override to post to contents route w/o id. */
save : buildHDCASave( PairDC.prototype.save ),
/** String representation. */
toString : function(){
return ([ 'HistoryPairDatasetCollection(', this.get( 'name' ), ')' ].join( '' ));
@@ -70,7 +95,9 @@ var HistoryListPairedDatasetCollection = ListPairedDC.extend( hcontentMixin ).ex
/** @lends HistoryListPairedDatasetCollection.prototype */{
defaults : _.extend( _.clone( ListPairedDC.prototype.defaults ), {
model_class : 'HistoryDatasetCollectionAssociation'
history_content_type: 'dataset_collection',
collection_type : 'list:paired',
model_class : 'HistoryDatasetCollectionAssociation'
}),
initialize : function( model, options ){
@@ -78,6 +105,9 @@ var HistoryListPairedDatasetCollection = ListPairedDC.extend( hcontentMixin ).ex
hcontentMixin.initialize.call( this, model, options );
},
/** Override to post to contents route w/o id. */
save : buildHDCASave( ListPairedDC.prototype.save ),
/** String representation. */
toString : function(){
return ([ 'HistoryListPairedDatasetCollection(', this.get( 'name' ), ')' ].join( '' ));
@@ -56,6 +56,13 @@ var HistoryContentMixin = {
this.set( 'type_id', this._typeIdStr() );
},
/** override because backbone tests boolean( idAttribute ), but it's not an empty string even for new models
* due to our use of type_id.
*/
isNew : function(){
return !this.get( 'id' );
},
// ........................................................................ common queries
/** the more common alias of visible */
hidden : function(){
@@ -85,7 +92,7 @@ var HistoryContentMixin = {
//TODO: global
//TODO: these are probably better done on the leaf classes
/** history content goes through the 'api/histories' API */
urlRoot: galaxy_config.root + 'api/histories/',
urlRoot: Galaxy.options.root + 'api/histories/',
/** full url spec. for this content */
url : function(){
@@ -31,7 +31,7 @@ var HistoryContents = Backbone.Collection.extend( BASE_MVC.LoggableMixin ).exten
if( attrs.history_content_type === "dataset" ) {
return new HDA_MODEL.HistoryDatasetAssociation( attrs, options );
} else if( attrs.history_content_type === "dataset_collection" ) {
switch( attrs.collection_type ){
case 'list':
@@ -242,82 +242,39 @@ var HistoryContents = Backbone.Collection.extend( BASE_MVC.LoggableMixin ).exten
/** override to ensure type id is set */
set : function( models, options ){
_.each( models, function( model ){
if( !model.type_id || !model.get( 'type_id' ) ){
if( !model.type_id || !model.get || !model.get( 'type_id' ) ){
model.type_id = HISTORY_CONTENT.typeIdStr( model.history_content_type, model.id );
}
});
Backbone.Collection.prototype.set.call( this, models, options );
},
/** Convert this ad-hoc collection of hdas to a formal collection tracked
by the server.
**/
promoteToHistoryDatasetCollection : function _promote( history, collection_type, options ){
//TODO: seems like this would be better in mvc/collections
options = options || {};
options.url = this.url();
options.type = "POST";
var full_collection_type = collection_type;
var element_identifiers = [],
name = null;
// This mechanism is rough - no error handling, allows invalid selections, no way
// for user to pick/override element identifiers. This is only really meant
if( collection_type === "list" ) {
this.chain().each( function( hda ) {
// TODO: Handle duplicate names.
var name = hda.attributes.name;
var id = hda.get('id');
var content_type = hda.attributes.history_content_type;
if( content_type === "dataset" ) {
if( full_collection_type !== "list" ) {
this.log( "Invalid collection type" );
}
element_identifiers.push( { name: name, src: "hda", id: id } );
} else {
if( full_collection_type === "list" ) {
full_collection_type = "list:" + hda.attributes.collection_type;
} else {
if( full_collection_type !== "list:" + hda.attributes.collection_type ) {
this.log( "Invalid collection type" );
}
}
element_identifiers.push( { name: name, src: "hdca", id: id } );
}
/** */
createHDCA : function( elementIdentifiers, collectionType, name, options ){
//precondition: elementIdentifiers is an array of plain js objects
// in the proper form to create the collectionType
var contents = this,
typeToModel = {
list : HDCA_MODEL.HistoryListDatasetCollection,
paired : HDCA_MODEL.HistoryPairDatasetCollection
},
hdca = new (typeToModel[ collectionType ])({
history_id : this.historyId,
name : name,
// should probably be able to just send in a bunch of json here and restruct per class
element_identifiers : elementIdentifiers
});
// do I even need to use new above, can I just pass the attrs here
return hdca.save()
.done( function( response ){
contents.add( hdca );
})
.fail( function( xhr, status, message ){
contents.trigger( 'error', xhr, status, message );
});
name = "New Dataset List";
} else if( collection_type === "paired" ) {
var ids = this.ids();
if( ids.length !== 2 ){
// TODO: Do something...
}
element_identifiers.push( { name: "forward", src: "hda", id: ids[ 0 ] } );
element_identifiers.push( { name: "reverse", src: "hda", id: ids[ 1 ] } );
name = "New Dataset Pair";
}
options.data = {
type: "dataset_collection",
name: name,
collection_type: full_collection_type,
element_identifiers: JSON.stringify( element_identifiers )
};
var xhr = jQuery.ajax( options );
xhr.done( function( message, status, responseObj ){
history.refresh( );
});
xhr.fail( function( xhr, status, message ){
if( xhr.responseJSON && xhr.responseJSON.error ){
error = xhr.responseJSON.error;
} else {
error = xhr.responseJSON;
}
xhr.responseText = error;
// Do something?
});
return xhr;
},
/** In this override, copy the historyId to the clone */
clone : function(){
var clone = Backbone.Collection.prototype.clone.call( this );
@@ -27,6 +27,63 @@ define([
TODO:
============================================================================= */
function createListCollection( history, collection ){
//TODO: filter out non-datasets, non-ready
//TODO: fail if no valid elements remain
//return jQuery.Deferred().reject( _l( 'No valid datasets to add' ) );
var name = 'New Dataset List',
elementIdentifiers = collection.toJSON().map( function( element ){
// TODO: Handle duplicate names.
return {
id : element.id,
name : element.name,
src : ( element.history_content_type === 'dataset'? 'hda' : 'hdca' )
}
});
return collection.createHDCA( elementIdentifiers, 'list', name );
}
function createPairCollection( history, collection ){
//TODO: filter out non-datasets, non-ready
//TODO: fail if no valid elements remain
//return jQuery.Deferred().reject( _l( 'No valid datasets to add' ) );
var elementsJSON = collection.toJSON(),
name = 'New Dataset Pair',
elementIdentifiers = [
{ name: "forward", src: "hda", id: elementsJSON[0].id },
{ name: "reverse", src: "hda", id: elementsJSON[1].id }
];
return collection.createHDCA( elementIdentifiers, 'paired', name );
}
function createListOfPairsCollection( history, collection ){
var datasets = collection.toJSON().filter( function( content ){
return content.history_content_type === 'dataset'
&& content.state === STATES.OK;
});
if( datasets.length ){
require([ 'mvc/collection/paired-collection-creator' ], function( creator ){
window.creator = creator.pairedCollectionCreatorModal( datasets, {
historyId : history.id
});
});
} else {
Galaxy.modal.show({
title : _l( 'No valid datasets were selected' ),
body : _l([
'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
});
}
}
// =============================================================================
var _super = HPANEL.HistoryPanel;
// base class for current-history-panel and used as-is in history/view.mako
/** @class Editable View/Controller for the history model.
@@ -272,48 +329,23 @@ var HistoryPanelEdit = _super.extend(
}
});
}
actions.push( {
html: _l( 'Build Dataset List' ), func: function() {
panel.getSelectedModels().promoteToHistoryDatasetCollection( panel.model, "list" );
}
});
actions.push( {
return actions.concat([
{ html: _l( 'Build Dataset List' ), func: function() {
createListCollection( panel.model, panel.getSelectedModels() )
.done( function(){ panel.model.refresh() });
}
},
// TODO: Only show quick pair if two things selected.
html: _l( 'Build Dataset Pair' ), func: function() {
panel.getSelectedModels().promoteToHistoryDatasetCollection( panel.model, "paired" );
}
});
actions.push( {
// TODO: Only show quick pair if two things selected.
html: _l( 'Build List of Dataset Pairs' ),
func: _.bind( panel._showPairedCollectionModal, panel )
});
return actions;
},
_showPairedCollectionModal : function(){
var panel = this,
datasets = panel.getSelectedModels().toJSON().filter( function( content ){
return content.history_content_type === 'dataset'
&& content.state === STATES.OK;
});
if( datasets.length ){
require([ 'mvc/collection/paired-collection-creator' ], function( creator ){
window.creator = creator.pairedCollectionCreatorModal( datasets, {
historyId : panel.model.id
});
});
} else {
Galaxy.modal.show({
title : _l( 'No valid datasets were selected' ),
body : _l([
'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
});
}
{ html: _l( 'Build Dataset Pair' ), func: function() {
createPairCollection( panel.model, panel.getSelectedModels() )
.done( function(){ panel.model.refresh() });
}
},
{ html: _l( 'Build List of Dataset Pairs' ), func: function() {
createListOfPairsCollection( panel.model, panel.getSelectedModels() );
}
},
]);
},
// ------------------------------------------------------------------------ sub-views
+4 -4
View File
@@ -306,7 +306,10 @@ var ListPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend(
].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 );
return $( html ).click( function( ev ){
ev.preventDefault();
return action.func( ev );
});
});
$newMenu.find( 'ul' ).append( $actions );
$menu.replaceWith( $newMenu );
@@ -516,7 +519,6 @@ var ListPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend(
/** Remove a view from the panel (if found) */
removeItemView : function( model, collection, options ){
console.log( this + '.removeItemView:', model );
this.log( this + '.removeItemView:', model );
var panel = this,
view = panel.viewFromModel( model );
@@ -563,10 +565,8 @@ var ListPanel = Backbone.View.extend( BASE_MVC.LoggableMixin ).extend(
//return view.model.matches( properties );
//TODO: replace with _.matches (underscore 1.6.0)
var json = view.model.toJSON();
//console.debug( '\t', json, properties );
for( var key in properties ){
if( properties.hasOwnProperty( key ) ){
//console.debug( '\t\t', json[ key ], view.model.properties[ key ] );
if( json[ key ] !== view.model.get( key ) ){
return false;
}
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"hdca-model.js","sources":["../../../src/mvc/history/hdca-model.js"],"names":["define","DC_MODEL","HISTORY_CONTENT","hcontentMixin","HistoryContentMixin","ListDC","ListDatasetCollection","PairDC","PairDatasetCollection","ListPairedDC","ListPairedDatasetCollection","HistoryListDatasetCollection","extend","defaults","_","clone","prototype","model_class","initialize","model","options","call","this","toString","get","join","HistoryPairDatasetCollection","HistoryListPairedDatasetCollection"],"mappings":"AAAAA,QACI,kCACA,oCACA,sBACD,SAAUC,EAAUC,GAUvB,GAAIC,GAAgBD,EAAgBE,oBAChCC,EAASJ,EAASK,sBAClBC,EAASN,EAASO,sBAClBC,EAAeR,EAASS,4BAKxBC,EAA+BN,EAAOO,OAAQT,GAAgBS,QAG9DC,SAAWC,EAAEF,OAAQE,EAAEC,MAAOV,EAAOW,UAAUH,WAC3CI,YAAc,wCAGlBC,WAAa,SAAUC,EAAOC,GAC1Bf,EAAOW,UAAUE,WAAWG,KAAMC,KAAMH,EAAOC,GAC/CjB,EAAce,WAAWG,KAAMC,KAAMH,EAAOC,IAIhDG,SAAW,WACN,OAAU,gCAAiCD,KAAKE,IAAK,QAAU,KAAMC,KAAM,OAShFC,EAA+BnB,EAAOK,OAAQT,GAAgBS,QAG9DC,SAAWC,EAAEF,OAAQE,EAAEC,MAAOR,EAAOS,UAAUH,WAC3CI,YAAc,wCAGlBC,WAAa,SAAUC,EAAOC,GAC1Bb,EAAOS,UAAUE,WAAWG,KAAMC,KAAMH,EAAOC,GAC/CjB,EAAce,WAAWG,KAAMC,KAAMH,EAAOC,IAIhDG,SAAW,WACN,OAAU,gCAAiCD,KAAKE,IAAK,QAAU,KAAMC,KAAM,OAShFE,EAAqClB,EAAaG,OAAQT,GAAgBS,QAG1EC,SAAWC,EAAEF,OAAQE,EAAEC,MAAON,EAAaO,UAAUH,WACjDI,YAAc,wCAGlBC,WAAa,SAAUC,EAAOC,GAC1BX,EAAaO,UAAUE,WAAWG,KAAMC,KAAMH,EAAOC,GACrDjB,EAAce,WAAWG,KAAMC,KAAMH,EAAOC,IAIhDG,SAAW,WACN,OAAU,sCAAuCD,KAAKE,IAAK,QAAU,KAAMC,KAAM,MAMtF,QACId,6BAAsCA,EACtCe,6BAAsCA,EACtCC,mCAAsCA"}
{"version":3,"file":"hdca-model.js","sources":["../../../src/mvc/history/hdca-model.js"],"names":["define","DC_MODEL","HISTORY_CONTENT","buildHDCASave","_super","attributes","options","this","isNew","url","urlRoot","get","type","call","hcontentMixin","HistoryContentMixin","ListDC","ListDatasetCollection","PairDC","PairDatasetCollection","ListPairedDC","ListPairedDatasetCollection","HistoryListDatasetCollection","extend","defaults","_","clone","prototype","history_content_type","collection_type","model_class","initialize","model","save","toString","join","HistoryPairDatasetCollection","HistoryListPairedDatasetCollection"],"mappings":"AAAAA,QACI,kCACA,oCACA,sBACD,SAAUC,EAAUC,GAiBvB,QAASC,GAAeC,GACpB,MAAO,UAAgBC,EAAYC,GAO/B,MANIC,MAAKC,UACLF,EAAUA,MACVA,EAAQG,IAAMF,KAAKG,QAAUH,KAAKI,IAAK,cAAiB,YACxDN,EAAaA,MACbA,EAAWO,KAAO,sBAEfR,EAAOS,KAAMN,KAAMF,EAAYC,IAf9C,GAAIQ,GAAgBZ,EAAgBa,oBAChCC,EAASf,EAASgB,sBAClBC,EAASjB,EAASkB,sBAClBC,EAAenB,EAASoB,4BAoBxBC,EAA+BN,EAAOO,OAAQT,GAAgBS,QAG9DC,SAAWC,EAAEF,OAAQE,EAAEC,MAAOV,EAAOW,UAAUH,WAC3CI,qBAAsB,qBACtBC,gBAAsB,OACtBC,YAAsB,wCAG1BC,WAAa,SAAUC,EAAO1B,GAC1BU,EAAOW,UAAUI,WAAWlB,KAAMN,KAAMyB,EAAO1B,GAC/CQ,EAAciB,WAAWlB,KAAMN,KAAMyB,EAAO1B,IAIhD2B,KAAO9B,EAAea,EAAOW,UAAUM,MAGvCC,SAAW,WACN,OAAU,gCAAiC3B,KAAKI,IAAK,QAAU,KAAMwB,KAAM,OAShFC,EAA+BlB,EAAOK,OAAQT,GAAgBS,QAG9DC,SAAWC,EAAEF,OAAQE,EAAEC,MAAOR,EAAOS,UAAUH,WAC3CI,qBAAsB,qBACtBC,gBAAsB,SACtBC,YAAsB,wCAG1BC,WAAa,SAAUC,EAAO1B,GAC1BY,EAAOS,UAAUI,WAAWlB,KAAMN,KAAMyB,EAAO1B,GAC/CQ,EAAciB,WAAWlB,KAAMN,KAAMyB,EAAO1B,IAIhD2B,KAAO9B,EAAee,EAAOS,UAAUM,MAGvCC,SAAW,WACN,OAAU,gCAAiC3B,KAAKI,IAAK,QAAU,KAAMwB,KAAM,OAShFE,EAAqCjB,EAAaG,OAAQT,GAAgBS,QAG1EC,SAAWC,EAAEF,OAAQE,EAAEC,MAAON,EAAaO,UAAUH,WACjDI,qBAAsB,qBACtBC,gBAAsB,cACtBC,YAAsB,wCAG1BC,WAAa,SAAUC,EAAO1B,GAC1Bc,EAAaO,UAAUI,WAAWlB,KAAMN,KAAMyB,EAAO1B,GACrDQ,EAAciB,WAAWlB,KAAMN,KAAMyB,EAAO1B,IAIhD2B,KAAO9B,EAAeiB,EAAaO,UAAUM,MAG7CC,SAAW,WACN,OAAU,sCAAuC3B,KAAKI,IAAK,QAAU,KAAMwB,KAAM,MAMtF,QACIb,6BAAsCA,EACtCc,6BAAsCA,EACtCC,mCAAsCA"}
@@ -1 +1 @@
{"version":3,"file":"history-content-model.js","sources":["../../../src/mvc/history/history-content-model.js"],"names":["define","STATES","BASE_MVC","typeIdStr","type","id","join","HistoryContentMixin","defaults","history_id","history_content_type","hid","visible","idAttribute","constructor","attrs","type_id","this","debug","Backbone","Model","apply","arguments","_typeIdStr","get","initialize","on","_createTypeId","set","hidden","isVisible","show_deleted","show_hidden","urlRoot","galaxy_config","root","url","hide","options","save","jQuery","when","unhide","toString","nameAndId","HistoryContent","extend","LoggableMixin"],"mappings":"AAAAA,QACI,qBACA,eACA,sBACD,SAAUC,EAAQC,GAGrB,GAAIC,GAAY,SAAqBC,EAAMC,GACvC,OAASD,EAAMC,GAAKC,KAAM,MAM1BC,GAIAC,UAEIC,WAAsB,KAEtBC,qBAAsB,KAEtBC,IAAsB,KAEtBC,SAAsB,GAQ1BC,YAAc,UAGdC,YAAc,SAAUC,GACpBA,EAAMC,QAAUb,EAAWY,EAAML,qBAAsBK,EAAMV,IAC7DY,KAAKC,MAAO,mCAAoCH,EAAMC,SACtDG,SAASC,MAAMC,MAAOJ,KAAMK,YAIhCC,WAAa,WACT,MAAOpB,GAAWc,KAAKO,IAAK,wBAA0BP,KAAKO,IAAK,QAIpEC,WAAa,WACTR,KAAKS,GAAI,YAAaT,KAAKU,gBAI/BA,cAAgB,WACZV,KAAKW,IAAK,UAAWX,KAAKM,eAK9BM,OAAS,WACL,OAAQZ,KAAKO,IAAK,YAQtBM,UAAY,SAAUC,EAAcC,GAEhC,GAAIF,IAAY,CAShB,OAROC,KACDd,KAAKO,IAAK,aAAeP,KAAKO,IAAK,YACrCM,GAAY,GAETE,GACAf,KAAKO,IAAK,aACbM,GAAY,GAETA,GAOXG,QAASC,cAAcC,KAAO,iBAG9BC,IAAM,WACF,GAAIA,GAAMnB,KAAKgB,QAAUhB,KAAKO,IAAK,cAAiB,aAC7CP,KAAKO,IAAI,wBAA0B,KAAOP,KAAKO,IAAK,KAC3D,OAAOY,IAIXC,KAAO,SAAUC,GACb,MAAKrB,MAAKO,IAAK,WACRP,KAAKsB,MAAQ3B,SAAS,GAAS0B,GADDE,OAAOC,QAIhDC,OAAS,SAAUJ,GACf,MAAIrB,MAAKO,IAAK,WAAsBgB,OAAOC,OACpCxB,KAAKsB,MAAQ3B,SAAS,GAAQ0B,IAKzCK,SAAW,WACP,GAAIC,GAAY3B,KAAKO,IAAK,OAAU,EAIpC,OAHIP,MAAKO,IAAK,UACVoB,EAAY3B,KAAKO,IAAK,OAAU,MAAQP,KAAKO,IAAK,QAAW,KAAOoB,GAEjE,kBAAoBA,EAAY,MAS3CC,EAAiB1B,SAASC,MAAM0B,OAAQ5C,EAAS6C,eAAgBD,OAAQvC,EAIzE,QACIJ,UAAsBA,EACtBI,oBAAsBA,EACtBsC,eAAsBA"}
{"version":3,"file":"history-content-model.js","sources":["../../../src/mvc/history/history-content-model.js"],"names":["define","STATES","BASE_MVC","typeIdStr","type","id","join","HistoryContentMixin","defaults","history_id","history_content_type","hid","visible","idAttribute","constructor","attrs","type_id","this","debug","Backbone","Model","apply","arguments","_typeIdStr","get","initialize","on","_createTypeId","set","isNew","hidden","isVisible","show_deleted","show_hidden","urlRoot","Galaxy","options","root","url","hide","save","jQuery","when","unhide","toString","nameAndId","HistoryContent","extend","LoggableMixin"],"mappings":"AAAAA,QACI,qBACA,eACA,sBACD,SAAUC,EAAQC,GAGrB,GAAIC,GAAY,SAAqBC,EAAMC,GACvC,OAASD,EAAMC,GAAKC,KAAM,MAM1BC,GAIAC,UAEIC,WAAsB,KAEtBC,qBAAsB,KAEtBC,IAAsB,KAEtBC,SAAsB,GAQ1BC,YAAc,UAGdC,YAAc,SAAUC,GACpBA,EAAMC,QAAUb,EAAWY,EAAML,qBAAsBK,EAAMV,IAC7DY,KAAKC,MAAO,mCAAoCH,EAAMC,SACtDG,SAASC,MAAMC,MAAOJ,KAAMK,YAIhCC,WAAa,WACT,MAAOpB,GAAWc,KAAKO,IAAK,wBAA0BP,KAAKO,IAAK,QAIpEC,WAAa,WACTR,KAAKS,GAAI,YAAaT,KAAKU,gBAI/BA,cAAgB,WACZV,KAAKW,IAAK,UAAWX,KAAKM,eAM9BM,MAAQ,WACJ,OAAQZ,KAAKO,IAAK,OAKtBM,OAAS,WACL,OAAQb,KAAKO,IAAK,YAQtBO,UAAY,SAAUC,EAAcC,GAEhC,GAAIF,IAAY,CAShB,OAROC,KACDf,KAAKO,IAAK,aAAeP,KAAKO,IAAK,YACrCO,GAAY,GAETE,GACAhB,KAAKO,IAAK,aACbO,GAAY,GAETA,GAOXG,QAASC,OAAOC,QAAQC,KAAO,iBAG/BC,IAAM,WACF,GAAIA,GAAMrB,KAAKiB,QAAUjB,KAAKO,IAAK,cAAiB,aAC7CP,KAAKO,IAAI,wBAA0B,KAAOP,KAAKO,IAAK,KAC3D,OAAOc,IAIXC,KAAO,SAAUH,GACb,MAAKnB,MAAKO,IAAK,WACRP,KAAKuB,MAAQ5B,SAAS,GAASwB,GADDK,OAAOC,QAIhDC,OAAS,SAAUP,GACf,MAAInB,MAAKO,IAAK,WAAsBiB,OAAOC,OACpCzB,KAAKuB,MAAQ5B,SAAS,GAAQwB,IAKzCQ,SAAW,WACP,GAAIC,GAAY5B,KAAKO,IAAK,OAAU,EAIpC,OAHIP,MAAKO,IAAK,UACVqB,EAAY5B,KAAKO,IAAK,OAAU,MAAQP,KAAKO,IAAK,QAAW,KAAOqB,GAEjE,kBAAoBA,EAAY,MAS3CC,EAAiB3B,SAASC,MAAM2B,OAAQ7C,EAAS8C,eAAgBD,OAAQxC,EAIzE,QACIJ,UAAsBA,EACtBI,oBAAsBA,EACtBuC,eAAsBA"}
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 -1
View File
@@ -1,2 +1,2 @@
define(["mvc/collection/collection-model","mvc/history/history-content-model","utils/localization"],function(a,b){var c=b.HistoryContentMixin,d=a.ListDatasetCollection,e=a.PairDatasetCollection,f=a.ListPairedDatasetCollection,g=d.extend(c).extend({defaults:_.extend(_.clone(d.prototype.defaults),{model_class:"HistoryDatasetCollectionAssociation"}),initialize:function(a,b){d.prototype.initialize.call(this,a,b),c.initialize.call(this,a,b)},toString:function(){return["HistoryListDatasetCollection(",this.get("name"),")"].join("")}}),h=e.extend(c).extend({defaults:_.extend(_.clone(e.prototype.defaults),{model_class:"HistoryDatasetCollectionAssociation"}),initialize:function(a,b){e.prototype.initialize.call(this,a,b),c.initialize.call(this,a,b)},toString:function(){return["HistoryPairDatasetCollection(",this.get("name"),")"].join("")}}),i=f.extend(c).extend({defaults:_.extend(_.clone(f.prototype.defaults),{model_class:"HistoryDatasetCollectionAssociation"}),initialize:function(a,b){f.prototype.initialize.call(this,a,b),c.initialize.call(this,a,b)},toString:function(){return["HistoryListPairedDatasetCollection(",this.get("name"),")"].join("")}});return{HistoryListDatasetCollection:g,HistoryPairDatasetCollection:h,HistoryListPairedDatasetCollection:i}});
define(["mvc/collection/collection-model","mvc/history/history-content-model","utils/localization"],function(a,b){function c(a){return function(b,c){return this.isNew()&&(c=c||{},c.url=this.urlRoot+this.get("history_id")+"/contents",b=b||{},b.type="dataset_collection"),a.call(this,b,c)}}var d=b.HistoryContentMixin,e=a.ListDatasetCollection,f=a.PairDatasetCollection,g=a.ListPairedDatasetCollection,h=e.extend(d).extend({defaults:_.extend(_.clone(e.prototype.defaults),{history_content_type:"dataset_collection",collection_type:"list",model_class:"HistoryDatasetCollectionAssociation"}),initialize:function(a,b){e.prototype.initialize.call(this,a,b),d.initialize.call(this,a,b)},save:c(e.prototype.save),toString:function(){return["HistoryListDatasetCollection(",this.get("name"),")"].join("")}}),i=f.extend(d).extend({defaults:_.extend(_.clone(f.prototype.defaults),{history_content_type:"dataset_collection",collection_type:"paired",model_class:"HistoryDatasetCollectionAssociation"}),initialize:function(a,b){f.prototype.initialize.call(this,a,b),d.initialize.call(this,a,b)},save:c(f.prototype.save),toString:function(){return["HistoryPairDatasetCollection(",this.get("name"),")"].join("")}}),j=g.extend(d).extend({defaults:_.extend(_.clone(g.prototype.defaults),{history_content_type:"dataset_collection",collection_type:"list:paired",model_class:"HistoryDatasetCollectionAssociation"}),initialize:function(a,b){g.prototype.initialize.call(this,a,b),d.initialize.call(this,a,b)},save:c(g.prototype.save),toString:function(){return["HistoryListPairedDatasetCollection(",this.get("name"),")"].join("")}});return{HistoryListDatasetCollection:h,HistoryPairDatasetCollection:i,HistoryListPairedDatasetCollection:j}});
//# sourceMappingURL=../../../maps/mvc/history/hdca-model.js.map
@@ -1,2 +1,2 @@
define(["mvc/dataset/states","mvc/base-mvc","utils/localization"],function(a,b){var c=function(a,b){return[a,b].join("-")},d={defaults:{history_id:null,history_content_type:null,hid:null,visible:!0},idAttribute:"type_id",constructor:function(a){a.type_id=c(a.history_content_type,a.id),this.debug("HistoryContentMixin.constructor:",a.type_id),Backbone.Model.apply(this,arguments)},_typeIdStr:function(){return c(this.get("history_content_type"),this.get("id"))},initialize:function(){this.on("change:id",this._createTypeId)},_createTypeId:function(){this.set("type_id",this._typeIdStr())},hidden:function(){return!this.get("visible")},isVisible:function(a,b){var c=!0;return a||!this.get("deleted")&&!this.get("purged")||(c=!1),b||this.get("visible")||(c=!1),c},urlRoot:galaxy_config.root+"api/histories/",url:function(){var a=this.urlRoot+this.get("history_id")+"/contents/"+this.get("history_content_type")+"s/"+this.get("id");return a},hide:function(a){return this.get("visible")?this.save({visible:!1},a):jQuery.when()},unhide:function(a){return this.get("visible")?jQuery.when():this.save({visible:!0},a)},toString:function(){var a=this.get("id")||"";return this.get("name")&&(a=this.get("hid")+' :"'+this.get("name")+'",'+a),"HistoryContent("+a+")"}},e=Backbone.Model.extend(b.LoggableMixin).extend(d);return{typeIdStr:c,HistoryContentMixin:d,HistoryContent:e}});
define(["mvc/dataset/states","mvc/base-mvc","utils/localization"],function(a,b){var c=function(a,b){return[a,b].join("-")},d={defaults:{history_id:null,history_content_type:null,hid:null,visible:!0},idAttribute:"type_id",constructor:function(a){a.type_id=c(a.history_content_type,a.id),this.debug("HistoryContentMixin.constructor:",a.type_id),Backbone.Model.apply(this,arguments)},_typeIdStr:function(){return c(this.get("history_content_type"),this.get("id"))},initialize:function(){this.on("change:id",this._createTypeId)},_createTypeId:function(){this.set("type_id",this._typeIdStr())},isNew:function(){return!this.get("id")},hidden:function(){return!this.get("visible")},isVisible:function(a,b){var c=!0;return a||!this.get("deleted")&&!this.get("purged")||(c=!1),b||this.get("visible")||(c=!1),c},urlRoot:Galaxy.options.root+"api/histories/",url:function(){var a=this.urlRoot+this.get("history_id")+"/contents/"+this.get("history_content_type")+"s/"+this.get("id");return a},hide:function(a){return this.get("visible")?this.save({visible:!1},a):jQuery.when()},unhide:function(a){return this.get("visible")?jQuery.when():this.save({visible:!0},a)},toString:function(){var a=this.get("id")||"";return this.get("name")&&(a=this.get("hid")+' :"'+this.get("name")+'",'+a),"HistoryContent("+a+")"}},e=Backbone.Model.extend(b.LoggableMixin).extend(d);return{typeIdStr:c,HistoryContentMixin:d,HistoryContent:e}});
//# sourceMappingURL=../../../maps/mvc/history/history-content-model.js.map
@@ -1,2 +1,2 @@
define(["mvc/history/history-content-model","mvc/history/hda-model","mvc/history/hdca-model","mvc/base-mvc","utils/localization"],function(a,b,c,d){var e=Backbone.Collection.extend(d.LoggableMixin).extend({model:function(a,d){if("dataset"===a.history_content_type)return new b.HistoryDatasetAssociation(a,d);if("dataset_collection"===a.history_content_type){switch(a.collection_type){case"list":return new c.HistoryListDatasetCollection(a,d);case"paired":return new c.HistoryPairDatasetCollection(a,d);case"list:paired":return new c.HistoryListPairedDatasetCollection(a,d)}throw new TypeError("Unknown collection_type: "+a.collection_type)}throw new TypeError("Unknown history_content_type: "+a.history_content_type)},initialize:function(a,b){b=b||{},this.historyId=b.historyId,this.model.prototype.idAttribute="type_id",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(a){return a.get("id")})},notReady:function(){return this.filter(function(a){return!a.inReadyState()})},running:function(){var a=[];return this.each(function(b){var c=!b.inReadyState();c&&a.push(b.get("id"))}),a},getByHid:function(a){return _.first(this.filter(function(b){return b.get("hid")===a}))},getVisible:function(a,b,c){c=c||[],this.debug("checking isVisible");var d=new e(this.filter(function(c){return c.isVisible(a,b)}));return _.each(c,function(a){_.isFunction(a)&&(d=new e(d.filter(a)))}),d},haveDetails:function(){return this.all(function(a){return a.hasDetails()})},fetchAllDetails:function(a){a=a||{};var b={details:"all"};return a.data=a.data?_.extend(a.data,b):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},matches:function(a){return this.filter(function(b){return b.matches(a)})},set:function(b,c){_.each(b,function(b){b.type_id&&b.get("type_id")||(b.type_id=a.typeIdStr(b.history_content_type,b.id))}),Backbone.Collection.prototype.set.call(this,b,c)},promoteToHistoryDatasetCollection:function(a,b,c){c=c||{},c.url=this.url(),c.type="POST";var d=b,e=[],f=null;if("list"===b)this.chain().each(function(a){var b=a.attributes.name,c=a.get("id"),f=a.attributes.history_content_type;"dataset"===f?("list"!==d&&this.log("Invalid collection type"),e.push({name:b,src:"hda",id:c})):("list"===d?d="list:"+a.attributes.collection_type:d!=="list:"+a.attributes.collection_type&&this.log("Invalid collection type"),e.push({name:b,src:"hdca",id:c}))}),f="New Dataset List";else if("paired"===b){var g=this.ids();2!==g.length,e.push({name:"forward",src:"hda",id:g[0]}),e.push({name:"reverse",src:"hda",id:g[1]}),f="New Dataset Pair"}c.data={type:"dataset_collection",name:f,collection_type:d,element_identifiers:JSON.stringify(e)};var h=jQuery.ajax(c);return h.done(function(){a.refresh()}),h.fail(function(a){error=a.responseJSON&&a.responseJSON.error?a.responseJSON.error:a.responseJSON,a.responseText=error}),h},clone:function(){var a=Backbone.Collection.prototype.clone.call(this);return a.historyId=this.historyId,a},print:function(){var a=this;a.each(function(b){a.debug(b),b.elements&&a.debug(" elements:",b.elements)})},toString:function(){return["HistoryContents(",[this.historyId,this.length].join(),")"].join("")}});return{HistoryContents:e}});
define(["mvc/history/history-content-model","mvc/history/hda-model","mvc/history/hdca-model","mvc/base-mvc","utils/localization"],function(a,b,c,d){var e=Backbone.Collection.extend(d.LoggableMixin).extend({model:function(a,d){if("dataset"===a.history_content_type)return new b.HistoryDatasetAssociation(a,d);if("dataset_collection"===a.history_content_type){switch(a.collection_type){case"list":return new c.HistoryListDatasetCollection(a,d);case"paired":return new c.HistoryPairDatasetCollection(a,d);case"list:paired":return new c.HistoryListPairedDatasetCollection(a,d)}throw new TypeError("Unknown collection_type: "+a.collection_type)}throw new TypeError("Unknown history_content_type: "+a.history_content_type)},initialize:function(a,b){b=b||{},this.historyId=b.historyId,this.model.prototype.idAttribute="type_id",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(a){return a.get("id")})},notReady:function(){return this.filter(function(a){return!a.inReadyState()})},running:function(){var a=[];return this.each(function(b){var c=!b.inReadyState();c&&a.push(b.get("id"))}),a},getByHid:function(a){return _.first(this.filter(function(b){return b.get("hid")===a}))},getVisible:function(a,b,c){c=c||[],this.debug("checking isVisible");var d=new e(this.filter(function(c){return c.isVisible(a,b)}));return _.each(c,function(a){_.isFunction(a)&&(d=new e(d.filter(a)))}),d},haveDetails:function(){return this.all(function(a){return a.hasDetails()})},fetchAllDetails:function(a){a=a||{};var b={details:"all"};return a.data=a.data?_.extend(a.data,b):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},matches:function(a){return this.filter(function(b){return b.matches(a)})},set:function(b,c){_.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)},createHDCA:function(a,b,d){var e=this,f={list:c.HistoryListDatasetCollection,paired:c.HistoryPairDatasetCollection},g=new f[b]({history_id:this.historyId,name:d,element_identifiers:a});return g.save().done(function(){e.add(g)}).fail(function(a,b,c){e.trigger("error",a,b,c)})},clone:function(){var a=Backbone.Collection.prototype.clone.call(this);return a.historyId=this.historyId,a},print:function(){var a=this;a.each(function(b){a.debug(b),b.elements&&a.debug(" elements:",b.elements)})},toString:function(){return["HistoryContents(",[this.historyId,this.length].join(),")"].join("")}});return{HistoryContents:e}});
//# 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