commit/galaxy-central: 3 new changesets
3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/366f58570550/ Changeset: 366f58570550 User: martenson Date: 2014-09-18 16:45:04+00:00 Summary: removed the fix setting min-width to all select2 containers, I believe it is unnecessary with width: 'resolve' and dropdownAutoWidth: true settings Affected #: 8 files diff -r 66abf553f05ebf5fa00fda6800b2a7bb95d3b559 -r 366f5857055021b69fe623acd4101707c9fe569a 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 66abf553f05ebf5fa00fda6800b2a7bb95d3b559 -r 366f5857055021b69fe623acd4101707c9fe569a 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 66abf553f05ebf5fa00fda6800b2a7bb95d3b559 -r 366f5857055021b69fe623acd4101707c9fe569a 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 66abf553f05ebf5fa00fda6800b2a7bb95d3b559 -r 366f5857055021b69fe623acd4101707c9fe569a 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 66abf553f05ebf5fa00fda6800b2a7bb95d3b559 -r 366f5857055021b69fe623acd4101707c9fe569a 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 66abf553f05ebf5fa00fda6800b2a7bb95d3b559 -r 366f5857055021b69fe623acd4101707c9fe569a 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 66abf553f05ebf5fa00fda6800b2a7bb95d3b559 -r 366f5857055021b69fe623acd4101707c9fe569a 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 66abf553f05ebf5fa00fda6800b2a7bb95d3b559 -r 366f5857055021b69fe623acd4101707c9fe569a 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"; https://bitbucket.org/galaxy/galaxy-central/commits/e6996e0ec636/ Changeset: e6996e0ec636 User: martenson Date: 2014-09-18 18:48:50+00:00 Summary: tweaks to UI for library import, also added ext types and genome selection Affected #: 6 files diff -r 366f5857055021b69fe623acd4101707c9fe569a -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab 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 366f5857055021b69fe623acd4101707c9fe569a -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab 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 366f5857055021b69fe623acd4101707c9fe569a -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab 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 366f5857055021b69fe623acd4101707c9fe569a -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab 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 366f5857055021b69fe623acd4101707c9fe569a -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab 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 366f5857055021b69fe623acd4101707c9fe569a -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab 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 https://bitbucket.org/galaxy/galaxy-central/commits/1cf25d3a5cdc/ Changeset: 1cf25d3a5cdc User: martenson Date: 2014-09-18 18:49:20+00:00 Summary: Merge Affected #: 22 files diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 client/galaxy/scripts/mvc/dataset/dataset-li-edit.js --- a/client/galaxy/scripts/mvc/dataset/dataset-li-edit.js +++ b/client/galaxy/scripts/mvc/dataset/dataset-li-edit.js @@ -257,12 +257,26 @@ // ......................................................................... events /** event map */ events : _.extend( _.clone( _super.prototype.events ), { - 'click .undelete-link' : function( ev ){ this.model.undelete(); return false; }, - 'click .purge-link' : '_confirmPurge' + 'click .undelete-link' : '_clickUndeleteLink', + 'click .purge-link' : '_clickPurgeLink', + + 'click .edit-btn' : function( ev ){ this.trigger( 'edit', this, ev ); }, + 'click .delete-btn' : function( ev ){ this.trigger( 'delete', this, ev ); }, + 'click .rerun-btn' : function( ev ){ this.trigger( 'rerun', this, ev ); }, + 'click .report-err-btn' : function( ev ){ this.trigger( 'report-err', this, ev ); }, + 'click .visualization-btn' : function( ev ){ this.trigger( 'visualize', this, ev ); }, + 'click .dbkey a' : function( ev ){ this.trigger( 'edit', this, ev ); } }), - /** listener for item purge */ - _confirmPurge : function _confirmPurge( ev ){ + + /** listener for item undelete (in the messages section) */ + _clickUndeleteLink : function( ev ){ + this.model.undelete(); + return false; + }, + + /** listener for item purge (in the messages section) */ + _clickPurgeLink : function( ev ){ //TODO: confirm dialog this.model.purge(); return false; diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 client/galaxy/scripts/mvc/dataset/dataset-li.js --- a/client/galaxy/scripts/mvc/dataset/dataset-li.js +++ b/client/galaxy/scripts/mvc/dataset/dataset-li.js @@ -314,6 +314,13 @@ }, // ......................................................................... misc + events : _.extend( _.clone( _super.prototype.events ), { + 'click .display-btn' : function( ev ){ this.trigger( 'display', this, ev ); }, + 'click .params-btn' : function( ev ){ this.trigger( 'params', this, ev ); }, + 'click .download-btn' : function( ev ){ this.trigger( 'download', this, ev ); } + }), + + // ......................................................................... misc /** String representation */ toString : function(){ var modelString = ( this.model )?( this.model + '' ):( '(no model)' ); diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 client/galaxy/scripts/mvc/history/history-panel-edit-current.js --- a/client/galaxy/scripts/mvc/history/history-panel-edit-current.js +++ b/client/galaxy/scripts/mvc/history/history-panel-edit-current.js @@ -14,7 +14,13 @@ /** should the tags editor be shown or hidden initially? */ tagsEditorShown : false, /** should the annotation editor be shown or hidden initially? */ - annotationEditorShown : false + annotationEditorShown : false, + ///** what is the currently focused content (dataset or collection) in the current history? + // * (the history panel will highlight and scroll to the focused content view) + // */ + //focusedContentId : null + /** Current scroll position */ + scrollPosition : 0 }, toString : function(){ return 'HistoryPanelPrefs(' + JSON.stringify( this.toJSON() ) + ')'; @@ -70,6 +76,20 @@ /** sub-views that will overlay this panel (collections) */ this.panelStack = []; + + /** id of currently focused content */ + this.currentContentId = attributes.currentContentId || null; + //NOTE: purposely not sent to localstorage since panel recreation roughly lines up with a reset of this value + }, + + /** Override to cache the current scroll position with a listener */ + _setUpListeners : function(){ + _super.prototype._setUpListeners.call( this ); + + var panel = this; + this.$scrollContainer().on( 'scroll', function( ev ){ + panel.preferences.set( 'scrollPosition', $( this ).scrollTop() ); + }); }, // ------------------------------------------------------------------------ loading history/item models @@ -243,11 +263,34 @@ }); }, + /** Override to scroll to cached position (in prefs) after swapping */ + _swapNewRender : function( $newRender ){ + _super.prototype._swapNewRender.call( this, $newRender ); + var panel = this; + + _.delay( function(){ + var pos = panel.preferences.get( 'scrollPosition' ); + if( pos ){ + panel.scrollTo( pos ); + } + }, 10 ); + //TODO: is this enough of a delay on larger histories? + + return this; + }, + // ------------------------------------------------------------------------ sub-views // reverse HID order - /** Override to reverse order of views - newest contents on top */ + /** Override to reverse order of views - newest contents on top + * and add the current-content highlight class to currentContentId's view + */ _attachItems : function( $whereTo ){ + var panel = this; this.$list( $whereTo ).append( this.views.reverse().map( function( view ){ + // add current content + if( panel.currentContentId && view.model.id === panel.currentContentId ){ + view.$el.addClass( 'current-content' ); + } return view.$el; })); return this; @@ -298,9 +341,26 @@ view.on( 'collapsed:drilldown', function( v, drilldown ){ this._collapseDrilldownPanel( drilldown ); }, this ); + + // when content is manipulated, make it the current-content + view.on( 'display edit params rerun report-err visualize', function( v, ev ){ + this.setCurrentContent( v ); + }, this ); + return this; }, + /** display 'current content': add a visible highlight and store the id of a content item */ + setCurrentContent : function( view ){ + this.$( '.history-content.current-content' ).removeClass( 'current-content' ); + if( view ){ + view.$el.addClass( 'current-content' ); + this.currentContentId = view.model.id; + } else { + this.currentContentId = null; + } + }, + /** Handle drill down by hiding this panels list and controls and showing the sub-panel */ _expandDrilldownPanel : function( drilldown ){ this.panelStack.push( drilldown ); diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 client/galaxy/scripts/mvc/list/list-panel.js --- a/client/galaxy/scripts/mvc/list/list-panel.js +++ b/client/galaxy/scripts/mvc/list/list-panel.js @@ -679,28 +679,28 @@ }, /** set the current scroll position of the panel in its parent */ - scrollTo : function( pos ){ - this.$scrollContainer().scrollTop( pos ); + scrollTo : function( pos, speed ){ + speed = speed || 0; + this.$scrollContainer().animate({ scrollTop: pos }, speed ); return this; }, /** Scrolls the panel to the top. */ - scrollToTop : function(){ - this.$scrollContainer().scrollTop( 0 ); - return this; + scrollToTop : function( speed ){ + return this.scrollTo( 0, speed ); }, /** */ - scrollToItem : function( view ){ + scrollToItem : function( view, speed ){ if( !view ){ return this; } - var itemTop = view.$el.offset().top; - this.$scrollContainer().scrollTop( itemTop ); - return this; + //var itemTop = view.$el.offset().top; + var itemTop = view.$el.position().top; + return this.scrollTo( itemTop, speed ); }, /** Scrolls the panel to show the content with the given id. */ - scrollToId : function( id ){ - return this.scrollToItem( this.viewFromModelId( id ) ); + scrollToId : function( id, speed ){ + return this.scrollToItem( this.viewFromModelId( id ), speed ); }, // ------------------------------------------------------------------------ panel events diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 client/galaxy/scripts/mvc/tools/tools-repeat.js --- a/client/galaxy/scripts/mvc/tools/tools-repeat.js +++ b/client/galaxy/scripts/mvc/tools/tools-repeat.js @@ -85,7 +85,7 @@ // append content portlet.append(options.$el); - // append section row class + // tag as section row portlet.$el.addClass('section-row'); // append to dom diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 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 @@ -141,16 +141,11 @@ cls : 'ui-table-plain' }); - // create input field wrapper - var input_element = new InputElement({ - label : '', - help : input_def.help, - $el : sub_section.$el, - highlight : true - }); + // displays as grouped subsection + sub_section.$el.addClass('ui-table-form-section'); // create table row - this.table.add(input_element.$el); + this.table.add(sub_section.$el); // append to table this.table.append(sub_section_id); @@ -234,7 +229,7 @@ $el : repeat.$el, highlight : true }); - + // create table row this.table.add(input_element.$el); diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 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 e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 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 e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 static/scripts/mvc/dataset/dataset-li-edit.js --- a/static/scripts/mvc/dataset/dataset-li-edit.js +++ b/static/scripts/mvc/dataset/dataset-li-edit.js @@ -257,12 +257,26 @@ // ......................................................................... events /** event map */ events : _.extend( _.clone( _super.prototype.events ), { - 'click .undelete-link' : function( ev ){ this.model.undelete(); return false; }, - 'click .purge-link' : '_confirmPurge' + 'click .undelete-link' : '_clickUndeleteLink', + 'click .purge-link' : '_clickPurgeLink', + + 'click .edit-btn' : function( ev ){ this.trigger( 'edit', this, ev ); }, + 'click .delete-btn' : function( ev ){ this.trigger( 'delete', this, ev ); }, + 'click .rerun-btn' : function( ev ){ this.trigger( 'rerun', this, ev ); }, + 'click .report-err-btn' : function( ev ){ this.trigger( 'report-err', this, ev ); }, + 'click .visualization-btn' : function( ev ){ this.trigger( 'visualize', this, ev ); }, + 'click .dbkey a' : function( ev ){ this.trigger( 'edit', this, ev ); } }), - /** listener for item purge */ - _confirmPurge : function _confirmPurge( ev ){ + + /** listener for item undelete (in the messages section) */ + _clickUndeleteLink : function( ev ){ + this.model.undelete(); + return false; + }, + + /** listener for item purge (in the messages section) */ + _clickPurgeLink : function( ev ){ //TODO: confirm dialog this.model.purge(); return false; diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 static/scripts/mvc/dataset/dataset-li.js --- a/static/scripts/mvc/dataset/dataset-li.js +++ b/static/scripts/mvc/dataset/dataset-li.js @@ -314,6 +314,13 @@ }, // ......................................................................... misc + events : _.extend( _.clone( _super.prototype.events ), { + 'click .display-btn' : function( ev ){ this.trigger( 'display', this, ev ); }, + 'click .params-btn' : function( ev ){ this.trigger( 'params', this, ev ); }, + 'click .download-btn' : function( ev ){ this.trigger( 'download', this, ev ); } + }), + + // ......................................................................... misc /** String representation */ toString : function(){ var modelString = ( this.model )?( this.model + '' ):( '(no model)' ); diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 static/scripts/mvc/history/history-panel-edit-current.js --- a/static/scripts/mvc/history/history-panel-edit-current.js +++ b/static/scripts/mvc/history/history-panel-edit-current.js @@ -14,7 +14,13 @@ /** should the tags editor be shown or hidden initially? */ tagsEditorShown : false, /** should the annotation editor be shown or hidden initially? */ - annotationEditorShown : false + annotationEditorShown : false, + ///** what is the currently focused content (dataset or collection) in the current history? + // * (the history panel will highlight and scroll to the focused content view) + // */ + //focusedContentId : null + /** Current scroll position */ + scrollPosition : 0 }, toString : function(){ return 'HistoryPanelPrefs(' + JSON.stringify( this.toJSON() ) + ')'; @@ -70,6 +76,20 @@ /** sub-views that will overlay this panel (collections) */ this.panelStack = []; + + /** id of currently focused content */ + this.currentContentId = attributes.currentContentId || null; + //NOTE: purposely not sent to localstorage since panel recreation roughly lines up with a reset of this value + }, + + /** Override to cache the current scroll position with a listener */ + _setUpListeners : function(){ + _super.prototype._setUpListeners.call( this ); + + var panel = this; + this.$scrollContainer().on( 'scroll', function( ev ){ + panel.preferences.set( 'scrollPosition', $( this ).scrollTop() ); + }); }, // ------------------------------------------------------------------------ loading history/item models @@ -243,11 +263,34 @@ }); }, + /** Override to scroll to cached position (in prefs) after swapping */ + _swapNewRender : function( $newRender ){ + _super.prototype._swapNewRender.call( this, $newRender ); + var panel = this; + + _.delay( function(){ + var pos = panel.preferences.get( 'scrollPosition' ); + if( pos ){ + panel.scrollTo( pos ); + } + }, 10 ); + //TODO: is this enough of a delay on larger histories? + + return this; + }, + // ------------------------------------------------------------------------ sub-views // reverse HID order - /** Override to reverse order of views - newest contents on top */ + /** Override to reverse order of views - newest contents on top + * and add the current-content highlight class to currentContentId's view + */ _attachItems : function( $whereTo ){ + var panel = this; this.$list( $whereTo ).append( this.views.reverse().map( function( view ){ + // add current content + if( panel.currentContentId && view.model.id === panel.currentContentId ){ + view.$el.addClass( 'current-content' ); + } return view.$el; })); return this; @@ -298,9 +341,26 @@ view.on( 'collapsed:drilldown', function( v, drilldown ){ this._collapseDrilldownPanel( drilldown ); }, this ); + + // when content is manipulated, make it the current-content + view.on( 'display edit params rerun report-err visualize', function( v, ev ){ + this.setCurrentContent( v ); + }, this ); + return this; }, + /** display 'current content': add a visible highlight and store the id of a content item */ + setCurrentContent : function( view ){ + this.$( '.history-content.current-content' ).removeClass( 'current-content' ); + if( view ){ + view.$el.addClass( 'current-content' ); + this.currentContentId = view.model.id; + } else { + this.currentContentId = null; + } + }, + /** Handle drill down by hiding this panels list and controls and showing the sub-panel */ _expandDrilldownPanel : function( drilldown ){ this.panelStack.push( drilldown ); diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 static/scripts/mvc/list/list-panel.js --- a/static/scripts/mvc/list/list-panel.js +++ b/static/scripts/mvc/list/list-panel.js @@ -679,28 +679,28 @@ }, /** set the current scroll position of the panel in its parent */ - scrollTo : function( pos ){ - this.$scrollContainer().scrollTop( pos ); + scrollTo : function( pos, speed ){ + speed = speed || 0; + this.$scrollContainer().animate({ scrollTop: pos }, speed ); return this; }, /** Scrolls the panel to the top. */ - scrollToTop : function(){ - this.$scrollContainer().scrollTop( 0 ); - return this; + scrollToTop : function( speed ){ + return this.scrollTo( 0, speed ); }, /** */ - scrollToItem : function( view ){ + scrollToItem : function( view, speed ){ if( !view ){ return this; } - var itemTop = view.$el.offset().top; - this.$scrollContainer().scrollTop( itemTop ); - return this; + //var itemTop = view.$el.offset().top; + var itemTop = view.$el.position().top; + return this.scrollTo( itemTop, speed ); }, /** Scrolls the panel to show the content with the given id. */ - scrollToId : function( id ){ - return this.scrollToItem( this.viewFromModelId( id ) ); + scrollToId : function( id, speed ){ + return this.scrollToItem( this.viewFromModelId( id ), speed ); }, // ------------------------------------------------------------------------ panel events diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 static/scripts/mvc/tools/tools-repeat.js --- a/static/scripts/mvc/tools/tools-repeat.js +++ b/static/scripts/mvc/tools/tools-repeat.js @@ -85,7 +85,7 @@ // append content portlet.append(options.$el); - // append section row class + // tag as section row portlet.$el.addClass('section-row'); // append to dom diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 static/scripts/mvc/tools/tools-section.js --- a/static/scripts/mvc/tools/tools-section.js +++ b/static/scripts/mvc/tools/tools-section.js @@ -141,16 +141,11 @@ cls : 'ui-table-plain' }); - // create input field wrapper - var input_element = new InputElement({ - label : '', - help : input_def.help, - $el : sub_section.$el, - highlight : true - }); + // displays as grouped subsection + sub_section.$el.addClass('ui-table-form-section'); // create table row - this.table.add(input_element.$el); + this.table.add(sub_section.$el); // append to table this.table.append(sub_section_id); @@ -234,7 +229,7 @@ $el : repeat.$el, highlight : true }); - + // create table row this.table.add(input_element.$el); diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 static/scripts/packed/mvc/dataset/dataset-li-edit.js --- a/static/scripts/packed/mvc/dataset/dataset-li-edit.js +++ b/static/scripts/packed/mvc/dataset/dataset-li-edit.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/states","mvc/dataset/dataset-li","mvc/tags","mvc/annotations","mvc/base-mvc","utils/localization"],function(g,d,e,a,h,b){var f=d.DatasetListItemView;var i=f.extend({initialize:function(j){f.prototype.initialize.call(this,j);this.hasUser=j.hasUser;this.purgeAllowed=j.purgeAllowed||false;this.tagsEditorShown=j.tagsEditorShown||false;this.annotationEditorShown=j.annotationEditorShown||false},_renderPrimaryActions:function(){var j=f.prototype._renderPrimaryActions.call(this);if(this.model.get("state")===g.NOT_VIEWABLE){return j}return f.prototype._renderPrimaryActions.call(this).concat([this._renderEditButton(),this._renderDeleteButton()])},_renderEditButton:function(){if((this.model.get("state")===g.DISCARDED)||(!this.model.get("accessible"))){return null}var l=this.model.get("purged"),j=this.model.get("deleted"),k={title:b("Edit attributes"),href:this.model.urls.edit,target:this.linkTarget,faIcon:"fa-pencil",classes:"edit-btn"};if(j||l){k.disabled=true;if(l){k.title=b("Cannot edit attributes of datasets removed from disk")}else{if(j){k.title=b("Undelete dataset to edit attributes")}}}else{if(_.contains([g.UPLOAD,g.NEW],this.model.get("state"))){k.disabled=true;k.title=b("This dataset is not yet editable")}}return faIconButton(k)},_renderDeleteButton:function(){if((!this.model.get("accessible"))){return null}var j=this,k=this.model.isDeletedOrPurged();return faIconButton({title:!k?b("Delete"):b("Dataset is already deleted"),disabled:k,faIcon:"fa-times",classes:"delete-btn",onclick:function(){j.$el.find(".icon-btn.delete-btn").trigger("mouseout");j.model["delete"]()}})},_renderDetails:function(){var j=f.prototype._renderDetails.call(this),k=this.model.get("state");if(!this.model.isDeletedOrPurged()&&_.contains([g.OK,g.FAILED_METADATA],k)){this._renderTags(j);this._renderAnnotation(j);this._makeDbkeyEditLink(j)}this._setUpBehaviors(j);return j},_renderSecondaryActions:function(){var j=f.prototype._renderSecondaryActions.call(this);switch(this.model.get("state")){case g.UPLOAD:case g.NEW:case g.NOT_VIEWABLE:return j;case g.ERROR:j.unshift(this._renderErrButton());return j.concat([this._renderRerunButton()]);case g.OK:case g.FAILED_METADATA:return j.concat([this._renderRerunButton(),this._renderVisualizationsButton()])}return j.concat([this._renderRerunButton()])},_renderErrButton:function(){return faIconButton({title:b("View or report this error"),href:this.model.urls.report_error,classes:"report-error-btn",target:this.linkTarget,faIcon:"fa-bug"})},_renderRerunButton:function(){return faIconButton({title:b("Run this job again"),href:this.model.urls.rerun,classes:"rerun-btn",target:this.linkTarget,faIcon:"fa-refresh"})},_renderVisualizationsButton:function(){var j=this.model.get("visualizations");if((this.model.isDeletedOrPurged())||(!this.hasUser)||(!this.model.hasData())||(_.isEmpty(j))){return null}if(!_.isObject(j[0])){this.warn("Visualizations have been switched off");return null}var k=$(this.templates.visualizations(j,this));this._addScratchBookFn(k.find(".visualization-link").addBack(".visualization-link"));return k},_addScratchBookFn:function(j){j.click(function(k){if(Galaxy.frame&&Galaxy.frame.active){Galaxy.frame.add({title:"Visualization",type:"url",content:$(this).attr("href")});k.preventDefault();k.stopPropagation()}})},_renderTags:function(j){if(!this.hasUser){return}var k=this;this.tagsEditor=new e.TagsEditor({model:this.model,el:j.find(".tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){k.tagsEditorShown=true},onhide:function(){k.tagsEditorShown=false},$activator:faIconButton({title:b("Edit dataset tags"),classes:"tag-btn",faIcon:"fa-tags"}).appendTo(j.find(".actions .right"))});if(this.tagsEditorShown){this.tagsEditor.toggle(true)}},_renderAnnotation:function(j){if(!this.hasUser){return}var k=this;this.annotationEditor=new a.AnnotationEditor({model:this.model,el:j.find(".annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){k.annotationEditorShown=true},onhide:function(){k.annotationEditorShown=false},$activator:faIconButton({title:b("Edit dataset annotation"),classes:"annotate-btn",faIcon:"fa-comment"}).appendTo(j.find(".actions .right"))});if(this.annotationEditorShown){this.annotationEditor.toggle(true)}},_makeDbkeyEditLink:function(j){if(this.model.get("metadata_dbkey")==="?"&&!this.model.isDeletedOrPurged()){var k=$('<a class="value">?</a>').attr("href",this.model.urls.edit).attr("target",this.linkTarget);j.find(".dbkey .value").replaceWith(k)}},events:_.extend(_.clone(f.prototype.events),{"click .undelete-link":function(j){this.model.undelete();return false},"click .purge-link":"_confirmPurge"}),_confirmPurge:function c(j){this.model.purge();return false},toString:function(){var j=(this.model)?(this.model+""):("(no model)");return"HDAEditView("+j+")"}});i.prototype.templates=(function(){var k=_.extend({},f.prototype.templates.warnings,{failed_metadata:h.wrapTemplate(['<% if( dataset.state === "failed_metadata" ){ %>','<div class="failed_metadata-warning warningmessagesmall">',b("An error occurred setting the metadata for this dataset"),'<br /><a href="<%= dataset.urls.edit %>" target="<%= view.linkTarget %>">',b("Set it manually or retry auto-detection"),"</a>","</div>","<% } %>"],"dataset"),deleted:h.wrapTemplate(["<% if( dataset.deleted && !dataset.purged ){ %>",'<div class="deleted-msg warningmessagesmall">',b("This dataset has been deleted"),'<br /><a class="undelete-link" href="javascript:void(0);">',b("Undelete it"),"</a>","<% if( view.purgeAllowed ){ %>",'<br /><a class="purge-link" href="javascript:void(0);">',b("Permanently remove it from disk"),"</a>","<% } %>","</div>","<% } %>"],"dataset")});var j=h.wrapTemplate(["<% if( visualizations.length === 1 ){ %>",'<a class="visualization-btn visualization-link icon-btn" href="<%= visualizations[0].href %>"',' target="<%= visualizations[0].target %>" title="',b("Visualize in"),' <%= visualizations[0].html %>">','<span class="fa fa-bar-chart-o"></span>',"</a>","<% } else { %>",'<div class="visualizations-dropdown dropdown">','<a class="visualization-btn icon-btn" data-toggle="dropdown" title="',b("Visualize"),'">','<span class="fa fa-bar-chart-o"></span>',"</a>",'<ul class="dropdown-menu" role="menu">',"<% _.each( visualizations, function( visualization ){ %>",'<li><a class="visualization-link" href="<%= visualization.href %>"',' target="<%= visualization.target %>">',"<%= visualization.html %>","</a></li>","<% }); %>","</ul>","</div>","<% } %>"],"visualizations");return _.extend({},f.prototype.templates,{warnings:k,visualizations:j})}());return{DatasetListItemEdit:i}}); \ No newline at end of file +define(["mvc/dataset/states","mvc/dataset/dataset-li","mvc/tags","mvc/annotations","mvc/base-mvc","utils/localization"],function(b,h,g,e,c,d){var f=h.DatasetListItemView;var a=f.extend({initialize:function(i){f.prototype.initialize.call(this,i);this.hasUser=i.hasUser;this.purgeAllowed=i.purgeAllowed||false;this.tagsEditorShown=i.tagsEditorShown||false;this.annotationEditorShown=i.annotationEditorShown||false},_renderPrimaryActions:function(){var i=f.prototype._renderPrimaryActions.call(this);if(this.model.get("state")===b.NOT_VIEWABLE){return i}return f.prototype._renderPrimaryActions.call(this).concat([this._renderEditButton(),this._renderDeleteButton()])},_renderEditButton:function(){if((this.model.get("state")===b.DISCARDED)||(!this.model.get("accessible"))){return null}var k=this.model.get("purged"),i=this.model.get("deleted"),j={title:d("Edit attributes"),href:this.model.urls.edit,target:this.linkTarget,faIcon:"fa-pencil",classes:"edit-btn"};if(i||k){j.disabled=true;if(k){j.title=d("Cannot edit attributes of datasets removed from disk")}else{if(i){j.title=d("Undelete dataset to edit attributes")}}}else{if(_.contains([b.UPLOAD,b.NEW],this.model.get("state"))){j.disabled=true;j.title=d("This dataset is not yet editable")}}return faIconButton(j)},_renderDeleteButton:function(){if((!this.model.get("accessible"))){return null}var i=this,j=this.model.isDeletedOrPurged();return faIconButton({title:!j?d("Delete"):d("Dataset is already deleted"),disabled:j,faIcon:"fa-times",classes:"delete-btn",onclick:function(){i.$el.find(".icon-btn.delete-btn").trigger("mouseout");i.model["delete"]()}})},_renderDetails:function(){var i=f.prototype._renderDetails.call(this),j=this.model.get("state");if(!this.model.isDeletedOrPurged()&&_.contains([b.OK,b.FAILED_METADATA],j)){this._renderTags(i);this._renderAnnotation(i);this._makeDbkeyEditLink(i)}this._setUpBehaviors(i);return i},_renderSecondaryActions:function(){var i=f.prototype._renderSecondaryActions.call(this);switch(this.model.get("state")){case b.UPLOAD:case b.NEW:case b.NOT_VIEWABLE:return i;case b.ERROR:i.unshift(this._renderErrButton());return i.concat([this._renderRerunButton()]);case b.OK:case b.FAILED_METADATA:return i.concat([this._renderRerunButton(),this._renderVisualizationsButton()])}return i.concat([this._renderRerunButton()])},_renderErrButton:function(){return faIconButton({title:d("View or report this error"),href:this.model.urls.report_error,classes:"report-error-btn",target:this.linkTarget,faIcon:"fa-bug"})},_renderRerunButton:function(){return faIconButton({title:d("Run this job again"),href:this.model.urls.rerun,classes:"rerun-btn",target:this.linkTarget,faIcon:"fa-refresh"})},_renderVisualizationsButton:function(){var i=this.model.get("visualizations");if((this.model.isDeletedOrPurged())||(!this.hasUser)||(!this.model.hasData())||(_.isEmpty(i))){return null}if(!_.isObject(i[0])){this.warn("Visualizations have been switched off");return null}var j=$(this.templates.visualizations(i,this));this._addScratchBookFn(j.find(".visualization-link").addBack(".visualization-link"));return j},_addScratchBookFn:function(i){i.click(function(j){if(Galaxy.frame&&Galaxy.frame.active){Galaxy.frame.add({title:"Visualization",type:"url",content:$(this).attr("href")});j.preventDefault();j.stopPropagation()}})},_renderTags:function(i){if(!this.hasUser){return}var j=this;this.tagsEditor=new g.TagsEditor({model:this.model,el:i.find(".tags-display"),onshowFirstTime:function(){this.render()},onshow:function(){j.tagsEditorShown=true},onhide:function(){j.tagsEditorShown=false},$activator:faIconButton({title:d("Edit dataset tags"),classes:"tag-btn",faIcon:"fa-tags"}).appendTo(i.find(".actions .right"))});if(this.tagsEditorShown){this.tagsEditor.toggle(true)}},_renderAnnotation:function(i){if(!this.hasUser){return}var j=this;this.annotationEditor=new e.AnnotationEditor({model:this.model,el:i.find(".annotation-display"),onshowFirstTime:function(){this.render()},onshow:function(){j.annotationEditorShown=true},onhide:function(){j.annotationEditorShown=false},$activator:faIconButton({title:d("Edit dataset annotation"),classes:"annotate-btn",faIcon:"fa-comment"}).appendTo(i.find(".actions .right"))});if(this.annotationEditorShown){this.annotationEditor.toggle(true)}},_makeDbkeyEditLink:function(i){if(this.model.get("metadata_dbkey")==="?"&&!this.model.isDeletedOrPurged()){var j=$('<a class="value">?</a>').attr("href",this.model.urls.edit).attr("target",this.linkTarget);i.find(".dbkey .value").replaceWith(j)}},events:_.extend(_.clone(f.prototype.events),{"click .undelete-link":"_clickUndeleteLink","click .purge-link":"_clickPurgeLink","click .edit-btn":function(i){this.trigger("edit",this,i)},"click .delete-btn":function(i){this.trigger("delete",this,i)},"click .rerun-btn":function(i){this.trigger("rerun",this,i)},"click .report-err-btn":function(i){this.trigger("report-err",this,i)},"click .visualization-btn":function(i){this.trigger("visualize",this,i)},"click .dbkey a":function(i){this.trigger("edit",this,i)}}),_clickUndeleteLink:function(i){this.model.undelete();return false},_clickPurgeLink:function(i){this.model.purge();return false},toString:function(){var i=(this.model)?(this.model+""):("(no model)");return"HDAEditView("+i+")"}});a.prototype.templates=(function(){var j=_.extend({},f.prototype.templates.warnings,{failed_metadata:c.wrapTemplate(['<% if( dataset.state === "failed_metadata" ){ %>','<div class="failed_metadata-warning warningmessagesmall">',d("An error occurred setting the metadata for this dataset"),'<br /><a href="<%= dataset.urls.edit %>" target="<%= view.linkTarget %>">',d("Set it manually or retry auto-detection"),"</a>","</div>","<% } %>"],"dataset"),deleted:c.wrapTemplate(["<% if( dataset.deleted && !dataset.purged ){ %>",'<div class="deleted-msg warningmessagesmall">',d("This dataset has been deleted"),'<br /><a class="undelete-link" href="javascript:void(0);">',d("Undelete it"),"</a>","<% if( view.purgeAllowed ){ %>",'<br /><a class="purge-link" href="javascript:void(0);">',d("Permanently remove it from disk"),"</a>","<% } %>","</div>","<% } %>"],"dataset")});var i=c.wrapTemplate(["<% if( visualizations.length === 1 ){ %>",'<a class="visualization-btn visualization-link icon-btn" href="<%= visualizations[0].href %>"',' target="<%= visualizations[0].target %>" title="',d("Visualize in"),' <%= visualizations[0].html %>">','<span class="fa fa-bar-chart-o"></span>',"</a>","<% } else { %>",'<div class="visualizations-dropdown dropdown">','<a class="visualization-btn icon-btn" data-toggle="dropdown" title="',d("Visualize"),'">','<span class="fa fa-bar-chart-o"></span>',"</a>",'<ul class="dropdown-menu" role="menu">',"<% _.each( visualizations, function( visualization ){ %>",'<li><a class="visualization-link" href="<%= visualization.href %>"',' target="<%= visualization.target %>">',"<%= visualization.html %>","</a></li>","<% }); %>","</ul>","</div>","<% } %>"],"visualizations");return _.extend({},f.prototype.templates,{warnings:j,visualizations:i})}());return{DatasetListItemEdit:a}}); \ No newline at end of file diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 static/scripts/packed/mvc/dataset/dataset-li.js --- a/static/scripts/packed/mvc/dataset/dataset-li.js +++ b/static/scripts/packed/mvc/dataset/dataset-li.js @@ -1,1 +1,1 @@ -define(["mvc/list/list-item","mvc/dataset/states","mvc/base-mvc","utils/localization"],function(d,a,b,c){var f=d.ListItemView;var e=f.extend({className:f.prototype.className+" dataset",id:function(){return["dataset",this.model.get("id")].join("-")},initialize:function(g){if(g.logger){this.logger=this.model.logger=g.logger}this.log(this+".initialize:",g);f.prototype.initialize.call(this,g);this.linkTarget=g.linkTarget||"_blank";this._setUpListeners()},_setUpListeners:function(){f.prototype._setUpListeners.call(this);this.model.on("change",function(h,g){if(this.model.changedAttributes().state&&this.model.inReadyState()&&this.expanded&&!this.model.hasDetails()){this.model.fetch()}else{this.render()}},this)},_fetchModelDetails:function(){var g=this;if(g.model.inReadyState()&&!g.model.hasDetails()){return g.model.fetch({silent:true})}return jQuery.when()},remove:function(h,i){var g=this;h=h||this.fxSpeed;this.$el.fadeOut(h,function(){Backbone.View.prototype.remove.call(g);if(i){i.call(g)}})},render:function(g){return f.prototype.render.call(this,g)},_swapNewRender:function(g){f.prototype._swapNewRender.call(this,g);if(this.model.has("state")){this.$el.addClass("state-"+this.model.get("state"))}return this.$el},_renderPrimaryActions:function(){return[this._renderDisplayButton()]},_renderDisplayButton:function(){var i=this.model.get("state");if((i===a.NOT_VIEWABLE)||(i===a.DISCARDED)||(!this.model.get("accessible"))){return null}var h={target:this.linkTarget,classes:"display-btn"};if(this.model.get("purged")){h.disabled=true;h.title=c("Cannot display datasets removed from disk")}else{if(i===a.UPLOAD){h.disabled=true;h.title=c("This dataset must finish uploading before it can be viewed")}else{if(i===a.NEW){h.disabled=true;h.title=c("This dataset is not yet viewable")}else{h.title=c("View data");h.href=this.model.urls.display;var g=this;h.onclick=function(j){if(Galaxy.frame&&Galaxy.frame.active){Galaxy.frame.add({title:"Data Viewer: "+g.model.get("name"),type:"other",content:function(k){require(["mvc/data"],function(l){var m=new l.TabularDataset({id:g.model.get("id")});$.when(m.fetch()).then(function(){l.createTabularDatasetChunkedView({model:m,parent_elt:k,embedded:true,height:"100%"})})})}});j.preventDefault()}}}}}h.faIcon="fa-eye";return faIconButton(h)},_renderDetails:function(){if(this.model.get("state")===a.NOT_VIEWABLE){return $(this.templates.noAccess(this.model.toJSON(),this))}var g=f.prototype._renderDetails.call(this);g.find(".actions .left").empty().append(this._renderSecondaryActions());g.find(".summary").html(this._renderSummary()).prepend(this._renderDetailMessages());g.find(".display-applications").html(this._renderDisplayApplications());this._setUpBehaviors(g);return g},_renderSummary:function(){var g=this.model.toJSON(),h=this.templates.summaries[g.state];h=h||this.templates.summaries.unknown;return h(g,this)},_renderDetailMessages:function(){var g=this,i=$('<div class="detail-messages"></div>'),h=g.model.toJSON();_.each(g.templates.detailMessages,function(j){i.append($(j(h,g)))});return i},_renderDisplayApplications:function(){if(this.model.isDeletedOrPurged()){return""}return[this.templates.displayApplications(this.model.get("display_apps"),this),this.templates.displayApplications(this.model.get("display_types"),this)].join("")},_renderSecondaryActions:function(){this.debug("_renderSecondaryActions");switch(this.model.get("state")){case a.NOT_VIEWABLE:return[];case a.OK:case a.FAILED_METADATA:case a.ERROR:return[this._renderDownloadButton(),this._renderShowParamsButton()]}return[this._renderShowParamsButton()]},_renderShowParamsButton:function(){return faIconButton({title:c("View details"),classes:"params-btn",href:this.model.urls.show_params,target:this.linkTarget,faIcon:"fa-info-circle"})},_renderDownloadButton:function(){if(this.model.get("purged")||!this.model.hasData()){return null}if(!_.isEmpty(this.model.get("meta_files"))){return this._renderMetaFileDownloadButton()}return $(['<a class="download-btn icon-btn" href="',this.model.urls.download,'" title="'+c("Download")+'">','<span class="fa fa-floppy-o"></span>',"</a>"].join(""))},_renderMetaFileDownloadButton:function(){var g=this.model.urls;return $(['<div class="metafile-dropdown dropdown">','<a class="download-btn icon-btn" href="javascript:void(0)" data-toggle="dropdown"',' title="'+c("Download")+'">','<span class="fa fa-floppy-o"></span>',"</a>",'<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">','<li><a href="'+g.download+'">',c("Download dataset"),"</a></li>",_.map(this.model.get("meta_files"),function(h){return['<li><a href="',g.meta_download+h.file_type,'">',c("Download")," ",h.file_type,"</a></li>"].join("")}).join("\n"),"</ul>","</div>"].join("\n"))},toString:function(){var g=(this.model)?(this.model+""):("(no model)");return"DatasetListItemView("+g+")"}});e.prototype.templates=(function(){var i=_.extend({},f.prototype.templates.warnings,{failed_metadata:b.wrapTemplate(['<% if( model.state === "failed_metadata" ){ %>','<div class="warningmessagesmall">',c("An error occurred setting the metadata for this dataset"),"</div>","<% } %>"]),error:b.wrapTemplate(["<% if( model.error ){ %>",'<div class="errormessagesmall">',c("There was an error getting the data for this dataset"),": <%- model.error %>","</div>","<% } %>"]),purged:b.wrapTemplate(["<% if( model.purged ){ %>",'<div class="purged-msg warningmessagesmall">',c("This dataset has been deleted and removed from disk"),"</div>","<% } %>"]),deleted:b.wrapTemplate(["<% if( model.deleted && !model.purged ){ %>",'<div class="deleted-msg warningmessagesmall">',c("This dataset has been deleted"),"</div>","<% } %>"])});var j=b.wrapTemplate(['<div class="details">','<div class="summary"></div>','<div class="actions clear">','<div class="left"></div>','<div class="right"></div>',"</div>","<% if( !dataset.deleted && !dataset.purged ){ %>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="display-applications"></div>',"<% if( dataset.peek ){ %>",'<pre class="dataset-peek"><%= dataset.peek %></pre>',"<% } %>","<% } %>","</div>"],"dataset");var h=b.wrapTemplate(['<div class="details">','<div class="summary">',c("You do not have permission to view this dataset"),"</div>","</div>"],"dataset");var k={};k[a.OK]=k[a.FAILED_METADATA]=b.wrapTemplate(["<% if( dataset.misc_blurb ){ %>",'<div class="blurb">','<span class="value"><%- dataset.misc_blurb %></span>',"</div>","<% } %>","<% if( dataset.file_ext ){ %>",'<div class="datatype">','<label class="prompt">',c("format"),"</label>",'<span class="value"><%- dataset.file_ext %></span>',"</div>","<% } %>","<% if( dataset.metadata_dbkey ){ %>",'<div class="dbkey">','<label class="prompt">',c("database"),"</label>",'<span class="value">',"<%- dataset.metadata_dbkey %>","</span>","</div>","<% } %>","<% if( dataset.misc_info ){ %>",'<div class="info">','<span class="value"><%- dataset.misc_info %></span>',"</div>","<% } %>"],"dataset");k[a.NEW]=b.wrapTemplate(["<div>",c("This is a new dataset and not all of its data are available yet"),"</div>"],"dataset");k[a.NOT_VIEWABLE]=b.wrapTemplate(["<div>",c("You do not have permission to view this dataset"),"</div>"],"dataset");k[a.DISCARDED]=b.wrapTemplate(["<div>",c("The job creating this dataset was cancelled before completion"),"</div>"],"dataset");k[a.QUEUED]=b.wrapTemplate(["<div>",c("This job is waiting to run"),"</div>"],"dataset");k[a.RUNNING]=b.wrapTemplate(["<div>",c("This job is currently running"),"</div>"],"dataset");k[a.UPLOAD]=b.wrapTemplate(["<div>",c("This dataset is currently uploading"),"</div>"],"dataset");k[a.SETTING_METADATA]=b.wrapTemplate(["<div>",c("Metadata is being auto-detected"),"</div>"],"dataset");k[a.PAUSED]=b.wrapTemplate(["<div>",c('This job is paused. Use the "Resume Paused Jobs" in the history menu to resume'),"</div>"],"dataset");k[a.ERROR]=b.wrapTemplate(["<% if( !dataset.purged ){ %>","<div><%- dataset.misc_blurb %></div>","<% } %>",'<span class="help-text">',c("An error occurred with this dataset"),":</span>",'<div class="job-error-text"><%- dataset.misc_info %></div>'],"dataset");k[a.EMPTY]=b.wrapTemplate(["<div>",c("No data"),": <i><%- dataset.misc_blurb %></i></div>"],"dataset");k.unknown=b.wrapTemplate(['<div>Error: unknown dataset state: "<%- dataset.state %>"</div>'],"dataset");var l={resubmitted:b.wrapTemplate(["<% if( model.resubmitted ){ %>",'<div class="resubmitted-msg infomessagesmall">',c("The job creating this dataset has been resubmitted"),"</div>","<% } %>"])};var g=b.wrapTemplate(["<% _.each( apps, function( app ){ %>",'<div class="display-application">','<span class="display-application-location"><%- app.label %></span> ','<span class="display-application-links">',"<% _.each( app.links, function( link ){ %>",'<a target="<%= link.target %>" href="<%= link.href %>">',"<% print( _l( link.text ) ); %>","</a> ","<% }); %>","</span>","</div>","<% }); %>"],"apps");return _.extend({},f.prototype.templates,{warnings:i,details:j,noAccess:h,summaries:k,detailMessages:l,displayApplications:g})}());return{DatasetListItemView:e}}); \ No newline at end of file +define(["mvc/list/list-item","mvc/dataset/states","mvc/base-mvc","utils/localization"],function(d,a,b,c){var f=d.ListItemView;var e=f.extend({className:f.prototype.className+" dataset",id:function(){return["dataset",this.model.get("id")].join("-")},initialize:function(g){if(g.logger){this.logger=this.model.logger=g.logger}this.log(this+".initialize:",g);f.prototype.initialize.call(this,g);this.linkTarget=g.linkTarget||"_blank";this._setUpListeners()},_setUpListeners:function(){f.prototype._setUpListeners.call(this);this.model.on("change",function(h,g){if(this.model.changedAttributes().state&&this.model.inReadyState()&&this.expanded&&!this.model.hasDetails()){this.model.fetch()}else{this.render()}},this)},_fetchModelDetails:function(){var g=this;if(g.model.inReadyState()&&!g.model.hasDetails()){return g.model.fetch({silent:true})}return jQuery.when()},remove:function(h,i){var g=this;h=h||this.fxSpeed;this.$el.fadeOut(h,function(){Backbone.View.prototype.remove.call(g);if(i){i.call(g)}})},render:function(g){return f.prototype.render.call(this,g)},_swapNewRender:function(g){f.prototype._swapNewRender.call(this,g);if(this.model.has("state")){this.$el.addClass("state-"+this.model.get("state"))}return this.$el},_renderPrimaryActions:function(){return[this._renderDisplayButton()]},_renderDisplayButton:function(){var i=this.model.get("state");if((i===a.NOT_VIEWABLE)||(i===a.DISCARDED)||(!this.model.get("accessible"))){return null}var h={target:this.linkTarget,classes:"display-btn"};if(this.model.get("purged")){h.disabled=true;h.title=c("Cannot display datasets removed from disk")}else{if(i===a.UPLOAD){h.disabled=true;h.title=c("This dataset must finish uploading before it can be viewed")}else{if(i===a.NEW){h.disabled=true;h.title=c("This dataset is not yet viewable")}else{h.title=c("View data");h.href=this.model.urls.display;var g=this;h.onclick=function(j){if(Galaxy.frame&&Galaxy.frame.active){Galaxy.frame.add({title:"Data Viewer: "+g.model.get("name"),type:"other",content:function(k){require(["mvc/data"],function(l){var m=new l.TabularDataset({id:g.model.get("id")});$.when(m.fetch()).then(function(){l.createTabularDatasetChunkedView({model:m,parent_elt:k,embedded:true,height:"100%"})})})}});j.preventDefault()}}}}}h.faIcon="fa-eye";return faIconButton(h)},_renderDetails:function(){if(this.model.get("state")===a.NOT_VIEWABLE){return $(this.templates.noAccess(this.model.toJSON(),this))}var g=f.prototype._renderDetails.call(this);g.find(".actions .left").empty().append(this._renderSecondaryActions());g.find(".summary").html(this._renderSummary()).prepend(this._renderDetailMessages());g.find(".display-applications").html(this._renderDisplayApplications());this._setUpBehaviors(g);return g},_renderSummary:function(){var g=this.model.toJSON(),h=this.templates.summaries[g.state];h=h||this.templates.summaries.unknown;return h(g,this)},_renderDetailMessages:function(){var g=this,i=$('<div class="detail-messages"></div>'),h=g.model.toJSON();_.each(g.templates.detailMessages,function(j){i.append($(j(h,g)))});return i},_renderDisplayApplications:function(){if(this.model.isDeletedOrPurged()){return""}return[this.templates.displayApplications(this.model.get("display_apps"),this),this.templates.displayApplications(this.model.get("display_types"),this)].join("")},_renderSecondaryActions:function(){this.debug("_renderSecondaryActions");switch(this.model.get("state")){case a.NOT_VIEWABLE:return[];case a.OK:case a.FAILED_METADATA:case a.ERROR:return[this._renderDownloadButton(),this._renderShowParamsButton()]}return[this._renderShowParamsButton()]},_renderShowParamsButton:function(){return faIconButton({title:c("View details"),classes:"params-btn",href:this.model.urls.show_params,target:this.linkTarget,faIcon:"fa-info-circle"})},_renderDownloadButton:function(){if(this.model.get("purged")||!this.model.hasData()){return null}if(!_.isEmpty(this.model.get("meta_files"))){return this._renderMetaFileDownloadButton()}return $(['<a class="download-btn icon-btn" href="',this.model.urls.download,'" title="'+c("Download")+'">','<span class="fa fa-floppy-o"></span>',"</a>"].join(""))},_renderMetaFileDownloadButton:function(){var g=this.model.urls;return $(['<div class="metafile-dropdown dropdown">','<a class="download-btn icon-btn" href="javascript:void(0)" data-toggle="dropdown"',' title="'+c("Download")+'">','<span class="fa fa-floppy-o"></span>',"</a>",'<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">','<li><a href="'+g.download+'">',c("Download dataset"),"</a></li>",_.map(this.model.get("meta_files"),function(h){return['<li><a href="',g.meta_download+h.file_type,'">',c("Download")," ",h.file_type,"</a></li>"].join("")}).join("\n"),"</ul>","</div>"].join("\n"))},events:_.extend(_.clone(f.prototype.events),{"click .display-btn":function(g){this.trigger("display",this,g)},"click .params-btn":function(g){this.trigger("params",this,g)},"click .download-btn":function(g){this.trigger("download",this,g)}}),toString:function(){var g=(this.model)?(this.model+""):("(no model)");return"DatasetListItemView("+g+")"}});e.prototype.templates=(function(){var i=_.extend({},f.prototype.templates.warnings,{failed_metadata:b.wrapTemplate(['<% if( model.state === "failed_metadata" ){ %>','<div class="warningmessagesmall">',c("An error occurred setting the metadata for this dataset"),"</div>","<% } %>"]),error:b.wrapTemplate(["<% if( model.error ){ %>",'<div class="errormessagesmall">',c("There was an error getting the data for this dataset"),": <%- model.error %>","</div>","<% } %>"]),purged:b.wrapTemplate(["<% if( model.purged ){ %>",'<div class="purged-msg warningmessagesmall">',c("This dataset has been deleted and removed from disk"),"</div>","<% } %>"]),deleted:b.wrapTemplate(["<% if( model.deleted && !model.purged ){ %>",'<div class="deleted-msg warningmessagesmall">',c("This dataset has been deleted"),"</div>","<% } %>"])});var j=b.wrapTemplate(['<div class="details">','<div class="summary"></div>','<div class="actions clear">','<div class="left"></div>','<div class="right"></div>',"</div>","<% if( !dataset.deleted && !dataset.purged ){ %>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="display-applications"></div>',"<% if( dataset.peek ){ %>",'<pre class="dataset-peek"><%= dataset.peek %></pre>',"<% } %>","<% } %>","</div>"],"dataset");var h=b.wrapTemplate(['<div class="details">','<div class="summary">',c("You do not have permission to view this dataset"),"</div>","</div>"],"dataset");var k={};k[a.OK]=k[a.FAILED_METADATA]=b.wrapTemplate(["<% if( dataset.misc_blurb ){ %>",'<div class="blurb">','<span class="value"><%- dataset.misc_blurb %></span>',"</div>","<% } %>","<% if( dataset.file_ext ){ %>",'<div class="datatype">','<label class="prompt">',c("format"),"</label>",'<span class="value"><%- dataset.file_ext %></span>',"</div>","<% } %>","<% if( dataset.metadata_dbkey ){ %>",'<div class="dbkey">','<label class="prompt">',c("database"),"</label>",'<span class="value">',"<%- dataset.metadata_dbkey %>","</span>","</div>","<% } %>","<% if( dataset.misc_info ){ %>",'<div class="info">','<span class="value"><%- dataset.misc_info %></span>',"</div>","<% } %>"],"dataset");k[a.NEW]=b.wrapTemplate(["<div>",c("This is a new dataset and not all of its data are available yet"),"</div>"],"dataset");k[a.NOT_VIEWABLE]=b.wrapTemplate(["<div>",c("You do not have permission to view this dataset"),"</div>"],"dataset");k[a.DISCARDED]=b.wrapTemplate(["<div>",c("The job creating this dataset was cancelled before completion"),"</div>"],"dataset");k[a.QUEUED]=b.wrapTemplate(["<div>",c("This job is waiting to run"),"</div>"],"dataset");k[a.RUNNING]=b.wrapTemplate(["<div>",c("This job is currently running"),"</div>"],"dataset");k[a.UPLOAD]=b.wrapTemplate(["<div>",c("This dataset is currently uploading"),"</div>"],"dataset");k[a.SETTING_METADATA]=b.wrapTemplate(["<div>",c("Metadata is being auto-detected"),"</div>"],"dataset");k[a.PAUSED]=b.wrapTemplate(["<div>",c('This job is paused. Use the "Resume Paused Jobs" in the history menu to resume'),"</div>"],"dataset");k[a.ERROR]=b.wrapTemplate(["<% if( !dataset.purged ){ %>","<div><%- dataset.misc_blurb %></div>","<% } %>",'<span class="help-text">',c("An error occurred with this dataset"),":</span>",'<div class="job-error-text"><%- dataset.misc_info %></div>'],"dataset");k[a.EMPTY]=b.wrapTemplate(["<div>",c("No data"),": <i><%- dataset.misc_blurb %></i></div>"],"dataset");k.unknown=b.wrapTemplate(['<div>Error: unknown dataset state: "<%- dataset.state %>"</div>'],"dataset");var l={resubmitted:b.wrapTemplate(["<% if( model.resubmitted ){ %>",'<div class="resubmitted-msg infomessagesmall">',c("The job creating this dataset has been resubmitted"),"</div>","<% } %>"])};var g=b.wrapTemplate(["<% _.each( apps, function( app ){ %>",'<div class="display-application">','<span class="display-application-location"><%- app.label %></span> ','<span class="display-application-links">',"<% _.each( app.links, function( link ){ %>",'<a target="<%= link.target %>" href="<%= link.href %>">',"<% print( _l( link.text ) ); %>","</a> ","<% }); %>","</span>","</div>","<% }); %>"],"apps");return _.extend({},f.prototype.templates,{warnings:i,details:j,noAccess:h,summaries:k,detailMessages:l,displayApplications:g})}());return{DatasetListItemView:e}}); \ No newline at end of file diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 static/scripts/packed/mvc/history/history-panel-edit-current.js --- a/static/scripts/packed/mvc/history/history-panel-edit-current.js +++ b/static/scripts/packed/mvc/history/history-panel-edit-current.js @@ -1,1 +1,1 @@ -define(["mvc/history/history-model","mvc/history/history-panel-edit","mvc/collection/collection-panel","mvc/base-mvc","utils/localization"],function(d,c,a,h,b){var e=h.SessionStorageModel.extend({defaults:{tagsEditorShown:false,annotationEditorShown:false},toString:function(){return"HistoryPanelPrefs("+JSON.stringify(this.toJSON())+")"}});e.storageKey=function f(){return("history-panel")};var g=c.HistoryPanelEdit;var i=g.extend({className:g.prototype.className+" current-history-panel",emptyMsg:b("This history is empty. Click 'Get Data' on the left tool menu to start"),noneFoundMsg:b("No matching datasets found"),HDCAViewClass:g.prototype.HDCAViewClass.extend({foldoutStyle:"drilldown"}),initialize:function(j){j=j||{};this.preferences=new e(_.extend({id:e.storageKey()},_.pick(j,_.keys(e.prototype.defaults))));g.prototype.initialize.call(this,j);this.panelStack=[]},loadCurrentHistory:function(k){this.debug(this+".loadCurrentHistory");var j=this;return this.loadHistoryWithDetails("current",k).then(function(m,l){j.trigger("current-history",j)})},switchToHistory:function(m,l){var j=this,k=function(){return jQuery.getJSON(galaxy_config.root+"history/set_as_current?id="+m)};return this.loadHistoryWithDetails(m,l,k).then(function(o,n){j.trigger("switched-history",j)})},createNewHistory:function(l){if(!Galaxy||!Galaxy.currUser||Galaxy.currUser.isAnonymous()){this.displayMessage("error",b("You must be logged in to create histories"));return $.when()}var j=this,k=function(){return jQuery.getJSON(galaxy_config.root+"history/create_new_current")};return this.loadHistory(undefined,l,k).then(function(n,m){j.trigger("new-history",j)})},setModel:function(k,j,l){g.prototype.setModel.call(this,k,j,l);if(this.model){this.log("checking for updates");this.model.checkForUpdates()}return this},_setUpCollectionListeners:function(){g.prototype._setUpCollectionListeners.call(this);this.collection.on("state:ready",function(k,l,j){if((!k.get("visible"))&&(!this.storage.get("show_hidden"))){this.removeItemView(this.viewFromModel(k))}},this)},_setUpModelListeners:function(){g.prototype._setUpModelListeners.call(this);if(Galaxy&&Galaxy.quotaMeter){this.listenTo(this.model,"change:nice_size",function(){Galaxy.quotaMeter.update()})}},_buildNewRender:function(){if(!this.model){return $()}var j=g.prototype._buildNewRender.call(this);j.find(".search").prependTo(j.find(".controls"));this._renderQuotaMessage(j);return j},_renderQuotaMessage:function(j){j=j||this.$el;return $(this.templates.quotaMsg({},this)).prependTo(j.find(".messages"))},_renderEmptyMessage:function(l){var k=this,j=k.$emptyMessage(l),m=$(".toolMenuContainer");if((_.isEmpty(k.views)&&!k.searchFor)&&(Galaxy&&Galaxy.upload&&m.size())){j.empty();j.html([b("This history is empty"),". ",b("You can "),'<a class="uploader-link" href="javascript:void(0)">',b("load your own data"),"</a>",b(" or "),'<a class="get-data-link" href="javascript:void(0)">',b("get data from an external source"),"</a>"].join(""));j.find(".uploader-link").click(function(n){Galaxy.upload._eventShow(n)});j.find(".get-data-link").click(function(n){m.parent().scrollTop(0);m.find('span:contains("Get Data")').click()});return j.show()}return g.prototype._renderEmptyMessage.call(this,l)},_renderTags:function(j){var k=this;g.prototype._renderTags.call(this,j);if(this.preferences.get("tagsEditorShown")){this.tagsEditor.toggle(true)}this.tagsEditor.on("hiddenUntilActivated:shown hiddenUntilActivated:hidden",function(l){k.preferences.set("tagsEditorShown",l.hidden)})},_renderAnnotation:function(j){var k=this;g.prototype._renderAnnotation.call(this,j);if(this.preferences.get("annotationEditorShown")){this.annotationEditor.toggle(true)}this.annotationEditor.on("hiddenUntilActivated:shown hiddenUntilActivated:hidden",function(l){k.preferences.set("annotationEditorShown",l.hidden)})},_attachItems:function(j){this.$list(j).append(this.views.reverse().map(function(k){return k.$el}));return this},addItemView:function(o,p,n){this.log(this+".addItemView:",o);var l=this;if(!l._filterItem(o)){return undefined}if(l.panelStack.length){return this._collapseDrilldownPanel()}var k=l._createItemView(o);l.views.unshift(k);l.scrollToTop();$({}).queue([function m(r){var q=l.$emptyMessage();if(q.is(":visible")){q.fadeOut(l.fxSpeed,r)}else{r()}},function j(q){l.$list().prepend(k.render(0).$el.hide());k.$el.slideDown(l.fxSpeed)}]);return k},_setUpItemViewListeners:function(k){var j=this;g.prototype._setUpItemViewListeners.call(j,k);k.on("expanded:drilldown",function(m,l){this._expandDrilldownPanel(l)},this);k.on("collapsed:drilldown",function(m,l){this._collapseDrilldownPanel(l)},this);return this},_expandDrilldownPanel:function(j){this.panelStack.push(j);this.$("> .controls").add(this.$list()).hide();j.parentName=this.model.get("name");this.$el.append(j.render().$el)},_collapseDrilldownPanel:function(j){this.panelStack.pop();this.render()},connectToQuotaMeter:function(j){if(!j){return this}this.listenTo(j,"quota:over",this.showQuotaMessage);this.listenTo(j,"quota:under",this.hideQuotaMessage);this.on("rendered rendered:initial",function(){if(j&&j.isOverQuota()){this.showQuotaMessage()}});return this},showQuotaMessage:function(){var j=this.$el.find(".quota-message");if(j.is(":hidden")){j.slideDown(this.fxSpeed)}},hideQuotaMessage:function(){var j=this.$el.find(".quota-message");if(!j.is(":hidden")){j.slideUp(this.fxSpeed)}},connectToOptionsMenu:function(j){if(!j){return this}this.on("new-storage",function(l,k){if(j&&l){j.findItemByHtml(b("Include Deleted Datasets")).checked=l.get("show_deleted");j.findItemByHtml(b("Include Hidden Datasets")).checked=l.get("show_hidden")}});return this},toString:function(){return"CurrentHistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});i.prototype.templates=(function(){var j=h.wrapTemplate(['<div class="quota-message errormessage">',b("You are over your disk quota"),". ",b("Tool execution is on hold until your disk usage drops below your allocated quota"),".","</div>"],"history");return _.extend(_.clone(g.prototype.templates),{quotaMsg:j})}());return{CurrentHistoryPanel:i}}); \ No newline at end of file +define(["mvc/history/history-model","mvc/history/history-panel-edit","mvc/collection/collection-panel","mvc/base-mvc","utils/localization"],function(d,c,a,h,b){var e=h.SessionStorageModel.extend({defaults:{tagsEditorShown:false,annotationEditorShown:false,scrollPosition:0},toString:function(){return"HistoryPanelPrefs("+JSON.stringify(this.toJSON())+")"}});e.storageKey=function f(){return("history-panel")};var g=c.HistoryPanelEdit;var i=g.extend({className:g.prototype.className+" current-history-panel",emptyMsg:b("This history is empty. Click 'Get Data' on the left tool menu to start"),noneFoundMsg:b("No matching datasets found"),HDCAViewClass:g.prototype.HDCAViewClass.extend({foldoutStyle:"drilldown"}),initialize:function(j){j=j||{};this.preferences=new e(_.extend({id:e.storageKey()},_.pick(j,_.keys(e.prototype.defaults))));g.prototype.initialize.call(this,j);this.panelStack=[];this.currentContentId=j.currentContentId||null},_setUpListeners:function(){g.prototype._setUpListeners.call(this);var j=this;this.$scrollContainer().on("scroll",function(k){j.preferences.set("scrollPosition",$(this).scrollTop())})},loadCurrentHistory:function(k){this.debug(this+".loadCurrentHistory");var j=this;return this.loadHistoryWithDetails("current",k).then(function(m,l){j.trigger("current-history",j)})},switchToHistory:function(m,l){var j=this,k=function(){return jQuery.getJSON(galaxy_config.root+"history/set_as_current?id="+m)};return this.loadHistoryWithDetails(m,l,k).then(function(o,n){j.trigger("switched-history",j)})},createNewHistory:function(l){if(!Galaxy||!Galaxy.currUser||Galaxy.currUser.isAnonymous()){this.displayMessage("error",b("You must be logged in to create histories"));return $.when()}var j=this,k=function(){return jQuery.getJSON(galaxy_config.root+"history/create_new_current")};return this.loadHistory(undefined,l,k).then(function(n,m){j.trigger("new-history",j)})},setModel:function(k,j,l){g.prototype.setModel.call(this,k,j,l);if(this.model){this.log("checking for updates");this.model.checkForUpdates()}return this},_setUpCollectionListeners:function(){g.prototype._setUpCollectionListeners.call(this);this.collection.on("state:ready",function(k,l,j){if((!k.get("visible"))&&(!this.storage.get("show_hidden"))){this.removeItemView(this.viewFromModel(k))}},this)},_setUpModelListeners:function(){g.prototype._setUpModelListeners.call(this);if(Galaxy&&Galaxy.quotaMeter){this.listenTo(this.model,"change:nice_size",function(){Galaxy.quotaMeter.update()})}},_buildNewRender:function(){if(!this.model){return $()}var j=g.prototype._buildNewRender.call(this);j.find(".search").prependTo(j.find(".controls"));this._renderQuotaMessage(j);return j},_renderQuotaMessage:function(j){j=j||this.$el;return $(this.templates.quotaMsg({},this)).prependTo(j.find(".messages"))},_renderEmptyMessage:function(l){var k=this,j=k.$emptyMessage(l),m=$(".toolMenuContainer");if((_.isEmpty(k.views)&&!k.searchFor)&&(Galaxy&&Galaxy.upload&&m.size())){j.empty();j.html([b("This history is empty"),". ",b("You can "),'<a class="uploader-link" href="javascript:void(0)">',b("load your own data"),"</a>",b(" or "),'<a class="get-data-link" href="javascript:void(0)">',b("get data from an external source"),"</a>"].join(""));j.find(".uploader-link").click(function(n){Galaxy.upload._eventShow(n)});j.find(".get-data-link").click(function(n){m.parent().scrollTop(0);m.find('span:contains("Get Data")').click()});return j.show()}return g.prototype._renderEmptyMessage.call(this,l)},_renderTags:function(j){var k=this;g.prototype._renderTags.call(this,j);if(this.preferences.get("tagsEditorShown")){this.tagsEditor.toggle(true)}this.tagsEditor.on("hiddenUntilActivated:shown hiddenUntilActivated:hidden",function(l){k.preferences.set("tagsEditorShown",l.hidden)})},_renderAnnotation:function(j){var k=this;g.prototype._renderAnnotation.call(this,j);if(this.preferences.get("annotationEditorShown")){this.annotationEditor.toggle(true)}this.annotationEditor.on("hiddenUntilActivated:shown hiddenUntilActivated:hidden",function(l){k.preferences.set("annotationEditorShown",l.hidden)})},_swapNewRender:function(k){g.prototype._swapNewRender.call(this,k);var j=this;_.delay(function(){var l=j.preferences.get("scrollPosition");if(l){j.scrollTo(l)}},10);return this},_attachItems:function(k){var j=this;this.$list(k).append(this.views.reverse().map(function(l){if(j.currentContentId&&l.model.id===j.currentContentId){l.$el.addClass("current-content")}return l.$el}));return this},addItemView:function(o,p,n){this.log(this+".addItemView:",o);var l=this;if(!l._filterItem(o)){return undefined}if(l.panelStack.length){return this._collapseDrilldownPanel()}var k=l._createItemView(o);l.views.unshift(k);l.scrollToTop();$({}).queue([function m(r){var q=l.$emptyMessage();if(q.is(":visible")){q.fadeOut(l.fxSpeed,r)}else{r()}},function j(q){l.$list().prepend(k.render(0).$el.hide());k.$el.slideDown(l.fxSpeed)}]);return k},_setUpItemViewListeners:function(k){var j=this;g.prototype._setUpItemViewListeners.call(j,k);k.on("expanded:drilldown",function(m,l){this._expandDrilldownPanel(l)},this);k.on("collapsed:drilldown",function(m,l){this._collapseDrilldownPanel(l)},this);k.on("display edit params rerun report-err visualize",function(l,m){this.setCurrentContent(l)},this);return this},setCurrentContent:function(j){this.$(".history-content.current-content").removeClass("current-content");if(j){j.$el.addClass("current-content");this.currentContentId=j.model.id}else{this.currentContentId=null}},_expandDrilldownPanel:function(j){this.panelStack.push(j);this.$("> .controls").add(this.$list()).hide();j.parentName=this.model.get("name");this.$el.append(j.render().$el)},_collapseDrilldownPanel:function(j){this.panelStack.pop();this.render()},connectToQuotaMeter:function(j){if(!j){return this}this.listenTo(j,"quota:over",this.showQuotaMessage);this.listenTo(j,"quota:under",this.hideQuotaMessage);this.on("rendered rendered:initial",function(){if(j&&j.isOverQuota()){this.showQuotaMessage()}});return this},showQuotaMessage:function(){var j=this.$el.find(".quota-message");if(j.is(":hidden")){j.slideDown(this.fxSpeed)}},hideQuotaMessage:function(){var j=this.$el.find(".quota-message");if(!j.is(":hidden")){j.slideUp(this.fxSpeed)}},connectToOptionsMenu:function(j){if(!j){return this}this.on("new-storage",function(l,k){if(j&&l){j.findItemByHtml(b("Include Deleted Datasets")).checked=l.get("show_deleted");j.findItemByHtml(b("Include Hidden Datasets")).checked=l.get("show_hidden")}});return this},toString:function(){return"CurrentHistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});i.prototype.templates=(function(){var j=h.wrapTemplate(['<div class="quota-message errormessage">',b("You are over your disk quota"),". ",b("Tool execution is on hold until your disk usage drops below your allocated quota"),".","</div>"],"history");return _.extend(_.clone(g.prototype.templates),{quotaMsg:j})}());return{CurrentHistoryPanel:i}}); \ No newline at end of file diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 static/scripts/packed/mvc/list/list-panel.js --- a/static/scripts/packed/mvc/list/list-panel.js +++ b/static/scripts/packed/mvc/list/list-panel.js @@ -1,1 +1,1 @@ -define(["mvc/list/list-item","mvc/base-mvc","utils/localization"],function(d,b,c){var e=Backbone.View.extend(b.LoggableMixin).extend({viewClass:d.ListItemView,collectionClass:Backbone.Collection,tagName:"div",className:"list-panel",fxSpeed:"fast",emptyMsg:c("This list is empty"),noneFoundMsg:c("No matching items found"),searchPlaceholder:c("search"),multiselectActions:[],initialize:function(f,g){f=f||{};if(f.logger){this.logger=f.logger}this.log(this+".initialize:",f);this.fxSpeed=_.has(f,"fxSpeed")?(f.fxSpeed):(this.fxSpeed);this.filters=[];this.searchFor=f.searchFor||"";this.indicator=new LoadingIndicator(this.$el);this.selecting=(f.selecting!==undefined)?f.selecting:true;this.selected=f.selected||[];this.lastSelected=null;this.viewClass=f.viewClass||this.viewClass;this.views=[];this.collection=f.collection||(new this.collectionClass([]));this.filters=f.filters||[];this.$scrollContainer=f.$scrollContainer||this.$scrollContainer;this.title=f.title||"";this.subtitle=f.subtitle||"";this.multiselectActions=f.multiselectActions||this.multiselectActions;this.actionsPopup=null;this._setUpListeners()},freeViews:function(){_.each(this.views,function(f){f.off()});this.views=[];return this},_setUpListeners:function(){this.off();this.on("error",function(g,j,f,i,h){console.error(g,j,f,i,h)},this);this.on("loading",function(){this._showLoadingIndicator("loading...",40)},this);this.on("loading-done",function(){this._hideLoadingIndicator(40)},this);this.once("rendered",function(){this.trigger("rendered:initial",this)},this);if(this.logger){this.on("all",function(f){this.log(this+"",arguments)},this)}this._setUpCollectionListeners();this._setUpViewListeners();return this},_setUpCollectionListeners:function(){this.log(this+"._setUpCollectionListeners",this.collection);this.collection.off();this.collection.on("error",function(g,j,f,i,h){this.trigger("error",g,j,f,i,h)},this);this.collection.on("reset",function(){this.renderItems()},this);this.collection.on("add",this.addItemView,this);this.collection.on("remove",this.removeItemView,this);if(this.logger){this.collection.on("all",function(f){this.info(this+"(collection)",arguments)},this)}return this},_setUpViewListeners:function(){this.log(this+"._setUpViewListeners");this.on("view:selected",function(f,g){if(g&&g.shiftKey&&this.lastSelected){var h=this.viewFromModelId(this.lastSelected);if(h){this.selectRange(f,h)}}this.selected.push(f.model.id);this.lastSelected=f.model.id},this);this.on("view:de-selected",function(f,g){this.selected=_.without(this.selected,f.model.id)},this)},render:function(g){this.log(this+".render",g);var f=this._buildNewRender();this._setUpBehaviors(f);this._queueNewRender(f,g);return this},_buildNewRender:function(){this.debug(this+"(ListPanel)._buildNewRender");var f=$(this.templates.el({},this));this._renderControls(f);this._renderTitle(f);this._renderSubtitle(f);this._renderSearch(f);this.renderItems(f);return f},_renderControls:function(g){this.debug(this+"(ListPanel)._renderControls");var f=$(this.templates.controls({},this));g.find(".controls").replaceWith(f);return f},_renderTitle:function(f){},_renderSubtitle:function(f){},_queueNewRender:function(g,h){h=(h===undefined)?(this.fxSpeed):(h);var f=this;f.log("_queueNewRender:",g,h);$(f).queue("fx",[function(i){this.$el.fadeOut(h,i)},function(i){f._swapNewRender(g);i()},function(i){this.$el.fadeIn(h,i)},function(i){f.trigger("rendered",f);i()}])},_swapNewRender:function(f){this.$el.empty().attr("class",this.className).append(f.children());if(this.selecting){this.showSelectors(0)}return this},_setUpBehaviors:function(f){f=f||this.$el;f.find(".controls [title]").tooltip({placement:"bottom"});return this},$scrollContainer:function(){return this.$el.parent().parent()},$list:function(f){return(f||this.$el).find("> .list-items")},$messages:function(f){return(f||this.$el).find("> .controls .messages")},$emptyMessage:function(f){return(f||this.$el).find("> .empty-message")},renderItems:function(h){h=h||this.$el;var f=this;f.log(this+".renderItems",h);var g=f.$list(h);f.views=f._filterCollection().map(function(i){return f._createItemView(i).render(0)});g.empty();if(f.views.length){f._attachItems(h);f.$emptyMessage(h).hide()}else{f._renderEmptyMessage(h).show()}return f.views},_filterCollection:function(){var f=this;return f.collection.filter(_.bind(f._filterItem,f))},_filterItem:function(g){var f=this;return(_.every(f.filters.map(function(h){return h.call(g)})))&&(!f.searchFor||g.matchesAll(f.searchFor))},_createItemView:function(h){var i=this._getItemViewClass(h),g=_.extend(this._getItemViewOptions(h),{model:h}),f=new i(g);this._setUpItemViewListeners(f);return f},_getItemViewClass:function(f){return this.viewClass},_getItemViewOptions:function(f){return{fxSpeed:this.fxSpeed,expanded:false,selectable:this.selecting,selected:_.contains(this.selected,f.id),draggable:this.dragging}},_setUpItemViewListeners:function(g){var f=this;g.on("all",function(){var h=Array.prototype.slice.call(arguments,0);h[0]="view:"+h[0];f.trigger.apply(f,h)});return f},_attachItems:function(f){this.$list(f).append(this.views.map(function(g){return g.$el}));return this},_renderEmptyMessage:function(f){this.debug("_renderEmptyMessage",f,this.searchFor);var g=this.searchFor?this.noneFoundMsg:this.emptyMsg;return this.$emptyMessage(f).text(g)},expandAll:function(){_.each(this.views,function(f){f.expand()})},collapseAll:function(){_.each(this.views,function(f){f.collapse()})},addItemView:function(i,j,h){this.log(this+".addItemView:",i);var g=this;if(!g._filterItem(i)){return undefined}var f=g._createItemView(i);g.views.push(f);$(f).queue("fx",[function(k){g.$emptyMessage().fadeOut(g.fxSpeed,k)},function(k){g.$list().append(f.render().$el);k()}]);return f},removeItemView:function(i,j,h){this.log(this+".removeItemView:",i);var g=this,f=g.viewFromModel(i);if(!f){return undefined}$({}).queue("fx",[function(k){f.$el.fadeOut(g.fxSpeed,k)},function(k){g.views=_.without(g.views,f);f.remove();if(!g.views.length){g._renderEmptyMessage().fadeIn(g.fxSpeed,k)}else{k()}}]);return f},viewFromModelId:function(g){for(var f=0;f<this.views.length;f++){if(this.views[f].model.id===g){return this.views[f]}}return undefined},viewFromModel:function(f){return this.viewFromModelId(f.id)},viewsWhereModel:function(f){return this.views.filter(function(g){var i=g.model.toJSON();for(var h in f){if(f.hasOwnProperty(h)){if(i[h]!==g.model.get(h)){return false}}}return true})},viewRange:function(i,h){if(i===h){return(i)?([i]):([])}var g=this.views.indexOf(i),f=this.views.indexOf(h);if(g===-1||f===-1){if(g===f){return[]}return(g===-1)?([h]):([i])}return(g<f)?this.views.slice(g,f+1):this.views.slice(f,g+1)},_renderSearch:function(f){f.find(".controls .search-input").searchInput({placeholder:this.searchPlaceholder,initialVal:this.searchFor,onfirstsearch:_.bind(this._firstSearch,this),onsearch:_.bind(this.searchItems,this),onclear:_.bind(this.clearSearch,this)});return f},_firstSearch:function(f){this.log("onFirstSearch",f);return this.searchItems(f)},searchItems:function(f){this.searchFor=f;this.trigger("search:searching",f,this);this.renderItems();return this},clearSearch:function(f){this.searchFor="";this.trigger("search:clear",this);this.renderItems();return this},showSelectors:function(f){f=(f!==undefined)?(f):(this.fxSpeed);this.selecting=true;this.$(".list-actions").slideDown(f);_.each(this.views,function(g){g.showSelector(f)})},hideSelectors:function(f){f=(f!==undefined)?(f):(this.fxSpeed);this.selecting=false;this.$(".list-actions").slideUp(f);_.each(this.views,function(g){g.hideSelector(f)});this.selected=[];this.lastSelected=null},toggleSelectors:function(){if(!this.selecting){this.showSelectors()}else{this.hideSelectors()}},selectAll:function(f){_.each(this.views,function(g){g.select(f)})},deselectAll:function(f){this.lastSelected=null;_.each(this.views,function(g){g.deselect(f)})},selectRange:function(h,g){var f=this.viewRange(h,g);_.each(f,function(i){i.select()});return f},getSelectedViews:function(){return _.filter(this.views,function(f){return f.selected})},getSelectedModels:function(){return new this.collection.constructor(_.map(this.getSelectedViews(),function(f){return f.model}))},_showLoadingIndicator:function(g,f,h){this.debug("_showLoadingIndicator",this.indicator,g,f,h);f=(f!==undefined)?(f):(this.fxSpeed);if(!this.indicator){this.indicator=new LoadingIndicator(this.$el,this.$el.parent());this.debug("\t created",this.indicator)}if(!this.$el.is(":visible")){this.indicator.show(0,h)}else{this.$el.fadeOut(f);this.indicator.show(g,f,h)}},_hideLoadingIndicator:function(f,g){this.debug("_hideLoadingIndicator",this.indicator,f,g);f=(f!==undefined)?(f):(this.fxSpeed);if(this.indicator){this.indicator.hide(f,g)}},scrollPosition:function(){return this.$scrollContainer().scrollTop()},scrollTo:function(f){this.$scrollContainer().scrollTop(f);return this},scrollToTop:function(){this.$scrollContainer().scrollTop(0);return this},scrollToItem:function(f){if(!f){return this}var g=f.$el.offset().top;this.$scrollContainer().scrollTop(g);return this},scrollToId:function(f){return this.scrollToItem(this.viewFromModelId(f))},events:{"click .select-all":"selectAll","click .deselect-all":"deselectAll"},toString:function(){return"ListPanel("+this.collection+")"}});e.prototype.templates=(function(){var g=b.wrapTemplate(["<div>",'<div class="controls"></div>','<div class="list-items"></div>','<div class="empty-message infomessagesmall"></div>',"</div>"]);var f=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= view.title %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>","</div>","</div>"]);return{el:g,controls:f}}());var a=e.extend({modelCollectionKey:"contents",initialize:function(f){e.prototype.initialize.call(this,f);this.selecting=(f.selecting!==undefined)?f.selecting:false;this.setModel(this.model,f)},setModel:function(g,f){f=f||{};this.debug(this+".setModel:",g,f);this.freeModel();this.freeViews();if(g){this.model=g;if(this.logger){this.model.logger=this.logger}this._setUpModelListeners();this.collection.off();this.collection=(this.model[this.modelCollectionKey])?this.model[this.modelCollectionKey]:(f.collection||(new this.collectionClass([])));this._setUpCollectionListeners();this.trigger("new-model",this)}return this},freeModel:function(){if(this.model){this.stopListening(this.model)}return this},_setUpModelListeners:function(){this.log(this+"._setUpModelListeners",this.model);this.model.on("error",function(){this.trigger.apply(panel,arguments)},this);return this},_renderControls:function(g){this.debug(this+"(ListPanel)._renderControls");var h=this.model?this.model.toJSON():{},f=$(this.templates.controls(h,this));g.find(".controls").replaceWith(f);return f},toString:function(){return"ModelListPanel("+this.model+")"}});a.prototype.templates=(function(){var f=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= model.name %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>","</div>","</div>"]);return _.extend(_.clone(e.prototype.templates),{controls:f})}());return{ListPanel:e,ModelListPanel:a}}); \ No newline at end of file +define(["mvc/list/list-item","mvc/base-mvc","utils/localization"],function(d,b,c){var e=Backbone.View.extend(b.LoggableMixin).extend({viewClass:d.ListItemView,collectionClass:Backbone.Collection,tagName:"div",className:"list-panel",fxSpeed:"fast",emptyMsg:c("This list is empty"),noneFoundMsg:c("No matching items found"),searchPlaceholder:c("search"),multiselectActions:[],initialize:function(f,g){f=f||{};if(f.logger){this.logger=f.logger}this.log(this+".initialize:",f);this.fxSpeed=_.has(f,"fxSpeed")?(f.fxSpeed):(this.fxSpeed);this.filters=[];this.searchFor=f.searchFor||"";this.indicator=new LoadingIndicator(this.$el);this.selecting=(f.selecting!==undefined)?f.selecting:true;this.selected=f.selected||[];this.lastSelected=null;this.viewClass=f.viewClass||this.viewClass;this.views=[];this.collection=f.collection||(new this.collectionClass([]));this.filters=f.filters||[];this.$scrollContainer=f.$scrollContainer||this.$scrollContainer;this.title=f.title||"";this.subtitle=f.subtitle||"";this.multiselectActions=f.multiselectActions||this.multiselectActions;this.actionsPopup=null;this._setUpListeners()},freeViews:function(){_.each(this.views,function(f){f.off()});this.views=[];return this},_setUpListeners:function(){this.off();this.on("error",function(g,j,f,i,h){console.error(g,j,f,i,h)},this);this.on("loading",function(){this._showLoadingIndicator("loading...",40)},this);this.on("loading-done",function(){this._hideLoadingIndicator(40)},this);this.once("rendered",function(){this.trigger("rendered:initial",this)},this);if(this.logger){this.on("all",function(f){this.log(this+"",arguments)},this)}this._setUpCollectionListeners();this._setUpViewListeners();return this},_setUpCollectionListeners:function(){this.log(this+"._setUpCollectionListeners",this.collection);this.collection.off();this.collection.on("error",function(g,j,f,i,h){this.trigger("error",g,j,f,i,h)},this);this.collection.on("reset",function(){this.renderItems()},this);this.collection.on("add",this.addItemView,this);this.collection.on("remove",this.removeItemView,this);if(this.logger){this.collection.on("all",function(f){this.info(this+"(collection)",arguments)},this)}return this},_setUpViewListeners:function(){this.log(this+"._setUpViewListeners");this.on("view:selected",function(f,g){if(g&&g.shiftKey&&this.lastSelected){var h=this.viewFromModelId(this.lastSelected);if(h){this.selectRange(f,h)}}this.selected.push(f.model.id);this.lastSelected=f.model.id},this);this.on("view:de-selected",function(f,g){this.selected=_.without(this.selected,f.model.id)},this)},render:function(g){this.log(this+".render",g);var f=this._buildNewRender();this._setUpBehaviors(f);this._queueNewRender(f,g);return this},_buildNewRender:function(){this.debug(this+"(ListPanel)._buildNewRender");var f=$(this.templates.el({},this));this._renderControls(f);this._renderTitle(f);this._renderSubtitle(f);this._renderSearch(f);this.renderItems(f);return f},_renderControls:function(g){this.debug(this+"(ListPanel)._renderControls");var f=$(this.templates.controls({},this));g.find(".controls").replaceWith(f);return f},_renderTitle:function(f){},_renderSubtitle:function(f){},_queueNewRender:function(g,h){h=(h===undefined)?(this.fxSpeed):(h);var f=this;f.log("_queueNewRender:",g,h);$(f).queue("fx",[function(i){this.$el.fadeOut(h,i)},function(i){f._swapNewRender(g);i()},function(i){this.$el.fadeIn(h,i)},function(i){f.trigger("rendered",f);i()}])},_swapNewRender:function(f){this.$el.empty().attr("class",this.className).append(f.children());if(this.selecting){this.showSelectors(0)}return this},_setUpBehaviors:function(f){f=f||this.$el;f.find(".controls [title]").tooltip({placement:"bottom"});return this},$scrollContainer:function(){return this.$el.parent().parent()},$list:function(f){return(f||this.$el).find("> .list-items")},$messages:function(f){return(f||this.$el).find("> .controls .messages")},$emptyMessage:function(f){return(f||this.$el).find("> .empty-message")},renderItems:function(h){h=h||this.$el;var f=this;f.log(this+".renderItems",h);var g=f.$list(h);f.views=f._filterCollection().map(function(i){return f._createItemView(i).render(0)});g.empty();if(f.views.length){f._attachItems(h);f.$emptyMessage(h).hide()}else{f._renderEmptyMessage(h).show()}return f.views},_filterCollection:function(){var f=this;return f.collection.filter(_.bind(f._filterItem,f))},_filterItem:function(g){var f=this;return(_.every(f.filters.map(function(h){return h.call(g)})))&&(!f.searchFor||g.matchesAll(f.searchFor))},_createItemView:function(h){var i=this._getItemViewClass(h),g=_.extend(this._getItemViewOptions(h),{model:h}),f=new i(g);this._setUpItemViewListeners(f);return f},_getItemViewClass:function(f){return this.viewClass},_getItemViewOptions:function(f){return{fxSpeed:this.fxSpeed,expanded:false,selectable:this.selecting,selected:_.contains(this.selected,f.id),draggable:this.dragging}},_setUpItemViewListeners:function(g){var f=this;g.on("all",function(){var h=Array.prototype.slice.call(arguments,0);h[0]="view:"+h[0];f.trigger.apply(f,h)});return f},_attachItems:function(f){this.$list(f).append(this.views.map(function(g){return g.$el}));return this},_renderEmptyMessage:function(f){this.debug("_renderEmptyMessage",f,this.searchFor);var g=this.searchFor?this.noneFoundMsg:this.emptyMsg;return this.$emptyMessage(f).text(g)},expandAll:function(){_.each(this.views,function(f){f.expand()})},collapseAll:function(){_.each(this.views,function(f){f.collapse()})},addItemView:function(i,j,h){this.log(this+".addItemView:",i);var g=this;if(!g._filterItem(i)){return undefined}var f=g._createItemView(i);g.views.push(f);$(f).queue("fx",[function(k){g.$emptyMessage().fadeOut(g.fxSpeed,k)},function(k){g.$list().append(f.render().$el);k()}]);return f},removeItemView:function(i,j,h){this.log(this+".removeItemView:",i);var g=this,f=g.viewFromModel(i);if(!f){return undefined}$({}).queue("fx",[function(k){f.$el.fadeOut(g.fxSpeed,k)},function(k){g.views=_.without(g.views,f);f.remove();if(!g.views.length){g._renderEmptyMessage().fadeIn(g.fxSpeed,k)}else{k()}}]);return f},viewFromModelId:function(g){for(var f=0;f<this.views.length;f++){if(this.views[f].model.id===g){return this.views[f]}}return undefined},viewFromModel:function(f){return this.viewFromModelId(f.id)},viewsWhereModel:function(f){return this.views.filter(function(g){var i=g.model.toJSON();for(var h in f){if(f.hasOwnProperty(h)){if(i[h]!==g.model.get(h)){return false}}}return true})},viewRange:function(i,h){if(i===h){return(i)?([i]):([])}var g=this.views.indexOf(i),f=this.views.indexOf(h);if(g===-1||f===-1){if(g===f){return[]}return(g===-1)?([h]):([i])}return(g<f)?this.views.slice(g,f+1):this.views.slice(f,g+1)},_renderSearch:function(f){f.find(".controls .search-input").searchInput({placeholder:this.searchPlaceholder,initialVal:this.searchFor,onfirstsearch:_.bind(this._firstSearch,this),onsearch:_.bind(this.searchItems,this),onclear:_.bind(this.clearSearch,this)});return f},_firstSearch:function(f){this.log("onFirstSearch",f);return this.searchItems(f)},searchItems:function(f){this.searchFor=f;this.trigger("search:searching",f,this);this.renderItems();return this},clearSearch:function(f){this.searchFor="";this.trigger("search:clear",this);this.renderItems();return this},showSelectors:function(f){f=(f!==undefined)?(f):(this.fxSpeed);this.selecting=true;this.$(".list-actions").slideDown(f);_.each(this.views,function(g){g.showSelector(f)})},hideSelectors:function(f){f=(f!==undefined)?(f):(this.fxSpeed);this.selecting=false;this.$(".list-actions").slideUp(f);_.each(this.views,function(g){g.hideSelector(f)});this.selected=[];this.lastSelected=null},toggleSelectors:function(){if(!this.selecting){this.showSelectors()}else{this.hideSelectors()}},selectAll:function(f){_.each(this.views,function(g){g.select(f)})},deselectAll:function(f){this.lastSelected=null;_.each(this.views,function(g){g.deselect(f)})},selectRange:function(h,g){var f=this.viewRange(h,g);_.each(f,function(i){i.select()});return f},getSelectedViews:function(){return _.filter(this.views,function(f){return f.selected})},getSelectedModels:function(){return new this.collection.constructor(_.map(this.getSelectedViews(),function(f){return f.model}))},_showLoadingIndicator:function(g,f,h){this.debug("_showLoadingIndicator",this.indicator,g,f,h);f=(f!==undefined)?(f):(this.fxSpeed);if(!this.indicator){this.indicator=new LoadingIndicator(this.$el,this.$el.parent());this.debug("\t created",this.indicator)}if(!this.$el.is(":visible")){this.indicator.show(0,h)}else{this.$el.fadeOut(f);this.indicator.show(g,f,h)}},_hideLoadingIndicator:function(f,g){this.debug("_hideLoadingIndicator",this.indicator,f,g);f=(f!==undefined)?(f):(this.fxSpeed);if(this.indicator){this.indicator.hide(f,g)}},scrollPosition:function(){return this.$scrollContainer().scrollTop()},scrollTo:function(g,f){f=f||0;this.$scrollContainer().animate({scrollTop:g},f);return this},scrollToTop:function(f){return this.scrollTo(0,f)},scrollToItem:function(f,h){if(!f){return this}var g=f.$el.position().top;return this.scrollTo(g,h)},scrollToId:function(g,f){return this.scrollToItem(this.viewFromModelId(g),f)},events:{"click .select-all":"selectAll","click .deselect-all":"deselectAll"},toString:function(){return"ListPanel("+this.collection+")"}});e.prototype.templates=(function(){var g=b.wrapTemplate(["<div>",'<div class="controls"></div>','<div class="list-items"></div>','<div class="empty-message infomessagesmall"></div>',"</div>"]);var f=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= view.title %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>","</div>","</div>"]);return{el:g,controls:f}}());var a=e.extend({modelCollectionKey:"contents",initialize:function(f){e.prototype.initialize.call(this,f);this.selecting=(f.selecting!==undefined)?f.selecting:false;this.setModel(this.model,f)},setModel:function(g,f){f=f||{};this.debug(this+".setModel:",g,f);this.freeModel();this.freeViews();if(g){this.model=g;if(this.logger){this.model.logger=this.logger}this._setUpModelListeners();this.collection.off();this.collection=(this.model[this.modelCollectionKey])?this.model[this.modelCollectionKey]:(f.collection||(new this.collectionClass([])));this._setUpCollectionListeners();this.trigger("new-model",this)}return this},freeModel:function(){if(this.model){this.stopListening(this.model)}return this},_setUpModelListeners:function(){this.log(this+"._setUpModelListeners",this.model);this.model.on("error",function(){this.trigger.apply(panel,arguments)},this);return this},_renderControls:function(g){this.debug(this+"(ListPanel)._renderControls");var h=this.model?this.model.toJSON():{},f=$(this.templates.controls(h,this));g.find(".controls").replaceWith(f);return f},toString:function(){return"ModelListPanel("+this.model+")"}});a.prototype.templates=(function(){var f=b.wrapTemplate(['<div class="controls">','<div class="title">','<div class="name"><%= model.name %></div>',"</div>",'<div class="subtitle"><%= view.subtitle %></div>','<div class="actions"></div>','<div class="messages"></div>','<div class="search">','<div class="search-input"></div>',"</div>",'<div class="list-actions">','<div class="btn-group">','<button class="select-all btn btn-default"','data-mode="select">',c("All"),"</button>",'<button class="deselect-all btn btn-default"','data-mode="select">',c("None"),"</button>","</div>","</div>","</div>"]);return _.extend(_.clone(e.prototype.templates),{controls:f})}());return{ListPanel:e,ModelListPanel:a}}); \ No newline at end of file diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 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 n=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});var m=new e({label:"",help:h.help,$el:n.$el,highlight:true});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;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 diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 static/style/blue/base.css --- a/static/style/blue/base.css +++ b/static/style/blue/base.css @@ -1285,9 +1285,9 @@ .ui-form-slider .ui-form-slider-element{width:calc(100% - 110px);float:left;top:8px;left:10px} .ui-radiobutton label{height:23px;line-height:1em} .ui-table tbody{cursor:pointer} -.ui-table-plain tbody td{padding:5px 0px 5px 5px !important;border:none !important} +.ui-table-plain tbody td{padding:5px 0px 5px 0px !important;border:none !important} .ui-table-plain tbody{cursor:auto !important} -.ui-table-form-section{border-left:solid 3px #ebd9b2;border-radius:5px;padding-left:5px} +.ui-table-form-section{border-left:solid 3px #ebd9b2;border-radius:5px !important;padding-left:10px} .ui-table-form-title-strong{font-weight:bold;padding-bottom:5px} .ui-table-form-info{clear:both !important} .ui-table-form-separator{font-weight:bold;font-size:0.9em} @@ -1307,7 +1307,7 @@ .ui-portlet .no-scroll{height:calc(100% - 80px)} .ui-portlet-repeat{border:none;border-left:solid 3px #ebd9b2;border-radius:5px}.ui-portlet-repeat .portlet-header{background:#ebd9b2;border-radius:3px;border-bottom-left-radius:0px;padding:1px 0px 0px 2px} .ui-portlet-repeat .portlet-title{padding-top:1px} -.ui-portlet-repeat .portlet-content{padding:0px}.ui-portlet-repeat .portlet-content .content{padding:0px;padding-left:5px} +.ui-portlet-repeat .portlet-content{padding:0px}.ui-portlet-repeat .portlet-content .content{padding:0px;padding-left:10px} .ui-popover{max-width:700px;display:none}.ui-popover .popover-close{position:absolute;right:10px;top:7px;font-size:1.2em;cursor:pointer} .ui-popover .popover-title{padding:4px 10px} .ui-select,.ui-select-multiple{position:relative;height:27px;overflow:hidden;border:1px solid #bfbfbf;-moz-border-radius:3px;border-radius:3px}.ui-select .button{position:relative;width:25px;height:100%;float:right;border-left:1px solid #bfbfbf;padding-left:9px;padding-top:4px;background:#f2f2f2} @@ -1953,6 +1953,9 @@ .history-panel .controls .list-actions .list-action-popup-btn{float:right} .history-panel .list-item.history-content{border-width:1px 0px 0px 0px}.history-panel .list-item.history-content:last-child{border-width:1px 0px 1px 0px} .history-panel .empty-message{margin:0px 10px 0px 10px} +.history-panel .dataset-collection .subtitle{margin-top:2px;font-size:90%;color:#777} +.history-panel .dataset-collection-panel .controls{padding:0px} +.history-panel .dataset-collection-panel .list-items{margin-top:0px} .annotated-history-panel .controls{margin:0px}.annotated-history-panel .controls .name{font-size:150%;margin-bottom:4px} .annotated-history-panel .controls .subtitle{color:black}.annotated-history-panel .controls .subtitle:not(:empty){margin:0px 0px 0px 4px} .annotated-history-panel .controls .messages:not(:empty){margin-top:16px} @@ -1964,9 +1967,8 @@ .annotated-history-panel table.list-items>tbody>tr>td:nth-child(2){padding:8px 16px 8px 16px;white-space:pre-wrap} .annotated-history-panel table.list-items>tbody>tr>td>.list-item{border:0px} .annotated-history-panel .empty-message{margin-top:8px} -.history-panel .dataset-collection .subtitle{margin-top:2px;font-size:90%;color:#777} -.history-panel .dataset-collection-panel .controls{padding:0px} -.history-panel .dataset-collection-panel .list-items{margin-top:0px} +.current-history-panel .list-item.history-content.current-content{border:2px solid black;border-bottom-width:2px}.current-history-panel .list-item.history-content.current-content .title-bar{padding:5px 8px 6px 6px} +.current-history-panel .list-item.history-content.current-content .details{padding:0px 8px 5px 6px} body.historyPage{background:#dfe5f9;color:#000;margin:5px;border:0;padding:0} div.historyLinks{margin:5px 5px} div.historyItem{margin:0 -5px;padding:8px 10px;border-top:solid #bfbfbf 1px;border-right:none;word-wrap:break-word;background:#eee}div.historyItem .state-icon{display:inline-block;vertical-align:middle;width:16px;height:16px;background-position:0 1px;background-repeat:no-repeat} diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 static/style/src/less/history.less --- a/static/style/src/less/history.less +++ b/static/style/src/less/history.less @@ -488,6 +488,27 @@ } } + +// ---------------------------------------------------------------------------- collections nested in histories +.history-panel { + .dataset-collection { + .subtitle { + margin-top: 2px; + font-size: 90%; + color: #777; + } + } + .dataset-collection-panel { + .controls { + padding: 0px; + } + .list-items { + margin-top: 0px; + } + } +} + + // ---------------------------------------------------------------------------- annotated-history-panel .annotated-history-panel { .controls { @@ -566,21 +587,31 @@ } -// ---------------------------------------------------------------------------- collections nested in histories -.history-panel { - .dataset-collection { - .subtitle { - margin-top: 2px; - font-size: 90%; - color: #777; +// ---------------------------------------------------------------------------- current-history-panel +.current-history-panel { + .list-item.history-content.current-content { + //border-top: 2px solid black; + //border-right: 1px solid black; + //border-bottom: 2px solid black; + //border-left: 1px solid black; + + //.title-bar { + // border-color: black; + // background: black; + // color: white; + //} + + //position: relative; + //margin-left: -24px; + //z-index: 1000; + + border: 2px solid black; + border-bottom-width: 2px; + .title-bar { + padding: 5px 8px 6px 6px; } - } - .dataset-collection-panel { - .controls { - padding: 0px; - } - .list-items { - margin-top: 0px; + .details { + padding: 0px 8px 5px 6px; } } } diff -r e6996e0ec636bd3dd8e9b11c608b999c3c2a50ab -r 1cf25d3a5cdc2f256e5519532d73c3c8e48faa48 static/style/src/less/ui.less --- a/static/style/src/less/ui.less +++ b/static/style/src/less/ui.less @@ -62,7 +62,7 @@ &:extend(.grid); tbody td { - padding: 5px 0px 5px 5px !important; + padding: 5px 0px 5px 0px !important; border: none !important; } @@ -73,8 +73,8 @@ .ui-table-form-section { border-left: solid 3px @form-heading-bg; - border-radius: 5px; - padding-left: 5px; + border-radius: 5px !important; + padding-left: 10px; } .ui-table-form-title-strong { @@ -239,7 +239,7 @@ padding: 0px; .content { padding : 0px; - padding-left: 5px; + padding-left: 10px; } } } 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.
participants (1)
-
commits-noreply@bitbucket.org