mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Originating workflow must be unchanged, load save as workflow to editor on save.
This commit is contained in:
@@ -413,21 +413,30 @@ EditorFormView = Backbone.View.extend({
|
||||
"Close": close_editor
|
||||
});
|
||||
|
||||
/******************************************** Issue 3000*/
|
||||
function workflow_save_as() {
|
||||
var body = $('<lable>Save as name: <input type="text" id="workflow_rename"></label>');
|
||||
var body = $('<form><label style="display:inline-block; width: 100%;">Save as name: </label><input type="text" id="workflow_rename" style="width: 80%;" autofocus/>' +
|
||||
'<br><label style="display:inline-block; width: 100%;">Annotation: </label><input type="text" id="wf_annotation" style="width: 80%;" /></form>');
|
||||
window.show_modal("Save As a New Workflow", body, {
|
||||
"OK": function () {
|
||||
self.rename_name = $('#workflow_rename').val();
|
||||
save_current_workflow(null, function() {
|
||||
var rename_name = $('#workflow_rename').val().length > 0 ? $('#workflow_rename').val() : "SavedAs_" + self.workflow.name;
|
||||
var rename_annotation = $('#wf_annotation').val().length > 0 ? $('#wf_annotation').val() : "";
|
||||
$.ajax({
|
||||
url: self.urls.workflow_save_as + "&save_as_name=" + self.rename_name,
|
||||
type: "GET",
|
||||
}).done(function(){
|
||||
window.location.href = self.urls.workflow_index;
|
||||
url: self.urls.workflow_save_as,
|
||||
type: "POST",
|
||||
data: {
|
||||
workflow_name: rename_name,
|
||||
workflow_annotation: rename_annotation,
|
||||
workflow_data: function() { return JSON.stringify( self.workflow.to_simple() ); }
|
||||
}
|
||||
}).done(function(id){
|
||||
window.onbeforeunload = undefined;
|
||||
window.location = "/workflow/editor?id=" + id;
|
||||
hide_modal();
|
||||
}).fail(function(){
|
||||
hide_modal();
|
||||
alert("Saving this workflow failed. Please contact this site's administrator.");
|
||||
})});
|
||||
hide_modal();
|
||||
});
|
||||
},
|
||||
"Cancel": hide_modal
|
||||
});
|
||||
|
||||
@@ -595,6 +595,50 @@ class WorkflowController( BaseUIController, SharableMixin, UsesStoredWorkflowMix
|
||||
value="",
|
||||
help="A description of the workflow; annotation is shown alongside shared or published workflows." )
|
||||
|
||||
@web.json
|
||||
def save_workflow_as(self, trans, workflow_name, workflow_data, workflow_annotation=""):
|
||||
"""
|
||||
Creates a new workflow based on Save As command. It is a new workflow, but
|
||||
is created with workflow_data already present.
|
||||
"""
|
||||
user = trans.get_user()
|
||||
if workflow_name is not None:
|
||||
workflow_contents_manager = workflows.WorkflowContentsManager(trans.app)
|
||||
stored_workflow = model.StoredWorkflow()
|
||||
stored_workflow.name = workflow_name
|
||||
stored_workflow.user = user
|
||||
self.create_item_slug(trans.sa_session, stored_workflow)
|
||||
workflow = model.Workflow()
|
||||
workflow.name = workflow_name
|
||||
workflow.stored_workflow = stored_workflow
|
||||
stored_workflow.latest_workflow = workflow
|
||||
# Add annotation.
|
||||
workflow_annotation = sanitize_html( workflow_annotation, 'utf-8', 'text/html' )
|
||||
self.add_item_annotation( trans.sa_session, trans.get_user(), stored_workflow, workflow_annotation )
|
||||
|
||||
# Persist
|
||||
session = trans.sa_session
|
||||
session.add( stored_workflow )
|
||||
session.flush()
|
||||
|
||||
try:
|
||||
workflow, errors = workflow_contents_manager.update_workflow_from_dict(
|
||||
trans,
|
||||
stored_workflow,
|
||||
workflow_data,
|
||||
)
|
||||
except workflows.MissingToolsException as e:
|
||||
return dict(
|
||||
name=e.workflow.name,
|
||||
message="This workflow includes missing or invalid tools. "
|
||||
"It cannot be saved until the following steps are removed or the missing tools are enabled.",
|
||||
errors=e.errors,
|
||||
)
|
||||
return (trans.security.encode_id(stored_workflow.id))
|
||||
else:
|
||||
#This is an error state, 'save as' must have a workflow_name
|
||||
log.exception("Error in Save As workflow: no name.")
|
||||
|
||||
@web.expose
|
||||
def delete( self, trans, id=None ):
|
||||
"""
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -16,7 +16,7 @@
|
||||
'get_new_module_info' : h.url_for(controller='workflow', action='get_new_module_info' ),
|
||||
'workflow_index' : h.url_for( controller='workflow', action='index' ),
|
||||
'save_workflow' : h.url_for(controller='workflow', action='save_workflow' ),
|
||||
'workflow_save_as' : h.url_for(controller='workflow', action='copy', id=trans.security.encode_id(stored.id))
|
||||
'workflow_save_as' : h.url_for(controller='workflow', action='save_workflow_as')
|
||||
},
|
||||
'workflows' : [{
|
||||
'id' : trans.security.encode_id( workflow.id ),
|
||||
|
||||
Reference in New Issue
Block a user