mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add file lost in previous merge (b52e562369).
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
define(["mvc/history/history-contents","mvc/base-mvc","utils/localization"],function(a,b){var c=Backbone.Model.extend(b.LoggableMixin).extend(b.mixin(b.SearchableModelMixin,{defaults:{model_class:"History",id:null,name:"Unnamed History",state:"new",diskSize:0,deleted:!1},urlRoot:galaxy_config.root+"api/histories",initialize:function(b,c,d){d=d||{},this.logger=d.logger||null,this.log(this+".initialize:",b,c,d),this.log("creating history contents:",c),this.contents=new a.HistoryContents(c||[],{historyId:this.get("id")}),this._setUpListeners(),this.updateTimeoutId=null},_setUpListeners:function(){this.on("error",function(a,b,c,d,e){this.errorHandler(a,b,c,d,e)}),this.contents&&this.listenTo(this.contents,"error",function(){this.trigger.apply(this,["error:contents"].concat(jQuery.makeArray(arguments)))}),this.on("change:id",function(a,b){this.contents&&(this.contents.historyId=b)},this)},errorHandler:function(){this.clearUpdateTimeout()},ownedByCurrUser:function(){return Galaxy&&Galaxy.currUser?Galaxy.currUser.isAnonymous()||Galaxy.currUser.id!==this.get("user_id")?!1:!0:!1},contentsCount:function(){return _.reduce(_.values(this.get("state_details")),function(a,b){return a+b},0)},searchAttributes:["name","annotation","tags"],searchAliases:{title:"name",tag:"tags"},checkForUpdates:function(a){return this.contents.running().length?this.setUpdateTimeout():(this.trigger("ready"),_.isFunction(a)&&a.call(this)),this},setUpdateTimeout:function(a){a=a||c.UPDATE_DELAY;var b=this;return this.clearUpdateTimeout(),this.updateTimeoutId=setTimeout(function(){b.refresh()},a),this.updateTimeoutId},clearUpdateTimeout:function(){this.updateTimeoutId&&(clearTimeout(this.updateTimeoutId),this.updateTimeoutId=null)},refresh:function(a,b){a=a||[],b=b||{};var c=this;b.data=b.data||{},a.length&&(b.data.details=a.join(","));var d=this.contents.fetch(b);return d.done(function(){c.checkForUpdates(function(){this.fetch()})}),d},_delete:function(a){return this.get("deleted")?jQuery.when():this.save({deleted:!0},a)},purge:function(a){return this.get("purged")?jQuery.when():this.save({deleted:!0,purged:!0},a)},undelete:function(a){return this.get("deleted")?this.save({deleted:!1},a):jQuery.when()},copy:function(a,b){if(a=void 0!==a?a:!0,!this.id)throw new Error("You must set the history ID before copying it.");var d={history_id:this.id};a&&(d.current=!0),b&&(d.name=b);var e=this,f=jQuery.post(this.urlRoot,d);return a?f.then(function(a){var b=new c(a);return b.setAsCurrent().done(function(){e.trigger("copied",e,a)})}):f.done(function(a){e.trigger("copied",e,a)})},setAsCurrent:function(){var a=this,b=jQuery.getJSON(galaxy_config.root+"history/set_as_current?id="+this.id);return b.done(function(){a.trigger("set-as-current",a)}),b},toString:function(){return"History("+this.get("id")+","+this.get("name")+")"}}));c.UPDATE_DELAY=4e3,c.getHistoryData=function(a,b){function c(){return"current"===a?jQuery.getJSON(galaxy_config.root+"history/current_history_json"):jQuery.ajax(galaxy_config.root+"api/histories/"+a)}function d(a){return a&&a.empty}function e(a){if(d(a))return[];_.isFunction(f)&&(f=f(a)),_.isFunction(g)&&(g=g(a));var b={};return f.length&&(b.dataset_details=f.join(",")),g.length&&(b.dataset_collection_details=g.join(",")),jQuery.ajax(galaxy_config.root+"api/histories/"+a.id+"/contents",{data:b})}b=b||{};var f=b.detailIdsFn||[],g=b.hdcaDetailIds||[],h=jQuery.Deferred(),i=null,j=b.historyFn||c,k=b.contentsFn||e,l=j(a);l.done(function(a){i=a,h.notify({status:"history data retrieved",historyJSON:i})}),l.fail(function(a){h.reject(a,"loading the history")});var m=l.then(k);return m.then(function(a){h.notify({status:"contents data retrieved",historyJSON:i,contentsJSON:a}),h.resolve(i,a)}),m.fail(function(a){h.reject(a,"loading the contents",{history:i})}),h};var d=Backbone.Collection.extend(b.LoggableMixin).extend({model:c,urlRoot:(window.galaxy_config?galaxy_config.root:"/")+"api/histories",initialize:function(a,b){b=b||{},this.log("HistoryCollection.initialize",arguments),this.includeDeleted=b.includeDeleted||!1,this.setUpListeners()},setUpListeners:function(){var a=this;this.on("change:deleted",function(b){this.debug("change:deleted",a.includeDeleted,b.get("deleted")),!a.includeDeleted&&b.get("deleted")&&a.remove(b)}),this.on("copied",function(a,b){this.unshift(new c(b,[]))})},create:function(a,b,d){var e=this,f=jQuery.getJSON(galaxy_config.root+"history/create_new_current");return f.done(function(a){var b=new c(a,[],d||{});e.unshift(b),e.trigger("new-current")})},toString:function(){return"HistoryCollection("+this.length+")"}});return{History:c,HistoryCollection:d}});
|
||||
//# sourceMappingURL=../../../maps/mvc/history/history-model.js.map
|
||||
Reference in New Issue
Block a user