/static/scripts/mvc/ui/ui-select-library.js

https://bitbucket.org/galaxy/galaxy-central/ · JavaScript · 2 lines · 1 code · 0 blank · 1 comment · 0 complexity · 8751bdbe7b6e265930b1a95405a7060f MD5 · raw file

  1. define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-table","mvc/ui/ui-list"],function(a,b,c,d){var e=Backbone.Collection.extend({url:Galaxy.root+"api/libraries?deleted=false"}),f=Backbone.Collection.extend({initialize:function(){var a=this;this.config=new Backbone.Model({library_id:null}),this.config.on("change",function(){a.fetch({reset:!0})})},url:function(){return Galaxy.root+"api/libraries/"+this.config.get("library_id")+"/contents"}}),g=Backbone.View.extend({initialize:function(a){var c=this;this.libraries=new e,this.datasets=new f,this.options=a,this.library_select=new b.Select.View({onchange:function(a){c.datasets.config.set("library_id",a)}}),this.dataset_list=new d.View({name:"dataset",optional:a.optional,multiple:a.multiple,onchange:function(){c.trigger("change")}}),this.libraries.on("reset",function(){var a=[];c.libraries.each(function(b){a.push({value:b.id,label:b.get("name")})}),c.library_select.update(a)}),this.datasets.on("reset",function(){var a=[],b=c.library_select.text();null!==b&&c.datasets.each(function(b){"file"===b.get("type")&&a.push({value:b.id,label:b.get("name")})}),c.dataset_list.update(a)}),this.on("change",function(){a.onchange&&a.onchange(c.value())}),this.setElement(this._template()),this.$(".library-select").append(this.library_select.$el),this.$el.append(this.dataset_list.$el),this.libraries.fetch({reset:!0,success:function(){c.library_select.trigger("change"),void 0!==c.options.value&&c.value(c.options.value)}})},value:function(a){return this.dataset_list.value(a)},_template:function(){return'<div class="ui-select-library"><div class="library ui-margin-bottom"><span class="library-title">Select Library</span><span class="library-select"/></div></div>'}});return{View:g}});
  2. //# sourceMappingURL=../../../maps/mvc/ui/ui-select-library.js.map