2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/cda6be2edfe6/ Changeset: cda6be2edfe6 User: guerler Date: 2014-09-18 18:57:46+00:00 Summary: Ui: Fix option fields Affected #: 10 files diff -r 5b745b6649d29bd576cccfd0466cb1f5950838aa -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d client/galaxy/scripts/mvc/tools/tools-section.js --- a/client/galaxy/scripts/mvc/tools/tools-section.js +++ b/client/galaxy/scripts/mvc/tools/tools-section.js @@ -25,12 +25,8 @@ // template _template: function(options) { - var $input; - if (options.highlight) { - $input = $('<div class="ui-table-element ui-table-form-section"/>'); - } else { - $input = $('<div class="ui-table-element"/>'); - } + // create table element + var $input = $('<div class="ui-table-element"/>'); // add error $input.append('<div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>'); @@ -226,10 +222,12 @@ var input_element = new InputElement({ label : input_def.title, help : input_def.help, - $el : repeat.$el, - highlight : true + $el : repeat.$el }); + // displays as grouped subsection + input_element.$el.addClass('ui-table-form-section'); + // create table row this.table.add(input_element.$el); diff -r 5b745b6649d29bd576cccfd0466cb1f5950838aa -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d client/galaxy/scripts/mvc/ui/ui-checkbox.js --- a/client/galaxy/scripts/mvc/ui/ui-checkbox.js +++ /dev/null @@ -1,91 +0,0 @@ -// dependencies -define(['utils/utils'], function(Utils) { - -// plugin -var View = Backbone.View.extend({ - // options - optionsDefault: { - value : '', - visible : true, - cls : '', - data : [], - id : Utils.uuid() - }, - - // initialize - initialize : function(options) { - // configure options - this.options = Utils.merge(options, this.optionsDefault); - - // create new element - this.setElement(this._template(this.options)); - - // hide input field - if (!this.options.visible) { - this.$el.hide(); - } - - // set initial value - if (this.options.value) { - this.value(this.options.value); - } - - // current value - this.current = this.options.value; - - // onchange event handler. fires on user activity. - var self = this; - this.$el.find('input').on('change', function() { - self.value(self._getValue()); - }); - }, - - // value - value : function (new_val) { - // get current value - var before = this.current; - - // set new value - if (new_val !== undefined) { - this.$el.find('label').removeClass('active'); - this.$el.find('[value="' + new_val + '"]').closest('label').addClass('active'); - this.current = new_val; - } - - // check value - var after = this.current; - if (after != before && this.options.onchange) { - this.options.onchange(this.current); - } - - // get and return value - return this.current; - }, - - // get value - _getValue: function() { - var selected = this.$el.find(':checked'); - var value = null; - if (selected.length > 0) { - value = selected.val(); - } - return value; - }, - - // element - _template: function(options) { - var tmpl = '<div class="ui-checkbox">'; - for (key in options.data) { - var pair = options.data[key]; - tmpl += '<input type="checkbox" name="' + options.id + '" value="' + pair.value + '" selected>' + pair.label + '<br>'; - } - tmpl += '</div>'; - return tmpl; - } -}); - -return { - View : View -}; - -}); diff -r 5b745b6649d29bd576cccfd0466cb1f5950838aa -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d client/galaxy/scripts/mvc/ui/ui-options.js --- /dev/null +++ b/client/galaxy/scripts/mvc/ui/ui-options.js @@ -0,0 +1,221 @@ +// dependencies +define(['utils/utils'], function(Utils) { + +/** base class for options based ui elements **/ +var OptionsBase = Backbone.View.extend({ + // initialize + initialize: function(options) { + // options + this.optionsDefault = { + value : [], + visible : true, + data : [], + id : Utils.uuid(), + empty : 'No data available' + }; + + // configure options + this.options = Utils.merge(options, this.optionsDefault); + + // create new element + this.setElement(this._template(this.options)); + + // hide input field + if (!this.options.visible) { + this.$el.hide(); + } + + // initialize data + this.update(this.options.data); + + // set initial value + if (this.options.value) { + this.value(this.options.value); + } + + // add change event. fires on trigger + var self = this; + this.on('change', function() { + self._change(); + }); + }, + + // update options + update: function(options) { + // backup current value + var current = this._getValue(); + + // remove all options + this.$el.find('.ui-option').remove(); + + // add new options + for (var key in options) { + this.$el.append(this._templateOption(options[key])); + } + + // add change events + var self = this; + this.$el.find('input').on('change', function() { + self.value(self._getValue()); + self._change(); + }); + + // refresh + this._refresh(); + + // set previous value + this.value(current); + }, + + // check if selected value exists (or any if multiple) + exists: function(value) { + if (typeof value === 'string') { + value = [value]; + } + for (var i in value) { + if (this.$el.find('input[value="' + value[i] + '"]').length > 0) { + return true; + } + } + return false; + }, + + // first + first: function() { + var options = this.$el.find('input'); + if (options.length > 0) { + return options.val(); + } else { + return undefined; + } + }, + + // change + _change: function() { + if (this.options.onchange) { + this.options.onchange(this._getValue()); + } + }, + + // refresh + _refresh: function() { + // remove placeholder + this.$el.find('.ui-error').remove(); + + // count remaining options + var remaining = this.$el.find('input').length; + if (remaining == 0) { + this.$el.append(this._templateEmpty()); + } + }, + + // get value + _getValue: function() { + // get selected values + var selected = this.$el.find(':checked'); + if (selected.length == 0) { + return null; + } + + // return multiple or single value + if (this.options.multiple) { + var values = []; + selected.each(function() { + values.push($(this).val()); + }); + return values; + } else { + return selected.val(); + } + }, + + // template for options + _templateEmpty: function() { + return '<div class="ui-error">' + this.options.empty + '</div>'; + } +}); + +/** checkbox options field **/ +var Checkbox = {}; +Checkbox.View = OptionsBase.extend({ + // initialize + initialize: function(options) { + options.multiple = true; + OptionsBase.prototype.initialize.call(this, options); + }, + + // value + value: function (new_val) { + // check if its an array + if (typeof new_val === 'string') { + new_val = [new_val]; + } + + // set new value + if (new_val !== undefined) { + // reset selection + this.$el.find('input').prop('checked', false); + + // update to new selection + for (var i in new_val) { + this.$el.find('input[value=' + new_val[i] + ']').prop('checked', true); + }; + } + + // get and return value + return this._getValue(); + }, + + // template for options + _templateOption: function(pair) { + return '<div class="ui-option">' + + '<input type="checkbox" name="' + this.options.id + '" value="' + pair.value + '"/>' + pair.label + '<br>' + + '</div>'; + }, + + // template + _template: function() { + return '<div class="ui-checkbox"/>'; + } +}); + +/** radio button options field **/ +var RadioButton = {}; +RadioButton.View = OptionsBase.extend({ + // initialize + initialize: function(options) { + OptionsBase.prototype.initialize.call(this, options); + }, + + // value + value: function (new_val) { + // set new value + if (new_val !== undefined) { + this.$el.find('input').prop('checked', false); + this.$el.find('label').removeClass('active'); + this.$el.find('[value="' + new_val + '"]').prop('checked', true).closest('label').addClass('active'); + } + + // get and return value + return this._getValue(); + }, + + // template for options + _templateOption: function(pair) { + return '<label class="ui-option btn btn-default">' + + '<input type="radio" name="' + this.options.id + '" value="' + pair.value + '">' + pair.label + + '</label>'; + }, + + // template + _template: function() { + return '<div class="btn-group ui-radiobutton" data-toggle="buttons"/>'; + } +}); + +return { + Checkbox : Checkbox, + RadioButton : RadioButton +}; + +}); diff -r 5b745b6649d29bd576cccfd0466cb1f5950838aa -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d client/galaxy/scripts/mvc/ui/ui-radiobutton.js --- a/client/galaxy/scripts/mvc/ui/ui-radiobutton.js +++ /dev/null @@ -1,93 +0,0 @@ -// dependencies -define(['utils/utils'], function(Utils) { - -// plugin -var View = Backbone.View.extend({ - // options - optionsDefault: { - value : '', - visible : true, - cls : '', - data : [], - id : Utils.uuid() - }, - - // initialize - initialize : function(options) { - // configure options - this.options = Utils.merge(options, this.optionsDefault); - - // create new element - this.setElement(this._template(this.options)); - - // hide input field - if (!this.options.visible) { - this.$el.hide(); - } - - // set initial value - if (this.options.value) { - this.value(this.options.value); - } - - // current value - this.current = this.options.value; - - // onchange event handler. fires on user activity. - var self = this; - this.$el.find('input').on('change', function() { - self.value(self._getValue()); - }); - }, - - // value - value : function (new_val) { - // get current value - var before = this.current; - - // set new value - if (new_val !== undefined) { - this.$el.find('label').removeClass('active'); - this.$el.find('[value="' + new_val + '"]').closest('label').addClass('active'); - this.current = new_val; - } - - // check value - var after = this.current; - if (after != before && this.options.onchange) { - this.options.onchange(this.current); - } - - // get and return value - return this.current; - }, - - // get value - _getValue: function() { - var selected = this.$el.find(':checked'); - var value = null; - if (selected.length > 0) { - value = selected.val(); - } - return value; - }, - - // element - _template: function(options) { - var tmpl = '<div class="btn-group ui-radiobutton" data-toggle="buttons">'; - for (key in options.data) { - var pair = options.data[key]; - tmpl += '<label class="btn btn-default">' + - '<input type="radio" name="' + options.id + '" value="' + pair.value + '" selected>' + pair.label + - '</label>'; - } - tmpl += '</div>'; - return tmpl; - } -}); - -return { - View : View -}; - -}); diff -r 5b745b6649d29bd576cccfd0466cb1f5950838aa -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d static/scripts/mvc/tools/tools-section.js --- a/static/scripts/mvc/tools/tools-section.js +++ b/static/scripts/mvc/tools/tools-section.js @@ -25,12 +25,8 @@ // template _template: function(options) { - var $input; - if (options.highlight) { - $input = $('<div class="ui-table-element ui-table-form-section"/>'); - } else { - $input = $('<div class="ui-table-element"/>'); - } + // create table element + var $input = $('<div class="ui-table-element"/>'); // add error $input.append('<div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>'); @@ -226,10 +222,12 @@ var input_element = new InputElement({ label : input_def.title, help : input_def.help, - $el : repeat.$el, - highlight : true + $el : repeat.$el }); + // displays as grouped subsection + input_element.$el.addClass('ui-table-form-section'); + // create table row this.table.add(input_element.$el); diff -r 5b745b6649d29bd576cccfd0466cb1f5950838aa -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d static/scripts/mvc/ui/ui-checkbox.js --- a/static/scripts/mvc/ui/ui-checkbox.js +++ /dev/null @@ -1,91 +0,0 @@ -// dependencies -define(['utils/utils'], function(Utils) { - -// plugin -var View = Backbone.View.extend({ - // options - optionsDefault: { - value : '', - visible : true, - cls : '', - data : [], - id : Utils.uuid() - }, - - // initialize - initialize : function(options) { - // configure options - this.options = Utils.merge(options, this.optionsDefault); - - // create new element - this.setElement(this._template(this.options)); - - // hide input field - if (!this.options.visible) { - this.$el.hide(); - } - - // set initial value - if (this.options.value) { - this.value(this.options.value); - } - - // current value - this.current = this.options.value; - - // onchange event handler. fires on user activity. - var self = this; - this.$el.find('input').on('change', function() { - self.value(self._getValue()); - }); - }, - - // value - value : function (new_val) { - // get current value - var before = this.current; - - // set new value - if (new_val !== undefined) { - this.$el.find('label').removeClass('active'); - this.$el.find('[value="' + new_val + '"]').closest('label').addClass('active'); - this.current = new_val; - } - - // check value - var after = this.current; - if (after != before && this.options.onchange) { - this.options.onchange(this.current); - } - - // get and return value - return this.current; - }, - - // get value - _getValue: function() { - var selected = this.$el.find(':checked'); - var value = null; - if (selected.length > 0) { - value = selected.val(); - } - return value; - }, - - // element - _template: function(options) { - var tmpl = '<div class="ui-checkbox">'; - for (key in options.data) { - var pair = options.data[key]; - tmpl += '<input type="checkbox" name="' + options.id + '" value="' + pair.value + '" selected>' + pair.label + '<br>'; - } - tmpl += '</div>'; - return tmpl; - } -}); - -return { - View : View -}; - -}); diff -r 5b745b6649d29bd576cccfd0466cb1f5950838aa -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d static/scripts/mvc/ui/ui-radiobutton.js --- a/static/scripts/mvc/ui/ui-radiobutton.js +++ /dev/null @@ -1,93 +0,0 @@ -// dependencies -define(['utils/utils'], function(Utils) { - -// plugin -var View = Backbone.View.extend({ - // options - optionsDefault: { - value : '', - visible : true, - cls : '', - data : [], - id : Utils.uuid() - }, - - // initialize - initialize : function(options) { - // configure options - this.options = Utils.merge(options, this.optionsDefault); - - // create new element - this.setElement(this._template(this.options)); - - // hide input field - if (!this.options.visible) { - this.$el.hide(); - } - - // set initial value - if (this.options.value) { - this.value(this.options.value); - } - - // current value - this.current = this.options.value; - - // onchange event handler. fires on user activity. - var self = this; - this.$el.find('input').on('change', function() { - self.value(self._getValue()); - }); - }, - - // value - value : function (new_val) { - // get current value - var before = this.current; - - // set new value - if (new_val !== undefined) { - this.$el.find('label').removeClass('active'); - this.$el.find('[value="' + new_val + '"]').closest('label').addClass('active'); - this.current = new_val; - } - - // check value - var after = this.current; - if (after != before && this.options.onchange) { - this.options.onchange(this.current); - } - - // get and return value - return this.current; - }, - - // get value - _getValue: function() { - var selected = this.$el.find(':checked'); - var value = null; - if (selected.length > 0) { - value = selected.val(); - } - return value; - }, - - // element - _template: function(options) { - var tmpl = '<div class="btn-group ui-radiobutton" data-toggle="buttons">'; - for (key in options.data) { - var pair = options.data[key]; - tmpl += '<label class="btn btn-default">' + - '<input type="radio" name="' + options.id + '" value="' + pair.value + '" selected>' + pair.label + - '</label>'; - } - tmpl += '</div>'; - return tmpl; - } -}); - -return { - View : View -}; - -}); diff -r 5b745b6649d29bd576cccfd0466cb1f5950838aa -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d static/scripts/packed/mvc/tools/tools-section.js --- a/static/scripts/packed/mvc/tools/tools-section.js +++ b/static/scripts/packed/mvc/tools/tools-section.js @@ -1,1 +1,1 @@ -define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-dataset"],function(d,a,g,c,b){var e=Backbone.View.extend({initialize:function(h){this.setElement(this._template(h))},error:function(h){this.$el.find(".ui-table-form-error-text").html(h);this.$el.find(".ui-table-form-error").fadeIn()},reset:function(){this.$el.find(".ui-table-form-error").hide()},_template:function(h){var i;if(h.highlight){i=$('<div class="ui-table-element ui-table-form-section"/>')}else{i=$('<div class="ui-table-element"/>')}i.append('<div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>');if(h.label){i.append('<div class="ui-table-form-title-strong">'+h.label+"</div>")}i.append(h.$el);if(h.help){i.append('<div class="ui-table-form-info">'+h.help+"</div>")}return i}});var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new a.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(k,h)}},_addConditional:function(h){h.label=h.test_param.label;h.value=h.test_param.value;var j=this._addRow("conditional",h);for(var l in h.cases){var k=h.id+"-section-"+l;var m=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});m.$el.addClass("ui-table-form-section");this.table.add(m.$el);this.table.append(k)}},_addRepeat:function(h){var j=this;var m=new c.View({title_new:h.title,max:h.max,onnew:function(){var i=h.id+"-section-"+d.uuid();var p=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:i,title:h.title,$el:p.$el,ondel:function(){m.del(i);m.retitle(h.title);j.app.refresh()}});m.retitle(h.title);j.app.refresh()}});for(var l=0;l<h.min;l++){var k=h.id+"-section-"+d.uuid();var o=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:k,title:h.title,$el:o.$el})}m.retitle(h.title);var n=new e({label:h.title,help:h.help,$el:m.$el,highlight:true});this.table.add(n.$el);this.table.append(h.id)},_addRow:function(j,h){var l=h.id;var i=null;switch(j){case"text":i=this._field_text(h);break;case"select":i=this._field_select(h);break;case"data":i=this._field_data(h);break;case"data_column":i=this._field_select(h);break;case"conditional":i=this._field_conditional(h);break;case"hidden":i=this._field_hidden(h);break;case"integer":i=this._field_slider(h);break;case"float":i=this._field_slider(h);break;case"boolean":i=this._field_boolean(h);break}if(!i){if(h.options){i=this._field_select(h)}else{i=this._field_text(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+j+").")}if(h.value!==undefined){i.value(h.value)}this.app.field_list[l]=i;var k=new e({label:h.label,help:h.help,$el:i.$el});this.app.element_list[l]=k;this.table.add(k.$el);this.table.append(l);return this.table.get(l)},_field_conditional:function(h){var j=this;var k=[];for(var l in h.test_param.options){var m=h.test_param.options[l];k.push({label:m[0],value:m[1]})}return new g.Select.View({id:"field-"+h.id,data:k,onchange:function(u){for(var s in h.cases){var o=h.cases[s];var r=h.id+"-section-"+s;var n=j.table.get(r);var q=false;for(var p in o.inputs){var t=o.inputs[p].type;if(t&&t!=="hidden"){q=true;break}}if(o.value==u&&q){n.fadeIn("fast")}else{n.hide()}}}})},_field_data:function(h){var i=this;var j=h.id;return new b.View(this.app,{id:"field-"+j,extensions:h.extensions,multiple:h.multiple,onchange:function(u){if(u instanceof Array){u=u[0]}var s=i.app.tree.references(j,"data_column");var m=i.app.datasets.filter(u);if(m&&s.length>0){console.debug("tool-form::field_data() - Selected dataset "+u+".");var w=m.get("metadata_column_types");if(!w){console.debug("tool-form::field_data() - FAILED: Could not find metadata for dataset "+u+".")}for(var o in s){var q=i.app.input_list[s[o]];var r=i.app.field_list[s[o]];if(!q||!r){console.debug("tool-form::field_data() - FAILED: Column not found.")}var n=q.numerical;var l=[];for(var v in w){var t=w[v];var k=(parseInt(v)+1);var p="Text";if(t=="int"||t=="float"){p="Number"}if(t=="int"||t=="float"||!n){l.push({label:"Column: "+k+" ["+p+"]",value:k})}}if(r){r.update(l);if(!r.exists(r.value())){r.value(r.first())}}}}else{console.debug("tool-form::field_data() - FAILED: Could not find dataset "+u+".")}}})},_field_select:function(h){var j=[];for(var k in h.options){var l=h.options[k];j.push({label:l[0],value:l[1]})}var m=g.Select;switch(h.display){case"checkboxes":m=g.Checkbox;break;case"radio":m=g.RadioButton;break}return new m.View({id:"field-"+h.id,data:j,multiple:h.multiple})},_field_data_colum:function(h){return new g.Select.View({id:"field-"+h.id,multiple:h.multiple})},_field_text:function(h){return new g.Input({id:"field-"+h.id,area:h.area})},_field_slider:function(h){var i=1;if(h.type=="float"){i=(h.max-h.min)/10000}return new g.Slider.View({id:"field-"+h.id,min:h.min||0,max:h.max||1000,step:i})},_field_hidden:function(h){return new g.Hidden({id:"field-"+h.id})},_field_boolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-dataset"],function(d,a,g,c,b){var e=Backbone.View.extend({initialize:function(h){this.setElement(this._template(h))},error:function(h){this.$el.find(".ui-table-form-error-text").html(h);this.$el.find(".ui-table-form-error").fadeIn()},reset:function(){this.$el.find(".ui-table-form-error").hide()},_template:function(h){var i=$('<div class="ui-table-element"/>');i.append('<div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>');if(h.label){i.append('<div class="ui-table-form-title-strong">'+h.label+"</div>")}i.append(h.$el);if(h.help){i.append('<div class="ui-table-form-info">'+h.help+"</div>")}return i}});var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new a.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(k,h)}},_addConditional:function(h){h.label=h.test_param.label;h.value=h.test_param.value;var j=this._addRow("conditional",h);for(var l in h.cases){var k=h.id+"-section-"+l;var m=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});m.$el.addClass("ui-table-form-section");this.table.add(m.$el);this.table.append(k)}},_addRepeat:function(h){var j=this;var m=new c.View({title_new:h.title,max:h.max,onnew:function(){var i=h.id+"-section-"+d.uuid();var p=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:i,title:h.title,$el:p.$el,ondel:function(){m.del(i);m.retitle(h.title);j.app.refresh()}});m.retitle(h.title);j.app.refresh()}});for(var l=0;l<h.min;l++){var k=h.id+"-section-"+d.uuid();var o=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:k,title:h.title,$el:o.$el})}m.retitle(h.title);var n=new e({label:h.title,help:h.help,$el:m.$el});n.$el.addClass("ui-table-form-section");this.table.add(n.$el);this.table.append(h.id)},_addRow:function(j,h){var l=h.id;var i=null;switch(j){case"text":i=this._field_text(h);break;case"select":i=this._field_select(h);break;case"data":i=this._field_data(h);break;case"data_column":i=this._field_select(h);break;case"conditional":i=this._field_conditional(h);break;case"hidden":i=this._field_hidden(h);break;case"integer":i=this._field_slider(h);break;case"float":i=this._field_slider(h);break;case"boolean":i=this._field_boolean(h);break}if(!i){if(h.options){i=this._field_select(h)}else{i=this._field_text(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+j+").")}if(h.value!==undefined){i.value(h.value)}this.app.field_list[l]=i;var k=new e({label:h.label,help:h.help,$el:i.$el});this.app.element_list[l]=k;this.table.add(k.$el);this.table.append(l);return this.table.get(l)},_field_conditional:function(h){var j=this;var k=[];for(var l in h.test_param.options){var m=h.test_param.options[l];k.push({label:m[0],value:m[1]})}return new g.Select.View({id:"field-"+h.id,data:k,onchange:function(u){for(var s in h.cases){var o=h.cases[s];var r=h.id+"-section-"+s;var n=j.table.get(r);var q=false;for(var p in o.inputs){var t=o.inputs[p].type;if(t&&t!=="hidden"){q=true;break}}if(o.value==u&&q){n.fadeIn("fast")}else{n.hide()}}}})},_field_data:function(h){var i=this;var j=h.id;return new b.View(this.app,{id:"field-"+j,extensions:h.extensions,multiple:h.multiple,onchange:function(u){if(u instanceof Array){u=u[0]}var s=i.app.tree.references(j,"data_column");var m=i.app.datasets.filter(u);if(m&&s.length>0){console.debug("tool-form::field_data() - Selected dataset "+u+".");var w=m.get("metadata_column_types");if(!w){console.debug("tool-form::field_data() - FAILED: Could not find metadata for dataset "+u+".")}for(var o in s){var q=i.app.input_list[s[o]];var r=i.app.field_list[s[o]];if(!q||!r){console.debug("tool-form::field_data() - FAILED: Column not found.")}var n=q.numerical;var l=[];for(var v in w){var t=w[v];var k=(parseInt(v)+1);var p="Text";if(t=="int"||t=="float"){p="Number"}if(t=="int"||t=="float"||!n){l.push({label:"Column: "+k+" ["+p+"]",value:k})}}if(r){r.update(l);if(!r.exists(r.value())){r.value(r.first())}}}}else{console.debug("tool-form::field_data() - FAILED: Could not find dataset "+u+".")}}})},_field_select:function(h){var j=[];for(var k in h.options){var l=h.options[k];j.push({label:l[0],value:l[1]})}var m=g.Select;switch(h.display){case"checkboxes":m=g.Checkbox;break;case"radio":m=g.RadioButton;break}return new m.View({id:"field-"+h.id,data:j,multiple:h.multiple})},_field_data_colum:function(h){return new g.Select.View({id:"field-"+h.id,multiple:h.multiple})},_field_text:function(h){return new g.Input({id:"field-"+h.id,area:h.area})},_field_slider:function(h){var i=1;if(h.type=="float"){i=(h.max-h.min)/10000}return new g.Slider.View({id:"field-"+h.id,min:h.min||0,max:h.max||1000,step:i})},_field_hidden:function(h){return new g.Hidden({id:"field-"+h.id})},_field_boolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}}); \ No newline at end of file diff -r 5b745b6649d29bd576cccfd0466cb1f5950838aa -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d static/scripts/packed/mvc/ui/ui-checkbox.js --- a/static/scripts/packed/mvc/ui/ui-checkbox.js +++ /dev/null @@ -1,1 +0,0 @@ -define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{value:"",visible:true,cls:"",data:[],id:a.uuid()},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));if(!this.options.visible){this.$el.hide()}if(this.options.value){this.value(this.options.value)}this.current=this.options.value;var c=this;this.$el.find("input").on("change",function(){c.value(c._getValue())})},value:function(c){var d=this.current;if(c!==undefined){this.$el.find("label").removeClass("active");this.$el.find('[value="'+c+'"]').closest("label").addClass("active");this.current=c}var e=this.current;if(e!=d&&this.options.onchange){this.options.onchange(this.current)}return this.current},_getValue:function(){var c=this.$el.find(":checked");var d=null;if(c.length>0){d=c.val()}return d},_template:function(d){var c='<div class="ui-checkbox">';for(key in d.data){var e=d.data[key];c+='<input type="checkbox" name="'+d.id+'" value="'+e.value+'" selected>'+e.label+"<br>"}c+="</div>";return c}});return{View:b}}); \ No newline at end of file diff -r 5b745b6649d29bd576cccfd0466cb1f5950838aa -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d static/scripts/packed/mvc/ui/ui-radiobutton.js --- a/static/scripts/packed/mvc/ui/ui-radiobutton.js +++ /dev/null @@ -1,1 +0,0 @@ -define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{value:"",visible:true,cls:"",data:[],id:a.uuid()},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));if(!this.options.visible){this.$el.hide()}if(this.options.value){this.value(this.options.value)}this.current=this.options.value;var c=this;this.$el.find("input").on("change",function(){c.value(c._getValue())})},value:function(c){var d=this.current;if(c!==undefined){this.$el.find("label").removeClass("active");this.$el.find('[value="'+c+'"]').closest("label").addClass("active");this.current=c}var e=this.current;if(e!=d&&this.options.onchange){this.options.onchange(this.current)}return this.current},_getValue:function(){var c=this.$el.find(":checked");var d=null;if(c.length>0){d=c.val()}return d},_template:function(d){var c='<div class="btn-group ui-radiobutton" data-toggle="buttons">';for(key in d.data){var e=d.data[key];c+='<label class="btn btn-default"><input type="radio" name="'+d.id+'" value="'+e.value+'" selected>'+e.label+"</label>"}c+="</div>";return c}});return{View:b}}); \ No newline at end of file https://bitbucket.org/galaxy/galaxy-central/commits/37e5c86d9fc0/ Changeset: 37e5c86d9fc0 User: guerler Date: 2014-09-18 18:58:12+00:00 Summary: Merge Affected #: 16 files diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa client/galaxy/scripts/galaxy.base.js --- a/client/galaxy/scripts/galaxy.base.js +++ b/client/galaxy/scripts/galaxy.base.js @@ -237,7 +237,8 @@ $.fn.refresh_select2 = function() { var select_elt = $(this); var options = { width: "resolve", - closeOnSelect: !select_elt.is("[MULTIPLE]") + closeOnSelect: !select_elt.is("[MULTIPLE]"), + dropdownAutoWidth : true }; return select_elt.select2( options ); } diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa client/galaxy/scripts/mvc/library/library-folderlist-view.js --- a/client/galaxy/scripts/mvc/library/library-folderlist-view.js +++ b/client/galaxy/scripts/mvc/library/library-folderlist-view.js @@ -1,4 +1,3 @@ -// dependencies define([ "galaxy.masthead", "utils/utils", diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js --- a/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js +++ b/client/galaxy/scripts/mvc/library/library-foldertoolbar-view.js @@ -2,11 +2,15 @@ "galaxy.masthead", "utils/utils", "libs/toastr", - "mvc/library/library-model"], + "mvc/library/library-model", + "mvc/ui/ui-select" + ], function( mod_masthead, - mod_utils, - mod_toastr, - mod_library_model ) { + mod_utils, + mod_toastr, + mod_library_model, + mod_select + ){ var FolderToolbarView = Backbone.View.extend({ el: '#center', @@ -37,8 +41,28 @@ // user's histories histories : null, + // genome select + select_genome : null, + + // extension select + select_extension : null, + + // extension types + list_extensions :[], + + // datatype placeholder for extension auto-detection + auto: { + id : 'auto', + text : 'Auto-detect', + description : 'This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed.' + }, + + // genomes + list_genomes : [], + initialize: function(options){ this.options = _.defaults( options || {}, this.defaults ); + this.fetchExtAndGenomes(); this.render(); }, @@ -321,7 +345,7 @@ var template_modal = this.templateImportPathModal(); this.modal.show({ closing_events : true, - title : 'Enter paths relative to Galaxy root', + title : 'Please enter paths to import', body : template_modal({}), buttons : { 'Import' : function() {that.importFromPathsClicked(that);}, @@ -332,9 +356,65 @@ Galaxy.libraries.library_router.navigate('folders/' + that.id, {trigger: true}); } }); + this.renderSelectBoxes(); }, /** + * Request all extensions and genomes from Galaxy + * and save them sorted in arrays. + */ + fetchExtAndGenomes: function(){ + var that = this; + mod_utils.get(galaxy_config.root + "api/datatypes?extension_only=False", + function(datatypes) { + for (key in datatypes) { + that.list_extensions.push({ + id : datatypes[key].extension, + text : datatypes[key].extension, + description : datatypes[key].description, + description_url : datatypes[key].description_url + }); + } + that.list_extensions.sort(function(a, b) { + return a.id > b.id ? 1 : a.id < b.id ? -1 : 0; + }); + that.list_extensions.unshift(that.auto); + + }); + mod_utils.get(galaxy_config.root + "api/genomes", + function(genomes) { + for (key in genomes) { + that.list_genomes.push({ + id : genomes[key][1], + text : genomes[key][0] + }); + } + that.list_genomes.sort(function(a, b) { + return a.id > b.id ? 1 : a.id < b.id ? -1 : 0; + }); + }); + }, + + renderSelectBoxes: function(){ + // This won't work properly unlesss we already have the data fetched. + // See this.fetchExtAndGenomes() + // TODO switch to common resources: + // https://trello.com/c/dIUE9YPl/1933-ui-common-resources-and-data-into-galaxy-... + var that = this; + this.select_genome = new mod_select.View( { + css: 'genome', + data: that.list_genomes, + container: Galaxy.modal.$el.find( '#genome' ), + value: '?' + } ); + this.select_extension = new mod_select.View({ + css: 'extension', + data: that.list_extensions, + container: Galaxy.modal.$el.find('#extension'), + value: 'auto' + }); + }, + /** * Create modal for importing form user's directory * on Galaxy. Bind jQuery events. */ @@ -343,18 +423,20 @@ this.modal = Galaxy.modal; var template_modal = this.templateBrowserModal(); this.modal.show({ - closing_events : true, - title : 'Select folders or files to import', - body : template_modal({}), - buttons : { - 'Import' : function() {that.importFromUserdirClicked(that);}, - 'Close' : function() {Galaxy.modal.hide();} - }, - closing_callback: function(){ - // TODO: should not trigger routes outside of the router - Galaxy.libraries.library_router.navigate('folders/' + that.id, {trigger: true}); - } - }); + closing_events : true, + title : 'Please select folders or files', + body : template_modal({}), + buttons : { + 'Import' : function() {that.importFromUserdirClicked(that);}, + 'Close' : function() {Galaxy.modal.hide();} + }, + closing_callback: function(){ + // TODO: should not trigger routes outside of the router + Galaxy.libraries.library_router.navigate('folders/' + that.id, {trigger: true}); + } + }); + + this.renderSelectBoxes(); this.renderJstree({disabled_jstree_element: 'folders'}); $('input[type=radio]').change(function(event){ @@ -431,6 +513,8 @@ importFromPathsClicked: function(){ var preserve_dirs = this.modal.$el.find('.preserve-checkbox').is(':checked'); var link_data = this.modal.$el.find('.link-checkbox').is(':checked'); + var file_type = this.select_extension.value(); + var dbkey = this.select_genome.value(); var paths = $('textarea#import_paths').val(); var valid_paths = []; if (!paths){ @@ -445,7 +529,12 @@ } }; this.initChainCallControl( { length: valid_paths.length, action: 'adding_datasets' } ); - this.chainCallImportingFolders(valid_paths, preserve_dirs, link_data, 'admin_path'); + this.chainCallImportingFolders( { paths: valid_paths, + preserve_dirs: preserve_dirs, + link_data: link_data, + source: 'admin_path', + file_type: file_type, + dbkey: dbkey } ); } }, @@ -494,6 +583,8 @@ var selected_nodes = $( '#jstree_browser' ).jstree().get_selected( true ); var preserve_dirs = this.modal.$el.find( '.preserve-checkbox' ).is( ':checked' ); var link_data = this.modal.$el.find( '.link-checkbox' ).is( ':checked' ); + var file_type = this.select_extension.value(); + var dbkey = this.select_genome.value(); var selection_type = selected_nodes[0].type; var paths = []; if ( selected_nodes.length < 1 ){ @@ -507,9 +598,17 @@ } this.initChainCallControl( { length: paths.length, action: 'adding_datasets' } ); if ( selection_type === 'folder' ){ - this.chainCallImportingFolders( paths, preserve_dirs, link_data, 'userdir_folder' ); + + this.chainCallImportingFolders( { paths: paths, + preserve_dirs: preserve_dirs, + link_data: link_data, + source: 'userdir_folder', + file_type: file_type, + dbkey: dbkey } ); } else if ( selection_type === 'file' ){ - this.chainCallImportingUserdirFiles( paths ); + this.chainCallImportingUserdirFiles( { paths : paths, + file_type: file_type, + dbkey: dbkey } ); } } }, @@ -600,9 +699,10 @@ * calling them in chain. Update the progress bar in between each. * @param {array} paths paths relative to user folder on Galaxy */ - chainCallImportingUserdirFiles: function( paths ){ + chainCallImportingUserdirFiles: function( options ){ + var that = this; - var popped_item = paths.pop(); + var popped_item = options.paths.pop(); if ( typeof popped_item === "undefined" ) { if ( this.options.chain_call_control.failed_number === 0 ){ mod_toastr.success( 'Selected files imported into the current folder' ); @@ -614,15 +714,17 @@ } var promise = $.when( $.post( '/api/libraries/datasets?encoded_folder_id=' + that.id + '&source=userdir_file' + - '&path=' + popped_item ) ) + '&path=' + popped_item + + '&file_type=' + options.file_type + + '&dbkey=' + options.dbkey ) ) promise.done( function( response ){ that.updateProgress(); - that.chainCallImportingUserdirFiles( paths ); + that.chainCallImportingUserdirFiles( options ); } ) .fail( function(){ that.options.chain_call_control.failed_number += 1; that.updateProgress(); - that.chainCallImportingUserdirFiles( paths ); + that.chainCallImportingUserdirFiles( options ); } ); }, @@ -635,10 +737,10 @@ * @param {str} source string representing what type of folder * is the source of import */ - chainCallImportingFolders: function(paths, preserve_dirs, link_data, source){ - // need to check which paths to call + chainCallImportingFolders: function( options ){ + // TODO need to check which paths to call var that = this; - var popped_item = paths.pop(); + var popped_item = options.paths.pop(); if (typeof popped_item == "undefined") { if (this.options.chain_call_control.failed_number === 0){ mod_toastr.success('Selected folders and their contents imported into the current folder.'); @@ -649,19 +751,31 @@ } return true; } - var promise = $.when($.post('/api/libraries/datasets?encoded_folder_id=' + that.id + - '&source=' + source + - '&path=' + popped_item + - '&preserve_dirs=' + preserve_dirs + - '&link_data=' + link_data)) + var promise = $.when( $.post( '/api/libraries/datasets?encoded_folder_id=' + that.id + + '&source=' + options.source + + '&path=' + popped_item + + '&preserve_dirs=' + options.preserve_dirs + + '&link_data=' + options.link_data + + '&file_type=' + options.file_type + + '&dbkey=' + options.dbkey ) ) promise.done(function(response){ that.updateProgress(); - that.chainCallImportingFolders(paths, preserve_dirs, link_data, source); + that.chainCallImportingFolders( { paths: options.paths, + preserve_dirs: options.preserve_dirs, + link_data: options.link_data, + source: options.source, + file_type: options.file_type, + dbkey: options.dbkey } ); }) .fail(function(){ that.options.chain_call_control.failed_number += 1; that.updateProgress(); - that.chainCallImportingFolders(paths, preserve_dirs, link_data, source); + that.chainCallImportingFolders( { paths: options.paths, + preserve_dirs: options.preserve_dirs, + link_data: options.link_data, + source: options.source, + file_type: options.file_type, + dbkey: options.dbkey } ); }); }, @@ -1012,7 +1126,10 @@ var tmpl_array = []; tmpl_array.push('<div id="file_browser_modal">'); + tmpl_array.push('<div class="alert alert-info jstree-files-message">All files you select will be imported into the current folder.</div>'); + tmpl_array.push('<div class="alert alert-info jstree-folders-message" style="display:none;">All files within the selected folders and their subfolders will be imported into the current folder.</div>'); + tmpl_array.push('<div style="margin-bottom:1em;">'); tmpl_array.push('<label class="radio-inline">'); tmpl_array.push(' <input title="Switch to selecting files" type="radio" name="jstree-radio" value="jstree-disable-folders" checked="checked"> Files'); @@ -1020,22 +1137,25 @@ tmpl_array.push('<label class="radio-inline">'); tmpl_array.push(' <input title="Switch to selecting folders" type="radio" name="jstree-radio" value="jstree-disable-files"> Folders'); tmpl_array.push('</label>'); - + tmpl_array.push('</div>'); + tmpl_array.push('<div style="margin-bottom:1em;">'); tmpl_array.push('<label class="checkbox-inline jstree-preserve-structure" style="display:none;">'); tmpl_array.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">'); tmpl_array.push('Preserve directory structure'); tmpl_array.push(' </label>'); - tmpl_array.push('<label class="checkbox-inline jstree-link-files" style="display:none;">'); tmpl_array.push(' <input class="link-checkbox" type="checkbox" value="link_files">'); tmpl_array.push('Link files instead of copying'); tmpl_array.push(' </label>'); tmpl_array.push('</div>'); + tmpl_array.push('<div id="jstree_browser">'); + tmpl_array.push('</div>'); - tmpl_array.push('<div class="alert alert-info jstree-files-message">All files you select will be imported into the current folder.</div>'); - tmpl_array.push('<div class="alert alert-info jstree-folders-message" style="display:none;">All files within the selected folders and their subfolders will be imported into the current folder.</div>'); - - tmpl_array.push('<div id="jstree_browser">'); + tmpl_array.push('<hr />'); + tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>'); + tmpl_array.push('<div>'); + tmpl_array.push('Type: <span id="extension" class="extension" />'); + tmpl_array.push(' Genome: <span id="genome" class="genome" />'); tmpl_array.push('</div>'); tmpl_array.push('</div>'); @@ -1046,21 +1166,28 @@ var tmpl_array = []; tmpl_array.push('<div id="file_browser_modal">'); + tmpl_array.push('<div class="alert alert-info jstree-folders-message">All files within the given folders and their subfolders will be imported into the current folder.</div>'); + tmpl_array.push('<div style="margin-bottom: 0.5em;">'); tmpl_array.push('<label class="checkbox-inline jstree-preserve-structure">'); tmpl_array.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">'); tmpl_array.push('Preserve directory structure'); tmpl_array.push(' </label>'); - tmpl_array.push('<label class="checkbox-inline jstree-link-files">'); tmpl_array.push(' <input class="link-checkbox" type="checkbox" value="link_files">'); tmpl_array.push('Link files instead of copying'); tmpl_array.push(' </label>'); tmpl_array.push('</div>'); - tmpl_array.push('<div class="alert alert-info jstree-folders-message">All files within the given folders and their subfolders will be imported into the current folder.</div>'); + tmpl_array.push('<textarea id="import_paths" class="form-control" rows="5" placeholder="Absolute paths (or paths relative to Galaxy root) separated by newline"></textarea>'); - tmpl_array.push('<textarea id="import_paths" class="form-control" rows="5" placeholder="Paths separated by newline"></textarea>'); + tmpl_array.push('<hr />'); + tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>'); + tmpl_array.push('<div>'); + tmpl_array.push('Type: <span id="extension" class="extension" />'); + tmpl_array.push(' Genome: <span id="genome" class="genome" />'); + tmpl_array.push('</div>'); + tmpl_array.push('</div>'); return _.template(tmpl_array.join('')); diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa client/galaxy/scripts/mvc/ui/ui-select.js --- a/client/galaxy/scripts/mvc/ui/ui-select.js +++ b/client/galaxy/scripts/mvc/ui/ui-select.js @@ -155,6 +155,8 @@ data : this.select_data, containerCssClass : this.options.css, placeholder : this.options.placeholder, + width : 'resolve', + dropdownAutoWidth : true }; this.$el.select2(select_opt); // select previous value (if exists) diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa lib/galaxy/visualization/registry.py --- a/lib/galaxy/visualization/registry.py +++ b/lib/galaxy/visualization/registry.py @@ -159,7 +159,7 @@ # config file is required, otherwise skip this visualization plugin[ 'config_file' ] = os.path.join( plugin_path, 'config', ( plugin.name + '.xml' ) ) config = self.config_parser.parse_file( plugin.config_file ) - + if not config: return None plugin[ 'config' ] = config @@ -390,14 +390,9 @@ Parse the given XML file for visualizations data. :returns: visualization config dictionary """ - try: - xml_tree = galaxy.util.parse_xml( xml_filepath ) - visualization = self.parse_visualization( xml_tree.getroot() ) - return visualization - # skip vis' with parsing errors - don't shutdown the startup - except ParsingException, parse_exc: - log.exception( 'Skipped visualization config "%s" due to parsing errors', xml_filepath ) - return None + xml_tree = galaxy.util.parse_xml( xml_filepath ) + visualization = self.parse_visualization( xml_tree.getroot() ) + return visualization def parse_visualization( self, xml_tree ): """ @@ -406,16 +401,16 @@ """ returned = {} - # allow manually turning off a vis by checking for a disabled property - if 'disabled' in xml_tree.attrib: -#TODO: differentiate between disabled and failed to parse, log.warn only on failure, log.info otherwise - return None - # a text display name for end user links returned[ 'name' ] = xml_tree.attrib.get( 'name', None ) if not returned[ 'name' ]: raise ParsingException( 'visualization needs a name attribute' ) + # allow manually turning off a vis by checking for a disabled property + if 'disabled' in xml_tree.attrib: + log.info( '%s, plugin disabled: %s. Skipping...', self, returned[ 'name' ] ) + return None + # record the embeddable flag - defaults to false # this is a design by contract promise that the visualization can be rendered inside another page # often by rendering only a DOM fragment. Since this is an advanced feature that requires a bit more diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa lib/galaxy/web/base/pluginframework.py --- a/lib/galaxy/web/base/pluginframework.py +++ b/lib/galaxy/web/base/pluginframework.py @@ -118,15 +118,14 @@ for plugin_path in self.find_plugins(): try: plugin = self.load_plugin( plugin_path ) - if not plugin: - log.warn( '%s, plugin load failed or disabled: %s. Skipping...', self, plugin_path ) + + if plugin and plugin.name not in self.plugins: + self.plugins[ plugin.name ] = plugin + log.info( '%s, loaded plugin: %s', self, plugin.name ) #NOTE: prevent silent, implicit overwrite here (two plugins in two diff directories) #TODO: overwriting may be desired - elif plugin.name in self.plugins: + elif plugin and plugin.name in self.plugins: log.warn( '%s, plugin with name already exists: %s. Skipping...', self, plugin.name ) - else: - self.plugins[ plugin.name ] = plugin - log.info( '%s, loaded plugin: %s', self, plugin.name ) except Exception, exc: if not self.skip_bad_plugins: diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa lib/galaxy/webapps/galaxy/api/lda_datasets.py --- a/lib/galaxy/webapps/galaxy/api/lda_datasets.py +++ b/lib/galaxy/webapps/galaxy/api/lda_datasets.py @@ -414,9 +414,9 @@ kwd[ 'space_to_tab' ] = 'False' kwd[ 'to_posix_lines' ] = 'True' - kwd[ 'dbkey' ] = '?' - kwd[ 'file_type' ] = 'auto' - + + kwd[ 'dbkey' ] = kwd.get( 'dbkey', '?' ) + kwd[ 'file_type' ] = kwd.get( 'file_type', 'auto' ) kwd[' link_data_only' ] = 'link_to_files' if util.string_as_bool( kwd.get( 'link_data', False ) ) else 'copy_files' encoded_folder_id = kwd.get( 'encoded_folder_id', None ) if encoded_folder_id is not None: @@ -473,9 +473,6 @@ trans, 'api', params, os.path.basename( file ), file, 'server_dir', library_bunch ) ) # user wants to import whole folder if source == "userdir_folder": - # import_folder_root = [next(part for part in path.split(os.path.sep) if part) for path in [os.path.splitdrive(path_to_root_import_folder)[1]]] - # new_folder = self.folder_manager.create( trans, folder_id, import_folder_root[0] ) - uploaded_datasets_bunch = trans.webapp.controllers[ 'library_common' ].get_path_paste_uploaded_datasets( trans, 'api', params, library_bunch, 200, '' ) uploaded_datasets = uploaded_datasets_bunch[0] @@ -495,7 +492,6 @@ for ud in uploaded_datasets: ud.path = os.path.abspath( ud.path ) abspath_datasets.append( ud ) - json_file_path = upload_common.create_paramfile( trans, abspath_datasets ) data_list = [ ud.data for ud in abspath_datasets ] job, output = upload_common.create_job( trans, tool_params, tool, json_file_path, data_list, folder=folder ) diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa static/scripts/galaxy.base.js --- a/static/scripts/galaxy.base.js +++ b/static/scripts/galaxy.base.js @@ -237,7 +237,8 @@ $.fn.refresh_select2 = function() { var select_elt = $(this); var options = { width: "resolve", - closeOnSelect: !select_elt.is("[MULTIPLE]") + closeOnSelect: !select_elt.is("[MULTIPLE]"), + dropdownAutoWidth : true }; return select_elt.select2( options ); } diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa static/scripts/mvc/library/library-folderlist-view.js --- a/static/scripts/mvc/library/library-folderlist-view.js +++ b/static/scripts/mvc/library/library-folderlist-view.js @@ -1,4 +1,3 @@ -// dependencies define([ "galaxy.masthead", "utils/utils", diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa static/scripts/mvc/library/library-foldertoolbar-view.js --- a/static/scripts/mvc/library/library-foldertoolbar-view.js +++ b/static/scripts/mvc/library/library-foldertoolbar-view.js @@ -2,11 +2,15 @@ "galaxy.masthead", "utils/utils", "libs/toastr", - "mvc/library/library-model"], + "mvc/library/library-model", + "mvc/ui/ui-select" + ], function( mod_masthead, - mod_utils, - mod_toastr, - mod_library_model ) { + mod_utils, + mod_toastr, + mod_library_model, + mod_select + ){ var FolderToolbarView = Backbone.View.extend({ el: '#center', @@ -37,8 +41,28 @@ // user's histories histories : null, + // genome select + select_genome : null, + + // extension select + select_extension : null, + + // extension types + list_extensions :[], + + // datatype placeholder for extension auto-detection + auto: { + id : 'auto', + text : 'Auto-detect', + description : 'This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed.' + }, + + // genomes + list_genomes : [], + initialize: function(options){ this.options = _.defaults( options || {}, this.defaults ); + this.fetchExtAndGenomes(); this.render(); }, @@ -321,7 +345,7 @@ var template_modal = this.templateImportPathModal(); this.modal.show({ closing_events : true, - title : 'Enter paths relative to Galaxy root', + title : 'Please enter paths to import', body : template_modal({}), buttons : { 'Import' : function() {that.importFromPathsClicked(that);}, @@ -332,9 +356,65 @@ Galaxy.libraries.library_router.navigate('folders/' + that.id, {trigger: true}); } }); + this.renderSelectBoxes(); }, /** + * Request all extensions and genomes from Galaxy + * and save them sorted in arrays. + */ + fetchExtAndGenomes: function(){ + var that = this; + mod_utils.get(galaxy_config.root + "api/datatypes?extension_only=False", + function(datatypes) { + for (key in datatypes) { + that.list_extensions.push({ + id : datatypes[key].extension, + text : datatypes[key].extension, + description : datatypes[key].description, + description_url : datatypes[key].description_url + }); + } + that.list_extensions.sort(function(a, b) { + return a.id > b.id ? 1 : a.id < b.id ? -1 : 0; + }); + that.list_extensions.unshift(that.auto); + + }); + mod_utils.get(galaxy_config.root + "api/genomes", + function(genomes) { + for (key in genomes) { + that.list_genomes.push({ + id : genomes[key][1], + text : genomes[key][0] + }); + } + that.list_genomes.sort(function(a, b) { + return a.id > b.id ? 1 : a.id < b.id ? -1 : 0; + }); + }); + }, + + renderSelectBoxes: function(){ + // This won't work properly unlesss we already have the data fetched. + // See this.fetchExtAndGenomes() + // TODO switch to common resources: + // https://trello.com/c/dIUE9YPl/1933-ui-common-resources-and-data-into-galaxy-... + var that = this; + this.select_genome = new mod_select.View( { + css: 'genome', + data: that.list_genomes, + container: Galaxy.modal.$el.find( '#genome' ), + value: '?' + } ); + this.select_extension = new mod_select.View({ + css: 'extension', + data: that.list_extensions, + container: Galaxy.modal.$el.find('#extension'), + value: 'auto' + }); + }, + /** * Create modal for importing form user's directory * on Galaxy. Bind jQuery events. */ @@ -343,18 +423,20 @@ this.modal = Galaxy.modal; var template_modal = this.templateBrowserModal(); this.modal.show({ - closing_events : true, - title : 'Select folders or files to import', - body : template_modal({}), - buttons : { - 'Import' : function() {that.importFromUserdirClicked(that);}, - 'Close' : function() {Galaxy.modal.hide();} - }, - closing_callback: function(){ - // TODO: should not trigger routes outside of the router - Galaxy.libraries.library_router.navigate('folders/' + that.id, {trigger: true}); - } - }); + closing_events : true, + title : 'Please select folders or files', + body : template_modal({}), + buttons : { + 'Import' : function() {that.importFromUserdirClicked(that);}, + 'Close' : function() {Galaxy.modal.hide();} + }, + closing_callback: function(){ + // TODO: should not trigger routes outside of the router + Galaxy.libraries.library_router.navigate('folders/' + that.id, {trigger: true}); + } + }); + + this.renderSelectBoxes(); this.renderJstree({disabled_jstree_element: 'folders'}); $('input[type=radio]').change(function(event){ @@ -431,6 +513,8 @@ importFromPathsClicked: function(){ var preserve_dirs = this.modal.$el.find('.preserve-checkbox').is(':checked'); var link_data = this.modal.$el.find('.link-checkbox').is(':checked'); + var file_type = this.select_extension.value(); + var dbkey = this.select_genome.value(); var paths = $('textarea#import_paths').val(); var valid_paths = []; if (!paths){ @@ -445,7 +529,12 @@ } }; this.initChainCallControl( { length: valid_paths.length, action: 'adding_datasets' } ); - this.chainCallImportingFolders(valid_paths, preserve_dirs, link_data, 'admin_path'); + this.chainCallImportingFolders( { paths: valid_paths, + preserve_dirs: preserve_dirs, + link_data: link_data, + source: 'admin_path', + file_type: file_type, + dbkey: dbkey } ); } }, @@ -494,6 +583,8 @@ var selected_nodes = $( '#jstree_browser' ).jstree().get_selected( true ); var preserve_dirs = this.modal.$el.find( '.preserve-checkbox' ).is( ':checked' ); var link_data = this.modal.$el.find( '.link-checkbox' ).is( ':checked' ); + var file_type = this.select_extension.value(); + var dbkey = this.select_genome.value(); var selection_type = selected_nodes[0].type; var paths = []; if ( selected_nodes.length < 1 ){ @@ -507,9 +598,17 @@ } this.initChainCallControl( { length: paths.length, action: 'adding_datasets' } ); if ( selection_type === 'folder' ){ - this.chainCallImportingFolders( paths, preserve_dirs, link_data, 'userdir_folder' ); + + this.chainCallImportingFolders( { paths: paths, + preserve_dirs: preserve_dirs, + link_data: link_data, + source: 'userdir_folder', + file_type: file_type, + dbkey: dbkey } ); } else if ( selection_type === 'file' ){ - this.chainCallImportingUserdirFiles( paths ); + this.chainCallImportingUserdirFiles( { paths : paths, + file_type: file_type, + dbkey: dbkey } ); } } }, @@ -600,9 +699,10 @@ * calling them in chain. Update the progress bar in between each. * @param {array} paths paths relative to user folder on Galaxy */ - chainCallImportingUserdirFiles: function( paths ){ + chainCallImportingUserdirFiles: function( options ){ + var that = this; - var popped_item = paths.pop(); + var popped_item = options.paths.pop(); if ( typeof popped_item === "undefined" ) { if ( this.options.chain_call_control.failed_number === 0 ){ mod_toastr.success( 'Selected files imported into the current folder' ); @@ -614,15 +714,17 @@ } var promise = $.when( $.post( '/api/libraries/datasets?encoded_folder_id=' + that.id + '&source=userdir_file' + - '&path=' + popped_item ) ) + '&path=' + popped_item + + '&file_type=' + options.file_type + + '&dbkey=' + options.dbkey ) ) promise.done( function( response ){ that.updateProgress(); - that.chainCallImportingUserdirFiles( paths ); + that.chainCallImportingUserdirFiles( options ); } ) .fail( function(){ that.options.chain_call_control.failed_number += 1; that.updateProgress(); - that.chainCallImportingUserdirFiles( paths ); + that.chainCallImportingUserdirFiles( options ); } ); }, @@ -635,10 +737,10 @@ * @param {str} source string representing what type of folder * is the source of import */ - chainCallImportingFolders: function(paths, preserve_dirs, link_data, source){ - // need to check which paths to call + chainCallImportingFolders: function( options ){ + // TODO need to check which paths to call var that = this; - var popped_item = paths.pop(); + var popped_item = options.paths.pop(); if (typeof popped_item == "undefined") { if (this.options.chain_call_control.failed_number === 0){ mod_toastr.success('Selected folders and their contents imported into the current folder.'); @@ -649,19 +751,31 @@ } return true; } - var promise = $.when($.post('/api/libraries/datasets?encoded_folder_id=' + that.id + - '&source=' + source + - '&path=' + popped_item + - '&preserve_dirs=' + preserve_dirs + - '&link_data=' + link_data)) + var promise = $.when( $.post( '/api/libraries/datasets?encoded_folder_id=' + that.id + + '&source=' + options.source + + '&path=' + popped_item + + '&preserve_dirs=' + options.preserve_dirs + + '&link_data=' + options.link_data + + '&file_type=' + options.file_type + + '&dbkey=' + options.dbkey ) ) promise.done(function(response){ that.updateProgress(); - that.chainCallImportingFolders(paths, preserve_dirs, link_data, source); + that.chainCallImportingFolders( { paths: options.paths, + preserve_dirs: options.preserve_dirs, + link_data: options.link_data, + source: options.source, + file_type: options.file_type, + dbkey: options.dbkey } ); }) .fail(function(){ that.options.chain_call_control.failed_number += 1; that.updateProgress(); - that.chainCallImportingFolders(paths, preserve_dirs, link_data, source); + that.chainCallImportingFolders( { paths: options.paths, + preserve_dirs: options.preserve_dirs, + link_data: options.link_data, + source: options.source, + file_type: options.file_type, + dbkey: options.dbkey } ); }); }, @@ -1012,7 +1126,10 @@ var tmpl_array = []; tmpl_array.push('<div id="file_browser_modal">'); + tmpl_array.push('<div class="alert alert-info jstree-files-message">All files you select will be imported into the current folder.</div>'); + tmpl_array.push('<div class="alert alert-info jstree-folders-message" style="display:none;">All files within the selected folders and their subfolders will be imported into the current folder.</div>'); + tmpl_array.push('<div style="margin-bottom:1em;">'); tmpl_array.push('<label class="radio-inline">'); tmpl_array.push(' <input title="Switch to selecting files" type="radio" name="jstree-radio" value="jstree-disable-folders" checked="checked"> Files'); @@ -1020,22 +1137,25 @@ tmpl_array.push('<label class="radio-inline">'); tmpl_array.push(' <input title="Switch to selecting folders" type="radio" name="jstree-radio" value="jstree-disable-files"> Folders'); tmpl_array.push('</label>'); - + tmpl_array.push('</div>'); + tmpl_array.push('<div style="margin-bottom:1em;">'); tmpl_array.push('<label class="checkbox-inline jstree-preserve-structure" style="display:none;">'); tmpl_array.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">'); tmpl_array.push('Preserve directory structure'); tmpl_array.push(' </label>'); - tmpl_array.push('<label class="checkbox-inline jstree-link-files" style="display:none;">'); tmpl_array.push(' <input class="link-checkbox" type="checkbox" value="link_files">'); tmpl_array.push('Link files instead of copying'); tmpl_array.push(' </label>'); tmpl_array.push('</div>'); + tmpl_array.push('<div id="jstree_browser">'); + tmpl_array.push('</div>'); - tmpl_array.push('<div class="alert alert-info jstree-files-message">All files you select will be imported into the current folder.</div>'); - tmpl_array.push('<div class="alert alert-info jstree-folders-message" style="display:none;">All files within the selected folders and their subfolders will be imported into the current folder.</div>'); - - tmpl_array.push('<div id="jstree_browser">'); + tmpl_array.push('<hr />'); + tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>'); + tmpl_array.push('<div>'); + tmpl_array.push('Type: <span id="extension" class="extension" />'); + tmpl_array.push(' Genome: <span id="genome" class="genome" />'); tmpl_array.push('</div>'); tmpl_array.push('</div>'); @@ -1046,21 +1166,28 @@ var tmpl_array = []; tmpl_array.push('<div id="file_browser_modal">'); + tmpl_array.push('<div class="alert alert-info jstree-folders-message">All files within the given folders and their subfolders will be imported into the current folder.</div>'); + tmpl_array.push('<div style="margin-bottom: 0.5em;">'); tmpl_array.push('<label class="checkbox-inline jstree-preserve-structure">'); tmpl_array.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">'); tmpl_array.push('Preserve directory structure'); tmpl_array.push(' </label>'); - tmpl_array.push('<label class="checkbox-inline jstree-link-files">'); tmpl_array.push(' <input class="link-checkbox" type="checkbox" value="link_files">'); tmpl_array.push('Link files instead of copying'); tmpl_array.push(' </label>'); tmpl_array.push('</div>'); - tmpl_array.push('<div class="alert alert-info jstree-folders-message">All files within the given folders and their subfolders will be imported into the current folder.</div>'); + tmpl_array.push('<textarea id="import_paths" class="form-control" rows="5" placeholder="Absolute paths (or paths relative to Galaxy root) separated by newline"></textarea>'); - tmpl_array.push('<textarea id="import_paths" class="form-control" rows="5" placeholder="Paths separated by newline"></textarea>'); + tmpl_array.push('<hr />'); + tmpl_array.push('<p>You can set extension type and genome for all imported datasets at once:</p>'); + tmpl_array.push('<div>'); + tmpl_array.push('Type: <span id="extension" class="extension" />'); + tmpl_array.push(' Genome: <span id="genome" class="genome" />'); + tmpl_array.push('</div>'); + tmpl_array.push('</div>'); return _.template(tmpl_array.join('')); diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa static/scripts/mvc/ui/ui-select.js --- a/static/scripts/mvc/ui/ui-select.js +++ b/static/scripts/mvc/ui/ui-select.js @@ -155,6 +155,8 @@ data : this.select_data, containerCssClass : this.options.css, placeholder : this.options.placeholder, + width : 'resolve', + dropdownAutoWidth : true }; this.$el.select2(select_opt); // select previous value (if exists) diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa static/scripts/packed/galaxy.base.js --- a/static/scripts/packed/galaxy.base.js +++ b/static/scripts/packed/galaxy.base.js @@ -1,1 +1,1 @@ -(function(){var b=0;var c=["ms","moz","webkit","o"];for(var a=0;a<c.length&&!window.requestAnimationFrame;++a){window.requestAnimationFrame=window[c[a]+"RequestAnimationFrame"];window.cancelRequestAnimationFrame=window[c[a]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame){window.requestAnimationFrame=function(h,e){var d=new Date().getTime();var f=Math.max(0,16-(d-b));var g=window.setTimeout(function(){h(d+f)},f);b=d+f;return g}}if(!window.cancelAnimationFrame){window.cancelAnimationFrame=function(d){clearTimeout(d)}}}());if(!Array.indexOf){Array.prototype.indexOf=function(c){for(var b=0,a=this.length;b<a;b++){if(this[b]==c){return b}}return -1}}function obj_length(c){if(c.length!==undefined){return c.length}var b=0;for(var a in c){b++}return b}$.fn.makeAbsolute=function(a){return this.each(function(){var b=$(this);var c=b.position();b.css({position:"absolute",marginLeft:0,marginTop:0,top:c.top,left:c.left,right:$(window).width()-(c.left+b.width())});if(a){b.remove().appendTo("body")}})};function make_popupmenu(b,c){var a=(b.data("menu_options"));b.data("menu_options",c);if(a){return}b.bind("click.show_popup",function(d){$(".popmenu-wrapper").remove();setTimeout(function(){var g=$("<ul class='dropdown-menu' id='"+b.attr("id")+"-menu'></ul>");var f=b.data("menu_options");if(obj_length(f)<=0){$("<li>No Options.</li>").appendTo(g)}$.each(f,function(j,i){if(i){var l=i.action||i;g.append($("<li></li>").append($("<a>").attr("href",i.url).html(j).click(l)))}else{g.append($("<li></li>").addClass("head").append($("<a href='#'></a>").html(j)))}});var h=$("<div class='popmenu-wrapper' style='position: absolute;left: 0; top: -1000;'></div>").append(g).appendTo("body");var e=d.pageX-h.width()/2;e=Math.min(e,$(document).scrollLeft()+$(window).width()-$(h).width()-5);e=Math.max(e,$(document).scrollLeft()+5);h.css({top:d.pageY,left:e})},10);setTimeout(function(){var f=function(h){$(h).bind("click.close_popup",function(){$(".popmenu-wrapper").remove();h.unbind("click.close_popup")})};f($(window.document));f($(window.top.document));for(var e=window.top.frames.length;e--;){var g=$(window.top.frames[e].document);f(g)}},50);return false})}function make_popup_menus(a){a=a||document;$(a).find("div[popupmenu]").each(function(){var b={};var d=$(this);d.find("a").each(function(){var g=$(this),i=g.get(0),e=i.getAttribute("confirm"),f=i.getAttribute("href"),h=i.getAttribute("target");if(!f){b[g.text()]=null}else{b[g.text()]={url:f,action:function(){if(!e||confirm(e)){if(h){window.open(f,h);return false}else{g.click()}}}}}});var c=$(a).find("#"+d.attr("popupmenu"));c.find("a").bind("click",function(f){f.stopPropagation();return true});make_popupmenu(c,b);c.addClass("popup");d.remove()})}function naturalSort(j,h){var p=/(-?[0-9\.]+)/g,k=j.toString().toLowerCase()||"",g=h.toString().toLowerCase()||"",l=String.fromCharCode(0),n=k.replace(p,l+"$1"+l).split(l),e=g.replace(p,l+"$1"+l).split(l),d=(new Date(k)).getTime(),o=d?(new Date(g)).getTime():null;if(o){if(d<o){return -1}else{if(d>o){return 1}}}var m,f;for(var i=0,c=Math.max(n.length,e.length);i<c;i++){m=parseFloat(n[i])||n[i];f=parseFloat(e[i])||e[i];if(m<f){return -1}else{if(m>f){return 1}}}return 0}$.fn.refresh_select2=function(){var b=$(this);var a={width:"resolve",closeOnSelect:!b.is("[MULTIPLE]")};return b.select2(a)};function replace_big_select_inputs(a,c,b){if(!jQuery.fn.select2){return}if(a===undefined){a=20}if(c===undefined){c=3000}b=b||$("select");b.each(function(){var e=$(this).not("[multiple]");var d=e.find("option").length;if((d<a)||(d>c)){return}if(e.hasClass("no-autocomplete")){return}e.refresh_select2()})}$.fn.make_text_editable=function(g){var d=("num_cols" in g?g.num_cols:30),c=("num_rows" in g?g.num_rows:4),e=("use_textarea" in g?g.use_textarea:false),b=("on_finish" in g?g.on_finish:null),f=("help_text" in g?g.help_text:null);var a=$(this);a.addClass("editable-text").click(function(l){if($(this).children(":input").length>0){return}a.removeClass("editable-text");var i=function(m){a.find(":input").remove();if(m!==""){a.text(m)}else{a.html("<br>")}a.addClass("editable-text");if(b){b(m)}};var h=("cur_text" in g?g.cur_text:a.text()),k,j;if(e){k=$("<textarea/>").attr({rows:c,cols:d}).text($.trim(h)).keyup(function(m){if(m.keyCode===27){i(h)}});j=$("<button/>").text("Done").click(function(){i(k.val());return false})}else{k=$("<input type='text'/>").attr({value:$.trim(h),size:d}).blur(function(){i(h)}).keyup(function(m){if(m.keyCode===27){$(this).trigger("blur")}else{if(m.keyCode===13){i($(this).val())}}m.stopPropagation()})}a.text("");a.append(k);if(j){a.append(j)}k.focus();k.select();l.stopPropagation()});if(f){a.attr("title",f).tooltip()}return a};function async_save_text(d,f,e,a,c,h,i,g,b){if(c===undefined){c=30}if(i===undefined){i=4}$("#"+d).click(function(){if($("#renaming-active").length>0){return}var l=$("#"+f),k=l.text(),j;if(h){j=$("<textarea></textarea>").attr({rows:i,cols:c}).text($.trim(k))}else{j=$("<input type='text'></input>").attr({value:$.trim(k),size:c})}j.attr("id","renaming-active");j.blur(function(){$(this).remove();l.show();if(b){b(j)}});j.keyup(function(n){if(n.keyCode===27){$(this).trigger("blur")}else{if(n.keyCode===13){var m={};m[a]=$(this).val();$(this).trigger("blur");$.ajax({url:e,data:m,error:function(){alert("Text editing for elt "+f+" failed")},success:function(o){if(o!==""){l.text(o)}else{l.html("<em>None</em>")}if(b){b(j)}}})}}});if(g){g(j)}l.hide();j.insertAfter(l);j.focus();j.select();return})}function commatize(b){b+="";var a=/(\d+)(\d{3})/;while(a.test(b)){b=b.replace(a,"$1,$2")}return b}function reset_tool_search(a){var c=$("#galaxy_tools").contents();if(c.length===0){c=$(document)}$(this).removeClass("search_active");c.find(".toolTitle").removeClass("search_match");c.find(".toolSectionBody").hide();c.find(".toolTitle").show();c.find(".toolPanelLabel").show();c.find(".toolSectionWrapper").each(function(){if($(this).attr("id")!=="recently_used_wrapper"){$(this).show()}else{if($(this).hasClass("user_pref_visible")){$(this).show()}}});c.find("#search-no-results").hide();c.find("#search-spinner").hide();if(a){var b=c.find("#tool-search-query");b.val("search tools")}}var GalaxyAsync=function(a){this.url_dict={};this.log_action=(a===undefined?false:a)};GalaxyAsync.prototype.set_func_url=function(a,b){this.url_dict[a]=b};GalaxyAsync.prototype.set_user_pref=function(a,b){var c=this.url_dict[arguments.callee];if(c===undefined){return false}$.ajax({url:c,data:{pref_name:a,pref_value:b},error:function(){return false},success:function(){return true}})};GalaxyAsync.prototype.log_user_action=function(c,b,d){if(!this.log_action){return}var a=this.url_dict[arguments.callee];if(a===undefined){return false}$.ajax({url:a,data:{action:c,context:b,params:d},error:function(){return false},success:function(){return true}})};function init_refresh_on_change(){$("select[refresh_on_change='true']").off("change").change(function(){var a=$(this),e=a.val(),d=false,c=a.attr("refresh_on_change_values");if(c){c=c.split(",");var b=a.attr("last_selected_value");if($.inArray(e,c)===-1&&$.inArray(b,c)===-1){return}}$(window).trigger("refresh_on_change");$(document).trigger("convert_to_values");a.get(0).form.submit()});$(":checkbox[refresh_on_change='true']").off("click").click(function(){var a=$(this),e=a.val(),d=false,c=a.attr("refresh_on_change_values");if(c){c=c.split(",");var b=a.attr("last_selected_value");if($.inArray(e,c)===-1&&$.inArray(b,c)===-1){return}}$(window).trigger("refresh_on_change");a.get(0).form.submit()});$("a[confirm]").off("click").click(function(){return confirm($(this).attr("confirm"))})}jQuery.fn.preventDoubleSubmission=function(){$(this).on("submit",function(b){var a=$(this);if(a.data("submitted")===true){b.preventDefault()}else{a.data("submitted",true)}});return this};$(document).ready(function(){init_refresh_on_change();if($.fn.tooltip){$(".unified-panel-header [title]").tooltip({placement:"bottom"});$("[title]").tooltip()}make_popup_menus();replace_big_select_inputs(20,1500);$("a").click(function(){var b=$(this);var c=(parent.frames&&parent.frames.galaxy_main);if((b.attr("target")=="galaxy_main")&&(!c)){var a=b.attr("href");if(a.indexOf("?")==-1){a+="?"}else{a+="&"}a+="use_panels=True";b.attr("href",a);b.attr("target","_self")}return b})}); \ No newline at end of file +(function(){var b=0;var c=["ms","moz","webkit","o"];for(var a=0;a<c.length&&!window.requestAnimationFrame;++a){window.requestAnimationFrame=window[c[a]+"RequestAnimationFrame"];window.cancelRequestAnimationFrame=window[c[a]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame){window.requestAnimationFrame=function(h,e){var d=new Date().getTime();var f=Math.max(0,16-(d-b));var g=window.setTimeout(function(){h(d+f)},f);b=d+f;return g}}if(!window.cancelAnimationFrame){window.cancelAnimationFrame=function(d){clearTimeout(d)}}}());if(!Array.indexOf){Array.prototype.indexOf=function(c){for(var b=0,a=this.length;b<a;b++){if(this[b]==c){return b}}return -1}}function obj_length(c){if(c.length!==undefined){return c.length}var b=0;for(var a in c){b++}return b}$.fn.makeAbsolute=function(a){return this.each(function(){var b=$(this);var c=b.position();b.css({position:"absolute",marginLeft:0,marginTop:0,top:c.top,left:c.left,right:$(window).width()-(c.left+b.width())});if(a){b.remove().appendTo("body")}})};function make_popupmenu(b,c){var a=(b.data("menu_options"));b.data("menu_options",c);if(a){return}b.bind("click.show_popup",function(d){$(".popmenu-wrapper").remove();setTimeout(function(){var g=$("<ul class='dropdown-menu' id='"+b.attr("id")+"-menu'></ul>");var f=b.data("menu_options");if(obj_length(f)<=0){$("<li>No Options.</li>").appendTo(g)}$.each(f,function(j,i){if(i){var l=i.action||i;g.append($("<li></li>").append($("<a>").attr("href",i.url).html(j).click(l)))}else{g.append($("<li></li>").addClass("head").append($("<a href='#'></a>").html(j)))}});var h=$("<div class='popmenu-wrapper' style='position: absolute;left: 0; top: -1000;'></div>").append(g).appendTo("body");var e=d.pageX-h.width()/2;e=Math.min(e,$(document).scrollLeft()+$(window).width()-$(h).width()-5);e=Math.max(e,$(document).scrollLeft()+5);h.css({top:d.pageY,left:e})},10);setTimeout(function(){var f=function(h){$(h).bind("click.close_popup",function(){$(".popmenu-wrapper").remove();h.unbind("click.close_popup")})};f($(window.document));f($(window.top.document));for(var e=window.top.frames.length;e--;){var g=$(window.top.frames[e].document);f(g)}},50);return false})}function make_popup_menus(a){a=a||document;$(a).find("div[popupmenu]").each(function(){var b={};var d=$(this);d.find("a").each(function(){var g=$(this),i=g.get(0),e=i.getAttribute("confirm"),f=i.getAttribute("href"),h=i.getAttribute("target");if(!f){b[g.text()]=null}else{b[g.text()]={url:f,action:function(){if(!e||confirm(e)){if(h){window.open(f,h);return false}else{g.click()}}}}}});var c=$(a).find("#"+d.attr("popupmenu"));c.find("a").bind("click",function(f){f.stopPropagation();return true});make_popupmenu(c,b);c.addClass("popup");d.remove()})}function naturalSort(j,h){var p=/(-?[0-9\.]+)/g,k=j.toString().toLowerCase()||"",g=h.toString().toLowerCase()||"",l=String.fromCharCode(0),n=k.replace(p,l+"$1"+l).split(l),e=g.replace(p,l+"$1"+l).split(l),d=(new Date(k)).getTime(),o=d?(new Date(g)).getTime():null;if(o){if(d<o){return -1}else{if(d>o){return 1}}}var m,f;for(var i=0,c=Math.max(n.length,e.length);i<c;i++){m=parseFloat(n[i])||n[i];f=parseFloat(e[i])||e[i];if(m<f){return -1}else{if(m>f){return 1}}}return 0}$.fn.refresh_select2=function(){var b=$(this);var a={width:"resolve",closeOnSelect:!b.is("[MULTIPLE]"),dropdownAutoWidth:true};return b.select2(a)};function replace_big_select_inputs(a,c,b){if(!jQuery.fn.select2){return}if(a===undefined){a=20}if(c===undefined){c=3000}b=b||$("select");b.each(function(){var e=$(this).not("[multiple]");var d=e.find("option").length;if((d<a)||(d>c)){return}if(e.hasClass("no-autocomplete")){return}e.refresh_select2()})}$.fn.make_text_editable=function(g){var d=("num_cols" in g?g.num_cols:30),c=("num_rows" in g?g.num_rows:4),e=("use_textarea" in g?g.use_textarea:false),b=("on_finish" in g?g.on_finish:null),f=("help_text" in g?g.help_text:null);var a=$(this);a.addClass("editable-text").click(function(l){if($(this).children(":input").length>0){return}a.removeClass("editable-text");var i=function(m){a.find(":input").remove();if(m!==""){a.text(m)}else{a.html("<br>")}a.addClass("editable-text");if(b){b(m)}};var h=("cur_text" in g?g.cur_text:a.text()),k,j;if(e){k=$("<textarea/>").attr({rows:c,cols:d}).text($.trim(h)).keyup(function(m){if(m.keyCode===27){i(h)}});j=$("<button/>").text("Done").click(function(){i(k.val());return false})}else{k=$("<input type='text'/>").attr({value:$.trim(h),size:d}).blur(function(){i(h)}).keyup(function(m){if(m.keyCode===27){$(this).trigger("blur")}else{if(m.keyCode===13){i($(this).val())}}m.stopPropagation()})}a.text("");a.append(k);if(j){a.append(j)}k.focus();k.select();l.stopPropagation()});if(f){a.attr("title",f).tooltip()}return a};function async_save_text(d,f,e,a,c,h,i,g,b){if(c===undefined){c=30}if(i===undefined){i=4}$("#"+d).click(function(){if($("#renaming-active").length>0){return}var l=$("#"+f),k=l.text(),j;if(h){j=$("<textarea></textarea>").attr({rows:i,cols:c}).text($.trim(k))}else{j=$("<input type='text'></input>").attr({value:$.trim(k),size:c})}j.attr("id","renaming-active");j.blur(function(){$(this).remove();l.show();if(b){b(j)}});j.keyup(function(n){if(n.keyCode===27){$(this).trigger("blur")}else{if(n.keyCode===13){var m={};m[a]=$(this).val();$(this).trigger("blur");$.ajax({url:e,data:m,error:function(){alert("Text editing for elt "+f+" failed")},success:function(o){if(o!==""){l.text(o)}else{l.html("<em>None</em>")}if(b){b(j)}}})}}});if(g){g(j)}l.hide();j.insertAfter(l);j.focus();j.select();return})}function commatize(b){b+="";var a=/(\d+)(\d{3})/;while(a.test(b)){b=b.replace(a,"$1,$2")}return b}function reset_tool_search(a){var c=$("#galaxy_tools").contents();if(c.length===0){c=$(document)}$(this).removeClass("search_active");c.find(".toolTitle").removeClass("search_match");c.find(".toolSectionBody").hide();c.find(".toolTitle").show();c.find(".toolPanelLabel").show();c.find(".toolSectionWrapper").each(function(){if($(this).attr("id")!=="recently_used_wrapper"){$(this).show()}else{if($(this).hasClass("user_pref_visible")){$(this).show()}}});c.find("#search-no-results").hide();c.find("#search-spinner").hide();if(a){var b=c.find("#tool-search-query");b.val("search tools")}}var GalaxyAsync=function(a){this.url_dict={};this.log_action=(a===undefined?false:a)};GalaxyAsync.prototype.set_func_url=function(a,b){this.url_dict[a]=b};GalaxyAsync.prototype.set_user_pref=function(a,b){var c=this.url_dict[arguments.callee];if(c===undefined){return false}$.ajax({url:c,data:{pref_name:a,pref_value:b},error:function(){return false},success:function(){return true}})};GalaxyAsync.prototype.log_user_action=function(c,b,d){if(!this.log_action){return}var a=this.url_dict[arguments.callee];if(a===undefined){return false}$.ajax({url:a,data:{action:c,context:b,params:d},error:function(){return false},success:function(){return true}})};function init_refresh_on_change(){$("select[refresh_on_change='true']").off("change").change(function(){var a=$(this),e=a.val(),d=false,c=a.attr("refresh_on_change_values");if(c){c=c.split(",");var b=a.attr("last_selected_value");if($.inArray(e,c)===-1&&$.inArray(b,c)===-1){return}}$(window).trigger("refresh_on_change");$(document).trigger("convert_to_values");a.get(0).form.submit()});$(":checkbox[refresh_on_change='true']").off("click").click(function(){var a=$(this),e=a.val(),d=false,c=a.attr("refresh_on_change_values");if(c){c=c.split(",");var b=a.attr("last_selected_value");if($.inArray(e,c)===-1&&$.inArray(b,c)===-1){return}}$(window).trigger("refresh_on_change");a.get(0).form.submit()});$("a[confirm]").off("click").click(function(){return confirm($(this).attr("confirm"))})}jQuery.fn.preventDoubleSubmission=function(){$(this).on("submit",function(b){var a=$(this);if(a.data("submitted")===true){b.preventDefault()}else{a.data("submitted",true)}});return this};$(document).ready(function(){init_refresh_on_change();if($.fn.tooltip){$(".unified-panel-header [title]").tooltip({placement:"bottom"});$("[title]").tooltip()}make_popup_menus();replace_big_select_inputs(20,1500);$("a").click(function(){var b=$(this);var c=(parent.frames&&parent.frames.galaxy_main);if((b.attr("target")=="galaxy_main")&&(!c)){var a=b.attr("href");if(a.indexOf("?")==-1){a+="?"}else{a+="&"}a+="use_panels=True";b.attr("href",a);b.attr("target","_self")}return b})}); \ No newline at end of file diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa static/scripts/packed/mvc/library/library-foldertoolbar-view.js --- a/static/scripts/packed/mvc/library/library-foldertoolbar-view.js +++ b/static/scripts/packed/mvc/library/library-foldertoolbar-view.js @@ -1,1 +1,1 @@ -define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model"],function(b,d,e,c){var a=Backbone.View.extend({el:"#center",events:{"click #toolbtn_create_folder":"createFolderFromModal","click #toolbtn_bulk_import":"modalBulkImport","click #include_deleted_datasets_chk":"checkIncludeDeleted","click #toolbtn_show_libinfo":"showLibInfo","click #toolbtn_bulk_delete":"deleteSelectedDatasets"},defaults:{can_add_library_item:false,contains_file:false,chain_call_control:{total_number:0,failed_number:0},disabled_jstree_element:"folders"},modal:null,jstree:null,histories:null,initialize:function(f){this.options=_.defaults(f||{},this.defaults);this.render()},render:function(f){this.options=_.extend(this.options,f);var h=this.templateToolBar();var g={id:this.options.id,is_admin:false,is_anonym:true,user_library_import_dir:Galaxy.config.user_library_import_dir,allow_library_path_paste:Galaxy.config.allow_library_path_paste,library_import_dir:Galaxy.config.library_import_dir,mutiple_add_dataset_options:false};if(Galaxy.currUser){g.is_admin=Galaxy.currUser.isAdmin();g.is_anonym=Galaxy.currUser.isAnonymous();if(g.user_library_import_dir!==null||g.allow_library_path_paste!==false||g.library_import_dir!==null){g.mutiple_add_dataset_options=true}}this.$el.html(h(g))},configureElements:function(f){this.options=_.extend(this.options,f);if(this.options.can_add_library_item===true){$(".add-library-items").show()}else{$(".add-library-items").hide()}if(this.options.contains_file===true){if(Galaxy.currUser){if(!Galaxy.currUser.isAnonymous()){$(".logged-dataset-manipulation").show();$(".dataset-manipulation").show()}else{$(".dataset-manipulation").show();$(".logged-dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}this.$el.find("[data-toggle]").tooltip()},createFolderFromModal:function(h){h.preventDefault();h.stopPropagation();var f=this;var g=this.templateNewFolderInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Create New Folder",body:g(),buttons:{Create:function(){f.create_new_folder_event()},Close:function(){Galaxy.modal.hide()}}})},create_new_folder_event:function(){var f=this.serialize_new_folder();if(this.validate_new_folder(f)){var g=new c.FolderAsModel();url_items=Backbone.history.fragment.split("/");current_folder_id=url_items[url_items.length-1];g.url=g.urlRoot+"/"+current_folder_id;g.save(f,{success:function(h){Galaxy.modal.hide();e.success("Folder created.");h.set({type:"folder"});Galaxy.libraries.folderListView.collection.add(h)},error:function(i,h){Galaxy.modal.hide();if(typeof h.responseJSON!=="undefined"){e.error(h.responseJSON.err_msg)}else{e.error("An error ocurred.")}}})}else{e.error("Folder's name is missing.")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(f){return f.name!==""},modalBulkImport:function(){var f=$("#folder_table").find(":checked");if(f.length===0){e.info("You must select some datasets first.")}else{this.refreshUserHistoriesList(function(h){var g=h.templateBulkImportInModal();h.modal=Galaxy.modal;h.modal.show({closing_events:true,title:"Import into History",body:g({histories:h.histories.models}),buttons:{Import:function(){h.importAllIntoHistory()},Close:function(){Galaxy.modal.hide()}}})})}},refreshUserHistoriesList:function(g){var f=this;this.histories=new c.GalaxyHistories();this.histories.fetch({success:function(){g(f)},error:function(i,h){if(typeof h.responseJSON!=="undefined"){e.error(h.responseJSON.err_msg)}else{e.error("An error ocurred.")}}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var j=$("select[name=dataset_import_bulk] option:selected").val();var m=$("select[name=dataset_import_bulk] option:selected").text();this.options.last_used_history_id=j;var g=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){g.push(this.parentElement.parentElement.id)}});var l=[];for(var h=g.length-1;h>=0;h--){var f=g[h];var k=new c.HistoryItem();k.url=k.urlRoot+j+"/contents";k.content=f;k.source="library";l.push(k)}this.initChainCallControl({length:l.length,action:"to_history",history_name:m});jQuery.getJSON(galaxy_config.root+"history/set_as_current?id="+j);this.chainCallImportingIntoHistory(l,m)},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},download:function(f,j){var h=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});var g="/api/libraries/datasets/download/"+j;var i={ldda_ids:h};this.processDownload(g,i,"get")},processDownload:function(g,h,i){if(g&&h){h=typeof h==="string"?h:$.param(h);var f="";$.each(h.split("&"),function(){var j=this.split("=");f+='<input type="hidden" name="'+j[0]+'" value="'+j[1]+'" />'});$('<form action="'+g+'" method="'+(i||"post")+'">'+f+"</form>").appendTo("body").submit().remove();e.info("Your download will begin soon.")}else{e.error("An error occurred.")}},addFilesFromHistoryModal:function(){this.refreshUserHistoriesList(function(f){f.modal=Galaxy.modal;var g=f.templateAddFilesFromHistory();var h=f.options.full_path[f.options.full_path.length-1][1];f.modal.show({closing_events:true,title:"Adding datasets from your history to folder "+h,body:g({histories:f.histories.models}),buttons:{Add:function(){f.addAllDatasetsFromHistory()},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.back()}});if(f.histories.models.length>0){f.fetchAndDisplayHistoryContents(f.histories.models[0].id);$("#dataset_add_bulk").change(function(i){f.fetchAndDisplayHistoryContents(i.target.value)})}else{e.error("An error ocurred.")}})},importFilesFromPathModal:function(){var g=this;this.modal=Galaxy.modal;var f=this.templateImportPathModal();this.modal.show({closing_events:true,title:"Enter paths relative to Galaxy root",body:f({}),buttons:{Import:function(){g.importFromPathsClicked(g)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+g.id,{trigger:true})}})},importFilesFromUserdirModal:function(){var g=this;this.modal=Galaxy.modal;var f=this.templateBrowserModal();this.modal.show({closing_events:true,title:"Select folders or files to import",body:f({}),buttons:{Import:function(){g.importFromUserdirClicked(g)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+g.id,{trigger:true})}});this.renderJstree({disabled_jstree_element:"folders"});$("input[type=radio]").change(function(h){if(h.target.value==="jstree-disable-folders"){g.renderJstree({disabled_jstree_element:"folders"});$(".jstree-folders-message").hide();$(".jstree-preserve-structure").hide();$(".jstree-link-files").hide();$(".jstree-files-message").show()}else{if(h.target.value==="jstree-disable-files"){$(".jstree-files-message").hide();$(".jstree-folders-message").show();$(".jstree-link-files").show();$(".jstree-preserve-structure").show();g.renderJstree({disabled_jstree_element:"files"})}}})},renderJstree:function(f){var h=this;this.options=_.extend(this.options,f);var g=this.options.disabled_jstree_element;this.jstree=new c.Jstree();this.jstree.url=this.jstree.urlRoot+"?target=userdir&format=jstree&disable="+g;this.jstree.fetch({success:function(j,i){define("jquery",function(){return jQuery});require(["libs/jquery/jstree"],function(k){$("#jstree_browser").jstree("destroy");$("#jstree_browser").jstree({core:{data:j},plugins:["types","checkbox"],types:{folder:{icon:"jstree-folder"},file:{icon:"jstree-file"}},checkbox:{three_state:false}})})},error:function(j,i){if(typeof i.responseJSON!=="undefined"){e.error(i.responseJSON.err_msg)}else{e.error("An error ocurred.")}}})},importFromPathsClicked:function(){var f=this.modal.$el.find(".preserve-checkbox").is(":checked");var k=this.modal.$el.find(".link-checkbox").is(":checked");var j=$("textarea#import_paths").val();var h=[];if(!j){e.info("Please enter a path relative to Galaxy root.")}else{this.modal.disableButton("Import");j=j.split("\n");for(var g=j.length-1;g>=0;g--){trimmed=j[g].trim();if(trimmed.length!==0){h.push(trimmed)}}this.initChainCallControl({length:h.length,action:"adding_datasets"});this.chainCallImportingFolders(h,f,k,"admin_path")}},initChainCallControl:function(f){var g;switch(f.action){case"adding_datasets":g=this.templateAddingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(g({folder_name:this.options.folder_name}));break;case"deleting_datasets":g=this.templateDeletingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(g());break;case"to_history":g=this.templateImportIntoHistoryProgressBar();this.modal.$el.find(".modal-body").html(g({history_name:f.history_name}));break;default:console.error("Wrong action specified.");break}this.progress=0;this.progressStep=100/f.length;this.options.chain_call_control.total_number=f.length;this.options.chain_call_control.failed_number=0},importFromUserdirClicked:function(k){var g=$("#jstree_browser").jstree().get_selected(true);var f=this.modal.$el.find(".preserve-checkbox").is(":checked");var m=this.modal.$el.find(".link-checkbox").is(":checked");var j=g[0].type;var l=[];if(g.length<1){e.info("You must select some items first.")}else{this.modal.disableButton("Import");for(var h=g.length-1;h>=0;h--){if(g[h].li_attr.full_path!==undefined){l.push(g[h].li_attr.full_path)}}this.initChainCallControl({length:l.length,action:"adding_datasets"});if(j==="folder"){this.chainCallImportingFolders(l,f,m,"userdir_folder")}else{if(j==="file"){this.chainCallImportingUserdirFiles(l)}}}},fetchAndDisplayHistoryContents:function(h){var g=new c.HistoryContents({id:h});var f=this;g.fetch({success:function(j){var i=f.templateHistoryContents();f.histories.get(h).set({contents:j});f.modal.$el.find("#selected_history_content").html(i({history_contents:j.models.reverse()}))},error:function(j,i){if(typeof i.responseJSON!=="undefined"){e.error(i.responseJSON.err_msg)}else{e.error("An error ocurred.")}}})},addAllDatasetsFromHistory:function(){var k=this.modal.$el.find("#selected_history_content").find(":checked");var f=[];var j=[];if(k.length<1){e.info("You must select some datasets first.")}else{this.modal.disableButton("Add");k.each(function(){var i=$(this.parentElement).data("id");if(i){f.push(i)}});for(var h=f.length-1;h>=0;h--){history_dataset_id=f[h];var g=new c.Item();g.url="/api/folders/"+this.options.id+"/contents";g.set({from_hda_id:history_dataset_id});j.push(g)}this.initChainCallControl({length:j.length,action:"adding_datasets"});this.chainCallAddingHdas(j)}},chainCallImportingIntoHistory:function(g,j){var f=this;var h=g.pop();if(typeof h=="undefined"){if(this.options.chain_call_control.failed_number===0){e.success("Selected datasets imported into history. Click this to start analysing it.","",{onclick:function(){window.location="/"}})}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){e.error("There was an error and no datasets were imported into history.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){e.warning("Some of the datasets could not be imported into history. Click this to see what was imported.","",{onclick:function(){window.location="/"}})}}}Galaxy.modal.hide();return true}var i=$.when(h.save({content:h.content,source:h.source}));i.done(function(){f.updateProgress();f.chainCallImportingIntoHistory(g,j)}).fail(function(){f.options.chain_call_control.failed_number+=1;f.updateProgress();f.chainCallImportingIntoHistory(g,j)})},chainCallImportingUserdirFiles:function(i){var f=this;var g=i.pop();if(typeof g==="undefined"){if(this.options.chain_call_control.failed_number===0){e.success("Selected files imported into the current folder");Galaxy.modal.hide()}else{e.error("An error occured.")}return true}var h=$.when($.post("/api/libraries/datasets?encoded_folder_id="+f.id+"&source=userdir_file&path="+g));h.done(function(j){f.updateProgress();f.chainCallImportingUserdirFiles(i)}).fail(function(){f.options.chain_call_control.failed_number+=1;f.updateProgress();f.chainCallImportingUserdirFiles(i)})},chainCallImportingFolders:function(k,f,l,i){var g=this;var h=k.pop();if(typeof h=="undefined"){if(this.options.chain_call_control.failed_number===0){e.success("Selected folders and their contents imported into the current folder.");Galaxy.modal.hide()}else{e.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+g.id+"&source="+i+"&path="+h+"&preserve_dirs="+f+"&link_data="+l));j.done(function(m){g.updateProgress();g.chainCallImportingFolders(k,f,l,i)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallImportingFolders(k,f,l,i)})},chainCallAddingHdas:function(g){var f=this;this.added_hdas=new c.Folder();var h=g.pop();if(typeof h=="undefined"){if(this.options.chain_call_control.failed_number===0){e.success("Selected datasets from history added to the folder")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){e.error("There was an error and no datasets were added to the folder.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){e.warning("Some of the datasets could not be added to the folder")}}}Galaxy.modal.hide();return this.added_hdas}var i=$.when(h.save({from_hda_id:h.get("from_hda_id")}));i.done(function(j){Galaxy.libraries.folderListView.collection.add(j);f.updateProgress();f.chainCallAddingHdas(g)}).fail(function(){f.options.chain_call_control.failed_number+=1;f.updateProgress();f.chainCallAddingHdas(g)})},chainCallDeletingHdas:function(g){var f=this;this.deleted_lddas=new c.Folder();var h=g.pop();if(typeof h==="undefined"){if(this.options.chain_call_control.failed_number===0){e.success("Selected datasets deleted")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){e.error("There was an error and no datasets were deleted.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){e.warning("Some of the datasets could not be deleted")}}}Galaxy.modal.hide();return this.deleted_lddas}var i=$.when(h.destroy());i.done(function(k){Galaxy.libraries.folderListView.collection.remove(h.id);f.updateProgress();if(Galaxy.libraries.folderListView.options.include_deleted){var j=new c.Item(k);Galaxy.libraries.folderListView.collection.add(j)}f.chainCallDeletingHdas(g)}).fail(function(){f.options.chain_call_control.failed_number+=1;f.updateProgress();f.chainCallDeletingHdas(g)})},checkIncludeDeleted:function(f){if(f.target.checked){Galaxy.libraries.folderListView.fetchFolder({include_deleted:true})}else{Galaxy.libraries.folderListView.fetchFolder({include_deleted:false})}},deleteSelectedDatasets:function(){var f=$("#folder_table").find(":checked");if(f.length===0){e.info("You must select at least one dataset for deletion.")}else{var j=this.templateDeletingDatasetsProgressBar();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Deleting selected datasets",body:j({}),buttons:{Close:function(){Galaxy.modal.hide()}}});this.options.chain_call_control.total_number=0;this.options.chain_call_control.failed_number=0;var g=[];f.each(function(){if(this.parentElement.parentElement.id!==""){g.push(this.parentElement.parentElement.id)}});this.progressStep=100/g.length;this.progress=0;var l=[];for(var h=g.length-1;h>=0;h--){var k=new c.Item({id:g[h]});l.push(k)}this.options.chain_call_control.total_number=g.length;this.chainCallDeletingHdas(l)}},showLibInfo:function(){var g=Galaxy.libraries.folderListView.folderContainer.attributes.metadata.parent_library_id;var f=null;var h=this;if(Galaxy.libraries.libraryListView!==null){f=Galaxy.libraries.libraryListView.collection.get(g);this.showLibInfoModal(f)}else{f=new c.Library({id:g});f.fetch({success:function(){h.showLibInfoModal(f)},error:function(j,i){if(typeof i.responseJSON!=="undefined"){e.error(i.responseJSON.err_msg)}else{e.error("An error ocurred.")}}})}},showLibInfoModal:function(f){var g=this.templateLibInfoInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Library Information",body:g({library:f}),buttons:{Close:function(){Galaxy.modal.hide()}}})},showImportModal:function(f){switch(f.source){case"history":this.addFilesFromHistoryModal();break;case"importdir":break;case"path":this.importFilesFromPathModal();break;case"userdir":this.importFilesFromUserdirModal();break;default:Galaxy.libraries.library_router.back();e.error("Invalid import source.");break}},templateToolBar:function(){tmpl_array=[];tmpl_array.push('<div class="library_style_container">');tmpl_array.push(' <div id="library_toolbar">');tmpl_array.push(" <span><strong>DATA LIBRARIES</strong></span>");tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" class="logged-dataset-manipulation" title="Include deleted datasets" style="display:none;"> | <input id="include_deleted_datasets_chk" style="margin: 0;" type="checkbox"> include deleted | </input></span>');tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Create New Folder" id="toolbtn_create_folder" class="btn btn-default primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-folder"></span></button>');tmpl_array.push("<% if(mutiple_add_dataset_options) { %>");tmpl_array.push(' <div class="btn-group add-library-items" style="display:none;">');tmpl_array.push(' <button title="Add Datasets to Current Folder" id="" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-plus"></span><span class="fa fa-file"></span><span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>');tmpl_array.push("<% if(user_library_import_dir !== null) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% if(allow_library_path_paste) { %>");tmpl_array.push(' <li class="divider"></li>');tmpl_array.push(' <li class="dropdown-header">Admins only</li>');tmpl_array.push("<% if(allow_library_path_paste) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% } %>");tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push("<% } else { %>");tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Add Datasets to Current Folder" id="toolbtn_add_files" class="btn btn-default toolbtn_add_files primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-file"></span></span></button>');tmpl_array.push("<% } %>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Import selected datasets into history" id="toolbtn_bulk_import" class="primary-button dataset-manipulation" style="margin-left: 0.5em; display:none;" type="button"><span class="fa fa-book"></span> to History</button>');tmpl_array.push(' <div id="toolbtn_dl" class="btn-group dataset-manipulation" style="margin-left: 0.5em; display:none; ">');tmpl_array.push(' <button title="Download selected datasets as archive" id="drop_toggle" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-download"></span> Download <span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tgz">.tar.gz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tbz">.tar.bz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/zip">.zip</a></li>');tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Mark selected datasets deleted" id="toolbtn_bulk_delete" class="primary-button logged-dataset-manipulation" style="margin-left: 0.5em; display:none; " type="button"><span class="fa fa-times"></span> Delete</button>');tmpl_array.push(' <button data-id="<%- id %>" data-toggle="tooltip" data-placement="top" title="Show library information" id="toolbtn_show_libinfo" class="primary-button" style="margin-left: 0.5em;" type="button"><span class="fa fa-info-circle"></span> Library Info</button>');tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/FolderContents" target="_blank"><button class="primary-button btn-xs" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>');tmpl_array.push(" </div>");tmpl_array.push(' <div id="folder_items_element">');tmpl_array.push(" </div>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateLibInfoInModal:function(){tmpl_array=[];tmpl_array.push('<div id="lif_info_modal">');tmpl_array.push("<h2>Library name:</h2>");tmpl_array.push('<p><%- library.get("name") %></p>');tmpl_array.push("<h3>Library description:</h3>");tmpl_array.push('<p><%- library.get("description") %></p>');tmpl_array.push("<h3>Library synopsis:</h3>");tmpl_array.push('<p><%- library.get("synopsis") %></p>');tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_folder_modal">');tmpl_array.push("<form>");tmpl_array.push('<input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push('<input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push("</form>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateBulkImportInModal:function(){var f=[];f.push('<span id="history_modal_combo_bulk" style="width:90%; margin-left: 1em; margin-right: 1em; ">');f.push("Select history: ");f.push('<select id="dataset_import_bulk" name="dataset_import_bulk" style="width:50%; margin-bottom: 1em; "> ');f.push(" <% _.each(histories, function(history) { %>");f.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');f.push(" <% }); %>");f.push("</select>");f.push("</span>");return _.template(f.join(""))},templateImportIntoHistoryProgressBar:function(){var f=[];f.push('<div class="import_text">');f.push("Importing selected datasets to history <b><%= _.escape(history_name) %></b>");f.push("</div>");f.push('<div class="progress">');f.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');f.push(' <span class="completion_span">0% Complete</span>');f.push(" </div>");f.push("</div>");f.push("");return _.template(f.join(""))},templateAddingDatasetsProgressBar:function(){var f=[];f.push('<div class="import_text">');f.push("Adding selected datasets to library folder <b><%= _.escape(folder_name) %></b>");f.push("</div>");f.push('<div class="progress">');f.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');f.push(' <span class="completion_span">0% Complete</span>');f.push(" </div>");f.push("</div>");f.push("");return _.template(f.join(""))},templateDeletingDatasetsProgressBar:function(){var f=[];f.push('<div class="import_text">');f.push("</div>");f.push('<div class="progress">');f.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');f.push(' <span class="completion_span">0% Complete</span>');f.push(" </div>");f.push("</div>");f.push("");return _.template(f.join(""))},templateBrowserModal:function(){var f=[];f.push('<div id="file_browser_modal">');f.push('<div style="margin-bottom:1em;">');f.push('<label class="radio-inline">');f.push(' <input title="Switch to selecting files" type="radio" name="jstree-radio" value="jstree-disable-folders" checked="checked"> Files');f.push("</label>");f.push('<label class="radio-inline">');f.push(' <input title="Switch to selecting folders" type="radio" name="jstree-radio" value="jstree-disable-files"> Folders');f.push("</label>");f.push('<label class="checkbox-inline jstree-preserve-structure" style="display:none;">');f.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');f.push("Preserve directory structure");f.push(" </label>");f.push('<label class="checkbox-inline jstree-link-files" style="display:none;">');f.push(' <input class="link-checkbox" type="checkbox" value="link_files">');f.push("Link files instead of copying");f.push(" </label>");f.push("</div>");f.push('<div class="alert alert-info jstree-files-message">All files you select will be imported into the current folder.</div>');f.push('<div class="alert alert-info jstree-folders-message" style="display:none;">All files within the selected folders and their subfolders will be imported into the current folder.</div>');f.push('<div id="jstree_browser">');f.push("</div>");f.push("</div>");return _.template(f.join(""))},templateImportPathModal:function(){var f=[];f.push('<div id="file_browser_modal">');f.push('<label class="checkbox-inline jstree-preserve-structure">');f.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');f.push("Preserve directory structure");f.push(" </label>");f.push('<label class="checkbox-inline jstree-link-files">');f.push(' <input class="link-checkbox" type="checkbox" value="link_files">');f.push("Link files instead of copying");f.push(" </label>");f.push("</div>");f.push('<div class="alert alert-info jstree-folders-message">All files within the given folders and their subfolders will be imported into the current folder.</div>');f.push('<textarea id="import_paths" class="form-control" rows="5" placeholder="Paths separated by newline"></textarea>');f.push("</div>");return _.template(f.join(""))},templateAddFilesFromHistory:function(){var f=[];f.push('<div id="add_files_modal">');f.push('<div id="history_modal_combo_bulk">');f.push("Select history: ");f.push('<select id="dataset_add_bulk" name="dataset_add_bulk" style="width:66%; "> ');f.push(" <% _.each(histories, function(history) { %>");f.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');f.push(" <% }); %>");f.push("</select>");f.push("</div>");f.push("<br/>");f.push('<div id="selected_history_content">');f.push("</div>");f.push("</div>");return _.template(f.join(""))},templateHistoryContents:function(){var f=[];f.push("<strong>Choose the datasets to import:</strong>");f.push("<ul>");f.push(" <% _.each(history_contents, function(history_item) { %>");f.push(' <li data-id="<%= _.escape(history_item.get("id")) %>">');f.push(' <input style="margin: 0;" type="checkbox"><%= _.escape(history_item.get("hid")) %>: <%= _.escape(history_item.get("name")) %>');f.push(" </li>");f.push(" <% }); %>");f.push("</ul>");return _.template(f.join(""))}});return{FolderToolbarView:a}}); \ No newline at end of file +define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(c,e,f,d,a){var b=Backbone.View.extend({el:"#center",events:{"click #toolbtn_create_folder":"createFolderFromModal","click #toolbtn_bulk_import":"modalBulkImport","click #include_deleted_datasets_chk":"checkIncludeDeleted","click #toolbtn_show_libinfo":"showLibInfo","click #toolbtn_bulk_delete":"deleteSelectedDatasets"},defaults:{can_add_library_item:false,contains_file:false,chain_call_control:{total_number:0,failed_number:0},disabled_jstree_element:"folders"},modal:null,jstree:null,histories:null,select_genome:null,select_extension:null,list_extensions:[],auto:{id:"auto",text:"Auto-detect",description:"This system will try to detect the file type automatically. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed."},list_genomes:[],initialize:function(g){this.options=_.defaults(g||{},this.defaults);this.fetchExtAndGenomes();this.render()},render:function(g){this.options=_.extend(this.options,g);var i=this.templateToolBar();var h={id:this.options.id,is_admin:false,is_anonym:true,user_library_import_dir:Galaxy.config.user_library_import_dir,allow_library_path_paste:Galaxy.config.allow_library_path_paste,library_import_dir:Galaxy.config.library_import_dir,mutiple_add_dataset_options:false};if(Galaxy.currUser){h.is_admin=Galaxy.currUser.isAdmin();h.is_anonym=Galaxy.currUser.isAnonymous();if(h.user_library_import_dir!==null||h.allow_library_path_paste!==false||h.library_import_dir!==null){h.mutiple_add_dataset_options=true}}this.$el.html(i(h))},configureElements:function(g){this.options=_.extend(this.options,g);if(this.options.can_add_library_item===true){$(".add-library-items").show()}else{$(".add-library-items").hide()}if(this.options.contains_file===true){if(Galaxy.currUser){if(!Galaxy.currUser.isAnonymous()){$(".logged-dataset-manipulation").show();$(".dataset-manipulation").show()}else{$(".dataset-manipulation").show();$(".logged-dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}}else{$(".logged-dataset-manipulation").hide();$(".dataset-manipulation").hide()}this.$el.find("[data-toggle]").tooltip()},createFolderFromModal:function(i){i.preventDefault();i.stopPropagation();var g=this;var h=this.templateNewFolderInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Create New Folder",body:h(),buttons:{Create:function(){g.create_new_folder_event()},Close:function(){Galaxy.modal.hide()}}})},create_new_folder_event:function(){var g=this.serialize_new_folder();if(this.validate_new_folder(g)){var h=new d.FolderAsModel();url_items=Backbone.history.fragment.split("/");current_folder_id=url_items[url_items.length-1];h.url=h.urlRoot+"/"+current_folder_id;h.save(g,{success:function(i){Galaxy.modal.hide();f.success("Folder created.");i.set({type:"folder"});Galaxy.libraries.folderListView.collection.add(i)},error:function(j,i){Galaxy.modal.hide();if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}else{f.error("Folder's name is missing.")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(g){return g.name!==""},modalBulkImport:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select some datasets first.")}else{this.refreshUserHistoriesList(function(i){var h=i.templateBulkImportInModal();i.modal=Galaxy.modal;i.modal.show({closing_events:true,title:"Import into History",body:h({histories:i.histories.models}),buttons:{Import:function(){i.importAllIntoHistory()},Close:function(){Galaxy.modal.hide()}}})})}},refreshUserHistoriesList:function(h){var g=this;this.histories=new d.GalaxyHistories();this.histories.fetch({success:function(){h(g)},error:function(j,i){if(typeof i.responseJSON!=="undefined"){f.error(i.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var k=$("select[name=dataset_import_bulk] option:selected").val();var n=$("select[name=dataset_import_bulk] option:selected").text();this.options.last_used_history_id=k;var h=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});var m=[];for(var j=h.length-1;j>=0;j--){var g=h[j];var l=new d.HistoryItem();l.url=l.urlRoot+k+"/contents";l.content=g;l.source="library";m.push(l)}this.initChainCallControl({length:m.length,action:"to_history",history_name:n});jQuery.getJSON(galaxy_config.root+"history/set_as_current?id="+k);this.chainCallImportingIntoHistory(m,n)},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},download:function(g,k){var i=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!==""){i.push(this.parentElement.parentElement.id)}});var h="/api/libraries/datasets/download/"+k;var j={ldda_ids:i};this.processDownload(h,j,"get")},processDownload:function(h,i,j){if(h&&i){i=typeof i==="string"?i:$.param(i);var g="";$.each(i.split("&"),function(){var k=this.split("=");g+='<input type="hidden" name="'+k[0]+'" value="'+k[1]+'" />'});$('<form action="'+h+'" method="'+(j||"post")+'">'+g+"</form>").appendTo("body").submit().remove();f.info("Your download will begin soon.")}else{f.error("An error occurred.")}},addFilesFromHistoryModal:function(){this.refreshUserHistoriesList(function(g){g.modal=Galaxy.modal;var h=g.templateAddFilesFromHistory();var i=g.options.full_path[g.options.full_path.length-1][1];g.modal.show({closing_events:true,title:"Adding datasets from your history to folder "+i,body:h({histories:g.histories.models}),buttons:{Add:function(){g.addAllDatasetsFromHistory()},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.back()}});if(g.histories.models.length>0){g.fetchAndDisplayHistoryContents(g.histories.models[0].id);$("#dataset_add_bulk").change(function(j){g.fetchAndDisplayHistoryContents(j.target.value)})}else{f.error("An error ocurred.")}})},importFilesFromPathModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateImportPathModal();this.modal.show({closing_events:true,title:"Please enter paths to import",body:g({}),buttons:{Import:function(){h.importFromPathsClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes()},fetchExtAndGenomes:function(){var g=this;e.get(galaxy_config.root+"api/datatypes?extension_only=False",function(h){for(key in h){g.list_extensions.push({id:h[key].extension,text:h[key].extension,description:h[key].description,description_url:h[key].description_url})}g.list_extensions.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0});g.list_extensions.unshift(g.auto)});e.get(galaxy_config.root+"api/genomes",function(h){for(key in h){g.list_genomes.push({id:h[key][1],text:h[key][0]})}g.list_genomes.sort(function(j,i){return j.id>i.id?1:j.id<i.id?-1:0})})},renderSelectBoxes:function(){var g=this;this.select_genome=new a.View({css:"genome",data:g.list_genomes,container:Galaxy.modal.$el.find("#genome"),value:"?"});this.select_extension=new a.View({css:"extension",data:g.list_extensions,container:Galaxy.modal.$el.find("#extension"),value:"auto"})},importFilesFromUserdirModal:function(){var h=this;this.modal=Galaxy.modal;var g=this.templateBrowserModal();this.modal.show({closing_events:true,title:"Please select folders or files",body:g({}),buttons:{Import:function(){h.importFromUserdirClicked(h)},Close:function(){Galaxy.modal.hide()}},closing_callback:function(){Galaxy.libraries.library_router.navigate("folders/"+h.id,{trigger:true})}});this.renderSelectBoxes();this.renderJstree({disabled_jstree_element:"folders"});$("input[type=radio]").change(function(i){if(i.target.value==="jstree-disable-folders"){h.renderJstree({disabled_jstree_element:"folders"});$(".jstree-folders-message").hide();$(".jstree-preserve-structure").hide();$(".jstree-link-files").hide();$(".jstree-files-message").show()}else{if(i.target.value==="jstree-disable-files"){$(".jstree-files-message").hide();$(".jstree-folders-message").show();$(".jstree-link-files").show();$(".jstree-preserve-structure").show();h.renderJstree({disabled_jstree_element:"files"})}}})},renderJstree:function(g){var i=this;this.options=_.extend(this.options,g);var h=this.options.disabled_jstree_element;this.jstree=new d.Jstree();this.jstree.url=this.jstree.urlRoot+"?target=userdir&format=jstree&disable="+h;this.jstree.fetch({success:function(k,j){define("jquery",function(){return jQuery});require(["libs/jquery/jstree"],function(l){$("#jstree_browser").jstree("destroy");$("#jstree_browser").jstree({core:{data:k},plugins:["types","checkbox"],types:{folder:{icon:"jstree-folder"},file:{icon:"jstree-file"}},checkbox:{three_state:false}})})},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},importFromPathsClicked:function(){var g=this.modal.$el.find(".preserve-checkbox").is(":checked");var n=this.modal.$el.find(".link-checkbox").is(":checked");var h=this.select_extension.value();var j=this.select_genome.value();var m=$("textarea#import_paths").val();var l=[];if(!m){f.info("Please enter a path relative to Galaxy root.")}else{this.modal.disableButton("Import");m=m.split("\n");for(var k=m.length-1;k>=0;k--){trimmed=m[k].trim();if(trimmed.length!==0){l.push(trimmed)}}this.initChainCallControl({length:l.length,action:"adding_datasets"});this.chainCallImportingFolders({paths:l,preserve_dirs:g,link_data:n,source:"admin_path",file_type:h,dbkey:j})}},initChainCallControl:function(g){var h;switch(g.action){case"adding_datasets":h=this.templateAddingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h({folder_name:this.options.folder_name}));break;case"deleting_datasets":h=this.templateDeletingDatasetsProgressBar();this.modal.$el.find(".modal-body").html(h());break;case"to_history":h=this.templateImportIntoHistoryProgressBar();this.modal.$el.find(".modal-body").html(h({history_name:g.history_name}));break;default:console.error("Wrong action specified.");break}this.progress=0;this.progressStep=100/g.length;this.options.chain_call_control.total_number=g.length;this.options.chain_call_control.failed_number=0},importFromUserdirClicked:function(m){var g=$("#jstree_browser").jstree().get_selected(true);var l=this.modal.$el.find(".preserve-checkbox").is(":checked");var n=this.modal.$el.find(".link-checkbox").is(":checked");var h=this.select_extension.value();var o=this.select_genome.value();var j=g[0].type;var p=[];if(g.length<1){f.info("You must select some items first.")}else{this.modal.disableButton("Import");for(var k=g.length-1;k>=0;k--){if(g[k].li_attr.full_path!==undefined){p.push(g[k].li_attr.full_path)}}this.initChainCallControl({length:p.length,action:"adding_datasets"});if(j==="folder"){this.chainCallImportingFolders({paths:p,preserve_dirs:l,link_data:n,source:"userdir_folder",file_type:h,dbkey:o})}else{if(j==="file"){this.chainCallImportingUserdirFiles({paths:p,file_type:h,dbkey:o})}}}},fetchAndDisplayHistoryContents:function(i){var h=new d.HistoryContents({id:i});var g=this;h.fetch({success:function(k){var j=g.templateHistoryContents();g.histories.get(i).set({contents:k});g.modal.$el.find("#selected_history_content").html(j({history_contents:k.models.reverse()}))},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})},addAllDatasetsFromHistory:function(){var l=this.modal.$el.find("#selected_history_content").find(":checked");var g=[];var k=[];if(l.length<1){f.info("You must select some datasets first.")}else{this.modal.disableButton("Add");l.each(function(){var i=$(this.parentElement).data("id");if(i){g.push(i)}});for(var j=g.length-1;j>=0;j--){history_dataset_id=g[j];var h=new d.Item();h.url="/api/folders/"+this.options.id+"/contents";h.set({from_hda_id:history_dataset_id});k.push(h)}this.initChainCallControl({length:k.length,action:"adding_datasets"});this.chainCallAddingHdas(k)}},chainCallImportingIntoHistory:function(h,k){var g=this;var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets imported into history. Click this to start analysing it.","",{onclick:function(){window.location="/"}})}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were imported into history.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be imported into history. Click this to see what was imported.","",{onclick:function(){window.location="/"}})}}}Galaxy.modal.hide();return true}var j=$.when(i.save({content:i.content,source:i.source}));j.done(function(){g.updateProgress();g.chainCallImportingIntoHistory(h,k)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallImportingIntoHistory(h,k)})},chainCallImportingUserdirFiles:function(g){var h=this;var i=g.paths.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected files imported into the current folder");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source=userdir_file&path="+i+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingUserdirFiles(g)}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingUserdirFiles(g)})},chainCallImportingFolders:function(g){var h=this;var i=g.paths.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected folders and their contents imported into the current folder.");Galaxy.modal.hide()}else{f.error("An error occured.")}return true}var j=$.when($.post("/api/libraries/datasets?encoded_folder_id="+h.id+"&source="+g.source+"&path="+i+"&preserve_dirs="+g.preserve_dirs+"&link_data="+g.link_data+"&file_type="+g.file_type+"&dbkey="+g.dbkey));j.done(function(k){h.updateProgress();h.chainCallImportingFolders({paths:g.paths,preserve_dirs:g.preserve_dirs,link_data:g.link_data,source:g.source,file_type:g.file_type,dbkey:g.dbkey})}).fail(function(){h.options.chain_call_control.failed_number+=1;h.updateProgress();h.chainCallImportingFolders({paths:g.paths,preserve_dirs:g.preserve_dirs,link_data:g.link_data,source:g.source,file_type:g.file_type,dbkey:g.dbkey})})},chainCallAddingHdas:function(h){var g=this;this.added_hdas=new d.Folder();var i=h.pop();if(typeof i=="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets from history added to the folder")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were added to the folder.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be added to the folder")}}}Galaxy.modal.hide();return this.added_hdas}var j=$.when(i.save({from_hda_id:i.get("from_hda_id")}));j.done(function(k){Galaxy.libraries.folderListView.collection.add(k);g.updateProgress();g.chainCallAddingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallAddingHdas(h)})},chainCallDeletingHdas:function(h){var g=this;this.deleted_lddas=new d.Folder();var i=h.pop();if(typeof i==="undefined"){if(this.options.chain_call_control.failed_number===0){f.success("Selected datasets deleted")}else{if(this.options.chain_call_control.failed_number===this.options.chain_call_control.total_number){f.error("There was an error and no datasets were deleted.")}else{if(this.options.chain_call_control.failed_number<this.options.chain_call_control.total_number){f.warning("Some of the datasets could not be deleted")}}}Galaxy.modal.hide();return this.deleted_lddas}var j=$.when(i.destroy());j.done(function(l){Galaxy.libraries.folderListView.collection.remove(i.id);g.updateProgress();if(Galaxy.libraries.folderListView.options.include_deleted){var k=new d.Item(l);Galaxy.libraries.folderListView.collection.add(k)}g.chainCallDeletingHdas(h)}).fail(function(){g.options.chain_call_control.failed_number+=1;g.updateProgress();g.chainCallDeletingHdas(h)})},checkIncludeDeleted:function(g){if(g.target.checked){Galaxy.libraries.folderListView.fetchFolder({include_deleted:true})}else{Galaxy.libraries.folderListView.fetchFolder({include_deleted:false})}},deleteSelectedDatasets:function(){var g=$("#folder_table").find(":checked");if(g.length===0){f.info("You must select at least one dataset for deletion.")}else{var k=this.templateDeletingDatasetsProgressBar();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Deleting selected datasets",body:k({}),buttons:{Close:function(){Galaxy.modal.hide()}}});this.options.chain_call_control.total_number=0;this.options.chain_call_control.failed_number=0;var h=[];g.each(function(){if(this.parentElement.parentElement.id!==""){h.push(this.parentElement.parentElement.id)}});this.progressStep=100/h.length;this.progress=0;var m=[];for(var j=h.length-1;j>=0;j--){var l=new d.Item({id:h[j]});m.push(l)}this.options.chain_call_control.total_number=h.length;this.chainCallDeletingHdas(m)}},showLibInfo:function(){var h=Galaxy.libraries.folderListView.folderContainer.attributes.metadata.parent_library_id;var g=null;var i=this;if(Galaxy.libraries.libraryListView!==null){g=Galaxy.libraries.libraryListView.collection.get(h);this.showLibInfoModal(g)}else{g=new d.Library({id:h});g.fetch({success:function(){i.showLibInfoModal(g)},error:function(k,j){if(typeof j.responseJSON!=="undefined"){f.error(j.responseJSON.err_msg)}else{f.error("An error ocurred.")}}})}},showLibInfoModal:function(g){var h=this.templateLibInfoInModal();this.modal=Galaxy.modal;this.modal.show({closing_events:true,title:"Library Information",body:h({library:g}),buttons:{Close:function(){Galaxy.modal.hide()}}})},showImportModal:function(g){switch(g.source){case"history":this.addFilesFromHistoryModal();break;case"importdir":break;case"path":this.importFilesFromPathModal();break;case"userdir":this.importFilesFromUserdirModal();break;default:Galaxy.libraries.library_router.back();f.error("Invalid import source.");break}},templateToolBar:function(){tmpl_array=[];tmpl_array.push('<div class="library_style_container">');tmpl_array.push(' <div id="library_toolbar">');tmpl_array.push(" <span><strong>DATA LIBRARIES</strong></span>");tmpl_array.push(' <span data-toggle="tooltip" data-placement="top" class="logged-dataset-manipulation" title="Include deleted datasets" style="display:none;"> | <input id="include_deleted_datasets_chk" style="margin: 0;" type="checkbox"> include deleted | </input></span>');tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Create New Folder" id="toolbtn_create_folder" class="btn btn-default primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-folder"></span></button>');tmpl_array.push("<% if(mutiple_add_dataset_options) { %>");tmpl_array.push(' <div class="btn-group add-library-items" style="display:none;">');tmpl_array.push(' <button title="Add Datasets to Current Folder" id="" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-plus"></span><span class="fa fa-file"></span><span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#folders/<%= id %>/import/history"> from History</a></li>');tmpl_array.push("<% if(user_library_import_dir !== null) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/userdir"> from User Directory</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% if(allow_library_path_paste) { %>");tmpl_array.push(' <li class="divider"></li>');tmpl_array.push(' <li class="dropdown-header">Admins only</li>');tmpl_array.push("<% if(allow_library_path_paste) { %>");tmpl_array.push(' <li><a href="#folders/<%= id %>/import/path">from Path</a></li>');tmpl_array.push("<% } %>");tmpl_array.push("<% } %>");tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push("<% } else { %>");tmpl_array.push(' <button style="display:none;" data-toggle="tooltip" data-placement="top" title="Add Datasets to Current Folder" id="toolbtn_add_files" class="btn btn-default toolbtn_add_files primary-button add-library-items" type="button"><span class="fa fa-plus"></span><span class="fa fa-file"></span></span></button>');tmpl_array.push("<% } %>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Import selected datasets into history" id="toolbtn_bulk_import" class="primary-button dataset-manipulation" style="margin-left: 0.5em; display:none;" type="button"><span class="fa fa-book"></span> to History</button>');tmpl_array.push(' <div id="toolbtn_dl" class="btn-group dataset-manipulation" style="margin-left: 0.5em; display:none; ">');tmpl_array.push(' <button title="Download selected datasets as archive" id="drop_toggle" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">');tmpl_array.push(' <span class="fa fa-download"></span> Download <span class="caret"></span>');tmpl_array.push(" </button>");tmpl_array.push(' <ul class="dropdown-menu" role="menu">');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tgz">.tar.gz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/tbz">.tar.bz</a></li>');tmpl_array.push(' <li><a href="#/folders/<%= id %>/download/zip">.zip</a></li>');tmpl_array.push(" </ul>");tmpl_array.push(" </div>");tmpl_array.push(' <button data-toggle="tooltip" data-placement="top" title="Mark selected datasets deleted" id="toolbtn_bulk_delete" class="primary-button logged-dataset-manipulation" style="margin-left: 0.5em; display:none; " type="button"><span class="fa fa-times"></span> Delete</button>');tmpl_array.push(' <button data-id="<%- id %>" data-toggle="tooltip" data-placement="top" title="Show library information" id="toolbtn_show_libinfo" class="primary-button" style="margin-left: 0.5em;" type="button"><span class="fa fa-info-circle"></span> Library Info</button>');tmpl_array.push(' <span class="help-button" data-toggle="tooltip" data-placement="top" title="Visit Libraries Wiki"><a href="https://wiki.galaxyproject.org/DataLibraries/screen/FolderContents" target="_blank"><button class="primary-button btn-xs" type="button"><span class="fa fa-question-circle"></span> Help</button></a></span>');tmpl_array.push(" </div>");tmpl_array.push(' <div id="folder_items_element">');tmpl_array.push(" </div>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateLibInfoInModal:function(){tmpl_array=[];tmpl_array.push('<div id="lif_info_modal">');tmpl_array.push("<h2>Library name:</h2>");tmpl_array.push('<p><%- library.get("name") %></p>');tmpl_array.push("<h3>Library description:</h3>");tmpl_array.push('<p><%- library.get("description") %></p>');tmpl_array.push("<h3>Library synopsis:</h3>");tmpl_array.push('<p><%- library.get("synopsis") %></p>');tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateNewFolderInModal:function(){tmpl_array=[];tmpl_array.push('<div id="new_folder_modal">');tmpl_array.push("<form>");tmpl_array.push('<input type="text" name="Name" value="" placeholder="Name">');tmpl_array.push('<input type="text" name="Description" value="" placeholder="Description">');tmpl_array.push("</form>");tmpl_array.push("</div>");return _.template(tmpl_array.join(""))},templateBulkImportInModal:function(){var g=[];g.push('<span id="history_modal_combo_bulk" style="width:90%; margin-left: 1em; margin-right: 1em; ">');g.push("Select history: ");g.push('<select id="dataset_import_bulk" name="dataset_import_bulk" style="width:50%; margin-bottom: 1em; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</span>");return _.template(g.join(""))},templateImportIntoHistoryProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Importing selected datasets to history <b><%= _.escape(history_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateAddingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("Adding selected datasets to library folder <b><%= _.escape(folder_name) %></b>");g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateDeletingDatasetsProgressBar:function(){var g=[];g.push('<div class="import_text">');g.push("</div>");g.push('<div class="progress">');g.push(' <div class="progress-bar progress-bar-import" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 00%;">');g.push(' <span class="completion_span">0% Complete</span>');g.push(" </div>");g.push("</div>");g.push("");return _.template(g.join(""))},templateBrowserModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-files-message">All files you select will be imported into the current folder.</div>');g.push('<div class="alert alert-info jstree-folders-message" style="display:none;">All files within the selected folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom:1em;">');g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting files" type="radio" name="jstree-radio" value="jstree-disable-folders" checked="checked"> Files');g.push("</label>");g.push('<label class="radio-inline">');g.push(' <input title="Switch to selecting folders" type="radio" name="jstree-radio" value="jstree-disable-files"> Folders');g.push("</label>");g.push("</div>");g.push('<div style="margin-bottom:1em;">');g.push('<label class="checkbox-inline jstree-preserve-structure" style="display:none;">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files" style="display:none;">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<div id="jstree_browser">');g.push("</div>");g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="extension" class="extension" />');g.push(' Genome: <span id="genome" class="genome" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateImportPathModal:function(){var g=[];g.push('<div id="file_browser_modal">');g.push('<div class="alert alert-info jstree-folders-message">All files within the given folders and their subfolders will be imported into the current folder.</div>');g.push('<div style="margin-bottom: 0.5em;">');g.push('<label class="checkbox-inline jstree-preserve-structure">');g.push(' <input class="preserve-checkbox" type="checkbox" value="preserve_directory_structure">');g.push("Preserve directory structure");g.push(" </label>");g.push('<label class="checkbox-inline jstree-link-files">');g.push(' <input class="link-checkbox" type="checkbox" value="link_files">');g.push("Link files instead of copying");g.push(" </label>");g.push("</div>");g.push('<textarea id="import_paths" class="form-control" rows="5" placeholder="Absolute paths (or paths relative to Galaxy root) separated by newline"></textarea>');g.push("<hr />");g.push("<p>You can set extension type and genome for all imported datasets at once:</p>");g.push("<div>");g.push('Type: <span id="extension" class="extension" />');g.push(' Genome: <span id="genome" class="genome" />');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateAddFilesFromHistory:function(){var g=[];g.push('<div id="add_files_modal">');g.push('<div id="history_modal_combo_bulk">');g.push("Select history: ");g.push('<select id="dataset_add_bulk" name="dataset_add_bulk" style="width:66%; "> ');g.push(" <% _.each(histories, function(history) { %>");g.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');g.push(" <% }); %>");g.push("</select>");g.push("</div>");g.push("<br/>");g.push('<div id="selected_history_content">');g.push("</div>");g.push("</div>");return _.template(g.join(""))},templateHistoryContents:function(){var g=[];g.push("<strong>Choose the datasets to import:</strong>");g.push("<ul>");g.push(" <% _.each(history_contents, function(history_item) { %>");g.push(' <li data-id="<%= _.escape(history_item.get("id")) %>">');g.push(' <input style="margin: 0;" type="checkbox"><%= _.escape(history_item.get("hid")) %>: <%= _.escape(history_item.get("name")) %>');g.push(" </li>");g.push(" <% }); %>");g.push("</ul>");return _.template(g.join(""))}});return{FolderToolbarView:b}}); \ No newline at end of file diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa static/scripts/packed/mvc/ui/ui-select.js --- a/static/scripts/packed/mvc/ui/ui-select.js +++ b/static/scripts/packed/mvc/ui/ui-select.js @@ -1,1 +1,1 @@ -define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{css:"",placeholder:"No data available",data:[],value:null,multiple:false,minimumInputLength:0,initialData:""},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));if(!this.options.container){console.log("ui-select::initialize() : container not specified.");return}this.options.container.append(this.$el);this.select_data=this.options.data;this._refresh();if(!this.options.multiple){if(this.options.value){this._setValue(this.options.value)}var c=this;if(this.options.onchange){this.$el.on("change",function(){c.options.onchange(c.value())})}}},value:function(c){var d=this._getValue();if(c!==undefined){this._setValue(c)}var e=this._getValue();if((e!=d&&this.options.onchange)){this.options.onchange(e)}return e},text:function(){return this.$el.select2("data").text},disabled:function(){return !this.$el.select2("enable")},enable:function(){this.$el.select2("enable",true)},disable:function(){this.$el.select2("enable",false)},add:function(c){this.select_data.push({id:c.id,text:c.text});this._refresh()},del:function(d){var c=this._getIndex(d);if(c!=-1){this.select_data.splice(c,1);this._refresh()}},remove:function(){this.$el.select2("destroy")},update:function(c){this.select_data=[];for(var d in c.data){this.select_data.push(c.data[d])}this._refresh()},_refresh:function(){if(!this.options.multiple){var d=this._getValue();var c={data:this.select_data,containerCssClass:this.options.css,placeholder:this.options.placeholder,};this.$el.select2(c);this._setValue(d)}else{var c={multiple:this.options.multiple,containerCssClass:this.options.css,placeholder:this.options.placeholder,minimumInputLength:this.options.minimumInputLength,ajax:this.options.ajax,dropdownCssClass:this.options.dropdownCssClass,escapeMarkup:this.options.escapeMarkup,formatResult:this.options.formatResult,formatSelection:this.options.formatSelection,initSelection:this.options.initSelection,initialData:this.options.initialData};this.$el.select2(c)}},_getIndex:function(d){for(var c in this.select_data){if(this.select_data[c].id==d){return c}}return -1},_getValue:function(){return this.$el.select2("val")},_setValue:function(d){var c=this._getIndex(d);if(c==-1){if(this.select_data.length>0){d=this.select_data[0].id}}this.$el.select2("val",d)},_template:function(c){return'<input type="hidden" value="'+this.options.initialData+'"/>'}});return{View:b}}); \ No newline at end of file +define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{css:"",placeholder:"No data available",data:[],value:null,multiple:false,minimumInputLength:0,initialData:""},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));if(!this.options.container){console.log("ui-select::initialize() : container not specified.");return}this.options.container.append(this.$el);this.select_data=this.options.data;this._refresh();if(!this.options.multiple){if(this.options.value){this._setValue(this.options.value)}var c=this;if(this.options.onchange){this.$el.on("change",function(){c.options.onchange(c.value())})}}},value:function(c){var d=this._getValue();if(c!==undefined){this._setValue(c)}var e=this._getValue();if((e!=d&&this.options.onchange)){this.options.onchange(e)}return e},text:function(){return this.$el.select2("data").text},disabled:function(){return !this.$el.select2("enable")},enable:function(){this.$el.select2("enable",true)},disable:function(){this.$el.select2("enable",false)},add:function(c){this.select_data.push({id:c.id,text:c.text});this._refresh()},del:function(d){var c=this._getIndex(d);if(c!=-1){this.select_data.splice(c,1);this._refresh()}},remove:function(){this.$el.select2("destroy")},update:function(c){this.select_data=[];for(var d in c.data){this.select_data.push(c.data[d])}this._refresh()},_refresh:function(){if(!this.options.multiple){var d=this._getValue();var c={data:this.select_data,containerCssClass:this.options.css,placeholder:this.options.placeholder,width:"resolve",dropdownAutoWidth:true};this.$el.select2(c);this._setValue(d)}else{var c={multiple:this.options.multiple,containerCssClass:this.options.css,placeholder:this.options.placeholder,minimumInputLength:this.options.minimumInputLength,ajax:this.options.ajax,dropdownCssClass:this.options.dropdownCssClass,escapeMarkup:this.options.escapeMarkup,formatResult:this.options.formatResult,formatSelection:this.options.formatSelection,initSelection:this.options.initSelection,initialData:this.options.initialData};this.$el.select2(c)}},_getIndex:function(d){for(var c in this.select_data){if(this.select_data[c].id==d){return c}}return -1},_getValue:function(){return this.$el.select2("val")},_setValue:function(d){var c=this._getIndex(d);if(c==-1){if(this.select_data.length>0){d=this.select_data[0].id}}this.$el.select2("val",d)},_template:function(c){return'<input type="hidden" value="'+this.options.initialData+'"/>'}});return{View:b}}); \ No newline at end of file diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa static/style/blue/base.css --- a/static/style/blue/base.css +++ b/static/style/blue/base.css @@ -1232,8 +1232,7 @@ .select2-offscreen,.select2-offscreen:focus{clip:rect(0 0 0 0) !important;width:1px !important;height:1px !important;border:0 !important;margin:0 !important;padding:0 !important;overflow:hidden !important;position:absolute !important;outline:0 !important;left:0px !important;top:0px !important} .select2-display-none{display:none} .select2-measure-scrollbar{position:absolute;top:-10000px;left:-10000px;width:100px;height:100px;overflow:scroll} -@media only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (min-resolution:144dpi){.select2-search input,.select2-search-choice-close,.select2-container .select2-choice abbr,.select2-container .select2-choice .select2-arrow b{background-image:url('../images/select2x2.png') !important;background-repeat:no-repeat !important;background-size:60px 40px !important} .select2-search input{background-position:100% -21px !important}}.select2-container{min-width:256px} -.galaxy-frame{}.galaxy-frame .corner{-moz-border-radius:5px;border-radius:5px} +@media only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (min-resolution:144dpi){.select2-search input,.select2-search-choice-close,.select2-container .select2-choice abbr,.select2-container .select2-choice .select2-arrow b{background-image:url('../images/select2x2.png') !important;background-repeat:no-repeat !important;background-size:60px 40px !important} .select2-search input{background-position:100% -21px !important}}.galaxy-frame{}.galaxy-frame .corner{-moz-border-radius:5px;border-radius:5px} .galaxy-frame .toggle{color:gold} .galaxy-frame .frame-background{z-index:1000;position:absolute;display:none;top:0px;left:0px;height:100%;width:100%;opacity:0.6;background:#000;overflow:auto} .galaxy-frame .frame-shadow{z-index:1001;position:absolute;display:none;top:0px;left:0px;opacity:0.5;background:#2c3143;border:1px solid #888} diff -r cda6be2edfe6dbc07d97d18a0d0f1160376a6b9d -r 37e5c86d9fc0d5c1c9defd3cc8a4c37c24ed13fa static/style/src/less/base.less --- a/static/style/src/less/base.less +++ b/static/style/src/less/base.less @@ -15,10 +15,6 @@ } @import "select2.less"; -/* fix for zero width select2 - remove when fixed there */ -.select2-container { - min-width: 256px; -} // galaxy sub-components @import "frame.less"; Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.