UI, History: use copy dialog in the embedded histories in Pages, add autoClose option to copy dialog

This commit is contained in:
carlfeberhard
2015-12-11 08:44:45 -05:00
parent d72b913c1d
commit 9e512f5246
11 changed files with 63 additions and 88 deletions
@@ -79,10 +79,12 @@ var CopyDialog = {
defaultCopyName = defaultCopyNameFn({ name: history.get( 'name' ) }),
// TODO: these two might be simpler as one 3 state option (all,active,no-choice)
defaultCopyWhat = options.allDatasets? 'copy-all' : 'copy-non-deleted',
allowAll = !_.isUndefined( options.allowAll )? options.allowAll : true;
allowAll = !_.isUndefined( options.allowAll )? options.allowAll : true,
autoClose = !_.isUndefined( options.autoClose )? options.autoClose : true;
this.modal = modal;
// validate the name and copy if good
function checkNameAndCopy(){
var name = modal.$( '#copy-modal-title' ).val();
@@ -104,7 +106,7 @@ var CopyDialog = {
deferred.rejectWith( deferred, arguments );
})
.always( function(){
modal.hide();
if( autoClose ){ modal.hide(); }
});
}
+1 -4
View File
@@ -1203,6 +1203,7 @@ class History( object, Dictifiable, UsesAnnotations, HasName ):
# Create new history.
if not name:
name = self.name
# wut. If it's an anon user, the target user becomes the original owner??
if not target_user:
target_user = self.user
quota = True
@@ -1213,10 +1214,6 @@ class History( object, Dictifiable, UsesAnnotations, HasName ):
db_session.add( new_history )
db_session.flush()
print '-' * 40
print 'target_user:', target_user, target_user.username, target_user.email
print '-' * 40
# copy history tags and annotations (if copying user is not anonymous)
if target_user:
self.copy_item_annotation( db_session, self.user, self, target_user, new_history )
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"copy-dialog.js","sources":["../../../src/mvc/history/copy-dialog.js"],"names":["define","MODAL","_l","CopyDialog","defaultName","_","template","title","submitLabel","errorMessage","progressive","activeLabel","allLabel","anonWarning","_template","join","_showAjaxIndicator","indicator","this","modal","$","empty","append","css","margin-top","dialog","history","options","checkNameAndCopy","name","val","show","copyAllDatasets","prop","copy","done","response","deferred","resolve","fail","alert","rejectWith","arguments","always","hide","jQuery","Deferred","defaultCopyNameFn","nameFn","defaultCopyName","get","defaultCopyWhat","allDatasets","allowAll","isUndefined","originalClosingCallback","closing_callback","extend","body","isAnon","Galaxy","user","isAnonymous","copyWhat","buttons","object","height","closing_events","cancelled","reject","focus","select","on","ev","keyCode","preventDefault","ImportDialog","historyCopyDialog","window","parent","View","useImport"],"mappings":"AAAAA,QACI,kBACA,sBACD,SAAUC,EAAOC,GAEpB,YAOA,IAAIC,IAGAC,YAAkBC,EAAEC,SAAU,yBAC9BC,MAAkBF,EAAEC,SAAUJ,EAAI,mBAAsB,kBACxDM,YAAkBN,EAAI,QACtBO,aAAkBP,EAAI,+BACtBQ,YAAkBR,EAAI,mBACtBS,YAAkBT,EAAI,8CACtBU,SAAkBV,EAAI,4CACtBW,YAAkBX,EAAI,2FACJA,EAAI,gCAGtBY,UAAYT,EAAEC,UAGV,sBACI,+BACI,qBACAJ,EAAI,WACJ,0BAA2BA,EAAI,cAAgB,QAASA,EAAI,MAAQ,IACpE,2BAA4BA,EAAI,iBAAmB,QACvD,SACJ,UACA,SACI,iCACIA,EAAI,qCAAuC,IAC/C,iBAGA,+FACA,iGACIA,EAAI,sCACR,OAEA,wBACI,SACA,MAAOA,EAAI,+DAAiE,OAE5E,uFACI,uEACJ,4DACA,SACA,uEACI,+DACJ,iDACJ,UACJ,WACFa,KAAM,KAGRC,mBAAqB,WACjB,GAAIC,GAAY,kDAAoDC,KAAKR,YAAc,SACvFQ,MAAKC,MAAMC,EAAG,eAAgBC,QAAQC,OAAQL,GAAYM,KAAMC,aAAc,SAKlFC,OAAS,SAAkBN,EAAOO,EAASC,GAevC,QAASC,KACL,GAAIC,GAAOV,EAAMC,EAAG,qBAAsBU,KAC1C,KAAKD,EAED,WADAV,GAAMC,EAAG,kBAAmBW,MAIhC,IAAIC,GAAyE,aAAvDb,EAAMC,EAAG,mCAAoCU,KACnEX,GAAMC,EAAG,UAAWa,KAAM,YAAY,GACtCR,EAAOT,qBACPU,EAAQQ,MAAM,EAAML,EAAMG,GACrBG,KAAM,SAAUC,GAC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CACtBQ,YAAkBR,EAAI,qBACtBS,YAAkBT,EAAI,gDACtBU,SAAkBV,EAAI,8CACtBW,YAAkBX,EAAI,2FACJA,EAAI,oCAoBtB2E,EAAoB,SAAUnD,EAASC,GACvCA,EAAUA,KAEV,IAAIR,GAAQ2D,OAAOC,OAAOnB,OAAOzC,OAAS,GAAIlB,GAAM+E,QACpD,OAAOrD,GAAQsD,UACXL,EAAanD,OAAQN,EAAOO,EAASC,GACrCxB,EAAWsB,OAAQN,EAAOO,EAASC,GAKvC,OAAOkD"}
{"version":3,"file":"copy-dialog.js","sources":["../../../src/mvc/history/copy-dialog.js"],"names":["define","MODAL","_l","CopyDialog","defaultName","_","template","title","submitLabel","errorMessage","progressive","activeLabel","allLabel","anonWarning","_template","join","_showAjaxIndicator","indicator","this","modal","$","empty","append","css","margin-top","dialog","history","options","checkNameAndCopy","name","val","show","copyAllDatasets","prop","copy","done","response","deferred","resolve","fail","alert","rejectWith","arguments","always","autoClose","hide","jQuery","Deferred","defaultCopyNameFn","nameFn","defaultCopyName","get","defaultCopyWhat","allDatasets","allowAll","isUndefined","originalClosingCallback","closing_callback","extend","body","isAnon","Galaxy","user","isAnonymous","copyWhat","buttons","object","height","closing_events","cancelled","reject","focus","select","on","ev","keyCode","preventDefault","ImportDialog","historyCopyDialog","window","parent","View","useImport"],"mappings":"AAAAA,QACI,kBACA,sBACD,SAAUC,EAAOC,GAEpB,YAOA,IAAIC,IAGAC,YAAkBC,EAAEC,SAAU,yBAC9BC,MAAkBF,EAAEC,SAAUJ,EAAI,mBAAsB,kBACxDM,YAAkBN,EAAI,QACtBO,aAAkBP,EAAI,+BACtBQ,YAAkBR,EAAI,mBACtBS,YAAkBT,EAAI,8CACtBU,SAAkBV,EAAI,4CACtBW,YAAkBX,EAAI,2FACJA,EAAI,gCAGtBY,UAAYT,EAAEC,UAGV,sBACI,+BACI,qBACAJ,EAAI,WACJ,0BAA2BA,EAAI,cAAgB,QAASA,EAAI,MAAQ,IACpE,2BAA4B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MAAUW,KAAKX,OAAQsB,KAAMH,EAAQyB,IAAK,UAC1CQ,KAAUvC,EAAGK,EAAOX,WACZe,KAAcqB,EACdU,OAAcC,OAAOC,KAAKC,cAC1BT,SAAcA,EACdU,SAAcZ,EACdzC,YAAcO,KAAKP,YACnBC,SAAcM,KAAKN,SACnBC,YAAcK,KAAKL,eAE3BoD,QAAU5D,EAAE6D,SACFhE,EAAI,UAAc,WAAYiB,EAAM0B,UACpC3B,KAAKV,YAAaoB,KAE5BuC,OAAkB,OAClBC,gBAAkB,EAClBX,iBAAkB,SAA4BY,GAClCA,GACAhC,EAASiC,QAASD,WAAY,IAE9Bb,GACAA,EAAyBa,OAMzClD,EAAMC,EAAG,qBAAsBmD,QAAQC,SACvCrD,EAAMC,EAAG,qBAAsBqD,GAAI,UAAW,SAAUC,GACjC,KAAfA,EAAGC,UACHD,EAAGE,iBACHhD,OAIDS,IASXwC,EAAexE,EAAEqD,UAAYvD,GAC7BC,YAAkBC,EAAEC,SAAU,yBAC9BC,MAAkBF,EAAEC,SAAUJ,EAAI,qBAAwB,kBAC1DM,YAAkBN,EAAI,UACtBO,aAAkBP,EAAI,iCACtBQ,YAAkBR,EAAI,qBACtBS,YAAkBT,EAAI,gDACtBU,SAAkBV,EAAI,8CACtBW,YAAkBX,EAAI,2FACJA,EAAI,oCAoBtB4E,EAAoB,SAAUpD,EAASC,GACvCA,EAAUA,KAEV,IAAIR,GAAQ4D,OAAOC,OAAOnB,OAAO1C,OAAS,GAAIlB,GAAMgF,QACpD,OAAOtD,GAAQuD,UACXL,EAAapD,OAAQN,EAAOO,EAASC,GACrCxB,EAAWsB,OAAQN,EAAOO,EAASC,GAKvC,OAAOmD"}
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 -1
View File
@@ -1,2 +1,2 @@
define(["mvc/ui/ui-modal","utils/localization"],function(a,b){"use strict";var c={defaultName:_.template("Copy of '<%- name %>'"),title:_.template(b("Copying history")+' "<%- name %>"'),submitLabel:b("Copy"),errorMessage:b("History could not be copied"),progressive:b("Copying history"),activeLabel:b("Copy only the active, non-deleted datasets"),allLabel:b("Copy all datasets including deleted ones"),anonWarning:b("As an anonymous user, unless you login or register, you will lose your current history ")+b("after copying this history. "),_template:_.template(["<% if( isAnon ){ %>",'<div class="warningmessage">',"<%- anonWarning %>",b("You can"),' <a href="/user/login">',b("login here"),"</a> ",b("or")," ",' <a href="/user/create">',b("register here"),"</a>.","</div>","<% } %>","<form>",'<label for="copy-modal-title">',b("Enter a title for the new history"),":","</label><br />",'<input id="copy-modal-title" class="form-control" style="width: 100%" value="<%= name %>" />','<p class="invalid-title bg-danger" style="color: red; margin: 8px 0px 8px 0px; display: none">',b("Please enter a valid history title"),"</p>","<% if( allowAll ){ %>","<br />","<p>",b("Choose which datasets from the original history to include:"),"</p>",'<input name="copy-what" type="radio" id="copy-non-deleted" value="copy-non-deleted" ','<% if( copyWhat === "copy-non-deleted" ){ print( "checked" ); } %>/>','<label for="copy-non-deleted"> <%- activeLabel %></label>',"<br />",'<input name="copy-what" type="radio" id="copy-all" value="copy-all" ','<% if( copyWhat === "copy-all" ){ print( "checked" ); } %>/>','<label for="copy-all"> <%- allLabel %></label>',"<% } %>","</form>"].join("")),_showAjaxIndicator:function(){var a='<p><span class="fa fa-spinner fa-spin"></span> '+this.progressive+"...</p>";this.modal.$(".modal-body").empty().append(a).css({"margin-top":"8px"})},dialog:function(a,c,d){function e(){var d=a.$("#copy-modal-title").val();if(!d)return void a.$(".invalid-title").show();var e="copy-all"===a.$('input[name="copy-what"]:checked').val();a.$("button").prop("disabled",!0),f._showAjaxIndicator(),c.copy(!0,d,e).done(function(a){g.resolve(a)}).fail(function(){alert([this.errorMessage,b("Please contact a Galaxy administrator")].join(". ")),g.rejectWith(g,arguments)}).always(function(){a.hide()})}d=d||{};var f=this,g=jQuery.Deferred(),h=d.nameFn||this.defaultName,i=h({name:c.get("name")}),j=d.allDatasets?"copy-all":"copy-non-deleted",k=_.isUndefined(d.allowAll)?!0:d.allowAll;this.modal=a;var l=d.closing_callback;return a.show(_.extend(d,{title:this.title({name:c.get("name")}),body:$(f._template({name:i,isAnon:Galaxy.user.isAnonymous(),allowAll:k,copyWhat:j,activeLabel:this.activeLabel,allLabel:this.allLabel,anonWarning:this.anonWarning})),buttons:_.object([[b("Cancel"),function(){a.hide()}],[this.submitLabel,e]]),height:"auto",closing_events:!0,closing_callback:function(a){a&&g.reject({cancelled:!0}),l&&l(a)}})),a.$("#copy-modal-title").focus().select(),a.$("#copy-modal-title").on("keydown",function(a){13===a.keyCode&&(a.preventDefault(),e())}),g}},d=_.extend({},c,{defaultName:_.template("imported: <%- name %>"),title:_.template(b("Importing history")+' "<%- name %>"'),submitLabel:b("Import"),errorMessage:b("History could not be imported"),progressive:b("Importing history"),activeLabel:b("Import only the active, non-deleted datasets"),allLabel:b("Import all datasets including deleted ones"),anonWarning:b("As an anonymous user, unless you login or register, you will lose your current history ")+b("after importing this history. ")}),e=function(b,e){e=e||{};var f=window.parent.Galaxy.modal||new a.View({});return e.useImport?d.dialog(f,b,e):c.dialog(f,b,e)};return e});
define(["mvc/ui/ui-modal","utils/localization"],function(a,b){"use strict";var c={defaultName:_.template("Copy of '<%- name %>'"),title:_.template(b("Copying history")+' "<%- name %>"'),submitLabel:b("Copy"),errorMessage:b("History could not be copied"),progressive:b("Copying history"),activeLabel:b("Copy only the active, non-deleted datasets"),allLabel:b("Copy all datasets including deleted ones"),anonWarning:b("As an anonymous user, unless you login or register, you will lose your current history ")+b("after copying this history. "),_template:_.template(["<% if( isAnon ){ %>",'<div class="warningmessage">',"<%- anonWarning %>",b("You can"),' <a href="/user/login">',b("login here"),"</a> ",b("or")," ",' <a href="/user/create">',b("register here"),"</a>.","</div>","<% } %>","<form>",'<label for="copy-modal-title">',b("Enter a title for the new history"),":","</label><br />",'<input id="copy-modal-title" class="form-control" style="width: 100%" value="<%= name %>" />','<p class="invalid-title bg-danger" style="color: red; margin: 8px 0px 8px 0px; display: none">',b("Please enter a valid history title"),"</p>","<% if( allowAll ){ %>","<br />","<p>",b("Choose which datasets from the original history to include:"),"</p>",'<input name="copy-what" type="radio" id="copy-non-deleted" value="copy-non-deleted" ','<% if( copyWhat === "copy-non-deleted" ){ print( "checked" ); } %>/>','<label for="copy-non-deleted"> <%- activeLabel %></label>',"<br />",'<input name="copy-what" type="radio" id="copy-all" value="copy-all" ','<% if( copyWhat === "copy-all" ){ print( "checked" ); } %>/>','<label for="copy-all"> <%- allLabel %></label>',"<% } %>","</form>"].join("")),_showAjaxIndicator:function(){var a='<p><span class="fa fa-spinner fa-spin"></span> '+this.progressive+"...</p>";this.modal.$(".modal-body").empty().append(a).css({"margin-top":"8px"})},dialog:function(a,c,d){function e(){var d=a.$("#copy-modal-title").val();if(!d)return void a.$(".invalid-title").show();var e="copy-all"===a.$('input[name="copy-what"]:checked').val();a.$("button").prop("disabled",!0),f._showAjaxIndicator(),c.copy(!0,d,e).done(function(a){g.resolve(a)}).fail(function(){alert([this.errorMessage,b("Please contact a Galaxy administrator")].join(". ")),g.rejectWith(g,arguments)}).always(function(){l&&a.hide()})}d=d||{};var f=this,g=jQuery.Deferred(),h=d.nameFn||this.defaultName,i=h({name:c.get("name")}),j=d.allDatasets?"copy-all":"copy-non-deleted",k=_.isUndefined(d.allowAll)?!0:d.allowAll,l=_.isUndefined(d.autoClose)?!0:d.autoClose;this.modal=a;var m=d.closing_callback;return a.show(_.extend(d,{title:this.title({name:c.get("name")}),body:$(f._template({name:i,isAnon:Galaxy.user.isAnonymous(),allowAll:k,copyWhat:j,activeLabel:this.activeLabel,allLabel:this.allLabel,anonWarning:this.anonWarning})),buttons:_.object([[b("Cancel"),function(){a.hide()}],[this.submitLabel,e]]),height:"auto",closing_events:!0,closing_callback:function(a){a&&g.reject({cancelled:!0}),m&&m(a)}})),a.$("#copy-modal-title").focus().select(),a.$("#copy-modal-title").on("keydown",function(a){13===a.keyCode&&(a.preventDefault(),e())}),g}},d=_.extend({},c,{defaultName:_.template("imported: <%- name %>"),title:_.template(b("Importing history")+' "<%- name %>"'),submitLabel:b("Import"),errorMessage:b("History could not be imported"),progressive:b("Importing history"),activeLabel:b("Import only the active, non-deleted datasets"),allLabel:b("Import all datasets including deleted ones"),anonWarning:b("As an anonymous user, unless you login or register, you will lose your current history ")+b("after importing this history. ")}),e=function(b,e){e=e||{};var f=window.parent.Galaxy.modal||new a.View({});return e.useImport?d.dialog(f,b,e):c.dialog(f,b,e)};return e});
//# sourceMappingURL=../../../maps/mvc/history/copy-dialog.js.map
+1 -1
View File
@@ -1,2 +1,2 @@
define(["utils/utils","utils/deferred","mvc/ui/ui-misc","mvc/form/form-view","mvc/tool/tools-template","mvc/citation/citation-model","mvc/citation/citation-view"],function(a,b,c,d,e,f,g){return Backbone.View.extend({initialize:function(c){if(this.options=a.merge(c,{}),this.setElement("<div/>"),this.deferred=new b,c.inputs)this._buildForm(c);else{var d=this;this.deferred.execute(function(a){d._buildModel(a,c,!0)})}},remove:function(){var a=this;this.$el.hide(),this.deferred.execute(function(){Backbone.View.prototype.remove.call(a),Galaxy.emit.debug("tools-form-base::remove()","Destroy view.")})},_buildForm:function(b){var c=this;this.options=a.merge(b,this.options),this.options=a.merge({icon:"fa-wrench",title:"<b>"+b.name+"</b> "+b.description+" (Galaxy Tool Version "+b.version+")",operations:this._operations(),onchange:function(){c.deferred.reset(),c.deferred.execute(function(a){c._updateModel(a)})}},this.options),this.options.customize&&this.options.customize(this.options),this.form=new d(this.options),this._footer(),this.$el.empty(),this.$el.append(this.form.$el)},_buildModel:function(b,d,e){var f=this;this.options.id=d.id,this.options.version=d.version;var g="",h={};d.job_id?g=Galaxy.root+"api/jobs/"+d.job_id+"/build_for_rerun":(g=Galaxy.root+"api/tools/"+d.id+"/build",Galaxy.params&&Galaxy.params.tool_id==d.id&&(h=$.extend({},Galaxy.params),d.version&&(h.tool_version=d.version))),a.request({type:"GET",url:g,data:h,success:function(a){f._buildForm(a.tool_model||a),!e&&f.form.message.update({status:"success",message:"Now you are using '"+f.options.name+"' version "+f.options.version+".",persistent:!1}),Galaxy.emit.debug("tools-form-base::initialize()","Initial tool model ready.",a),b.resolve()},error:function(a){var d=a&&a.err_msg||"Uncaught error.";f.$el.is(":empty")?f.$el.prepend(new c.Message({message:d,status:"danger",persistent:!0,large:!0}).$el):Galaxy.modal.show({title:"Tool request failed",body:d,buttons:{Close:function(){Galaxy.modal.hide()}}}),Galaxy.emit.debug("tools-form::initialize()","Initial tool model request failed.",a),b.reject()}})},_updateModel:function(b){var c=this.options.update_url||Galaxy.root+"api/tools/"+this.options.id+"/build",d=this,e=this.form,f={tool_id:this.options.id,tool_version:this.options.version,inputs:$.extend(!0,{},d.form.data.create())};e.wait(!0),Galaxy.emit.debug("tools-form-base::_updateModel()","Sending current state.",f),a.request({type:"POST",url:c,data:f,success:function(a){d.form.update(a.tool_model||a),d.options.update&&d.options.update(a),e.wait(!1),Galaxy.emit.debug("tools-form-base::_updateModel()","Received new model.",a),b.resolve()},error:function(a){Galaxy.emit.debug("tools-form-base::_updateModel()","Refresh request failed.",a),b.reject()}})},_operations:function(){var a=this,b=this.options,d=new c.ButtonMenu({icon:"fa-cubes",title:!b.narrow&&"Versions"||null,tooltip:"Select another tool version"});if(!b.is_workflow&&b.versions&&b.versions.length>1)for(var f in b.versions){var g=b.versions[f];g!=b.version&&d.addMenu({title:"Switch to "+g,version:g,icon:"fa-cube",onclick:function(){var c=b.id.replace(b.version,this.version),d=this.version;a.deferred.reset(),a.deferred.execute(function(b){a._buildModel(b,{id:c,version:d})})}})}else d.$el.hide();var h=new c.ButtonMenu({icon:"fa-caret-down",title:!b.narrow&&"Options"||null,tooltip:"View available options"});return b.biostar_url&&(h.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(b.biostar_url+"/p/new/post/")}}),h.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(b.biostar_url+"/local/search/page/?q="+b.name)}})),h.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+Galaxy.root+"root?tool_id="+b.id)}}),Galaxy.user&&Galaxy.user.get("is_admin")&&h.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",href:Galaxy.root+"api/tools/"+b.id+"/download",download:b.id}),b.requirements&&b.requirements.length>0&&h.addMenu({icon:"fa-info-circle",title:"Requirements",tooltip:"Display tool requirements",onclick:function(){this.visible?(this.visible=!1,a.form.message.update({message:""})):(this.visible=!0,a.form.message.update({persistent:!0,message:e.requirements(b),status:"info"}))}}),b.sharable_url&&h.addMenu({icon:"fa-external-link",title:"See in Tool Shed",tooltip:"Access the repository",onclick:function(){window.open(b.sharable_url)}}),{menu:h,versions:d}},_footer:function(){var a=this.options;if(""!=a.help&&this.form.$el.append(e.help(a)),a.citations){var b=$("<div/>"),c=new f.ToolCitationCollection;c.tool_id=a.id;var d=new g.CitationListView({el:b,collection:c});d.render(),c.fetch(),this.form.$el.append(b)}}})});
define(["utils/utils","utils/deferred","mvc/ui/ui-misc","mvc/form/form-view","mvc/tool/tools-template","mvc/citation/citation-model","mvc/citation/citation-view"],function(a,b,c,d,e,f,g){return Backbone.View.extend({initialize:function(c){if(this.options=a.merge(c,{}),this.setElement("<div/>"),this.deferred=new b,c.inputs)this._buildForm(c);else{var d=this;this.deferred.execute(function(a){d._buildModel(a,c,!0)})}},remove:function(){var a=this;this.$el.hide(),this.deferred.execute(function(){Backbone.View.prototype.remove.call(a),Galaxy.emit.debug("tools-form-base::remove()","Destroy view.")})},_buildForm:function(b){var c=this;this.options=a.merge(b,this.options),this.options=a.merge({icon:"fa-wrench",title:"<b>"+b.name+"</b> "+b.description+" (Galaxy Tool Version "+b.version+")",operations:this._operations(),onchange:function(){c.deferred.reset(),c.deferred.execute(function(a){c._updateModel(a)})}},this.options),this.options.customize&&this.options.customize(this.options),this.form=new d(this.options),this._footer(),this.$el.empty(),this.$el.append(this.form.$el)},_buildModel:function(b,d,e){var f=this;this.options.id=d.id,this.options.version=d.version;var g="",h={};d.job_id?g=Galaxy.root+"api/jobs/"+d.job_id+"/build_for_rerun":(g=Galaxy.root+"api/tools/"+d.id+"/build",Galaxy.params&&Galaxy.params.tool_id==d.id&&(h=$.extend({},Galaxy.params),d.version&&(h.tool_version=d.version))),a.request({type:"GET",url:g,data:h,success:function(a){f._buildForm(a.tool_model||a),!e&&f.form.message.update({status:"success",message:"Now you are using '"+f.options.name+"' version "+f.options.version+", id '"+f.options.id+"'.",persistent:!1}),Galaxy.emit.debug("tools-form-base::initialize()","Initial tool model ready.",a),b.resolve()},error:function(a){var d=a&&a.err_msg||"Uncaught error.";f.$el.is(":empty")?f.$el.prepend(new c.Message({message:d,status:"danger",persistent:!0,large:!0}).$el):Galaxy.modal.show({title:"Tool request failed",body:d,buttons:{Close:function(){Galaxy.modal.hide()}}}),Galaxy.emit.debug("tools-form::initialize()","Initial tool model request failed.",a),b.reject()}})},_updateModel:function(b){var c=this.options.update_url||Galaxy.root+"api/tools/"+this.options.id+"/build",d=this,e=this.form,f={tool_id:this.options.id,tool_version:this.options.version,inputs:$.extend(!0,{},d.form.data.create())};e.wait(!0),Galaxy.emit.debug("tools-form-base::_updateModel()","Sending current state.",f),a.request({type:"POST",url:c,data:f,success:function(a){d.form.update(a.tool_model||a),d.options.update&&d.options.update(a),e.wait(!1),Galaxy.emit.debug("tools-form-base::_updateModel()","Received new model.",a),b.resolve()},error:function(a){Galaxy.emit.debug("tools-form-base::_updateModel()","Refresh request failed.",a),b.reject()}})},_operations:function(){var a=this,b=this.options,d=new c.ButtonMenu({icon:"fa-cubes",title:!b.narrow&&"Versions"||null,tooltip:"Select another tool version"});if(!b.is_workflow&&b.versions&&b.versions.length>1)for(var f in b.versions){var g=b.versions[f];g!=b.version&&d.addMenu({title:"Switch to "+g,version:g,icon:"fa-cube",onclick:function(){var c=b.id.replace(b.version,this.version),d=this.version;a.deferred.reset(),a.deferred.execute(function(b){a._buildModel(b,{id:c,version:d})})}})}else d.$el.hide();var h=new c.ButtonMenu({icon:"fa-caret-down",title:!b.narrow&&"Options"||null,tooltip:"View available options"});return b.biostar_url&&(h.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(b.biostar_url+"/p/new/post/")}}),h.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(b.biostar_url+"/local/search/page/?q="+b.name)}})),h.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+Galaxy.root+"root?tool_id="+b.id)}}),Galaxy.user&&Galaxy.user.get("is_admin")&&h.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",href:Galaxy.root+"api/tools/"+b.id+"/download",download:b.id}),b.requirements&&b.requirements.length>0&&h.addMenu({icon:"fa-info-circle",title:"Requirements",tooltip:"Display tool requirements",onclick:function(){this.visible?(this.visible=!1,a.form.message.update({message:""})):(this.visible=!0,a.form.message.update({persistent:!0,message:e.requirements(b),status:"info"}))}}),b.sharable_url&&h.addMenu({icon:"fa-external-link",title:"See in Tool Shed",tooltip:"Access the repository",onclick:function(){window.open(b.sharable_url)}}),{menu:h,versions:d}},_footer:function(){var a=this.options;if(""!=a.help&&this.form.$el.append(e.help(a)),a.citations){var b=$("<div/>"),c=new f.ToolCitationCollection;c.tool_id=a.id;var d=new g.CitationListView({el:b,collection:c});d.render(),c.fetch(),this.form.$el.append(b)}}})});
//# sourceMappingURL=../../../maps/mvc/tool/tools-form-base.js.map
+2 -58
View File
@@ -1,58 +1,2 @@
define([], function() {
function AjaxQueue(initialFunctions) {
var self = this;
return self.deferred = jQuery.Deferred(), self.queue = [], self.responses = [],
self.numToProcess = 0, self.running = !1, self.init(initialFunctions || []), self.start(),
self;
}
function NamedAjaxQueue(initialFunctions) {
var self = this;
return self.names = {}, AjaxQueue.call(this, initialFunctions), self;
}
return AjaxQueue.prototype.init = function(initialFunctions) {
var self = this;
initialFunctions.forEach(function(fn) {
self.add(fn);
});
}, AjaxQueue.prototype.add = function(fn) {
var self = this, index = this.queue.length;
this.numToProcess += 1, this.queue.push(function() {
var fnIndex = index, xhr = fn();
xhr.done(function(response) {
self.deferred.notify({
curr: fnIndex,
total: self.numToProcess,
response: response
});
}), xhr.always(function(response) {
self.responses.push(response), self.queue.length ? self.queue.shift()() : self.stop();
});
});
}, AjaxQueue.prototype.start = function() {
this.queue.length && (this.running = !0, this.queue.shift()());
}, AjaxQueue.prototype.stop = function(causeFail, msg) {
return this.running = !1, this.queue = [], causeFail ? this.deferred.reject(msg) : this.deferred.resolve(this.responses),
this.numToProcess = 0, this.deferred = jQuery.Deferred(), this;
}, AjaxQueue.prototype.done = function(fn) {
return this.deferred.done(fn);
}, AjaxQueue.prototype.fail = function(fn) {
return this.deferred.fail(fn);
}, AjaxQueue.prototype.always = function(fn) {
return this.deferred.always(fn);
}, AjaxQueue.prototype.progress = function(fn) {
return this.deferred.progress(fn);
}, AjaxQueue.create = function(initialFunctions) {
return new AjaxQueue(initialFunctions).deferred;
}, NamedAjaxQueue.prototype = new AjaxQueue(), NamedAjaxQueue.prototype.constructor = NamedAjaxQueue,
NamedAjaxQueue.prototype.add = function(obj) {
if (!obj.hasOwnProperty("name") || !obj.hasOwnProperty("fn")) throw new Error('NamedAjaxQueue.add requires an object with both "name" and "fn": ' + JSON.stringify(obj));
this.names.hasOwnProperty(obj.name) || (this.names[obj.name] = !0, AjaxQueue.prototype.add.call(this, obj.fn));
}, NamedAjaxQueue.prototype.clear = function() {
this.names = {};
}, NamedAjaxQueue.create = function(initialFunctions) {
return new NamedAjaxQueue(initialFunctions).deferred;
}, {
AjaxQueue: AjaxQueue,
NamedAjaxQueue: NamedAjaxQueue
};
});
define([],function(){function a(a){var b=this;return b.deferred=jQuery.Deferred(),b.queue=[],b.responses=[],b.numToProcess=0,b.running=!1,b.init(a||[]),b.start(),b}function b(b){var c=this;return c.names={},a.call(this,b),c}return a.prototype.init=function(a){var b=this;a.forEach(function(a){b.add(a)})},a.prototype.add=function(a){var b=this,c=this.queue.length;this.numToProcess+=1,this.queue.push(function(){var d=c,e=a();e.done(function(a){b.deferred.notify({curr:d,total:b.numToProcess,response:a})}),e.always(function(a){b.responses.push(a),b.queue.length?b.queue.shift()():b.stop()})})},a.prototype.start=function(){this.queue.length&&(this.running=!0,this.queue.shift()())},a.prototype.stop=function(a,b){return this.running=!1,this.queue=[],a?this.deferred.reject(b):this.deferred.resolve(this.responses),this.numToProcess=0,this.deferred=jQuery.Deferred(),this},a.prototype.done=function(a){return this.deferred.done(a)},a.prototype.fail=function(a){return this.deferred.fail(a)},a.prototype.always=function(a){return this.deferred.always(a)},a.prototype.progress=function(a){return this.deferred.progress(a)},a.create=function(b){return new a(b).deferred},b.prototype=new a,b.prototype.constructor=b,b.prototype.add=function(b){if(!b.hasOwnProperty("name")||!b.hasOwnProperty("fn"))throw new Error('NamedAjaxQueue.add requires an object with both "name" and "fn": '+JSON.stringify(b));this.names.hasOwnProperty(b.name)||(this.names[b.name]=!0,a.prototype.add.call(this,b.fn))},b.prototype.clear=function(){this.names={}},b.create=function(a){return new b(a).deferred},{AjaxQueue:a,NamedAjaxQueue:b}});
//# sourceMappingURL=../../maps/utils/ajax-queue.js.map
+48 -16
View File
@@ -14,7 +14,7 @@
title="Show or hide history contents"></a>
</div>
<div style="float: right;">
<a title="Import history" class="icon-button import" href="${import_href}"></a>
<a title="Import history" class="icon-button import" data-id="${encoded_history_id}" href="javascript:void(0)"></a>
<a title="View history" class="icon-button go-to-full-screen" href="${display_href}"></a>
</div>
<h4>
@@ -51,29 +51,61 @@
baseUrl : "${h.url_for( '/static/scripts' )}",
urlArgs: 'v=${app.server_starttime}'
});
require([ 'mvc/history/history-view-annotated' ], function( viewMod ){
function toggleExpanded( ev ){
var $embeddedHistory = $( thisScript ).prev();
$embeddedHistory.find( '.expand-content-btn' ).toggleClass( 'toggle-expand' ).toggleClass( 'toggle' );
$embeddedHistory.find( ".summary-content" ).slideToggle( "fast" );
$embeddedHistory.find( ".annotation" ).slideToggle( "fast" );
$embeddedHistory.find( ".expanded-content" ).slideToggle( "fast" );
ev.preventDefault();
}
require([
'mvc/history/history-view-annotated',
'mvc/history/copy-dialog'
], function( viewMod, historyCopyDialog ){
var $embeddedHistory = $( thisScript ).prev();
$(function(){
var historyModel = require( 'mvc/history/history-model' ),
var historyMod = require( 'mvc/history/history-model' ),
historyModel = new historyMod.History(
${h.dumps( history_dict )},
${h.dumps( content_dicts )}
),
view = new viewMod.AnnotatedHistoryView({
el : $embeddedHistory.find( ".history-panel" ),
model : new historyModel.History(
${h.dumps( history_dict )},
${h.dumps( content_dicts )}
)
model : historyModel
}).render();
function toggleExpanded( ev ){
ev.preventDefault();
$embeddedHistory.find( '.expand-content-btn' ).toggleClass( 'toggle-expand' ).toggleClass( 'toggle' );
$embeddedHistory.find( ".summary-content" ).slideToggle( "fast" );
$embeddedHistory.find( ".annotation" ).slideToggle( "fast" );
$embeddedHistory.find( ".expanded-content" ).slideToggle( "fast" );
}
$embeddedHistory.find( '.expand-content-btn' ).click( toggleExpanded );
$embeddedHistory.find( '.toggle-embed' ).click( toggleExpanded );
function showConfirmationModal( name ){
var body = [
'<div class="donemessagelarge">',
_l( 'History imported' ), ': ', _.escape( historyModel.get( 'name' ) ),
'</div>'
].join('');
Galaxy.modal.show({
title : _l( 'Success!' ),
body : $( body ),
buttons : {
'Return to the published page' : function(){
Galaxy.modal.hide();
},
'Start using the history' : function(){
window.location = Galaxy.root;
},
}
});
Galaxy.modal.$( '.modal-header' ).hide();
Galaxy.modal.$( '.modal-body' ).css( 'padding-bottom', 0 );
Galaxy.modal.$( '.modal-footer' ).css({ border : 0, 'padding-top': 0 });
}
$embeddedHistory.find( '.import' ).click( function( ev ){
var dialogOptions = { useImport: true, allowAll: false, autoClose: false };
historyCopyDialog( historyModel, dialogOptions ).done( showConfirmationModal );
})
});
});
})();