API, histories: correct copy to copy both non-deleted and deleted contents by default, add all_datasets flag to support copying only non-deleted; UI, histories: separate out history copy dialog for use in multi-panel (and later: the options menu), include deleted filter in choices

This commit is contained in:
Carl Eberhard
2015-09-17 14:41:07 -04:00
parent 7c78e01b7d
commit e71826889f
7 changed files with 16 additions and 77 deletions
@@ -1,3 +1,4 @@
define([
"mvc/history/history-contents",
"utils/utils",
@@ -243,7 +244,7 @@ var History = Backbone.Model.extend( BASE_MVC.LoggableMixin ).extend(
* @fires copied passed this history and the response JSON from the copy
* @returns {xhr}
*/
copy : function( current, name ){
copy : function( current, name, allDatasets ){
current = ( current !== undefined )?( current ):( true );
if( !this.id ){
throw new Error( 'You must set the history ID before copying it.' );
@@ -256,8 +257,9 @@ var History = Backbone.Model.extend( BASE_MVC.LoggableMixin ).extend(
if( name ){
postData.name = name;
}
//TODO:?? all datasets?
if( !allDatasets ){
postData.all_datasets = false;
}
var history = this,
copy = jQuery.post( this.urlRoot, postData );
@@ -1,79 +1,12 @@
define([
"mvc/history/history-model",
"mvc/history/history-panel-edit",
"mvc/history/copy-dialog",
"mvc/base-mvc",
"utils/ajax-queue",
"ui/mode-button",
"ui/search-input"
], function( HISTORY_MODEL, HPANEL_EDIT, baseMVC, ajaxQueue ){
//==============================================================================
/** */
function historyCopyDialog( history, options ){
options = options || {};
// fall back to un-notifying copy
if( !( Galaxy && Galaxy.modal ) ){
return history.copy();
}
// maybe better as multiselect dialog?
var historyName = history.get( 'name' ),
defaultCopyName = "Copy of '" + historyName + "'";
function validateName( name ){
if( !name ){
if( !Galaxy.modal.$( '#invalid-title' ).size() ){
var $invalidTitle = $( '<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( $invalidTitle );
}
return false;
}
return name;
}
function copyHistory( name ){
var $copyIndicator = $( '<p><span class="fa fa-spinner fa-spin"></span> Copying history...</p>' )
.css( 'margin-top', '8px' );
Galaxy.modal.$( '.modal-body' ).append( $copyIndicator );
history.copy( true, name )
//TODO: make this unneccessary with pub-sub error
.fail( function(){
alert( _l( 'History could not be copied. Please contact a Galaxy administrator' ) );
})
.always( function(){
Galaxy.modal.hide();
});
}
function checkNameAndCopy(){
var name = Galaxy.modal.$( '#copy-modal-title' ).val();
if( !validateName( name ) ){ return; }
copyHistory( name );
}
Galaxy.modal.show( _.extend({
title : _l( 'Copying history' ) + ' "' + historyName + '"',
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="',
defaultCopyName, '" />'
].join('')),
buttons : {
'Cancel' : function(){ Galaxy.modal.hide(); },
'Copy' : checkNameAndCopy
}
}, options ));
$( '#copy-modal-title' ).focus().select();
$( '#copy-modal-title' ).on( 'keydown', function( ev ){
if( ev.keyCode === 13 ){
checkNameAndCopy();
}
});
}
], function( HISTORY_MODEL, HPANEL_EDIT, historyCopyDialog, baseMVC, ajaxQueue ){
/* ==============================================================================
TODO:
rendering/delayed rendering is a mess
+5 -1
View File
@@ -22,6 +22,7 @@ from galaxy.web.base.controller import ImportsHistoryMixin
from galaxy.managers import histories, citations, users
from galaxy import util
from galaxy.util import string_as_bool
from galaxy.util import restore_text
from galaxy.web import url_for
@@ -286,6 +287,7 @@ class HistoriesController( BaseAPIController, ExportsHistoryMixin, ImportsHistor
:param payload: (optional) dictionary structure containing:
* name: the new history's name
* history_id: the id of the history to copy
* all_datasets: copy deleted hdas/hdcas? 'True' or 'False', defaults to True
* archive_source: the url that will generate the archive to import
* archive_type: 'url' (default)
@@ -300,6 +302,8 @@ class HistoriesController( BaseAPIController, ExportsHistoryMixin, ImportsHistor
hist_name = restore_text( payload['name'] )
copy_this_history_id = payload.get( 'history_id', None )
all_datasets = util.string_as_bool( payload.get( 'all_datasets', True ) )
if "archive_source" in payload:
archive_source = payload[ "archive_source" ]
archive_type = payload.get( "archive_type", "url" )
@@ -312,7 +316,7 @@ class HistoriesController( BaseAPIController, ExportsHistoryMixin, ImportsHistor
decoded_id = self.decode_id( copy_this_history_id )
original_history = self.history_manager.get_accessible( decoded_id, trans.user, current_history=trans.history )
hist_name = hist_name or ( "Copy of '%s'" % original_history.name )
new_history = original_history.copy( name=hist_name, target_user=trans.user )
new_history = original_history.copy( name=hist_name, target_user=trans.user, all_datasets=all_datasets )
# otherwise, create a new empty history
else:
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