galaxy-commits
Threads by month
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
February 2015
- 2 participants
- 305 discussions
commit/galaxy-central: dan: Fix for parsing Tool Data Table columns that are defined as individual xml elements.
by commits-noreply@bitbucket.org 11 Feb '15
by commits-noreply@bitbucket.org 11 Feb '15
11 Feb '15
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/d00255be341d/
Changeset: d00255be341d
User: dan
Date: 2015-02-11 17:40:33+00:00
Summary: Fix for parsing Tool Data Table columns that are defined as individual xml elements.
Affected #: 1 file
diff -r da99d403f3375c31e8d784a91d430fe7068de1ab -r d00255be341d2b08af3fceeb2c8f46d3d6ce610b lib/galaxy/tools/data/__init__.py
--- a/lib/galaxy/tools/data/__init__.py
+++ b/lib/galaxy/tools/data/__init__.py
@@ -386,6 +386,7 @@
self.columns[ name ] = index
self.largest_index = index
else:
+ self.largest_index = 0
for column_elem in config_element.findall( 'column' ):
name = column_elem.get( 'name', None )
assert name is not None, "Required 'name' attribute missing from column def"
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.
1
0
commit/galaxy-central: dan: Fix for TabularToolDataTable.get_named_fields_list() when a data line has extra columns.
by commits-noreply@bitbucket.org 11 Feb '15
by commits-noreply@bitbucket.org 11 Feb '15
11 Feb '15
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/da99d403f337/
Changeset: da99d403f337
User: dan
Date: 2015-02-11 17:37:59+00:00
Summary: Fix for TabularToolDataTable.get_named_fields_list() when a data line has extra columns.
Affected #: 1 file
diff -r 70caaa5b7ff7dd4a11ddead7d946cb145e58686a -r da99d403f3375c31e8d784a91d430fe7068de1ab lib/galaxy/tools/data/__init__.py
--- a/lib/galaxy/tools/data/__init__.py
+++ b/lib/galaxy/tools/data/__init__.py
@@ -353,11 +353,13 @@
def get_named_fields_list( self ):
rval = []
- named_colums = self.get_column_name_list()
+ named_columns = self.get_column_name_list()
for fields in self.get_fields():
field_dict = {}
for i, field in enumerate( fields ):
- field_name = named_colums[i]
+ if i == len( named_columns ):
+ break
+ field_name = named_columns[i]
if field_name is None:
field_name = i # check that this is supposed to be 0 based.
field_dict[ field_name ] = field
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.
1
0
commit/galaxy-central: dan: Fix for Data Tables persisting when .loc file doesn't exist.
by commits-noreply@bitbucket.org 11 Feb '15
by commits-noreply@bitbucket.org 11 Feb '15
11 Feb '15
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/70caaa5b7ff7/
Changeset: 70caaa5b7ff7
User: dan
Date: 2015-02-11 17:33:49+00:00
Summary: Fix for Data Tables persisting when .loc file doesn't exist.
Affected #: 1 file
diff -r 75d1aa0e7663ec42f004a785ece731fd992f979d -r 70caaa5b7ff7dd4a11ddead7d946cb145e58686a lib/galaxy/tools/data/__init__.py
--- a/lib/galaxy/tools/data/__init__.py
+++ b/lib/galaxy/tools/data/__init__.py
@@ -513,7 +513,7 @@
try:
data_table_fh = open( filename, 'r+b' )
except IOError, e:
- log.warning( 'Error opening data table file (%s) with r+b, assuming file does not exist and will open as wb: %s', self.filename, e )
+ log.warning( 'Error opening data table file (%s) with r+b, assuming file does not exist and will open as wb: %s', filename, e )
data_table_fh = open( filename, 'wb' )
if os.stat( filename )[6] != 0:
# ensure last existing line ends with new line
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.
1
0
commit/galaxy-central: guerler: ToolForm: Move debug output
by commits-noreply@bitbucket.org 11 Feb '15
by commits-noreply@bitbucket.org 11 Feb '15
11 Feb '15
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/75d1aa0e7663/
Changeset: 75d1aa0e7663
User: guerler
Date: 2015-02-11 17:27:18+00:00
Summary: ToolForm: Move debug output
Affected #: 6 files
diff -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e -r 75d1aa0e7663ec42f004a785ece731fd992f979d client/galaxy/scripts/mvc/tools/tools-content.js
--- a/client/galaxy/scripts/mvc/tools/tools-content.js
+++ b/client/galaxy/scripts/mvc/tools/tools-content.js
@@ -15,9 +15,6 @@
this.summary[c.id + '_' + c.src] = c;
}
}
-
- // log
- console.debug('tools-content::initialize() - Completed.');
},
/** Returns matched content from summary.
diff -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e -r 75d1aa0e7663ec42f004a785ece731fd992f979d client/galaxy/scripts/mvc/tools/tools-form-base.js
--- a/client/galaxy/scripts/mvc/tools/tools-form-base.js
+++ b/client/galaxy/scripts/mvc/tools/tools-form-base.js
@@ -350,6 +350,9 @@
message : options.message
});
}
+
+ // log
+ console.debug('tools-form-base::initialize() - Completed.');
}
});
});
diff -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e -r 75d1aa0e7663ec42f004a785ece731fd992f979d static/scripts/mvc/tools/tools-content.js
--- a/static/scripts/mvc/tools/tools-content.js
+++ b/static/scripts/mvc/tools/tools-content.js
@@ -15,9 +15,6 @@
this.summary[c.id + '_' + c.src] = c;
}
}
-
- // log
- console.debug('tools-content::initialize() - Completed.');
},
/** Returns matched content from summary.
diff -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e -r 75d1aa0e7663ec42f004a785ece731fd992f979d static/scripts/mvc/tools/tools-form-base.js
--- a/static/scripts/mvc/tools/tools-form-base.js
+++ b/static/scripts/mvc/tools/tools-form-base.js
@@ -350,6 +350,9 @@
message : options.message
});
}
+
+ // log
+ console.debug('tools-form-base::initialize() - Completed.');
}
});
});
diff -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e -r 75d1aa0e7663ec42f004a785ece731fd992f979d static/scripts/packed/mvc/tools/tools-content.js
--- a/static/scripts/packed/mvc/tools/tools-content.js
+++ b/static/scripts/packed/mvc/tools/tools-content.js
@@ -1,1 +1,1 @@
-define(["utils/utils"],function(a){return Backbone.Model.extend({initialize:function(b){this.summary={}},add:function(e){for(var d in e){for(var b in e[d]){var f=e[d][b];this.summary[f.id+"_"+f.src]=f}}console.debug("tools-content::initialize() - Completed.")},get:function(b){return _.findWhere(this.summary,b)||{}},getDetails:function(b){if(!b.id||b.id==="null"){b.success&&b.success();return}var c=this.base_url+"/datasets/"+b.id;if(b.src=="hdca"){c=this.base_url+"/dataset_collections/"+b.id}a.get({url:c,success:function(d){b.success&&b.success(d)},error:function(d){b.success&&b.success();console.debug("tools-content::getDetails() - Ajax request for content failed.");console.debug(d)}})}})});
\ No newline at end of file
+define(["utils/utils"],function(a){return Backbone.Model.extend({initialize:function(b){this.summary={}},add:function(e){for(var d in e){for(var b in e[d]){var f=e[d][b];this.summary[f.id+"_"+f.src]=f}}},get:function(b){return _.findWhere(this.summary,b)||{}},getDetails:function(b){if(!b.id||b.id==="null"){b.success&&b.success();return}var c=this.base_url+"/datasets/"+b.id;if(b.src=="hdca"){c=this.base_url+"/dataset_collections/"+b.id}a.get({url:c,success:function(d){b.success&&b.success(d)},error:function(d){b.success&&b.success();console.debug("tools-content::getDetails() - Ajax request for content failed.");console.debug(d)}})}})});
\ No newline at end of file
diff -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e -r 75d1aa0e7663ec42f004a785ece731fd992f979d static/scripts/packed/mvc/tools/tools-form-base.js
--- a/static/scripts/packed/mvc/tools/tools-form-base.js
+++ b/static/scripts/packed/mvc/tools/tools-form-base.js
@@ -1,1 +1,1 @@
-define(["utils/utils","utils/deferred","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree"],function(g,h,f,k,i,a,d,c,e,j,b){return Backbone.View.extend({initialize:function(l){this.optionsDefault={is_dynamic:true,narrow:false,initial_errors:false,cls_portlet:"ui-portlet-limited"};this.options=g.merge(l,this.optionsDefault);console.debug(this.options);var m=parent.Galaxy;if(m&&m.modal){this.modal=m.modal}else{this.modal=new k.Modal.View()}if(m&&m.currUser){this.is_admin=m.currUser.get("is_admin")}else{this.is_admin=false}this.container=this.options.container||"body";this.deferred=new h();this.setElement("<div/>");$(this.container).append(this.$el);this.build(this.options)},build:function(m){var l=this;this.off("refresh");this.off("reset");this.field_list={};this.input_list={};this.element_list={};this.tree=new b(this);this.content=new e(this);l.options.inputs=m&&m.inputs;this._renderForm(m);this.tree.finalize();if(m.initial_errors){this._errors(m)}this.on("refresh",function(){l.deferred.reset();l.deferred.execute(function(){l._updateModel()})});this.on("reset",function(){for(var n in this.element_list){this.element_list[n].reset()}});this.trigger("refresh")},reciept:function(l){$(this.container).empty();$(this.container).append(l)},highlight:function(m,n,l){var o=this.element_list[m];if(o){o.error(n||"Please verify this parameter.");if(!l){$(this.container).animate({scrollTop:o.$el.offset().top-20},500)}}},_errors:function(n){this.trigger("reset");if(n&&n.errors){var o=this.tree.matchResponse(n.errors);for(var m in this.element_list){var l=this.element_list[m];if(o[m]){this.highlight(m,o[m],true)}}}},_renderForm:function(t){var s=this;this.message=new k.Message();var m=new k.ButtonMenu({icon:"fa-cubes",title:(!t.narrow&&"Versions")||null,tooltip:"Select another tool version"});if(t.versions&&t.versions.length>1){for(var o in t.versions){var q=t.versions[o];if(q!=t.version){m.addMenu({title:"Switch to "+q,version:q,icon:"fa-cube",onclick:function(){s.options.id=s.options.id.replace(s.options.version,this.version);s.options.version=this.version;s.deferred.reset();s.deferred.execute(function(){s._buildModel()})}})}}}else{m.$el.hide()}var p=new k.ButtonMenu({icon:"fa-caret-down",title:(!t.narrow&&"Options")||null,tooltip:"View available options"});if(t.biostar_url){p.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(t.biostar_url+"/p/new/post/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(t.biostar_url+"/t/"+t.id+"/")}})}p.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+t.id)}});if(this.is_admin){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+t.id+"/download"}})}if(t.requirements&&t.requirements.length>0){p.addMenu({icon:"fa-info-circle",title:"Requirements",tooltip:"Display tool requirements",onclick:function(){if(!this.visible){this.visible=true;s.message.update({persistent:true,message:c.requirements(t),status:"info"})}else{this.visible=false;s.message.update({message:""})}}})}if(this.options.sharable_url){p.addMenu({icon:"fa-external-link",title:"Open in Toolshed",tooltip:"Access the repository",onclick:function(){window.open(s.options.sharable_url)}})}this.section=new j.View(s,{inputs:t.inputs});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new f.View({icon:"fa-wrench",title:"<b>"+t.name+"</b> "+t.description+" (Galaxy Tool Version "+t.version+")",cls:this.options.cls_portlet,operations:{menu:p,versions:m},buttons:this.buttons});this.portlet.append(this.message.$el.addClass("ui-margin-top"));this.portlet.append(this.section.$el);this.$el.empty();this.$el.append(this.portlet.$el);if(t.help!=""){this.$el.append(c.help(t.help))}if(t.citations){var r=$("<div/>");var l=new i.ToolCitationCollection();l.tool_id=t.id;var n=new a.CitationListView({el:r,collection:l});n.render();l.fetch();this.$el.append(r)}if(t.message){this.message.update({persistent:true,status:"warning",message:t.message})}}})});
\ No newline at end of file
+define(["utils/utils","utils/deferred","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree"],function(g,h,f,k,i,a,d,c,e,j,b){return Backbone.View.extend({initialize:function(l){this.optionsDefault={is_dynamic:true,narrow:false,initial_errors:false,cls_portlet:"ui-portlet-limited"};this.options=g.merge(l,this.optionsDefault);console.debug(this.options);var m=parent.Galaxy;if(m&&m.modal){this.modal=m.modal}else{this.modal=new k.Modal.View()}if(m&&m.currUser){this.is_admin=m.currUser.get("is_admin")}else{this.is_admin=false}this.container=this.options.container||"body";this.deferred=new h();this.setElement("<div/>");$(this.container).append(this.$el);this.build(this.options)},build:function(m){var l=this;this.off("refresh");this.off("reset");this.field_list={};this.input_list={};this.element_list={};this.tree=new b(this);this.content=new e(this);l.options.inputs=m&&m.inputs;this._renderForm(m);this.tree.finalize();if(m.initial_errors){this._errors(m)}this.on("refresh",function(){l.deferred.reset();l.deferred.execute(function(){l._updateModel()})});this.on("reset",function(){for(var n in this.element_list){this.element_list[n].reset()}});this.trigger("refresh")},reciept:function(l){$(this.container).empty();$(this.container).append(l)},highlight:function(m,n,l){var o=this.element_list[m];if(o){o.error(n||"Please verify this parameter.");if(!l){$(this.container).animate({scrollTop:o.$el.offset().top-20},500)}}},_errors:function(n){this.trigger("reset");if(n&&n.errors){var o=this.tree.matchResponse(n.errors);for(var m in this.element_list){var l=this.element_list[m];if(o[m]){this.highlight(m,o[m],true)}}}},_renderForm:function(t){var s=this;this.message=new k.Message();var m=new k.ButtonMenu({icon:"fa-cubes",title:(!t.narrow&&"Versions")||null,tooltip:"Select another tool version"});if(t.versions&&t.versions.length>1){for(var o in t.versions){var q=t.versions[o];if(q!=t.version){m.addMenu({title:"Switch to "+q,version:q,icon:"fa-cube",onclick:function(){s.options.id=s.options.id.replace(s.options.version,this.version);s.options.version=this.version;s.deferred.reset();s.deferred.execute(function(){s._buildModel()})}})}}}else{m.$el.hide()}var p=new k.ButtonMenu({icon:"fa-caret-down",title:(!t.narrow&&"Options")||null,tooltip:"View available options"});if(t.biostar_url){p.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(t.biostar_url+"/p/new/post/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(t.biostar_url+"/t/"+t.id+"/")}})}p.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+t.id)}});if(this.is_admin){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+t.id+"/download"}})}if(t.requirements&&t.requirements.length>0){p.addMenu({icon:"fa-info-circle",title:"Requirements",tooltip:"Display tool requirements",onclick:function(){if(!this.visible){this.visible=true;s.message.update({persistent:true,message:c.requirements(t),status:"info"})}else{this.visible=false;s.message.update({message:""})}}})}if(this.options.sharable_url){p.addMenu({icon:"fa-external-link",title:"Open in Toolshed",tooltip:"Access the repository",onclick:function(){window.open(s.options.sharable_url)}})}this.section=new j.View(s,{inputs:t.inputs});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new f.View({icon:"fa-wrench",title:"<b>"+t.name+"</b> "+t.description+" (Galaxy Tool Version "+t.version+")",cls:this.options.cls_portlet,operations:{menu:p,versions:m},buttons:this.buttons});this.portlet.append(this.message.$el.addClass("ui-margin-top"));this.portlet.append(this.section.$el);this.$el.empty();this.$el.append(this.portlet.$el);if(t.help!=""){this.$el.append(c.help(t.help))}if(t.citations){var r=$("<div/>");var l=new i.ToolCitationCollection();l.tool_id=t.id;var n=new a.CitationListView({el:r,collection:l});n.render();l.fetch();this.$el.append(r)}if(t.message){this.message.update({persistent:true,status:"warning",message:t.message})}console.debug("tools-form-base::initialize() - Completed.")}})});
\ No newline at end of file
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.
1
0
commit/galaxy-central: guerler: ToolForm: Update select validation, remove spaces
by commits-noreply@bitbucket.org 11 Feb '15
by commits-noreply@bitbucket.org 11 Feb '15
11 Feb '15
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/bbd5375d27aa/
Changeset: bbd5375d27aa
User: guerler
Date: 2015-02-11 17:20:06+00:00
Summary: ToolForm: Update select validation, remove spaces
Affected #: 6 files
diff -r 52e80be61a360ea2cf1387920ebdffdff5c0218c -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e client/galaxy/scripts/mvc/ui/ui-options.js
--- a/client/galaxy/scripts/mvc/ui/ui-options.js
+++ b/client/galaxy/scripts/mvc/ui/ui-options.js
@@ -105,7 +105,7 @@
if (new_value !== undefined) {
// reset selection
this.$('input').prop('checked', false);
-
+
// set value
if (new_value !== null) {
// check if its an array
@@ -122,7 +122,7 @@
// refresh
this._refresh();
-
+
// get and return value
return this._getValue();
},
@@ -146,7 +146,7 @@
/** Return first available option
*/
first: function() {
- var options = this.$('input');
+ var options = this.$('input').first();
if (options.length > 0) {
return options.val();
} else {
diff -r 52e80be61a360ea2cf1387920ebdffdff5c0218c -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e client/galaxy/scripts/mvc/ui/ui-select-default.js
--- a/client/galaxy/scripts/mvc/ui/ui-select-default.js
+++ b/client/galaxy/scripts/mvc/ui/ui-select-default.js
@@ -87,21 +87,17 @@
}
// validate and return value
- var val = this.$select.val();
- if (!Utils.validate(val)) {
- return null;
- }
- return val;
+ return this._getValue();
},
/** Return the first select option
*/
first: function() {
- var options = this.$select.find('option');
+ var options = this.$select.find('option').first();
if (options.length > 0) {
return options.val();
} else {
- return undefined;
+ return null;
}
},
@@ -182,7 +178,7 @@
*/
update: function(options) {
// backup current value
- var current = this.$select.val();
+ var current = this._getValue();
// remove all options
this.$select.find('option').remove();
@@ -204,7 +200,7 @@
this.$select.val(current);
// check if any value was set
- if (!this.$select.val()) {
+ if (this._getValue() === null) {
this.$select.val(this.first());
}
@@ -232,10 +228,19 @@
*/
_change: function() {
if (this.options.onchange) {
- this.options.onchange(this.$select.val());
+ this.options.onchange(this._getValue());
}
},
+ /** Validate */
+ _getValue: function() {
+ var val = this.$select.val();
+ if (!Utils.validate(val)) {
+ return null;
+ }
+ return val;
+ },
+
/** Refresh the select view
*/
_refresh: function() {
diff -r 52e80be61a360ea2cf1387920ebdffdff5c0218c -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e static/scripts/mvc/ui/ui-options.js
--- a/static/scripts/mvc/ui/ui-options.js
+++ b/static/scripts/mvc/ui/ui-options.js
@@ -105,7 +105,7 @@
if (new_value !== undefined) {
// reset selection
this.$('input').prop('checked', false);
-
+
// set value
if (new_value !== null) {
// check if its an array
@@ -122,7 +122,7 @@
// refresh
this._refresh();
-
+
// get and return value
return this._getValue();
},
@@ -146,7 +146,7 @@
/** Return first available option
*/
first: function() {
- var options = this.$('input');
+ var options = this.$('input').first();
if (options.length > 0) {
return options.val();
} else {
diff -r 52e80be61a360ea2cf1387920ebdffdff5c0218c -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e static/scripts/mvc/ui/ui-select-default.js
--- a/static/scripts/mvc/ui/ui-select-default.js
+++ b/static/scripts/mvc/ui/ui-select-default.js
@@ -87,21 +87,17 @@
}
// validate and return value
- var val = this.$select.val();
- if (!Utils.validate(val)) {
- return null;
- }
- return val;
+ return this._getValue();
},
/** Return the first select option
*/
first: function() {
- var options = this.$select.find('option');
+ var options = this.$select.find('option').first();
if (options.length > 0) {
return options.val();
} else {
- return undefined;
+ return null;
}
},
@@ -182,7 +178,7 @@
*/
update: function(options) {
// backup current value
- var current = this.$select.val();
+ var current = this._getValue();
// remove all options
this.$select.find('option').remove();
@@ -204,7 +200,7 @@
this.$select.val(current);
// check if any value was set
- if (!this.$select.val()) {
+ if (this._getValue() === null) {
this.$select.val(this.first());
}
@@ -232,10 +228,19 @@
*/
_change: function() {
if (this.options.onchange) {
- this.options.onchange(this.$select.val());
+ this.options.onchange(this._getValue());
}
},
+ /** Validate */
+ _getValue: function() {
+ var val = this.$select.val();
+ if (!Utils.validate(val)) {
+ return null;
+ }
+ return val;
+ },
+
/** Refresh the select view
*/
_refresh: function() {
diff -r 52e80be61a360ea2cf1387920ebdffdff5c0218c -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e static/scripts/packed/mvc/ui/ui-options.js
--- a/static/scripts/packed/mvc/ui/ui-options.js
+++ b/static/scripts/packed/mvc/ui/ui-options.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/ui/ui-button-check"],function(c,e){var b=Backbone.View.extend({initialize:function(i){this.optionsDefault={visible:true,data:[],id:c.uuid(),error_text:"No data available.",wait_text:"Please wait...",multiple:false};this.options=c.merge(i,this.optionsDefault);this.setElement('<div class="ui-options"/>');this.$message=$("<div/>");this.$options=$(this._template(i));this.$menu=$('<div class="ui-options-menu"/>');this.$el.append(this.$message);this.$el.append(this.$menu);this.$el.append(this.$options);if(this.options.multiple){this.select_button=new e({onclick:function(){h.$("input").prop("checked",h.select_button.value()!==0);h._change()}});this.$menu.addClass("ui-margin-bottom");this.$menu.append(this.select_button.$el);this.$menu.append("Select/Unselect all")}if(!this.options.visible){this.$el.hide()}this.update(this.options.data);if(this.options.value!==undefined){this.value(this.options.value)}var h=this;this.on("change",function(){h._change()})},update:function(i){var l=this._getValue();this.$options.empty();if(this._templateOptions){this.$options.append(this._templateOptions(i))}else{for(var j in i){var k=$(this._templateOption(i[j]));k.addClass("ui-option");k.tooltip({title:i[j].tooltip,placement:"bottom"});this.$options.append(k)}}var h=this;this.$("input").on("change",function(){h.value(h._getValue());h._change()});this.value(l)},value:function(j){if(j!==undefined){this.$("input").prop("checked",false);if(j!==null){if(!(j instanceof Array)){j=[j]}for(var h in j){this.$('input[value="'+j[h]+'"]').first().prop("checked",true)}}}this._refresh();return this._getValue()},exists:function(j){if(j!==undefined){if(!(j instanceof Array)){j=[j]}for(var h in j){if(this.$('input[value="'+j[h]+'"]').length>0){return true}}}return false},first:function(){var h=this.$("input");if(h.length>0){return h.val()}else{return null}},wait:function(){if(this._size()==0){this._messageShow(this.options.wait_text,"info");this.$options.hide();this.$menu.hide()}},unwait:function(){this._refresh()},_change:function(){if(this.options.onchange){this.options.onchange(this._getValue())}},_refresh:function(){if(this._size()==0){this._messageShow(this.options.error_text,"danger");this.$options.hide();this.$menu.hide()}else{this._messageHide();this.$options.css("display","inline-block");this.$menu.show()}if(this.select_button){var h=this._size();var i=this._getValue();if(!(i instanceof Array)){this.select_button.value(0)}else{if(i.length!==h){this.select_button.value(1)}else{this.select_button.value(2)}}}},_getValue:function(){var h=[];this.$(":checked").each(function(){h.push($(this).val())});if(!c.validate(h)){return null}if(this.options.multiple){return h}else{return h[0]}},_size:function(){return this.$(".ui-option").length},_messageShow:function(i,h){this.$message.show();this.$message.removeClass();this.$message.addClass("ui-message alert alert-"+h);this.$message.html(i)},_messageHide:function(){this.$message.hide()},_template:function(){return'<div class="ui-options-list"/>'}});var a=b.extend({_templateOption:function(h){var i=c.uuid();return'<div class="ui-option"><input id="'+i+'" type="'+this.options.type+'" name="'+this.options.id+'" value="'+h.value+'"/><label class="ui-options-label" for="'+i+'">'+h.label+"</label></div>"}});var f={};f.View=a.extend({initialize:function(h){h.type="radio";a.prototype.initialize.call(this,h)}});var d={};d.View=a.extend({initialize:function(h){h.multiple=true;h.type="checkbox";a.prototype.initialize.call(this,h)}});var g={};g.View=b.extend({initialize:function(h){b.prototype.initialize.call(this,h)},value:function(h){if(h!==undefined){this.$("input").prop("checked",false);this.$("label").removeClass("active");this.$('[value="'+h+'"]').prop("checked",true).closest("label").addClass("active")}return this._getValue()},_templateOption:function(j){var h="fa "+j.icon;if(!j.label){h+=" no-padding"}var i='<label class="btn btn-default">';if(j.icon){i+='<i class="'+h+'"/>'}i+='<input type="radio" name="'+this.options.id+'" value="'+j.value+'"/>';if(j.label){i+=j.label}i+="</label>";return i},_template:function(){return'<div class="btn-group ui-radiobutton" data-toggle="buttons"/>'}});return{Base:b,BaseIcons:a,Radio:f,RadioButton:g,Checkbox:d}});
\ No newline at end of file
+define(["utils/utils","mvc/ui/ui-button-check"],function(c,e){var b=Backbone.View.extend({initialize:function(i){this.optionsDefault={visible:true,data:[],id:c.uuid(),error_text:"No data available.",wait_text:"Please wait...",multiple:false};this.options=c.merge(i,this.optionsDefault);this.setElement('<div class="ui-options"/>');this.$message=$("<div/>");this.$options=$(this._template(i));this.$menu=$('<div class="ui-options-menu"/>');this.$el.append(this.$message);this.$el.append(this.$menu);this.$el.append(this.$options);if(this.options.multiple){this.select_button=new e({onclick:function(){h.$("input").prop("checked",h.select_button.value()!==0);h._change()}});this.$menu.addClass("ui-margin-bottom");this.$menu.append(this.select_button.$el);this.$menu.append("Select/Unselect all")}if(!this.options.visible){this.$el.hide()}this.update(this.options.data);if(this.options.value!==undefined){this.value(this.options.value)}var h=this;this.on("change",function(){h._change()})},update:function(i){var l=this._getValue();this.$options.empty();if(this._templateOptions){this.$options.append(this._templateOptions(i))}else{for(var j in i){var k=$(this._templateOption(i[j]));k.addClass("ui-option");k.tooltip({title:i[j].tooltip,placement:"bottom"});this.$options.append(k)}}var h=this;this.$("input").on("change",function(){h.value(h._getValue());h._change()});this.value(l)},value:function(j){if(j!==undefined){this.$("input").prop("checked",false);if(j!==null){if(!(j instanceof Array)){j=[j]}for(var h in j){this.$('input[value="'+j[h]+'"]').first().prop("checked",true)}}}this._refresh();return this._getValue()},exists:function(j){if(j!==undefined){if(!(j instanceof Array)){j=[j]}for(var h in j){if(this.$('input[value="'+j[h]+'"]').length>0){return true}}}return false},first:function(){var h=this.$("input").first();if(h.length>0){return h.val()}else{return null}},wait:function(){if(this._size()==0){this._messageShow(this.options.wait_text,"info");this.$options.hide();this.$menu.hide()}},unwait:function(){this._refresh()},_change:function(){if(this.options.onchange){this.options.onchange(this._getValue())}},_refresh:function(){if(this._size()==0){this._messageShow(this.options.error_text,"danger");this.$options.hide();this.$menu.hide()}else{this._messageHide();this.$options.css("display","inline-block");this.$menu.show()}if(this.select_button){var h=this._size();var i=this._getValue();if(!(i instanceof Array)){this.select_button.value(0)}else{if(i.length!==h){this.select_button.value(1)}else{this.select_button.value(2)}}}},_getValue:function(){var h=[];this.$(":checked").each(function(){h.push($(this).val())});if(!c.validate(h)){return null}if(this.options.multiple){return h}else{return h[0]}},_size:function(){return this.$(".ui-option").length},_messageShow:function(i,h){this.$message.show();this.$message.removeClass();this.$message.addClass("ui-message alert alert-"+h);this.$message.html(i)},_messageHide:function(){this.$message.hide()},_template:function(){return'<div class="ui-options-list"/>'}});var a=b.extend({_templateOption:function(h){var i=c.uuid();return'<div class="ui-option"><input id="'+i+'" type="'+this.options.type+'" name="'+this.options.id+'" value="'+h.value+'"/><label class="ui-options-label" for="'+i+'">'+h.label+"</label></div>"}});var f={};f.View=a.extend({initialize:function(h){h.type="radio";a.prototype.initialize.call(this,h)}});var d={};d.View=a.extend({initialize:function(h){h.multiple=true;h.type="checkbox";a.prototype.initialize.call(this,h)}});var g={};g.View=b.extend({initialize:function(h){b.prototype.initialize.call(this,h)},value:function(h){if(h!==undefined){this.$("input").prop("checked",false);this.$("label").removeClass("active");this.$('[value="'+h+'"]').prop("checked",true).closest("label").addClass("active")}return this._getValue()},_templateOption:function(j){var h="fa "+j.icon;if(!j.label){h+=" no-padding"}var i='<label class="btn btn-default">';if(j.icon){i+='<i class="'+h+'"/>'}i+='<input type="radio" name="'+this.options.id+'" value="'+j.value+'"/>';if(j.label){i+=j.label}i+="</label>";return i},_template:function(){return'<div class="btn-group ui-radiobutton" data-toggle="buttons"/>'}});return{Base:b,BaseIcons:a,Radio:f,RadioButton:g,Checkbox:d}});
\ No newline at end of file
diff -r 52e80be61a360ea2cf1387920ebdffdff5c0218c -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e static/scripts/packed/mvc/ui/ui-select-default.js
--- a/static/scripts/packed/mvc/ui/ui-select-default.js
+++ b/static/scripts/packed/mvc/ui/ui-select-default.js
@@ -1,1 +1,1 @@
-define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{id:"",cls:"",error_text:"No data available",empty_text:"No selection",visible:true,wait:false,multiple:false,searchable:false,optional:false},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));this.$select=this.$el.find(".select");this.$icon=this.$el.find(".icon");this.$button=this.$el.find(".button");if(this.options.multiple){this.$select.prop("multiple",true);this.$select.addClass("ui-select-multiple");this.$icon.remove()}else{this.$el.addClass("ui-select")}this.update(this.options.data);if(this.options.value!==undefined){this.value(this.options.value)}if(!this.options.visible){this.hide()}if(this.options.wait){this.wait()}else{this.show()}var c=this;this.$select.on("change",function(){c._change()});this.on("change",function(){c._change()})},value:function(c){if(c!==undefined){if(c===null){c="__null__"}this.$select.val(c);if(this.$select.select2){this.$select.select2("val",c)}}var d=this.$select.val();if(!a.validate(d)){return null}return d},first:function(){var c=this.$select.find("option");if(c.length>0){return c.val()}else{return undefined}},text:function(){return this.$select.find("option:selected").text()},show:function(){this.unwait();this.$select.show();this.$el.show()},hide:function(){this.$el.hide()},wait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-spinner fa-spin")},unwait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-caret-down")},disabled:function(){return this.$select.is(":disabled")},enable:function(){this.$select.prop("disabled",false)},disable:function(){this.$select.prop("disabled",true)},add:function(c){this.$select.append(this._templateOption(c));this._refresh()},del:function(c){this.$select.find("option[value="+c+"]").remove();this.$select.trigger("change");this._refresh()},update:function(c){var e=this.$select.val();this.$select.find("option").remove();if(this.options.optional&&!this.options.multiple){this.$select.append(this._templateOption({value:"__null__",label:this.options.empty_text}))}for(var d in c){this.$select.append(this._templateOption(c[d]))}this._refresh();this.$select.val(e);if(!this.$select.val()){this.$select.val(this.first())}if(this.options.searchable){this.$button.hide();this.$select.select2("destroy");this.$select.select2()}},setOnChange:function(c){this.options.onchange=c},exists:function(c){return this.$select.find('option[value="'+c+'"]').length>0},_change:function(){if(this.options.onchange){this.options.onchange(this.$select.val())}},_refresh:function(){this.$select.find('option[value="__undefined__"]').remove();var c=this.$select.find("option").length;if(c==0){this.disable();this.$select.append(this._templateOption({value:"__undefined__",label:this.options.error_text}))}else{this.enable()}},_templateOption:function(c){return'<option value="'+c.value+'">'+c.label+"</option>"},_template:function(c){return'<div id="'+c.id+'"><select id="select" class="select '+c.cls+" "+c.id+'"></select><div class="button"><i class="icon"/></div></div>'}});return{View:b}});
\ No newline at end of file
+define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{id:"",cls:"",error_text:"No data available",empty_text:"No selection",visible:true,wait:false,multiple:false,searchable:false,optional:false},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));this.$select=this.$el.find(".select");this.$icon=this.$el.find(".icon");this.$button=this.$el.find(".button");if(this.options.multiple){this.$select.prop("multiple",true);this.$select.addClass("ui-select-multiple");this.$icon.remove()}else{this.$el.addClass("ui-select")}this.update(this.options.data);if(this.options.value!==undefined){this.value(this.options.value)}if(!this.options.visible){this.hide()}if(this.options.wait){this.wait()}else{this.show()}var c=this;this.$select.on("change",function(){c._change()});this.on("change",function(){c._change()})},value:function(c){if(c!==undefined){if(c===null){c="__null__"}this.$select.val(c);if(this.$select.select2){this.$select.select2("val",c)}}return this._getValue()},first:function(){var c=this.$select.find("option").first();if(c.length>0){return c.val()}else{return null}},text:function(){return this.$select.find("option:selected").text()},show:function(){this.unwait();this.$select.show();this.$el.show()},hide:function(){this.$el.hide()},wait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-spinner fa-spin")},unwait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-caret-down")},disabled:function(){return this.$select.is(":disabled")},enable:function(){this.$select.prop("disabled",false)},disable:function(){this.$select.prop("disabled",true)},add:function(c){this.$select.append(this._templateOption(c));this._refresh()},del:function(c){this.$select.find("option[value="+c+"]").remove();this.$select.trigger("change");this._refresh()},update:function(c){var e=this._getValue();this.$select.find("option").remove();if(this.options.optional&&!this.options.multiple){this.$select.append(this._templateOption({value:"__null__",label:this.options.empty_text}))}for(var d in c){this.$select.append(this._templateOption(c[d]))}this._refresh();this.$select.val(e);if(this._getValue()===null){this.$select.val(this.first())}if(this.options.searchable){this.$button.hide();this.$select.select2("destroy");this.$select.select2()}},setOnChange:function(c){this.options.onchange=c},exists:function(c){return this.$select.find('option[value="'+c+'"]').length>0},_change:function(){if(this.options.onchange){this.options.onchange(this._getValue())}},_getValue:function(){var c=this.$select.val();if(!a.validate(c)){return null}return c},_refresh:function(){this.$select.find('option[value="__undefined__"]').remove();var c=this.$select.find("option").length;if(c==0){this.disable();this.$select.append(this._templateOption({value:"__undefined__",label:this.options.error_text}))}else{this.enable()}},_templateOption:function(c){return'<option value="'+c.value+'">'+c.label+"</option>"},_template:function(c){return'<div id="'+c.id+'"><select id="select" class="select '+c.cls+" "+c.id+'"></select><div class="button"><i class="icon"/></div></div>'}});return{View:b}});
\ No newline at end of file
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.
1
0
commit/galaxy-central: guerler: ToolForm: Remove brackets
by commits-noreply@bitbucket.org 11 Feb '15
by commits-noreply@bitbucket.org 11 Feb '15
11 Feb '15
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/52e80be61a36/
Changeset: 52e80be61a36
User: guerler
Date: 2015-02-11 16:19:29+00:00
Summary: ToolForm: Remove brackets
Affected #: 3 files
diff -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 -r 52e80be61a360ea2cf1387920ebdffdff5c0218c client/galaxy/scripts/mvc/tools/tools-input.js
--- a/client/galaxy/scripts/mvc/tools/tools-input.js
+++ b/client/galaxy/scripts/mvc/tools/tools-input.js
@@ -34,9 +34,9 @@
this.field.skip = false;
var v = this.field.value && this.field.value();
this.field.skip = Boolean(options.optional &&
- ((v === null || (v == this.default_value) ||
- (Number(v) == Number(this.default_value)) ||
- (JSON.stringify(v) == JSON.stringify(this.default_value)))));
+ (v === null || v == this.default_value ||
+ Number(v) == Number(this.default_value) ||
+ JSON.stringify(v) == JSON.stringify(this.default_value)));
// refresh view
this._refresh();
diff -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 -r 52e80be61a360ea2cf1387920ebdffdff5c0218c static/scripts/mvc/tools/tools-input.js
--- a/static/scripts/mvc/tools/tools-input.js
+++ b/static/scripts/mvc/tools/tools-input.js
@@ -34,9 +34,9 @@
this.field.skip = false;
var v = this.field.value && this.field.value();
this.field.skip = Boolean(options.optional &&
- ((v === null || (v == this.default_value) ||
- (Number(v) == Number(this.default_value)) ||
- (JSON.stringify(v) == JSON.stringify(this.default_value)))));
+ (v === null || v == this.default_value ||
+ Number(v) == Number(this.default_value) ||
+ JSON.stringify(v) == JSON.stringify(this.default_value)));
// refresh view
this._refresh();
diff -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 -r 52e80be61a360ea2cf1387920ebdffdff5c0218c static/scripts/packed/mvc/tools/tools-input.js
--- a/static/scripts/packed/mvc/tools/tools-input.js
+++ b/static/scripts/packed/mvc/tools/tools-input.js
@@ -1,1 +1,1 @@
-define([],function(){return Backbone.View.extend({initialize:function(d,c){this.app=d;this.text_enable=d.options.text_enable||"Enable";this.text_disable=d.options.text_disable||"Disable";this.field=c.field;this.default_value=c.default_value;this.setElement(this._template(c));this.$field=this.$el.find(".ui-table-form-field");this.$title_optional=this.$el.find(".ui-table-form-title-optional");this.$error_text=this.$el.find(".ui-table-form-error-text");this.$error=this.$el.find(".ui-table-form-error");this.$field.prepend(this.field.$el);this.field.skip=false;var b=this.field.value&&this.field.value();this.field.skip=Boolean(c.optional&&((b===null||(b==this.default_value)||(Number(b)==Number(this.default_value))||(JSON.stringify(b)==JSON.stringify(this.default_value)))));this._refresh();var a=this;this.$title_optional.on("click",function(){a.field.skip=!a.field.skip;a._refresh();a.app.trigger("refresh")})},error:function(a){this.$error_text.html(a);this.$error.show();this.$el.addClass("ui-error")},reset:function(){this.$error.hide();this.$el.removeClass("ui-error")},_refresh:function(){if(!this.field.skip){this.$field.fadeIn("fast");this.$title_optional.html(this.text_disable)}else{this.reset();this.$field.hide();this.$title_optional.html(this.text_enable);this.field.value&&this.field.value(this.default_value)}},_template:function(a){var b='<div class="ui-table-form-element"><div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/></div><div class="ui-table-form-title-strong">';if(a.optional){b+=a.label+'<span> [<span class="ui-table-form-title-optional"/>]</span>'}else{b+=a.label}b+='</div><div class="ui-table-form-field">';if(a.help){b+='<div class="ui-table-form-info">'+a.help+"</div>"}b+="</div></div>";return b}})});
\ No newline at end of file
+define([],function(){return Backbone.View.extend({initialize:function(d,c){this.app=d;this.text_enable=d.options.text_enable||"Enable";this.text_disable=d.options.text_disable||"Disable";this.field=c.field;this.default_value=c.default_value;this.setElement(this._template(c));this.$field=this.$el.find(".ui-table-form-field");this.$title_optional=this.$el.find(".ui-table-form-title-optional");this.$error_text=this.$el.find(".ui-table-form-error-text");this.$error=this.$el.find(".ui-table-form-error");this.$field.prepend(this.field.$el);this.field.skip=false;var b=this.field.value&&this.field.value();this.field.skip=Boolean(c.optional&&(b===null||b==this.default_value||Number(b)==Number(this.default_value)||JSON.stringify(b)==JSON.stringify(this.default_value)));this._refresh();var a=this;this.$title_optional.on("click",function(){a.field.skip=!a.field.skip;a._refresh();a.app.trigger("refresh")})},error:function(a){this.$error_text.html(a);this.$error.show();this.$el.addClass("ui-error")},reset:function(){this.$error.hide();this.$el.removeClass("ui-error")},_refresh:function(){if(!this.field.skip){this.$field.fadeIn("fast");this.$title_optional.html(this.text_disable)}else{this.reset();this.$field.hide();this.$title_optional.html(this.text_enable);this.field.value&&this.field.value(this.default_value)}},_template:function(a){var b='<div class="ui-table-form-element"><div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/></div><div class="ui-table-form-title-strong">';if(a.optional){b+=a.label+'<span> [<span class="ui-table-form-title-optional"/>]</span>'}else{b+=a.label}b+='</div><div class="ui-table-form-field">';if(a.help){b+='<div class="ui-table-form-info">'+a.help+"</div>"}b+="</div></div>";return b}})});
\ No newline at end of file
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.
1
0
commit/galaxy-central: guerler: ToolForm: Move forward with drill down element, simplify validation
by commits-noreply@bitbucket.org 11 Feb '15
by commits-noreply@bitbucket.org 11 Feb '15
11 Feb '15
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/15cd0c4f1a40/
Changeset: 15cd0c4f1a40
User: guerler
Date: 2015-02-11 16:03:22+00:00
Summary: ToolForm: Move forward with drill down element, simplify validation
Affected #: 21 files
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 client/galaxy/scripts/mvc/tools/tools-input.js
--- a/client/galaxy/scripts/mvc/tools/tools-input.js
+++ b/client/galaxy/scripts/mvc/tools/tools-input.js
@@ -34,9 +34,9 @@
this.field.skip = false;
var v = this.field.value && this.field.value();
this.field.skip = Boolean(options.optional &&
- (((this.field.validate && !this.field.validate()) || !v ||
- (v == this.default_value) || (Number(v) == Number(this.default_value)) ||
- (JSON.stringify(v) == JSON.stringify(this.default_value)))));
+ ((v === null || (v == this.default_value) ||
+ (Number(v) == Number(this.default_value)) ||
+ (JSON.stringify(v) == JSON.stringify(this.default_value)))));
// refresh view
this._refresh();
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 client/galaxy/scripts/mvc/tools/tools-select-content.js
--- a/client/galaxy/scripts/mvc/tools/tools-select-content.js
+++ b/client/galaxy/scripts/mvc/tools/tools-select-content.js
@@ -233,18 +233,28 @@
console.debug('tools-select-content::value() - Skipped.');
}
} else {
- this.select_single && this.select_single.value('__null__');
- this.select_multiple && this.select_multiple.value('__null__');
- this.select_collection && this.select_collection.value('__null__');
+ this.select_single && this.select_single.value(null);
+ this.select_multiple && this.select_multiple.value(null);
+ this.select_collection && this.select_collection.value(null);
}
this.refresh();
}
+ // validate value
+ var id_list = this._select().value();
+ if (id_list === null) {
+ return null;
+ }
+
// transform into an array
- var id_list = this._select().value();
if (!(id_list instanceof Array)) {
id_list = [id_list];
}
+
+ // check if value exists
+ if (id_list.length === 0) {
+ return null;
+ }
// prepare result dict
var result = {
@@ -264,12 +274,6 @@
return result;
},
- /** Validate current selection
- */
- validate: function() {
- return this._select().validate();
- },
-
/** Refreshes data selection view */
refresh: function() {
this.button_type.value(this.current);
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 client/galaxy/scripts/mvc/tools/tools-tree.js
--- a/client/galaxy/scripts/mvc/tools/tools-tree.js
+++ b/client/galaxy/scripts/mvc/tools/tools-tree.js
@@ -118,9 +118,6 @@
if (field && field.value) {
// validate field value
var value = field.value();
- if (field.validate && !field.validate()) {
- value = null;
- }
// get and patch field value
if (patch[input.type]) {
@@ -128,7 +125,7 @@
}
// ignore certain values
- if (input.ignore === undefined || (value !== null && input.ignore != value)) {
+ if (input.ignore === undefined || input.ignore != value) {
// add value to submission
add (job_input_id, input.id, value);
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 client/galaxy/scripts/mvc/ui/ui-drilldown.js
--- a/client/galaxy/scripts/mvc/ui/ui-drilldown.js
+++ b/client/galaxy/scripts/mvc/ui/ui-drilldown.js
@@ -12,33 +12,44 @@
Options.BaseIcons.prototype.initialize.call(this, options);
},
+ /** Expand/collapse a sub group
+ */
+ _setState: function (header_id, is_expanded) {
+ var $button = this.$('#button-' + header_id);
+ var $subgroup = this.$('#subgroup-' + header_id);
+ $button.data('is_expanded', is_expanded);
+ if (is_expanded) {
+ $subgroup.fadeIn('fast')
+ $button.removeClass('toggle-expand');
+ $button.addClass('toggle');
+ } else {
+ $subgroup.hide();
+ $button.removeClass('toggle');
+ $button.addClass('toggle-expand');
+ }
+ },
+
/** Template to create options tree
*/
_templateOptions: function(options) {
// link this
var self = this;
- // attach show/hide event
- function attachEvents($button, $subgroup) {
- function setVisibility (visible) {
- if (visible) {
- $subgroup.fadeIn('fast')
- $button.removeClass('toggle-expand');
- $button.addClass('toggle');
- $button.is_expanded = true;
- } else {
- $subgroup.hide();
- $button.removeClass('toggle');
- $button.addClass('toggle-expand');
- $button.is_expanded = false;
- }
- };
+
+ // link data
+ this.header_index = {};
+ this.header_list = [];
+
+ // attach event handler
+ function attach($el, header_id) {
+ var $button = $el.find('#button-' + header_id);
$button.on('click', function() {
- setVisibility(!$button.is_expanded);
+ self._setState(header_id, !$button.data('is_expanded'));
});
}
// recursive function which iterates through options
- function iterate ($tmpl, options) {
+ function iterate ($tmpl, options, header) {
+ header = header || [];
for (i in options) {
// current option level in hierarchy
var level = options[i];
@@ -46,13 +57,21 @@
// check for options
var has_options = level.options.length > 0;
+ // copy current header list
+ var new_header = header.slice(0);
+
// build template
var $group = $('<div/>');
if (has_options) {
- // create button and add flag
- var $button = $('<span class="ui-drilldown-button form-toggle icon-button toggle-expand"/>');
+ // create button and subgroup
+ var header_id = Utils.uuid();
+ var $button = $('<span id="button-' + header_id + '" class="ui-drilldown-button form-toggle icon-button toggle-expand"/>');
+ var $subgroup = $('<div id="subgroup-' + header_id + '" style="display: none; margin-left: 25px;"/>');
- // add expand group
+ // keep track of button and subgroup
+ new_header.push(header_id);
+
+ // create expandable header section
var $buttongroup = $('<div/>');
$buttongroup.append($button);
$buttongroup.append(self._templateOption({
@@ -60,19 +79,17 @@
value: level.value
}));
$group.append($buttongroup);
-
- // add sub group
- var $subgroup = $('<div style="display: none; margin-left: 25px;"/>');
- iterate($subgroup, level.options);
+ iterate($subgroup, level.options, new_header);
$group.append($subgroup);
-
- // attach click event to collapse/expand hierarchy
- attachEvents($button, $subgroup);
} else {
+ // append child options
$group.append(self._templateOption({
label: level.name,
value: level.value
}));
+
+ // keep track of header list
+ self.header_index[level.value] = new_header;
}
$tmpl.append($group);
}
@@ -81,6 +98,18 @@
// iterate through options and create dom
var $tmpl = $('<div/>');
iterate($tmpl, options);
+
+ // merge index to create a non-duplicate list of headers
+ for (var i in this.header_index) {
+ this.header_list = _.uniq(this.header_list.concat(this.header_index[i]));
+ }
+
+ // attach expand/collapse events
+ for (var i in this.header_list) {
+ attach($tmpl, this.header_list[i]);
+ }
+
+ // return template
return $tmpl;
},
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 client/galaxy/scripts/mvc/ui/ui-options.js
--- a/client/galaxy/scripts/mvc/ui/ui-options.js
+++ b/client/galaxy/scripts/mvc/ui/ui-options.js
@@ -101,19 +101,22 @@
/** Return/Set current value
*/
value: function (new_value) {
- // set new value if provided
+ // set new value if available
if (new_value !== undefined) {
- // check if its an array
- if (!(new_value instanceof Array)) {
- new_value = [new_value];
- }
-
// reset selection
this.$('input').prop('checked', false);
+
+ // set value
+ if (new_value !== null) {
+ // check if its an array
+ if (!(new_value instanceof Array)) {
+ new_value = [new_value];
+ }
- // update to new selection
- for (var i in new_value) {
- this.$('input[value="' + new_value[i] + '"]').first().prop('checked', true);
+ // update to new selection
+ for (var i in new_value) {
+ this.$('input[value="' + new_value[i] + '"]').first().prop('checked', true);
+ }
};
}
@@ -147,16 +150,10 @@
if (options.length > 0) {
return options.val();
} else {
- return undefined;
+ return null;
}
},
- /** Validate the selected option/options
- */
- validate: function() {
- return Utils.validate(this.value());
- },
-
/** Wait message during request processing
*/
wait: function() {
@@ -213,21 +210,22 @@
/** Return current selection
*/
_getValue: function() {
- // get selected values
- var selected = this.$(':checked');
- if (selected.length == 0) {
- return '__null__';
+ // track values in array
+ var selected = [];
+ this.$(':checked').each(function() {
+ selected.push($(this).val());
+ });
+
+ // get selected elements
+ if (!Utils.validate(selected)) {
+ return null;
}
-
+
// return multiple or single value
if (this.options.multiple) {
- var values = [];
- selected.each(function() {
- values.push($(this).val());
- });
- return values;
+ return selected;
} else {
- return selected.val();
+ return selected[0];
}
},
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 client/galaxy/scripts/mvc/ui/ui-select-default.js
--- a/client/galaxy/scripts/mvc/ui/ui-select-default.js
+++ b/client/galaxy/scripts/mvc/ui/ui-select-default.js
@@ -75,13 +75,23 @@
/** Return/Set current selection
*/
value : function (new_value) {
+ // set new value
if (new_value !== undefined) {
+ if (new_value === null) {
+ new_value = '__null__';
+ }
this.$select.val(new_value);
if (this.$select.select2) {
this.$select.select2('val', new_value);
}
}
- return this.$select.val();
+
+ // validate and return value
+ var val = this.$select.val();
+ if (!Utils.validate(val)) {
+ return null;
+ }
+ return val;
},
/** Return the first select option
@@ -95,12 +105,6 @@
}
},
- /** Validate the current selection
- */
- validate: function() {
- return Utils.validate(this.value());
- },
-
/** Return the label/text of the current selection
*/
text : function () {
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 client/galaxy/scripts/utils/utils.js
--- a/client/galaxy/scripts/utils/utils.js
+++ b/client/galaxy/scripts/utils/utils.js
@@ -35,6 +35,9 @@
if (!(value instanceof Array)) {
value = [value];
}
+ if (value.length === 0) {
+ return false;
+ }
for (var i in value) {
if (['__null__', '__undefined__', 'None', null, undefined].indexOf(value[i]) > -1) {
return false;
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/mvc/tools/tools-input.js
--- a/static/scripts/mvc/tools/tools-input.js
+++ b/static/scripts/mvc/tools/tools-input.js
@@ -34,9 +34,9 @@
this.field.skip = false;
var v = this.field.value && this.field.value();
this.field.skip = Boolean(options.optional &&
- (((this.field.validate && !this.field.validate()) || !v ||
- (v == this.default_value) || (Number(v) == Number(this.default_value)) ||
- (JSON.stringify(v) == JSON.stringify(this.default_value)))));
+ ((v === null || (v == this.default_value) ||
+ (Number(v) == Number(this.default_value)) ||
+ (JSON.stringify(v) == JSON.stringify(this.default_value)))));
// refresh view
this._refresh();
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/mvc/tools/tools-select-content.js
--- a/static/scripts/mvc/tools/tools-select-content.js
+++ b/static/scripts/mvc/tools/tools-select-content.js
@@ -233,18 +233,28 @@
console.debug('tools-select-content::value() - Skipped.');
}
} else {
- this.select_single && this.select_single.value('__null__');
- this.select_multiple && this.select_multiple.value('__null__');
- this.select_collection && this.select_collection.value('__null__');
+ this.select_single && this.select_single.value(null);
+ this.select_multiple && this.select_multiple.value(null);
+ this.select_collection && this.select_collection.value(null);
}
this.refresh();
}
+ // validate value
+ var id_list = this._select().value();
+ if (id_list === null) {
+ return null;
+ }
+
// transform into an array
- var id_list = this._select().value();
if (!(id_list instanceof Array)) {
id_list = [id_list];
}
+
+ // check if value exists
+ if (id_list.length === 0) {
+ return null;
+ }
// prepare result dict
var result = {
@@ -264,12 +274,6 @@
return result;
},
- /** Validate current selection
- */
- validate: function() {
- return this._select().validate();
- },
-
/** Refreshes data selection view */
refresh: function() {
this.button_type.value(this.current);
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/mvc/tools/tools-tree.js
--- a/static/scripts/mvc/tools/tools-tree.js
+++ b/static/scripts/mvc/tools/tools-tree.js
@@ -118,9 +118,6 @@
if (field && field.value) {
// validate field value
var value = field.value();
- if (field.validate && !field.validate()) {
- value = null;
- }
// get and patch field value
if (patch[input.type]) {
@@ -128,7 +125,7 @@
}
// ignore certain values
- if (input.ignore === undefined || (value !== null && input.ignore != value)) {
+ if (input.ignore === undefined || input.ignore != value) {
// add value to submission
add (job_input_id, input.id, value);
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/mvc/ui/ui-drilldown.js
--- a/static/scripts/mvc/ui/ui-drilldown.js
+++ b/static/scripts/mvc/ui/ui-drilldown.js
@@ -12,33 +12,44 @@
Options.BaseIcons.prototype.initialize.call(this, options);
},
+ /** Expand/collapse a sub group
+ */
+ _setState: function (header_id, is_expanded) {
+ var $button = this.$('#button-' + header_id);
+ var $subgroup = this.$('#subgroup-' + header_id);
+ $button.data('is_expanded', is_expanded);
+ if (is_expanded) {
+ $subgroup.fadeIn('fast')
+ $button.removeClass('toggle-expand');
+ $button.addClass('toggle');
+ } else {
+ $subgroup.hide();
+ $button.removeClass('toggle');
+ $button.addClass('toggle-expand');
+ }
+ },
+
/** Template to create options tree
*/
_templateOptions: function(options) {
// link this
var self = this;
- // attach show/hide event
- function attachEvents($button, $subgroup) {
- function setVisibility (visible) {
- if (visible) {
- $subgroup.fadeIn('fast')
- $button.removeClass('toggle-expand');
- $button.addClass('toggle');
- $button.is_expanded = true;
- } else {
- $subgroup.hide();
- $button.removeClass('toggle');
- $button.addClass('toggle-expand');
- $button.is_expanded = false;
- }
- };
+
+ // link data
+ this.header_index = {};
+ this.header_list = [];
+
+ // attach event handler
+ function attach($el, header_id) {
+ var $button = $el.find('#button-' + header_id);
$button.on('click', function() {
- setVisibility(!$button.is_expanded);
+ self._setState(header_id, !$button.data('is_expanded'));
});
}
// recursive function which iterates through options
- function iterate ($tmpl, options) {
+ function iterate ($tmpl, options, header) {
+ header = header || [];
for (i in options) {
// current option level in hierarchy
var level = options[i];
@@ -46,13 +57,21 @@
// check for options
var has_options = level.options.length > 0;
+ // copy current header list
+ var new_header = header.slice(0);
+
// build template
var $group = $('<div/>');
if (has_options) {
- // create button and add flag
- var $button = $('<span class="ui-drilldown-button form-toggle icon-button toggle-expand"/>');
+ // create button and subgroup
+ var header_id = Utils.uuid();
+ var $button = $('<span id="button-' + header_id + '" class="ui-drilldown-button form-toggle icon-button toggle-expand"/>');
+ var $subgroup = $('<div id="subgroup-' + header_id + '" style="display: none; margin-left: 25px;"/>');
- // add expand group
+ // keep track of button and subgroup
+ new_header.push(header_id);
+
+ // create expandable header section
var $buttongroup = $('<div/>');
$buttongroup.append($button);
$buttongroup.append(self._templateOption({
@@ -60,19 +79,17 @@
value: level.value
}));
$group.append($buttongroup);
-
- // add sub group
- var $subgroup = $('<div style="display: none; margin-left: 25px;"/>');
- iterate($subgroup, level.options);
+ iterate($subgroup, level.options, new_header);
$group.append($subgroup);
-
- // attach click event to collapse/expand hierarchy
- attachEvents($button, $subgroup);
} else {
+ // append child options
$group.append(self._templateOption({
label: level.name,
value: level.value
}));
+
+ // keep track of header list
+ self.header_index[level.value] = new_header;
}
$tmpl.append($group);
}
@@ -81,6 +98,18 @@
// iterate through options and create dom
var $tmpl = $('<div/>');
iterate($tmpl, options);
+
+ // merge index to create a non-duplicate list of headers
+ for (var i in this.header_index) {
+ this.header_list = _.uniq(this.header_list.concat(this.header_index[i]));
+ }
+
+ // attach expand/collapse events
+ for (var i in this.header_list) {
+ attach($tmpl, this.header_list[i]);
+ }
+
+ // return template
return $tmpl;
},
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/mvc/ui/ui-options.js
--- a/static/scripts/mvc/ui/ui-options.js
+++ b/static/scripts/mvc/ui/ui-options.js
@@ -101,19 +101,22 @@
/** Return/Set current value
*/
value: function (new_value) {
- // set new value if provided
+ // set new value if available
if (new_value !== undefined) {
- // check if its an array
- if (!(new_value instanceof Array)) {
- new_value = [new_value];
- }
-
// reset selection
this.$('input').prop('checked', false);
+
+ // set value
+ if (new_value !== null) {
+ // check if its an array
+ if (!(new_value instanceof Array)) {
+ new_value = [new_value];
+ }
- // update to new selection
- for (var i in new_value) {
- this.$('input[value="' + new_value[i] + '"]').first().prop('checked', true);
+ // update to new selection
+ for (var i in new_value) {
+ this.$('input[value="' + new_value[i] + '"]').first().prop('checked', true);
+ }
};
}
@@ -147,16 +150,10 @@
if (options.length > 0) {
return options.val();
} else {
- return undefined;
+ return null;
}
},
- /** Validate the selected option/options
- */
- validate: function() {
- return Utils.validate(this.value());
- },
-
/** Wait message during request processing
*/
wait: function() {
@@ -213,21 +210,22 @@
/** Return current selection
*/
_getValue: function() {
- // get selected values
- var selected = this.$(':checked');
- if (selected.length == 0) {
- return '__null__';
+ // track values in array
+ var selected = [];
+ this.$(':checked').each(function() {
+ selected.push($(this).val());
+ });
+
+ // get selected elements
+ if (!Utils.validate(selected)) {
+ return null;
}
-
+
// return multiple or single value
if (this.options.multiple) {
- var values = [];
- selected.each(function() {
- values.push($(this).val());
- });
- return values;
+ return selected;
} else {
- return selected.val();
+ return selected[0];
}
},
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/mvc/ui/ui-select-default.js
--- a/static/scripts/mvc/ui/ui-select-default.js
+++ b/static/scripts/mvc/ui/ui-select-default.js
@@ -75,13 +75,23 @@
/** Return/Set current selection
*/
value : function (new_value) {
+ // set new value
if (new_value !== undefined) {
+ if (new_value === null) {
+ new_value = '__null__';
+ }
this.$select.val(new_value);
if (this.$select.select2) {
this.$select.select2('val', new_value);
}
}
- return this.$select.val();
+
+ // validate and return value
+ var val = this.$select.val();
+ if (!Utils.validate(val)) {
+ return null;
+ }
+ return val;
},
/** Return the first select option
@@ -95,12 +105,6 @@
}
},
- /** Validate the current selection
- */
- validate: function() {
- return Utils.validate(this.value());
- },
-
/** Return the label/text of the current selection
*/
text : function () {
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/packed/mvc/tools/tools-input.js
--- a/static/scripts/packed/mvc/tools/tools-input.js
+++ b/static/scripts/packed/mvc/tools/tools-input.js
@@ -1,1 +1,1 @@
-define([],function(){return Backbone.View.extend({initialize:function(d,c){this.app=d;this.text_enable=d.options.text_enable||"Enable";this.text_disable=d.options.text_disable||"Disable";this.field=c.field;this.default_value=c.default_value;this.setElement(this._template(c));this.$field=this.$el.find(".ui-table-form-field");this.$title_optional=this.$el.find(".ui-table-form-title-optional");this.$error_text=this.$el.find(".ui-table-form-error-text");this.$error=this.$el.find(".ui-table-form-error");this.$field.prepend(this.field.$el);this.field.skip=false;var b=this.field.value&&this.field.value();this.field.skip=Boolean(c.optional&&(((this.field.validate&&!this.field.validate())||!b||(b==this.default_value)||(Number(b)==Number(this.default_value))||(JSON.stringify(b)==JSON.stringify(this.default_value)))));this._refresh();var a=this;this.$title_optional.on("click",function(){a.field.skip=!a.field.skip;a._refresh();a.app.trigger("refresh")})},error:function(a){this.$error_text.html(a);this.$error.show();this.$el.addClass("ui-error")},reset:function(){this.$error.hide();this.$el.removeClass("ui-error")},_refresh:function(){if(!this.field.skip){this.$field.fadeIn("fast");this.$title_optional.html(this.text_disable)}else{this.reset();this.$field.hide();this.$title_optional.html(this.text_enable);this.field.value&&this.field.value(this.default_value)}},_template:function(a){var b='<div class="ui-table-form-element"><div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/></div><div class="ui-table-form-title-strong">';if(a.optional){b+=a.label+'<span> [<span class="ui-table-form-title-optional"/>]</span>'}else{b+=a.label}b+='</div><div class="ui-table-form-field">';if(a.help){b+='<div class="ui-table-form-info">'+a.help+"</div>"}b+="</div></div>";return b}})});
\ No newline at end of file
+define([],function(){return Backbone.View.extend({initialize:function(d,c){this.app=d;this.text_enable=d.options.text_enable||"Enable";this.text_disable=d.options.text_disable||"Disable";this.field=c.field;this.default_value=c.default_value;this.setElement(this._template(c));this.$field=this.$el.find(".ui-table-form-field");this.$title_optional=this.$el.find(".ui-table-form-title-optional");this.$error_text=this.$el.find(".ui-table-form-error-text");this.$error=this.$el.find(".ui-table-form-error");this.$field.prepend(this.field.$el);this.field.skip=false;var b=this.field.value&&this.field.value();this.field.skip=Boolean(c.optional&&((b===null||(b==this.default_value)||(Number(b)==Number(this.default_value))||(JSON.stringify(b)==JSON.stringify(this.default_value)))));this._refresh();var a=this;this.$title_optional.on("click",function(){a.field.skip=!a.field.skip;a._refresh();a.app.trigger("refresh")})},error:function(a){this.$error_text.html(a);this.$error.show();this.$el.addClass("ui-error")},reset:function(){this.$error.hide();this.$el.removeClass("ui-error")},_refresh:function(){if(!this.field.skip){this.$field.fadeIn("fast");this.$title_optional.html(this.text_disable)}else{this.reset();this.$field.hide();this.$title_optional.html(this.text_enable);this.field.value&&this.field.value(this.default_value)}},_template:function(a){var b='<div class="ui-table-form-element"><div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/></div><div class="ui-table-form-title-strong">';if(a.optional){b+=a.label+'<span> [<span class="ui-table-form-title-optional"/>]</span>'}else{b+=a.label}b+='</div><div class="ui-table-form-field">';if(a.help){b+='<div class="ui-table-form-info">'+a.help+"</div>"}b+="</div></div>";return b}})});
\ No newline at end of file
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/packed/mvc/tools/tools-select-content.js
--- a/static/scripts/packed/mvc/tools/tools-select-content.js
+++ b/static/scripts/packed/mvc/tools/tools-select-content.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(g,p){this.app=g;this.options=p;var o=this;this.setElement('<div class="ui-select-content"/>');this.list={};var m=[];if(p.type=="data_collection"){this.mode="collection"}else{if(p.multiple){this.mode="multiple"}else{this.mode="single"}}this.current=this.mode;this.list={};var k=c.textify(p.extensions);var j="No dataset available.";if(k){j="No "+k+" dataset available."}var l="No dataset list available.";if(k){l="No "+k+" dataset collection available."}if(this.mode=="single"){m.push({icon:"fa-file-o",value:"single",tooltip:"Single dataset"});this.select_single=new e.Select.View({optional:p.optional,error_text:j,onchange:function(){o.trigger("change")}});this.list.single={field:this.select_single,type:"hda"}}if(this.mode=="single"||this.mode=="multiple"){m.push({icon:"fa-files-o",value:"multiple",tooltip:"Multiple datasets"});this.select_multiple=new e.Select.View({multiple:true,error_text:j,onchange:function(){o.trigger("change")}});this.list.multiple={field:this.select_multiple,type:"hda"}}if(this.mode=="single"||this.mode=="collection"){m.push({icon:"fa-folder-o",value:"collection",tooltip:"Dataset collection"});this.select_collection=new e.Select.View({error_text:l,optional:p.optional,onchange:function(){o.trigger("change")}});this.list.collection={field:this.select_collection,type:"hdca"}}this.button_type=new e.RadioButton.View({value:this.current,data:m,onchange:function(i){o.current=i;o.refresh();o.trigger("change")}});this.$batch=$(a.batchMode());var f=_.size(this.list);var n=0;if(f>1){this.$el.append(this.button_type.$el);n=Math.max(0,_.size(this.list)*35)+"px"}for(var h in this.list){this.$el.append(this.list[h].field.$el.css({"margin-left":n}))}this.$el.append(this.$batch.css({"margin-left":n}));this.update(p.data);if(this.options.value!==undefined){this.value(this.options.value)}this.refresh();this.on("change",function(){if(p.onchange){p.onchange(o.value())}})},wait:function(){for(var f in this.list){this.list[f].field.wait()}},unwait:function(){for(var f in this.list){this.list[f].field.unwait()}},update:function(g){var l=[];for(var j in g.hda){var k=g.hda[j];l.push({label:k.hid+": "+k.name,value:k.id})}var f=[];for(var j in g.hdca){var h=g.hdca[j];f.push({label:h.hid+": "+h.name,value:h.id})}this.select_single&&this.select_single.update(l);this.select_multiple&&this.select_multiple.update(l);this.select_collection&&this.select_collection.update(f);this.app.content.add(g)},value:function(h){if(h!==undefined){if(h&&h.values){try{var l=[];for(var g in h.values){l.push(h.values[g].id)}if(h&&h.values.length>0&&h.values[0].src=="hcda"){this.current="collection";this.select_collection.value(l[0])}else{if(this.mode=="multiple"){this.current="multiple";this.select_multiple.value(l)}else{this.current="single";this.select_single.value(l[0])}}}catch(k){console.debug("tools-select-content::value() - Skipped.")}}else{this.select_single&&this.select_single.value("__null__");this.select_multiple&&this.select_multiple.value("__null__");this.select_collection&&this.select_collection.value("__null__")}this.refresh()}var j=this._select().value();if(!(j instanceof Array)){j=[j]}var f={batch:this.mode=="single"&&this.current!="single",values:[]};for(var g in j){f.values.push({id:j[g],src:this.list[this.current].type})}return f},validate:function(){return this._select().validate()},refresh:function(){this.button_type.value(this.current);for(var g in this.list){var f=this.list[g].field.$el;if(this.current==g){f.show()}else{f.hide()}}if(this.mode=="single"&&this.current!="single"){this.$batch.show()}else{this.$batch.hide()}},_select:function(){return this.list[this.current].field}});return{View:d}});
\ No newline at end of file
+define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(g,p){this.app=g;this.options=p;var o=this;this.setElement('<div class="ui-select-content"/>');this.list={};var m=[];if(p.type=="data_collection"){this.mode="collection"}else{if(p.multiple){this.mode="multiple"}else{this.mode="single"}}this.current=this.mode;this.list={};var k=c.textify(p.extensions);var j="No dataset available.";if(k){j="No "+k+" dataset available."}var l="No dataset list available.";if(k){l="No "+k+" dataset collection available."}if(this.mode=="single"){m.push({icon:"fa-file-o",value:"single",tooltip:"Single dataset"});this.select_single=new e.Select.View({optional:p.optional,error_text:j,onchange:function(){o.trigger("change")}});this.list.single={field:this.select_single,type:"hda"}}if(this.mode=="single"||this.mode=="multiple"){m.push({icon:"fa-files-o",value:"multiple",tooltip:"Multiple datasets"});this.select_multiple=new e.Select.View({multiple:true,error_text:j,onchange:function(){o.trigger("change")}});this.list.multiple={field:this.select_multiple,type:"hda"}}if(this.mode=="single"||this.mode=="collection"){m.push({icon:"fa-folder-o",value:"collection",tooltip:"Dataset collection"});this.select_collection=new e.Select.View({error_text:l,optional:p.optional,onchange:function(){o.trigger("change")}});this.list.collection={field:this.select_collection,type:"hdca"}}this.button_type=new e.RadioButton.View({value:this.current,data:m,onchange:function(i){o.current=i;o.refresh();o.trigger("change")}});this.$batch=$(a.batchMode());var f=_.size(this.list);var n=0;if(f>1){this.$el.append(this.button_type.$el);n=Math.max(0,_.size(this.list)*35)+"px"}for(var h in this.list){this.$el.append(this.list[h].field.$el.css({"margin-left":n}))}this.$el.append(this.$batch.css({"margin-left":n}));this.update(p.data);if(this.options.value!==undefined){this.value(this.options.value)}this.refresh();this.on("change",function(){if(p.onchange){p.onchange(o.value())}})},wait:function(){for(var f in this.list){this.list[f].field.wait()}},unwait:function(){for(var f in this.list){this.list[f].field.unwait()}},update:function(g){var l=[];for(var j in g.hda){var k=g.hda[j];l.push({label:k.hid+": "+k.name,value:k.id})}var f=[];for(var j in g.hdca){var h=g.hdca[j];f.push({label:h.hid+": "+h.name,value:h.id})}this.select_single&&this.select_single.update(l);this.select_multiple&&this.select_multiple.update(l);this.select_collection&&this.select_collection.update(f);this.app.content.add(g)},value:function(h){if(h!==undefined){if(h&&h.values){try{var l=[];for(var g in h.values){l.push(h.values[g].id)}if(h&&h.values.length>0&&h.values[0].src=="hcda"){this.current="collection";this.select_collection.value(l[0])}else{if(this.mode=="multiple"){this.current="multiple";this.select_multiple.value(l)}else{this.current="single";this.select_single.value(l[0])}}}catch(k){console.debug("tools-select-content::value() - Skipped.")}}else{this.select_single&&this.select_single.value(null);this.select_multiple&&this.select_multiple.value(null);this.select_collection&&this.select_collection.value(null)}this.refresh()}var j=this._select().value();if(j===null){return null}if(!(j instanceof Array)){j=[j]}if(j.length===0){return null}var f={batch:this.mode=="single"&&this.current!="single",values:[]};for(var g in j){f.values.push({id:j[g],src:this.list[this.current].type})}return f},refresh:function(){this.button_type.value(this.current);for(var g in this.list){var f=this.list[g].field.$el;if(this.current==g){f.show()}else{f.hide()}}if(this.mode=="single"&&this.current!="single"){this.$batch.show()}else{this.$batch.hide()}},_select:function(){return this.list[this.current].field}});return{View:d}});
\ No newline at end of file
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/packed/mvc/tools/tools-tree.js
--- a/static/scripts/packed/mvc/tools/tools-tree.js
+++ b/static/scripts/packed/mvc/tools/tools-tree.js
@@ -1,1 +1,1 @@
-define(["utils/utils"],function(a){return Backbone.Model.extend({initialize:function(b){this.app=b},finalize:function(g){var b=this;this.map_dict={};if(!this.app.section){return{}}g=g||{};var f={};var e={};this._iterate(this.app.section.$el,e);function d(j,i,h){f[j]=h;b.map_dict[j]=i}function c(p,s){for(var n in s){var k=s[n];if(k.input){var u=k.input;var o=p;if(p!=""){o+="|"}o+=u.name;switch(u.type){case"repeat":var j="section-";var x=[];var r=null;for(var w in k){var q=w.indexOf(j);if(q!=-1){q+=j.length;x.push(parseInt(w.substr(q)));if(!r){r=w.substr(0,q)}}}x.sort(function(y,i){return y-i});var n=0;for(var l in x){c(o+"_"+n++,k[r+x[l]])}break;case"conditional":var v=b.app.field_list[u.id].value();if(g[u.test_param.type]){v=g[u.test_param.type](v)}d(o+"|"+u.test_param.name,u.id,v);var h=b.matchCase(u,v);if(h!=-1){c(o,s[u.id+"-section-"+h])}break;case"section":c("",k);break;default:var t=b.app.field_list[u.id];if(t&&t.value){var v=t.value();if(t.validate&&!t.validate()){v=null}if(g[u.type]){v=g[u.type](v)}if(u.ignore===undefined||(v!==null&&u.ignore!=v)){d(o,u.id,v);if(u.payload){for(var m in u.payload){d(m,u.id,u.payload[m])}}}}}}}}c("",e);return f},match:function(b){return this.map_dict&&this.map_dict[b]},matchCase:function(b,d){if(b.test_param.type=="boolean"){if(d=="true"){d=b.test_param.truevalue||"true"}else{d=b.test_param.falsevalue||"false"}}for(var c in b.cases){if(b.cases[c].value==d){return c}}return -1},matchModel:function(d,f){var b={};var c=this;function e(g,p){for(var m in p){var k=p[m];var n=k.name;if(g!=""){n=g+"|"+n}switch(k.type){case"repeat":for(var l in k.cache){e(n+"_"+l,k.cache[l])}break;case"conditional":var q=k.test_param&&k.test_param.value;var h=c.matchCase(k,q);if(h!=-1){e(n,k.cases[h].inputs)}break;default:var o=c.map_dict[n];if(o){f(o,k)}}}}e("",d.inputs);return b},matchResponse:function(d){var b={};var c=this;function e(l,j){if(typeof j==="string"){var g=c.map_dict[l];if(g){b[g]=j}}else{for(var h in j){var f=h;if(l!==""){var k="|";if(j instanceof Array){k="_"}f=l+k+f}e(f,j[h])}}}e("",d);return b},_iterate:function(d,e){var b=this;var c=$(d).children();c.each(function(){var h=this;var g=$(h).attr("id");if($(h).hasClass("section-row")){e[g]={};var f=b.app.input_list[g];if(f){e[g]={input:f}}b._iterate(h,e[g])}else{b._iterate(h,e)}})}})});
\ No newline at end of file
+define(["utils/utils"],function(a){return Backbone.Model.extend({initialize:function(b){this.app=b},finalize:function(g){var b=this;this.map_dict={};if(!this.app.section){return{}}g=g||{};var f={};var e={};this._iterate(this.app.section.$el,e);function d(j,i,h){f[j]=h;b.map_dict[j]=i}function c(p,s){for(var n in s){var k=s[n];if(k.input){var u=k.input;var o=p;if(p!=""){o+="|"}o+=u.name;switch(u.type){case"repeat":var j="section-";var x=[];var r=null;for(var w in k){var q=w.indexOf(j);if(q!=-1){q+=j.length;x.push(parseInt(w.substr(q)));if(!r){r=w.substr(0,q)}}}x.sort(function(y,i){return y-i});var n=0;for(var l in x){c(o+"_"+n++,k[r+x[l]])}break;case"conditional":var v=b.app.field_list[u.id].value();if(g[u.test_param.type]){v=g[u.test_param.type](v)}d(o+"|"+u.test_param.name,u.id,v);var h=b.matchCase(u,v);if(h!=-1){c(o,s[u.id+"-section-"+h])}break;case"section":c("",k);break;default:var t=b.app.field_list[u.id];if(t&&t.value){var v=t.value();if(g[u.type]){v=g[u.type](v)}if(u.ignore===undefined||u.ignore!=v){d(o,u.id,v);if(u.payload){for(var m in u.payload){d(m,u.id,u.payload[m])}}}}}}}}c("",e);return f},match:function(b){return this.map_dict&&this.map_dict[b]},matchCase:function(b,d){if(b.test_param.type=="boolean"){if(d=="true"){d=b.test_param.truevalue||"true"}else{d=b.test_param.falsevalue||"false"}}for(var c in b.cases){if(b.cases[c].value==d){return c}}return -1},matchModel:function(d,f){var b={};var c=this;function e(g,p){for(var m in p){var k=p[m];var n=k.name;if(g!=""){n=g+"|"+n}switch(k.type){case"repeat":for(var l in k.cache){e(n+"_"+l,k.cache[l])}break;case"conditional":var q=k.test_param&&k.test_param.value;var h=c.matchCase(k,q);if(h!=-1){e(n,k.cases[h].inputs)}break;default:var o=c.map_dict[n];if(o){f(o,k)}}}}e("",d.inputs);return b},matchResponse:function(d){var b={};var c=this;function e(l,j){if(typeof j==="string"){var g=c.map_dict[l];if(g){b[g]=j}}else{for(var h in j){var f=h;if(l!==""){var k="|";if(j instanceof Array){k="_"}f=l+k+f}e(f,j[h])}}}e("",d);return b},_iterate:function(d,e){var b=this;var c=$(d).children();c.each(function(){var h=this;var g=$(h).attr("id");if($(h).hasClass("section-row")){e[g]={};var f=b.app.input_list[g];if(f){e[g]={input:f}}b._iterate(h,e[g])}else{b._iterate(h,e)}})}})});
\ No newline at end of file
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/packed/mvc/ui/ui-drilldown.js
--- a/static/scripts/packed/mvc/ui/ui-drilldown.js
+++ b/static/scripts/packed/mvc/ui/ui-drilldown.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/ui/ui-options"],function(b,a){var c=a.BaseIcons.extend({initialize:function(d){d.type=d.display||"checkbox";d.multiple=(d.display=="checkbox");a.BaseIcons.prototype.initialize.call(this,d)},_templateOptions:function(f){var e=this;function g(k,l){function j(m){if(m){l.fadeIn("fast");k.removeClass("toggle-expand");k.addClass("toggle");k.is_expanded=true}else{l.hide();k.removeClass("toggle");k.addClass("toggle-expand");k.is_expanded=false}}k.on("click",function(){j(!k.is_expanded)})}function d(p,k){for(i in k){var q=k[i];var m=q.options.length>0;var l=$("<div/>");if(m){var n=$('<span class="ui-drilldown-button form-toggle icon-button toggle-expand"/>');var j=$("<div/>");j.append(n);j.append(e._templateOption({label:q.name,value:q.value}));l.append(j);var o=$('<div style="display: none; margin-left: 25px;"/>');d(o,q.options);l.append(o);g(n,o)}else{l.append(e._templateOption({label:q.name,value:q.value}))}p.append(l)}}var h=$("<div/>");d(h,f);return h},_template:function(d){return'<div class="ui-options-list drilldown-container" id="'+d.id+'"/>'}});return{View:c}});
\ No newline at end of file
+define(["utils/utils","mvc/ui/ui-options"],function(b,a){var c=a.BaseIcons.extend({initialize:function(d){d.type=d.display||"checkbox";d.multiple=(d.display=="checkbox");a.BaseIcons.prototype.initialize.call(this,d)},_setState:function(d,e){var f=this.$("#button-"+d);var g=this.$("#subgroup-"+d);f.data("is_expanded",e);if(e){g.fadeIn("fast");f.removeClass("toggle-expand");f.addClass("toggle")}else{g.hide();f.removeClass("toggle");f.addClass("toggle-expand")}},_templateOptions:function(g){var f=this;this.header_index={};this.header_list=[];function e(k,i){var l=k.find("#button-"+i);l.on("click",function(){f._setState(i,!l.data("is_expanded"))})}function d(r,t,o){o=o||[];for(h in t){var k=t[h];var l=k.options.length>0;var q=o.slice(0);var s=$("<div/>");if(l){var n=b.uuid();var i=$('<span id="button-'+n+'" class="ui-drilldown-button form-toggle icon-button toggle-expand"/>');var m=$('<div id="subgroup-'+n+'" style="display: none; margin-left: 25px;"/>');q.push(n);var p=$("<div/>");p.append(i);p.append(f._templateOption({label:k.name,value:k.value}));s.append(p);d(m,k.options,q);s.append(m)}else{s.append(f._templateOption({label:k.name,value:k.value}));f.header_index[k.value]=q}r.append(s)}}var j=$("<div/>");d(j,g);for(var h in this.header_index){this.header_list=_.uniq(this.header_list.concat(this.header_index[h]))}for(var h in this.header_list){e(j,this.header_list[h])}return j},_template:function(d){return'<div class="ui-options-list drilldown-container" id="'+d.id+'"/>'}});return{View:c}});
\ No newline at end of file
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/packed/mvc/ui/ui-options.js
--- a/static/scripts/packed/mvc/ui/ui-options.js
+++ b/static/scripts/packed/mvc/ui/ui-options.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/ui/ui-button-check"],function(c,e){var b=Backbone.View.extend({initialize:function(i){this.optionsDefault={visible:true,data:[],id:c.uuid(),error_text:"No data available.",wait_text:"Please wait...",multiple:false};this.options=c.merge(i,this.optionsDefault);this.setElement('<div class="ui-options"/>');this.$message=$("<div/>");this.$options=$(this._template(i));this.$menu=$('<div class="ui-options-menu"/>');this.$el.append(this.$message);this.$el.append(this.$menu);this.$el.append(this.$options);if(this.options.multiple){this.select_button=new e({onclick:function(){h.$("input").prop("checked",h.select_button.value()!==0);h._change()}});this.$menu.addClass("ui-margin-bottom");this.$menu.append(this.select_button.$el);this.$menu.append("Select/Unselect all")}if(!this.options.visible){this.$el.hide()}this.update(this.options.data);if(this.options.value!==undefined){this.value(this.options.value)}var h=this;this.on("change",function(){h._change()})},update:function(i){var l=this._getValue();this.$options.empty();if(this._templateOptions){this.$options.append(this._templateOptions(i))}else{for(var j in i){var k=$(this._templateOption(i[j]));k.addClass("ui-option");k.tooltip({title:i[j].tooltip,placement:"bottom"});this.$options.append(k)}}var h=this;this.$("input").on("change",function(){h.value(h._getValue());h._change()});this.value(l)},value:function(j){if(j!==undefined){if(!(j instanceof Array)){j=[j]}this.$("input").prop("checked",false);for(var h in j){this.$('input[value="'+j[h]+'"]').first().prop("checked",true)}}this._refresh();return this._getValue()},exists:function(j){if(j!==undefined){if(!(j instanceof Array)){j=[j]}for(var h in j){if(this.$('input[value="'+j[h]+'"]').length>0){return true}}}return false},first:function(){var h=this.$("input");if(h.length>0){return h.val()}else{return undefined}},validate:function(){return c.validate(this.value())},wait:function(){if(this._size()==0){this._messageShow(this.options.wait_text,"info");this.$options.hide();this.$menu.hide()}},unwait:function(){this._refresh()},_change:function(){if(this.options.onchange){this.options.onchange(this._getValue())}},_refresh:function(){if(this._size()==0){this._messageShow(this.options.error_text,"danger");this.$options.hide();this.$menu.hide()}else{this._messageHide();this.$options.css("display","inline-block");this.$menu.show()}if(this.select_button){var h=this._size();var i=this._getValue();if(!(i instanceof Array)){this.select_button.value(0)}else{if(i.length!==h){this.select_button.value(1)}else{this.select_button.value(2)}}}},_getValue:function(){var i=this.$(":checked");if(i.length==0){return"__null__"}if(this.options.multiple){var h=[];i.each(function(){h.push($(this).val())});return h}else{return i.val()}},_size:function(){return this.$(".ui-option").length},_messageShow:function(i,h){this.$message.show();this.$message.removeClass();this.$message.addClass("ui-message alert alert-"+h);this.$message.html(i)},_messageHide:function(){this.$message.hide()},_template:function(){return'<div class="ui-options-list"/>'}});var a=b.extend({_templateOption:function(h){var i=c.uuid();return'<div class="ui-option"><input id="'+i+'" type="'+this.options.type+'" name="'+this.options.id+'" value="'+h.value+'"/><label class="ui-options-label" for="'+i+'">'+h.label+"</label></div>"}});var f={};f.View=a.extend({initialize:function(h){h.type="radio";a.prototype.initialize.call(this,h)}});var d={};d.View=a.extend({initialize:function(h){h.multiple=true;h.type="checkbox";a.prototype.initialize.call(this,h)}});var g={};g.View=b.extend({initialize:function(h){b.prototype.initialize.call(this,h)},value:function(h){if(h!==undefined){this.$("input").prop("checked",false);this.$("label").removeClass("active");this.$('[value="'+h+'"]').prop("checked",true).closest("label").addClass("active")}return this._getValue()},_templateOption:function(j){var h="fa "+j.icon;if(!j.label){h+=" no-padding"}var i='<label class="btn btn-default">';if(j.icon){i+='<i class="'+h+'"/>'}i+='<input type="radio" name="'+this.options.id+'" value="'+j.value+'"/>';if(j.label){i+=j.label}i+="</label>";return i},_template:function(){return'<div class="btn-group ui-radiobutton" data-toggle="buttons"/>'}});return{Base:b,BaseIcons:a,Radio:f,RadioButton:g,Checkbox:d}});
\ No newline at end of file
+define(["utils/utils","mvc/ui/ui-button-check"],function(c,e){var b=Backbone.View.extend({initialize:function(i){this.optionsDefault={visible:true,data:[],id:c.uuid(),error_text:"No data available.",wait_text:"Please wait...",multiple:false};this.options=c.merge(i,this.optionsDefault);this.setElement('<div class="ui-options"/>');this.$message=$("<div/>");this.$options=$(this._template(i));this.$menu=$('<div class="ui-options-menu"/>');this.$el.append(this.$message);this.$el.append(this.$menu);this.$el.append(this.$options);if(this.options.multiple){this.select_button=new e({onclick:function(){h.$("input").prop("checked",h.select_button.value()!==0);h._change()}});this.$menu.addClass("ui-margin-bottom");this.$menu.append(this.select_button.$el);this.$menu.append("Select/Unselect all")}if(!this.options.visible){this.$el.hide()}this.update(this.options.data);if(this.options.value!==undefined){this.value(this.options.value)}var h=this;this.on("change",function(){h._change()})},update:function(i){var l=this._getValue();this.$options.empty();if(this._templateOptions){this.$options.append(this._templateOptions(i))}else{for(var j in i){var k=$(this._templateOption(i[j]));k.addClass("ui-option");k.tooltip({title:i[j].tooltip,placement:"bottom"});this.$options.append(k)}}var h=this;this.$("input").on("change",function(){h.value(h._getValue());h._change()});this.value(l)},value:function(j){if(j!==undefined){this.$("input").prop("checked",false);if(j!==null){if(!(j instanceof Array)){j=[j]}for(var h in j){this.$('input[value="'+j[h]+'"]').first().prop("checked",true)}}}this._refresh();return this._getValue()},exists:function(j){if(j!==undefined){if(!(j instanceof Array)){j=[j]}for(var h in j){if(this.$('input[value="'+j[h]+'"]').length>0){return true}}}return false},first:function(){var h=this.$("input");if(h.length>0){return h.val()}else{return null}},wait:function(){if(this._size()==0){this._messageShow(this.options.wait_text,"info");this.$options.hide();this.$menu.hide()}},unwait:function(){this._refresh()},_change:function(){if(this.options.onchange){this.options.onchange(this._getValue())}},_refresh:function(){if(this._size()==0){this._messageShow(this.options.error_text,"danger");this.$options.hide();this.$menu.hide()}else{this._messageHide();this.$options.css("display","inline-block");this.$menu.show()}if(this.select_button){var h=this._size();var i=this._getValue();if(!(i instanceof Array)){this.select_button.value(0)}else{if(i.length!==h){this.select_button.value(1)}else{this.select_button.value(2)}}}},_getValue:function(){var h=[];this.$(":checked").each(function(){h.push($(this).val())});if(!c.validate(h)){return null}if(this.options.multiple){return h}else{return h[0]}},_size:function(){return this.$(".ui-option").length},_messageShow:function(i,h){this.$message.show();this.$message.removeClass();this.$message.addClass("ui-message alert alert-"+h);this.$message.html(i)},_messageHide:function(){this.$message.hide()},_template:function(){return'<div class="ui-options-list"/>'}});var a=b.extend({_templateOption:function(h){var i=c.uuid();return'<div class="ui-option"><input id="'+i+'" type="'+this.options.type+'" name="'+this.options.id+'" value="'+h.value+'"/><label class="ui-options-label" for="'+i+'">'+h.label+"</label></div>"}});var f={};f.View=a.extend({initialize:function(h){h.type="radio";a.prototype.initialize.call(this,h)}});var d={};d.View=a.extend({initialize:function(h){h.multiple=true;h.type="checkbox";a.prototype.initialize.call(this,h)}});var g={};g.View=b.extend({initialize:function(h){b.prototype.initialize.call(this,h)},value:function(h){if(h!==undefined){this.$("input").prop("checked",false);this.$("label").removeClass("active");this.$('[value="'+h+'"]').prop("checked",true).closest("label").addClass("active")}return this._getValue()},_templateOption:function(j){var h="fa "+j.icon;if(!j.label){h+=" no-padding"}var i='<label class="btn btn-default">';if(j.icon){i+='<i class="'+h+'"/>'}i+='<input type="radio" name="'+this.options.id+'" value="'+j.value+'"/>';if(j.label){i+=j.label}i+="</label>";return i},_template:function(){return'<div class="btn-group ui-radiobutton" data-toggle="buttons"/>'}});return{Base:b,BaseIcons:a,Radio:f,RadioButton:g,Checkbox:d}});
\ No newline at end of file
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/packed/mvc/ui/ui-select-default.js
--- a/static/scripts/packed/mvc/ui/ui-select-default.js
+++ b/static/scripts/packed/mvc/ui/ui-select-default.js
@@ -1,1 +1,1 @@
-define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{id:"",cls:"",error_text:"No data available",empty_text:"No selection",visible:true,wait:false,multiple:false,searchable:false,optional:false},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));this.$select=this.$el.find(".select");this.$icon=this.$el.find(".icon");this.$button=this.$el.find(".button");if(this.options.multiple){this.$select.prop("multiple",true);this.$select.addClass("ui-select-multiple");this.$icon.remove()}else{this.$el.addClass("ui-select")}this.update(this.options.data);if(this.options.value!==undefined){this.value(this.options.value)}if(!this.options.visible){this.hide()}if(this.options.wait){this.wait()}else{this.show()}var c=this;this.$select.on("change",function(){c._change()});this.on("change",function(){c._change()})},value:function(c){if(c!==undefined){this.$select.val(c);if(this.$select.select2){this.$select.select2("val",c)}}return this.$select.val()},first:function(){var c=this.$select.find("option");if(c.length>0){return c.val()}else{return undefined}},validate:function(){return a.validate(this.value())},text:function(){return this.$select.find("option:selected").text()},show:function(){this.unwait();this.$select.show();this.$el.show()},hide:function(){this.$el.hide()},wait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-spinner fa-spin")},unwait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-caret-down")},disabled:function(){return this.$select.is(":disabled")},enable:function(){this.$select.prop("disabled",false)},disable:function(){this.$select.prop("disabled",true)},add:function(c){this.$select.append(this._templateOption(c));this._refresh()},del:function(c){this.$select.find("option[value="+c+"]").remove();this.$select.trigger("change");this._refresh()},update:function(c){var e=this.$select.val();this.$select.find("option").remove();if(this.options.optional&&!this.options.multiple){this.$select.append(this._templateOption({value:"__null__",label:this.options.empty_text}))}for(var d in c){this.$select.append(this._templateOption(c[d]))}this._refresh();this.$select.val(e);if(!this.$select.val()){this.$select.val(this.first())}if(this.options.searchable){this.$button.hide();this.$select.select2("destroy");this.$select.select2()}},setOnChange:function(c){this.options.onchange=c},exists:function(c){return this.$select.find('option[value="'+c+'"]').length>0},_change:function(){if(this.options.onchange){this.options.onchange(this.$select.val())}},_refresh:function(){this.$select.find('option[value="__undefined__"]').remove();var c=this.$select.find("option").length;if(c==0){this.disable();this.$select.append(this._templateOption({value:"__undefined__",label:this.options.error_text}))}else{this.enable()}},_templateOption:function(c){return'<option value="'+c.value+'">'+c.label+"</option>"},_template:function(c){return'<div id="'+c.id+'"><select id="select" class="select '+c.cls+" "+c.id+'"></select><div class="button"><i class="icon"/></div></div>'}});return{View:b}});
\ No newline at end of file
+define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{id:"",cls:"",error_text:"No data available",empty_text:"No selection",visible:true,wait:false,multiple:false,searchable:false,optional:false},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));this.$select=this.$el.find(".select");this.$icon=this.$el.find(".icon");this.$button=this.$el.find(".button");if(this.options.multiple){this.$select.prop("multiple",true);this.$select.addClass("ui-select-multiple");this.$icon.remove()}else{this.$el.addClass("ui-select")}this.update(this.options.data);if(this.options.value!==undefined){this.value(this.options.value)}if(!this.options.visible){this.hide()}if(this.options.wait){this.wait()}else{this.show()}var c=this;this.$select.on("change",function(){c._change()});this.on("change",function(){c._change()})},value:function(c){if(c!==undefined){if(c===null){c="__null__"}this.$select.val(c);if(this.$select.select2){this.$select.select2("val",c)}}var d=this.$select.val();if(!a.validate(d)){return null}return d},first:function(){var c=this.$select.find("option");if(c.length>0){return c.val()}else{return undefined}},text:function(){return this.$select.find("option:selected").text()},show:function(){this.unwait();this.$select.show();this.$el.show()},hide:function(){this.$el.hide()},wait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-spinner fa-spin")},unwait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-caret-down")},disabled:function(){return this.$select.is(":disabled")},enable:function(){this.$select.prop("disabled",false)},disable:function(){this.$select.prop("disabled",true)},add:function(c){this.$select.append(this._templateOption(c));this._refresh()},del:function(c){this.$select.find("option[value="+c+"]").remove();this.$select.trigger("change");this._refresh()},update:function(c){var e=this.$select.val();this.$select.find("option").remove();if(this.options.optional&&!this.options.multiple){this.$select.append(this._templateOption({value:"__null__",label:this.options.empty_text}))}for(var d in c){this.$select.append(this._templateOption(c[d]))}this._refresh();this.$select.val(e);if(!this.$select.val()){this.$select.val(this.first())}if(this.options.searchable){this.$button.hide();this.$select.select2("destroy");this.$select.select2()}},setOnChange:function(c){this.options.onchange=c},exists:function(c){return this.$select.find('option[value="'+c+'"]').length>0},_change:function(){if(this.options.onchange){this.options.onchange(this.$select.val())}},_refresh:function(){this.$select.find('option[value="__undefined__"]').remove();var c=this.$select.find("option").length;if(c==0){this.disable();this.$select.append(this._templateOption({value:"__undefined__",label:this.options.error_text}))}else{this.enable()}},_templateOption:function(c){return'<option value="'+c.value+'">'+c.label+"</option>"},_template:function(c){return'<div id="'+c.id+'"><select id="select" class="select '+c.cls+" "+c.id+'"></select><div class="button"><i class="icon"/></div></div>'}});return{View:b}});
\ No newline at end of file
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/packed/utils/utils.js
--- a/static/scripts/packed/utils/utils.js
+++ b/static/scripts/packed/utils/utils.js
@@ -1,1 +1,1 @@
-define(["libs/underscore"],function(l){function m(q,p){for(var n in q){var o=q[n];if(o&&typeof(o)=="object"){p(o);m(o,p)}}}function c(n){return $("<div/>").text(n).html()}function k(o){if(!(o instanceof Array)){o=[o]}for(var n in o){if(["__null__","__undefined__","None",null,undefined].indexOf(o[n])>-1){return false}}return true}function g(n){var n=n.toString();if(n){n=n.replace(/,/g,", ");var o=n.lastIndexOf(", ");if(o!=-1){n=n.substr(0,o)+" or "+n.substr(o+1)}return n}return""}function d(n){top.__utils__get__=top.__utils__get__||{};if(n.cache&&top.__utils__get__[n.url]){n.success&&n.success(top.__utils__get__[n.url]);console.debug("utils.js::get() - Fetching from cache ["+n.url+"].")}else{h({url:n.url,data:n.data,success:function(o){top.__utils__get__[n.url]=o;n.success&&n.success(o)},error:function(o){n.error&&n.error(o)}})}}function h(o){var n={contentType:"application/json",type:o.type||"GET",data:o.data||{},url:o.url};if(n.type=="GET"||n.type=="DELETE"){if(n.url.indexOf("?")==-1){n.url+="?"}else{n.url+="&"}n.url=n.url+$.param(n.data,true);n.data=null}else{n.dataType="json";n.url=n.url;n.data=JSON.stringify(n.data)}$.ajax(n).done(function(p){if(typeof p==="string"){try{p=p.replace("Infinity,",'"Infinity",');p=jQuery.parseJSON(p)}catch(q){console.debug(q)}}o.success&&o.success(p)}).fail(function(q){var p=null;try{p=jQuery.parseJSON(q.responseText)}catch(r){p=q.responseText}o.error&&o.error(p,q)})}function i(q,n){var o=$('<div class="'+q+'"></div>');o.appendTo(":eq(0)");var p=o.css(n);o.remove();return p}function f(n){if(!$('link[href^="'+n+'"]').length){$('<link href="'+galaxy_config.root+n+'" rel="stylesheet">').appendTo("head")}}function j(n,o){if(n){return l.defaults(n,o)}else{return o}}function b(o,q){var p="";if(o>=100000000000){o=o/100000000000;p="TB"}else{if(o>=100000000){o=o/100000000;p="GB"}else{if(o>=100000){o=o/100000;p="MB"}else{if(o>=100){o=o/100;p="KB"}else{if(o>0){o=o*10;p="b"}else{return"<strong>-</strong>"}}}}}var n=(Math.round(o)/10);if(q){return n+" "+p}else{return"<strong>"+n+"</strong> "+p}}function a(){return"x"+Math.random().toString(36).substring(2,9)}function e(){var p=new Date();var n=(p.getHours()<10?"0":"")+p.getHours();var o=(p.getMinutes()<10?"0":"")+p.getMinutes();var q=p.getDate()+"/"+(p.getMonth()+1)+"/"+p.getFullYear()+", "+n+":"+o;return q}return{cssLoadFile:f,cssGetAttribute:i,get:d,merge:j,bytesToString:b,uuid:a,time:e,request:h,sanitize:c,textify:g,validate:k,deepeach:m}});
\ No newline at end of file
+define(["libs/underscore"],function(l){function m(q,p){for(var n in q){var o=q[n];if(o&&typeof(o)=="object"){p(o);m(o,p)}}}function c(n){return $("<div/>").text(n).html()}function k(o){if(!(o instanceof Array)){o=[o]}if(o.length===0){return false}for(var n in o){if(["__null__","__undefined__","None",null,undefined].indexOf(o[n])>-1){return false}}return true}function g(n){var n=n.toString();if(n){n=n.replace(/,/g,", ");var o=n.lastIndexOf(", ");if(o!=-1){n=n.substr(0,o)+" or "+n.substr(o+1)}return n}return""}function d(n){top.__utils__get__=top.__utils__get__||{};if(n.cache&&top.__utils__get__[n.url]){n.success&&n.success(top.__utils__get__[n.url]);console.debug("utils.js::get() - Fetching from cache ["+n.url+"].")}else{h({url:n.url,data:n.data,success:function(o){top.__utils__get__[n.url]=o;n.success&&n.success(o)},error:function(o){n.error&&n.error(o)}})}}function h(o){var n={contentType:"application/json",type:o.type||"GET",data:o.data||{},url:o.url};if(n.type=="GET"||n.type=="DELETE"){if(n.url.indexOf("?")==-1){n.url+="?"}else{n.url+="&"}n.url=n.url+$.param(n.data,true);n.data=null}else{n.dataType="json";n.url=n.url;n.data=JSON.stringify(n.data)}$.ajax(n).done(function(p){if(typeof p==="string"){try{p=p.replace("Infinity,",'"Infinity",');p=jQuery.parseJSON(p)}catch(q){console.debug(q)}}o.success&&o.success(p)}).fail(function(q){var p=null;try{p=jQuery.parseJSON(q.responseText)}catch(r){p=q.responseText}o.error&&o.error(p,q)})}function i(q,n){var o=$('<div class="'+q+'"></div>');o.appendTo(":eq(0)");var p=o.css(n);o.remove();return p}function f(n){if(!$('link[href^="'+n+'"]').length){$('<link href="'+galaxy_config.root+n+'" rel="stylesheet">').appendTo("head")}}function j(n,o){if(n){return l.defaults(n,o)}else{return o}}function b(o,q){var p="";if(o>=100000000000){o=o/100000000000;p="TB"}else{if(o>=100000000){o=o/100000000;p="GB"}else{if(o>=100000){o=o/100000;p="MB"}else{if(o>=100){o=o/100;p="KB"}else{if(o>0){o=o*10;p="b"}else{return"<strong>-</strong>"}}}}}var n=(Math.round(o)/10);if(q){return n+" "+p}else{return"<strong>"+n+"</strong> "+p}}function a(){return"x"+Math.random().toString(36).substring(2,9)}function e(){var p=new Date();var n=(p.getHours()<10?"0":"")+p.getHours();var o=(p.getMinutes()<10?"0":"")+p.getMinutes();var q=p.getDate()+"/"+(p.getMonth()+1)+"/"+p.getFullYear()+", "+n+":"+o;return q}return{cssLoadFile:f,cssGetAttribute:i,get:d,merge:j,bytesToString:b,uuid:a,time:e,request:h,sanitize:c,textify:g,validate:k,deepeach:m}});
\ No newline at end of file
diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/utils/utils.js
--- a/static/scripts/utils/utils.js
+++ b/static/scripts/utils/utils.js
@@ -35,6 +35,9 @@
if (!(value instanceof Array)) {
value = [value];
}
+ if (value.length === 0) {
+ return false;
+ }
for (var i in value) {
if (['__null__', '__undefined__', 'None', null, undefined].indexOf(value[i]) > -1) {
return false;
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.
1
0
commit/galaxy-central: guerler: ToolForm: Place requirements into pulldown menu, add toolshed link, remove spaces
by commits-noreply@bitbucket.org 10 Feb '15
by commits-noreply@bitbucket.org 10 Feb '15
10 Feb '15
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/1bb9dcb87c49/
Changeset: 1bb9dcb87c49
User: guerler
Date: 2015-02-11 03:13:42+00:00
Summary: ToolForm: Place requirements into pulldown menu, add toolshed link, remove spaces
Affected #: 4 files
diff -r 0afbc9b476c5cd7ebf827b834628c877f75fe3e6 -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 client/galaxy/scripts/mvc/tools/tools-form-base.js
--- a/client/galaxy/scripts/mvc/tools/tools-form-base.js
+++ b/client/galaxy/scripts/mvc/tools/tools-form-base.js
@@ -22,13 +22,13 @@
// portlet style
cls_portlet : 'ui-portlet-limited'
};
-
+
// configure options
this.options = Utils.merge(options, this.optionsDefault);
-
+
// log options
console.debug(this.options);
-
+
// link galaxy modal or create one
var galaxy = parent.Galaxy;
if (galaxy && galaxy.modal) {
@@ -36,84 +36,84 @@
} else {
this.modal = new Ui.Modal.View();
}
-
+
// check if the user is an admin
if (galaxy && galaxy.currUser) {
this.is_admin = galaxy.currUser.get('is_admin');
} else {
this.is_admin = false;
}
-
+
// link container
this.container = this.options.container || 'body';
-
+
// create deferred processing queue handler
// this handler reduces the number of requests to the api by filtering redundant requests
this.deferred = new Deferred();
-
+
// set element
this.setElement('<div/>');
-
+
// add to main element
$(this.container).append(this.$el);
-
+
// build this form
this.build(this.options);
},
-
+
/** Main tool form build function. This function is called once a new model is available.
*/
build: function(options) {
// link this
var self = this;
-
+
// reset events
this.off('refresh');
this.off('reset');
-
+
// reset field list, which contains the input field elements
this.field_list = {};
-
+
// reset sequential input definition list, which contains the input definitions as provided from the api
this.input_list = {};
-
+
// reset input element list, which contains the dom elements of each input element (includes also the input field)
this.element_list = {};
-
+
// creates a tree/json data structure from the input form
this.tree = new ToolTree(this);
-
+
// request history content and build form
this.content = new ToolContent(this);
-
+
// update model data
self.options.inputs = options && options.inputs;
-
+
// create ui elements
this._renderForm(options);
-
+
// rebuild the underlying data structure
this.tree.finalize();
-
+
// show errors on startup
if (options.initial_errors) {
this._errors(options);
}
-
+
// add refresh listener
this.on('refresh', function() {
// by using/resetting the deferred ajax queue the number of redundant calls is reduced
self.deferred.reset();
self.deferred.execute(function(){self._updateModel()});
});
-
+
// add reset listener
this.on('reset', function() {
for (var i in this.element_list) {
this.element_list[i].reset();
}
});
-
+
// refresh
this.trigger('refresh');
},
@@ -124,7 +124,7 @@
$(this.container).empty();
$(this.container).append($el);
},
-
+
/** Highlight and scroll to input element (currently only used for error notifications)
*/
highlight: function (input_id, message, silent) {
@@ -144,7 +144,7 @@
}
}
},
-
+
/** Highlights errors
*/
_errors: function(options) {
@@ -168,35 +168,10 @@
_renderForm: function(options) {
// link this
var self = this;
-
+
// create message view
this.message = new Ui.Message();
-
- // button for version selection
- var requirements_button = new Ui.ButtonIcon({
- icon : 'fa-info-circle',
- title : (!options.narrow && 'Requirements') || null,
- tooltip : 'Display tool requirements',
- onclick : function() {
- if (!this.visible) {
- this.visible = true;
- self.message.update({
- persistent : true,
- message : ToolTemplate.requirements(options),
- status : 'info'
- });
- } else {
- this.visible = false;
- self.message.update({
- message : ''
- });
- }
- }
- });
- if (!options.requirements || options.requirements.length == 0) {
- requirements_button.$el.hide();
- }
-
+
// button for version selection
var versions_button = new Ui.ButtonMenu({
icon : 'fa-cubes',
@@ -226,14 +201,14 @@
} else {
versions_button.$el.hide();
}
-
+
// button menu
var menu_button = new Ui.ButtonMenu({
icon : 'fa-caret-down',
title : (!options.narrow && 'Options') || null,
tooltip : 'View available options'
});
-
+
// configure button selection
if(options.biostar_url) {
// add question option
@@ -256,7 +231,7 @@
}
});
};
-
+
// create share button
menu_button.addMenu({
icon : 'fa-share',
@@ -266,7 +241,7 @@
prompt('Copy to clipboard: Ctrl+C, Enter', window.location.origin + galaxy_config.root + 'root?tool_id=' + options.id);
}
});
-
+
// add admin operations
if (this.is_admin) {
// create download button
@@ -279,47 +254,83 @@
}
});
}
-
+
+ // button for version selection
+ if (options.requirements && options.requirements.length > 0) {
+ menu_button.addMenu({
+ icon : 'fa-info-circle',
+ title : 'Requirements',
+ tooltip : 'Display tool requirements',
+ onclick : function() {
+ if (!this.visible) {
+ this.visible = true;
+ self.message.update({
+ persistent : true,
+ message : ToolTemplate.requirements(options),
+ status : 'info'
+ });
+ } else {
+ this.visible = false;
+ self.message.update({
+ message : ''
+ });
+ }
+ }
+ });
+ }
+
+
+ // add toolshed url
+ if (this.options.sharable_url) {
+ menu_button.addMenu({
+ icon : 'fa-external-link',
+ title : 'Open in Toolshed',
+ tooltip : 'Access the repository',
+ onclick : function() {
+ window.open(self.options.sharable_url);
+ }
+ });
+ }
+
// create tool form section
this.section = new ToolSection.View(self, {
inputs : options.inputs
});
-
+
// switch to classic tool form mako if the form definition is incompatible
if (this.incompatible) {
this.$el.hide();
$('#tool-form-classic').show();
return;
}
-
+
// create portlet
this.portlet = new Portlet.View({
icon : 'fa-wrench',
title : '<b>' + options.name + '</b> ' + options.description + ' (Galaxy Tool Version ' + options.version + ')',
cls : this.options.cls_portlet,
operations: {
- requirements : requirements_button,
- menu : menu_button,
- versions : versions_button
+ menu : menu_button,
+ versions : versions_button
},
buttons : this.buttons
});
-
+
// append message
this.portlet.append(this.message.$el.addClass('ui-margin-top'));
-
+
// append tool section
this.portlet.append(this.section.$el);
-
+
// start form
this.$el.empty();
this.$el.append(this.portlet.$el);
-
+
// append help
if (options.help != '') {
this.$el.append(ToolTemplate.help(options.help));
}
-
+
// append citations
if (options.citations) {
var $citations = $('<div/>');
@@ -330,7 +341,7 @@
citations.fetch();
this.$el.append($citations);
}
-
+
// show message if available in model
if (options.message) {
this.message.update({
diff -r 0afbc9b476c5cd7ebf827b834628c877f75fe3e6 -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -2520,7 +2520,7 @@
for t in tools:
tool_versions.append(t.version)
- ## add information with underlying requirements and their versions
+ # add information with underlying requirements and their versions
tool_requirements = []
if self.requirements:
for requirement in self.requirements:
@@ -2529,11 +2529,17 @@
'version' : requirement.version
})
+ # add toolshed url
+ sharable_url = None
+ if self.tool_shed_repository:
+ sharable_url = self.tool_shed_repository.get_sharable_url( trans.app )
+
# add additional properties
tool_model.update({
'help' : tool_help,
'citations' : tool_citations,
'biostar_url' : trans.app.config.biostar_url,
+ 'sharable_url' : sharable_url,
'message' : tool_message,
'versions' : tool_versions,
'requirements' : tool_requirements,
diff -r 0afbc9b476c5cd7ebf827b834628c877f75fe3e6 -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 static/scripts/mvc/tools/tools-form-base.js
--- a/static/scripts/mvc/tools/tools-form-base.js
+++ b/static/scripts/mvc/tools/tools-form-base.js
@@ -22,13 +22,13 @@
// portlet style
cls_portlet : 'ui-portlet-limited'
};
-
+
// configure options
this.options = Utils.merge(options, this.optionsDefault);
-
+
// log options
console.debug(this.options);
-
+
// link galaxy modal or create one
var galaxy = parent.Galaxy;
if (galaxy && galaxy.modal) {
@@ -36,84 +36,84 @@
} else {
this.modal = new Ui.Modal.View();
}
-
+
// check if the user is an admin
if (galaxy && galaxy.currUser) {
this.is_admin = galaxy.currUser.get('is_admin');
} else {
this.is_admin = false;
}
-
+
// link container
this.container = this.options.container || 'body';
-
+
// create deferred processing queue handler
// this handler reduces the number of requests to the api by filtering redundant requests
this.deferred = new Deferred();
-
+
// set element
this.setElement('<div/>');
-
+
// add to main element
$(this.container).append(this.$el);
-
+
// build this form
this.build(this.options);
},
-
+
/** Main tool form build function. This function is called once a new model is available.
*/
build: function(options) {
// link this
var self = this;
-
+
// reset events
this.off('refresh');
this.off('reset');
-
+
// reset field list, which contains the input field elements
this.field_list = {};
-
+
// reset sequential input definition list, which contains the input definitions as provided from the api
this.input_list = {};
-
+
// reset input element list, which contains the dom elements of each input element (includes also the input field)
this.element_list = {};
-
+
// creates a tree/json data structure from the input form
this.tree = new ToolTree(this);
-
+
// request history content and build form
this.content = new ToolContent(this);
-
+
// update model data
self.options.inputs = options && options.inputs;
-
+
// create ui elements
this._renderForm(options);
-
+
// rebuild the underlying data structure
this.tree.finalize();
-
+
// show errors on startup
if (options.initial_errors) {
this._errors(options);
}
-
+
// add refresh listener
this.on('refresh', function() {
// by using/resetting the deferred ajax queue the number of redundant calls is reduced
self.deferred.reset();
self.deferred.execute(function(){self._updateModel()});
});
-
+
// add reset listener
this.on('reset', function() {
for (var i in this.element_list) {
this.element_list[i].reset();
}
});
-
+
// refresh
this.trigger('refresh');
},
@@ -124,7 +124,7 @@
$(this.container).empty();
$(this.container).append($el);
},
-
+
/** Highlight and scroll to input element (currently only used for error notifications)
*/
highlight: function (input_id, message, silent) {
@@ -144,7 +144,7 @@
}
}
},
-
+
/** Highlights errors
*/
_errors: function(options) {
@@ -168,35 +168,10 @@
_renderForm: function(options) {
// link this
var self = this;
-
+
// create message view
this.message = new Ui.Message();
-
- // button for version selection
- var requirements_button = new Ui.ButtonIcon({
- icon : 'fa-info-circle',
- title : (!options.narrow && 'Requirements') || null,
- tooltip : 'Display tool requirements',
- onclick : function() {
- if (!this.visible) {
- this.visible = true;
- self.message.update({
- persistent : true,
- message : ToolTemplate.requirements(options),
- status : 'info'
- });
- } else {
- this.visible = false;
- self.message.update({
- message : ''
- });
- }
- }
- });
- if (!options.requirements || options.requirements.length == 0) {
- requirements_button.$el.hide();
- }
-
+
// button for version selection
var versions_button = new Ui.ButtonMenu({
icon : 'fa-cubes',
@@ -226,14 +201,14 @@
} else {
versions_button.$el.hide();
}
-
+
// button menu
var menu_button = new Ui.ButtonMenu({
icon : 'fa-caret-down',
title : (!options.narrow && 'Options') || null,
tooltip : 'View available options'
});
-
+
// configure button selection
if(options.biostar_url) {
// add question option
@@ -256,7 +231,7 @@
}
});
};
-
+
// create share button
menu_button.addMenu({
icon : 'fa-share',
@@ -266,7 +241,7 @@
prompt('Copy to clipboard: Ctrl+C, Enter', window.location.origin + galaxy_config.root + 'root?tool_id=' + options.id);
}
});
-
+
// add admin operations
if (this.is_admin) {
// create download button
@@ -279,47 +254,83 @@
}
});
}
-
+
+ // button for version selection
+ if (options.requirements && options.requirements.length > 0) {
+ menu_button.addMenu({
+ icon : 'fa-info-circle',
+ title : 'Requirements',
+ tooltip : 'Display tool requirements',
+ onclick : function() {
+ if (!this.visible) {
+ this.visible = true;
+ self.message.update({
+ persistent : true,
+ message : ToolTemplate.requirements(options),
+ status : 'info'
+ });
+ } else {
+ this.visible = false;
+ self.message.update({
+ message : ''
+ });
+ }
+ }
+ });
+ }
+
+
+ // add toolshed url
+ if (this.options.sharable_url) {
+ menu_button.addMenu({
+ icon : 'fa-external-link',
+ title : 'Open in Toolshed',
+ tooltip : 'Access the repository',
+ onclick : function() {
+ window.open(self.options.sharable_url);
+ }
+ });
+ }
+
// create tool form section
this.section = new ToolSection.View(self, {
inputs : options.inputs
});
-
+
// switch to classic tool form mako if the form definition is incompatible
if (this.incompatible) {
this.$el.hide();
$('#tool-form-classic').show();
return;
}
-
+
// create portlet
this.portlet = new Portlet.View({
icon : 'fa-wrench',
title : '<b>' + options.name + '</b> ' + options.description + ' (Galaxy Tool Version ' + options.version + ')',
cls : this.options.cls_portlet,
operations: {
- requirements : requirements_button,
- menu : menu_button,
- versions : versions_button
+ menu : menu_button,
+ versions : versions_button
},
buttons : this.buttons
});
-
+
// append message
this.portlet.append(this.message.$el.addClass('ui-margin-top'));
-
+
// append tool section
this.portlet.append(this.section.$el);
-
+
// start form
this.$el.empty();
this.$el.append(this.portlet.$el);
-
+
// append help
if (options.help != '') {
this.$el.append(ToolTemplate.help(options.help));
}
-
+
// append citations
if (options.citations) {
var $citations = $('<div/>');
@@ -330,7 +341,7 @@
citations.fetch();
this.$el.append($citations);
}
-
+
// show message if available in model
if (options.message) {
this.message.update({
diff -r 0afbc9b476c5cd7ebf827b834628c877f75fe3e6 -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 static/scripts/packed/mvc/tools/tools-form-base.js
--- a/static/scripts/packed/mvc/tools/tools-form-base.js
+++ b/static/scripts/packed/mvc/tools/tools-form-base.js
@@ -1,1 +1,1 @@
-define(["utils/utils","utils/deferred","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree"],function(g,h,f,k,i,a,d,c,e,j,b){return Backbone.View.extend({initialize:function(l){this.optionsDefault={is_dynamic:true,narrow:false,initial_errors:false,cls_portlet:"ui-portlet-limited"};this.options=g.merge(l,this.optionsDefault);console.debug(this.options);var m=parent.Galaxy;if(m&&m.modal){this.modal=m.modal}else{this.modal=new k.Modal.View()}if(m&&m.currUser){this.is_admin=m.currUser.get("is_admin")}else{this.is_admin=false}this.container=this.options.container||"body";this.deferred=new h();this.setElement("<div/>");$(this.container).append(this.$el);this.build(this.options)},build:function(m){var l=this;this.off("refresh");this.off("reset");this.field_list={};this.input_list={};this.element_list={};this.tree=new b(this);this.content=new e(this);l.options.inputs=m&&m.inputs;this._renderForm(m);this.tree.finalize();if(m.initial_errors){this._errors(m)}this.on("refresh",function(){l.deferred.reset();l.deferred.execute(function(){l._updateModel()})});this.on("reset",function(){for(var n in this.element_list){this.element_list[n].reset()}});this.trigger("refresh")},reciept:function(l){$(this.container).empty();$(this.container).append(l)},highlight:function(m,n,l){var o=this.element_list[m];if(o){o.error(n||"Please verify this parameter.");if(!l){$(this.container).animate({scrollTop:o.$el.offset().top-20},500)}}},_errors:function(n){this.trigger("reset");if(n&&n.errors){var o=this.tree.matchResponse(n.errors);for(var m in this.element_list){var l=this.element_list[m];if(o[m]){this.highlight(m,o[m],true)}}}},_renderForm:function(u){var t=this;this.message=new k.Message();var q=new k.ButtonIcon({icon:"fa-info-circle",title:(!u.narrow&&"Requirements")||null,tooltip:"Display tool requirements",onclick:function(){if(!this.visible){this.visible=true;t.message.update({persistent:true,message:c.requirements(u),status:"info"})}else{this.visible=false;t.message.update({message:""})}}});if(!u.requirements||u.requirements.length==0){q.$el.hide()}var m=new k.ButtonMenu({icon:"fa-cubes",title:(!u.narrow&&"Versions")||null,tooltip:"Select another tool version"});if(u.versions&&u.versions.length>1){for(var o in u.versions){var r=u.versions[o];if(r!=u.version){m.addMenu({title:"Switch to "+r,version:r,icon:"fa-cube",onclick:function(){t.options.id=t.options.id.replace(t.options.version,this.version);t.options.version=this.version;t.deferred.reset();t.deferred.execute(function(){t._buildModel()})}})}}}else{m.$el.hide()}var p=new k.ButtonMenu({icon:"fa-caret-down",title:(!u.narrow&&"Options")||null,tooltip:"View available options"});if(u.biostar_url){p.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(u.biostar_url+"/p/new/post/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(u.biostar_url+"/t/"+u.id+"/")}})}p.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+u.id)}});if(this.is_admin){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+u.id+"/download"}})}this.section=new j.View(t,{inputs:u.inputs});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new f.View({icon:"fa-wrench",title:"<b>"+u.name+"</b> "+u.description+" (Galaxy Tool Version "+u.version+")",cls:this.options.cls_portlet,operations:{requirements:q,menu:p,versions:m},buttons:this.buttons});this.portlet.append(this.message.$el.addClass("ui-margin-top"));this.portlet.append(this.section.$el);this.$el.empty();this.$el.append(this.portlet.$el);if(u.help!=""){this.$el.append(c.help(u.help))}if(u.citations){var s=$("<div/>");var l=new i.ToolCitationCollection();l.tool_id=u.id;var n=new a.CitationListView({el:s,collection:l});n.render();l.fetch();this.$el.append(s)}if(u.message){this.message.update({persistent:true,status:"warning",message:u.message})}}})});
\ No newline at end of file
+define(["utils/utils","utils/deferred","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree"],function(g,h,f,k,i,a,d,c,e,j,b){return Backbone.View.extend({initialize:function(l){this.optionsDefault={is_dynamic:true,narrow:false,initial_errors:false,cls_portlet:"ui-portlet-limited"};this.options=g.merge(l,this.optionsDefault);console.debug(this.options);var m=parent.Galaxy;if(m&&m.modal){this.modal=m.modal}else{this.modal=new k.Modal.View()}if(m&&m.currUser){this.is_admin=m.currUser.get("is_admin")}else{this.is_admin=false}this.container=this.options.container||"body";this.deferred=new h();this.setElement("<div/>");$(this.container).append(this.$el);this.build(this.options)},build:function(m){var l=this;this.off("refresh");this.off("reset");this.field_list={};this.input_list={};this.element_list={};this.tree=new b(this);this.content=new e(this);l.options.inputs=m&&m.inputs;this._renderForm(m);this.tree.finalize();if(m.initial_errors){this._errors(m)}this.on("refresh",function(){l.deferred.reset();l.deferred.execute(function(){l._updateModel()})});this.on("reset",function(){for(var n in this.element_list){this.element_list[n].reset()}});this.trigger("refresh")},reciept:function(l){$(this.container).empty();$(this.container).append(l)},highlight:function(m,n,l){var o=this.element_list[m];if(o){o.error(n||"Please verify this parameter.");if(!l){$(this.container).animate({scrollTop:o.$el.offset().top-20},500)}}},_errors:function(n){this.trigger("reset");if(n&&n.errors){var o=this.tree.matchResponse(n.errors);for(var m in this.element_list){var l=this.element_list[m];if(o[m]){this.highlight(m,o[m],true)}}}},_renderForm:function(t){var s=this;this.message=new k.Message();var m=new k.ButtonMenu({icon:"fa-cubes",title:(!t.narrow&&"Versions")||null,tooltip:"Select another tool version"});if(t.versions&&t.versions.length>1){for(var o in t.versions){var q=t.versions[o];if(q!=t.version){m.addMenu({title:"Switch to "+q,version:q,icon:"fa-cube",onclick:function(){s.options.id=s.options.id.replace(s.options.version,this.version);s.options.version=this.version;s.deferred.reset();s.deferred.execute(function(){s._buildModel()})}})}}}else{m.$el.hide()}var p=new k.ButtonMenu({icon:"fa-caret-down",title:(!t.narrow&&"Options")||null,tooltip:"View available options"});if(t.biostar_url){p.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(t.biostar_url+"/p/new/post/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(t.biostar_url+"/t/"+t.id+"/")}})}p.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+t.id)}});if(this.is_admin){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+t.id+"/download"}})}if(t.requirements&&t.requirements.length>0){p.addMenu({icon:"fa-info-circle",title:"Requirements",tooltip:"Display tool requirements",onclick:function(){if(!this.visible){this.visible=true;s.message.update({persistent:true,message:c.requirements(t),status:"info"})}else{this.visible=false;s.message.update({message:""})}}})}if(this.options.sharable_url){p.addMenu({icon:"fa-external-link",title:"Open in Toolshed",tooltip:"Access the repository",onclick:function(){window.open(s.options.sharable_url)}})}this.section=new j.View(s,{inputs:t.inputs});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new f.View({icon:"fa-wrench",title:"<b>"+t.name+"</b> "+t.description+" (Galaxy Tool Version "+t.version+")",cls:this.options.cls_portlet,operations:{menu:p,versions:m},buttons:this.buttons});this.portlet.append(this.message.$el.addClass("ui-margin-top"));this.portlet.append(this.section.$el);this.$el.empty();this.$el.append(this.portlet.$el);if(t.help!=""){this.$el.append(c.help(t.help))}if(t.citations){var r=$("<div/>");var l=new i.ToolCitationCollection();l.tool_id=t.id;var n=new a.CitationListView({el:r,collection:l});n.render();l.fetch();this.$el.append(r)}if(t.message){this.message.update({persistent:true,status:"warning",message:t.message})}}})});
\ No newline at end of file
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.
1
0
commit/galaxy-central: guerler: ToolForm: Modify refresh trigger
by commits-noreply@bitbucket.org 10 Feb '15
by commits-noreply@bitbucket.org 10 Feb '15
10 Feb '15
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/0afbc9b476c5/
Changeset: 0afbc9b476c5
User: guerler
Date: 2015-02-11 00:59:03+00:00
Summary: ToolForm: Modify refresh trigger
Affected #: 3 files
diff -r 581d871b810205f6a02e994983ffe316e206b746 -r 0afbc9b476c5cd7ebf827b834628c877f75fe3e6 client/galaxy/scripts/mvc/tools/tools-input.js
--- a/client/galaxy/scripts/mvc/tools/tools-input.js
+++ b/client/galaxy/scripts/mvc/tools/tools-input.js
@@ -49,6 +49,9 @@
// refresh view
self._refresh();
+
+ // refresh state
+ self.app.trigger('refresh');
});
},
@@ -79,7 +82,6 @@
this.$title_optional.html(this.text_enable);
this.field.value && this.field.value(this.default_value);
}
- this.app.trigger('refresh');
},
/** Main Template
diff -r 581d871b810205f6a02e994983ffe316e206b746 -r 0afbc9b476c5cd7ebf827b834628c877f75fe3e6 static/scripts/mvc/tools/tools-input.js
--- a/static/scripts/mvc/tools/tools-input.js
+++ b/static/scripts/mvc/tools/tools-input.js
@@ -49,6 +49,9 @@
// refresh view
self._refresh();
+
+ // refresh state
+ self.app.trigger('refresh');
});
},
@@ -79,7 +82,6 @@
this.$title_optional.html(this.text_enable);
this.field.value && this.field.value(this.default_value);
}
- this.app.trigger('refresh');
},
/** Main Template
diff -r 581d871b810205f6a02e994983ffe316e206b746 -r 0afbc9b476c5cd7ebf827b834628c877f75fe3e6 static/scripts/packed/mvc/tools/tools-input.js
--- a/static/scripts/packed/mvc/tools/tools-input.js
+++ b/static/scripts/packed/mvc/tools/tools-input.js
@@ -1,1 +1,1 @@
-define([],function(){return Backbone.View.extend({initialize:function(d,c){this.app=d;this.text_enable=d.options.text_enable||"Enable";this.text_disable=d.options.text_disable||"Disable";this.field=c.field;this.default_value=c.default_value;this.setElement(this._template(c));this.$field=this.$el.find(".ui-table-form-field");this.$title_optional=this.$el.find(".ui-table-form-title-optional");this.$error_text=this.$el.find(".ui-table-form-error-text");this.$error=this.$el.find(".ui-table-form-error");this.$field.prepend(this.field.$el);this.field.skip=false;var b=this.field.value&&this.field.value();this.field.skip=Boolean(c.optional&&(((this.field.validate&&!this.field.validate())||!b||(b==this.default_value)||(Number(b)==Number(this.default_value))||(JSON.stringify(b)==JSON.stringify(this.default_value)))));this._refresh();var a=this;this.$title_optional.on("click",function(){a.field.skip=!a.field.skip;a._refresh()})},error:function(a){this.$error_text.html(a);this.$error.show();this.$el.addClass("ui-error")},reset:function(){this.$error.hide();this.$el.removeClass("ui-error")},_refresh:function(){if(!this.field.skip){this.$field.fadeIn("fast");this.$title_optional.html(this.text_disable)}else{this.reset();this.$field.hide();this.$title_optional.html(this.text_enable);this.field.value&&this.field.value(this.default_value)}this.app.trigger("refresh")},_template:function(a){var b='<div class="ui-table-form-element"><div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/></div><div class="ui-table-form-title-strong">';if(a.optional){b+=a.label+'<span> [<span class="ui-table-form-title-optional"/>]</span>'}else{b+=a.label}b+='</div><div class="ui-table-form-field">';if(a.help){b+='<div class="ui-table-form-info">'+a.help+"</div>"}b+="</div></div>";return b}})});
\ No newline at end of file
+define([],function(){return Backbone.View.extend({initialize:function(d,c){this.app=d;this.text_enable=d.options.text_enable||"Enable";this.text_disable=d.options.text_disable||"Disable";this.field=c.field;this.default_value=c.default_value;this.setElement(this._template(c));this.$field=this.$el.find(".ui-table-form-field");this.$title_optional=this.$el.find(".ui-table-form-title-optional");this.$error_text=this.$el.find(".ui-table-form-error-text");this.$error=this.$el.find(".ui-table-form-error");this.$field.prepend(this.field.$el);this.field.skip=false;var b=this.field.value&&this.field.value();this.field.skip=Boolean(c.optional&&(((this.field.validate&&!this.field.validate())||!b||(b==this.default_value)||(Number(b)==Number(this.default_value))||(JSON.stringify(b)==JSON.stringify(this.default_value)))));this._refresh();var a=this;this.$title_optional.on("click",function(){a.field.skip=!a.field.skip;a._refresh();a.app.trigger("refresh")})},error:function(a){this.$error_text.html(a);this.$error.show();this.$el.addClass("ui-error")},reset:function(){this.$error.hide();this.$el.removeClass("ui-error")},_refresh:function(){if(!this.field.skip){this.$field.fadeIn("fast");this.$title_optional.html(this.text_disable)}else{this.reset();this.$field.hide();this.$title_optional.html(this.text_enable);this.field.value&&this.field.value(this.default_value)}},_template:function(a){var b='<div class="ui-table-form-element"><div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/></div><div class="ui-table-form-title-strong">';if(a.optional){b+=a.label+'<span> [<span class="ui-table-form-title-optional"/>]</span>'}else{b+=a.label}b+='</div><div class="ui-table-form-field">';if(a.help){b+='<div class="ui-table-form-info">'+a.help+"</div>"}b+="</div></div>";return b}})});
\ No newline at end of file
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.
1
0
commit/galaxy-central: carlfeberhard: UI, paired collection creator: refactor autopairing and add tests
by commits-noreply@bitbucket.org 10 Feb '15
by commits-noreply@bitbucket.org 10 Feb '15
10 Feb '15
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/581d871b8102/
Changeset: 581d871b8102
User: carlfeberhard
Date: 2015-02-10 23:15:43+00:00
Summary: UI, paired collection creator: refactor autopairing and add tests
Affected #: 4 files
diff -r cd41c43e857f7db0d21a093f0d59ce8bf82a049e -r 581d871b810205f6a02e994983ffe316e206b746 client/galaxy/scripts/mvc/collection/paired-collection-creator.js
--- a/client/galaxy/scripts/mvc/collection/paired-collection-creator.js
+++ b/client/galaxy/scripts/mvc/collection/paired-collection-creator.js
@@ -3,7 +3,7 @@
"utils/natural-sort",
"mvc/base-mvc",
"utils/localization"
-], function( levelshteinDistance, naturalSort, baseMVC, _l ){
+], function( levenshteinDistance, naturalSort, baseMVC, _l ){
/* ============================================================================
TODO:
_adjPairedOnScrollBar
@@ -28,7 +28,6 @@
className : 'dataset paired',
initialize : function( attributes ){
- //console.debug( 'PairView.initialize:', attributes );
this.pair = attributes.pair || {};
},
@@ -46,9 +45,6 @@
.data( 'pair', this.pair )
.html( this.template({ pair: this.pair }) )
.addClass( 'flex-column-container' );
-
-//TODO: would be good to get the unpair-btn into this view - but haven't found a way with css
-
return this;
},
@@ -61,24 +57,17 @@
/** dragging pairs for re-ordering */
_dragstart : function( ev ){
- //console.debug( this, '_dragstartPair', ev );
ev.currentTarget.style.opacity = '0.4';
if( ev.originalEvent ){ ev = ev.originalEvent; }
ev.dataTransfer.effectAllowed = 'move';
ev.dataTransfer.setData( 'text/plain', JSON.stringify( this.pair ) );
- //ev.dataTransfer.setDragImage( null, 0, 0 );
-
- // the canvas can be used to create the image
- //ev.dataTransfer.setDragImage( canvasCrossHairs(), 25, 25 );
-
- //console.debug( 'ev.dataTransfer:', ev.dataTransfer );
this.$el.parent().trigger( 'pair.dragstart', [ this ] );
},
+
/** dragging pairs for re-ordering */
_dragend : function( ev ){
- //console.debug( this, '_dragendPair', ev );
ev.currentTarget.style.opacity = '1.0';
this.$el.parent().trigger( 'pair.dragend', [ this ] );
},
@@ -92,8 +81,106 @@
toString : function(){
return 'PairView(' + this.pair.name + ')';
}
+});
-});
+
+/** returns an autopair function that uses the provided options.match function */
+function autoPairFnBuilder( options ){
+ options = options || {};
+ options.createPair = options.createPair || function _defaultCreatePair( params ){
+ this.debug( 'creating pair:', params.listA[ params.indexA ].name, params.listB[ params.indexB ].name );
+ params = params || {};
+ return this._pair(
+ params.listA.splice( params.indexA, 1 )[0],
+ params.listB.splice( params.indexB, 1 )[0],
+ { silent: true }
+ );
+ };
+ // compile these here outside of the loop
+ var _regexps = [];
+ function getRegExps(){
+ if( !_regexps.length ){
+ _regexps = [
+ new RegExp( this.filters[0] ),
+ new RegExp( this.filters[1] )
+ ];
+ }
+ return _regexps;
+ }
+ // mangle params as needed
+ options.preprocessMatch = options.preprocessMatch || function _defaultPreprocessMatch( params ){
+ var regexps = getRegExps.call( this );
+ return _.extend( params, {
+ matchTo : params.matchTo.name.replace( regexps[0], '' ),
+ possible : params.possible.name.replace( regexps[1], '' )
+ });
+ };
+
+ return function _strategy( params ){
+ this.debug( 'autopair _strategy ---------------------------' );
+ params = params || {};
+ var listA = params.listA,
+ listB = params.listB,
+ indexA = 0, indexB,
+ bestMatch = {
+ score : 0.0,
+ index : null
+ },
+ paired = [];
+ //console.debug( 'params:', JSON.stringify( params, null, ' ' ) );
+ this.debug( 'starting list lens:', listA.length, listB.length );
+ this.debug( 'bestMatch (starting):', JSON.stringify( bestMatch, null, ' ' ) );
+
+ while( indexA < listA.length ){
+ var matchTo = listA[ indexA ];
+ bestMatch.score = 0.0;
+
+ for( indexB=0; indexB<listB.length; indexB++ ){
+ var possible = listB[ indexB ];
+ this.debug( indexA + ':' + matchTo.name );
+ this.debug( indexB + ':' + possible.name );
+
+ // no matching with self
+ if( listA[ indexA ] !== listB[ indexB ] ){
+ bestMatch = options.match.call( this, options.preprocessMatch.call( this, {
+ matchTo : matchTo,
+ possible: possible,
+ index : indexB,
+ bestMatch : bestMatch
+ }));
+ this.debug( 'bestMatch:', JSON.stringify( bestMatch, null, ' ' ) );
+ if( bestMatch.score === 1.0 ){
+ this.debug( 'breaking early due to perfect match' );
+ break;
+ }
+ }
+ }
+ var scoreThreshold = options.scoreThreshold.call( this );
+ this.debug( 'scoreThreshold:', scoreThreshold );
+ this.debug( 'bestMatch.score:', bestMatch.score );
+
+ if( bestMatch.score >= scoreThreshold ){
+ this.debug( 'creating pair' );
+ paired.push( options.createPair.call( this, {
+ listA : listA,
+ indexA : indexA,
+ listB : listB,
+ indexB : bestMatch.index
+ }));
+ this.debug( 'list lens now:', listA.length, listB.length );
+ } else {
+ indexA += 1;
+ }
+ if( !listA.length || !listB.length ){
+ return paired;
+ }
+ }
+ this.debug( 'paired:', JSON.stringify( paired, null, ' ' ) );
+ this.debug( 'autopair _strategy ---------------------------' );
+ return paired;
+ };
+}
+
/** An interface for building collections of paired datasets.
*/
@@ -108,15 +195,11 @@
attributes = _.defaults( attributes, {
datasets : [],
filters : this.DEFAULT_FILTERS,
- //automaticallyPair : false,
automaticallyPair : true,
- matchPercentage : 1.0,
- //matchPercentage : 0.9,
- //matchPercentage : 0.8,
- //strategy : 'levenshtein'
- strategy : 'lcs'
+ strategy : 'lcs',
+ matchPercentage : 0.9,
+ twoPassAutopairing : true
});
- //this.debug( 'attributes now:', attributes );
/** unordered, original list */
this.initialList = attributes.datasets;
@@ -133,15 +216,18 @@
/** try to auto pair the unpaired datasets on load? */
this.automaticallyPair = attributes.automaticallyPair;
- /** distance/mismatch level allowed for autopairing */
- this.matchPercentage = attributes.matchPercentage;
-
/** what method to use for auto pairing (will be passed aggression level) */
this.strategy = this.strategies[ attributes.strategy ] || this.strategies[ this.DEFAULT_STRATEGY ];
if( _.isFunction( attributes.strategy ) ){
this.strategy = attributes.strategy;
}
+ /** distance/mismatch level allowed for autopairing */
+ this.matchPercentage = attributes.matchPercentage;
+
+ /** try to autopair using simple first, then this.strategy on the remainder */
+ this.twoPassAutopairing = attributes.twoPassAutopairing;
+
/** remove file extensions (\.*) from created pair names? */
this.removeExtensions = true;
//this.removeExtensions = false;
@@ -173,12 +259,12 @@
},
/** which commonFilter to use by default */
DEFAULT_FILTERS : 'illumina',
- //DEFAULT_FILTERS : 'none',
/** map of name->fn for autopairing */
strategies : {
- 'lcs' : 'autoPairLCSs',
- 'levenshtein' : 'autoPairLevenshtein'
+ 'simple' : 'autopairSimple',
+ 'lcs' : 'autopairLCS',
+ 'levenshtein' : 'autopairLevenshtein'
},
/** default autopair strategy name */
DEFAULT_STRATEGY : 'lcs',
@@ -191,8 +277,6 @@
this.paired = [];
this.unpaired = [];
- //this.fwdSelectedIds = [];
- //this.revSelectedIds = [];
this.selectedIds = [];
// sort initial list, add ids if needed, and save new working copy to unpaired
@@ -212,7 +296,6 @@
_sortInitialList : function(){
//this.debug( '-- _sortInitialList' );
this._sortDatasetList( this.initialList );
- //this._printList( this.unpaired );
},
/** sort a list of datasets */
@@ -229,39 +312,31 @@
dataset.id = _.uniqueId();
}
});
- //this._printList( this.unpaired );
return this.initialList;
},
/** split initial list into two lists, those that pass forward filters & those passing reverse */
- _splitByFilters : function( filters ){
- var fwd = [],
- rev = [];
+ _splitByFilters : function(){
+ var regexFilters = this.filters.map( function( stringFilter ){
+ return new RegExp( stringFilter );
+ }),
+ split = [ [], [] ];
- function _addToFwdOrRev( unpaired ){
- if( this._filterFwdFn( unpaired ) ){
- fwd.push( unpaired );
- }
- if( this._filterRevFn( unpaired ) ){
- rev.push( unpaired );
- }
+ function _filter( unpaired, filter ){
+ return filter.test( unpaired.name );
+ //return dataset.name.indexOf( filter ) >= 0;
}
- this.unpaired.forEach( _.bind( _addToFwdOrRev, this ) );
- return [ fwd, rev ];
- },
-
- /** filter fn to apply to forward datasets */
- _filterFwdFn : function( dataset ){
-//TODO: this treats *all* strings as regex which may confuse people
- var regexp = new RegExp( this.filters[0] );
- return regexp.test( dataset.name );
- //return dataset.name.indexOf( this.filters[0] ) >= 0;
- },
-
- /** filter fn to apply to reverse datasets */
- _filterRevFn : function( dataset ){
- var regexp = new RegExp( this.filters[1] );
- return regexp.test( dataset.name );
+ this.unpaired.forEach( function _filterEach( unpaired ){
+ // 90% of the time this seems to work, but:
+ //TODO: this treats *all* strings as regex which may confuse people - possibly check for // surrounding?
+ // would need explanation in help as well
+ regexFilters.forEach( function( filter, i ){
+ if( _filter( unpaired, filter ) ){
+ split[i].push( unpaired );
+ }
+ });
+ });
+ return split;
},
/** add a dataset to the unpaired list in it's proper order */
@@ -288,202 +363,79 @@
},
// ------------------------------------------------------------------------ auto pairing
-//TODO: lots of boiler plate btwn the three auto pair fns
/** two passes to automatically create pairs:
* use both simpleAutoPair, then the fn mentioned in strategy
*/
autoPair : function( strategy ){
+ // split first using exact matching
+ var split = this._splitByFilters(),
+ paired = [];
+ if( this.twoPassAutopairing ){
+ paired = this.autopairSimple({
+ listA : split[0],
+ listB : split[1]
+ });
+ split = this._splitByFilters();
+ }
+
+ // uncomment to see printlns while running tests
+ //this.debug = function(){ console.log.apply( console, arguments ); };
+
+ // then try the remainder with something less strict
strategy = strategy || this.strategy;
- //this.debug( '-- autoPair', strategy );
- var paired = this.simpleAutoPair();
- paired = paired.concat( this[ strategy ].call( this ) );
+ split = this._splitByFilters();
+ paired = paired.concat( this[ strategy ].call( this, {
+ listA : split[0],
+ listB : split[1]
+ }));
return paired;
},
- /** attempts to pair forward with reverse when names exactly match (after removing filters) */
- simpleAutoPair : function(){
- //this.debug( '-- simpleAutoPair' );
- // simplified auto pair that moves down unpaired lists *in order*,
- // removes filters' strings from fwd and rev,
- // and, if names w/o filters *exactly* match, creates a pair
- // possibly good as a first pass
- var i = 0, j,
- split = this._splitByFilters(),
- fwdList = split[0],
- revList = split[1],
- fwdName, revName,
- matchFound = false,
- paired = [];
+ autopairSimple : autoPairFnBuilder({
+ scoreThreshold: function(){ return 1.0; },
+ match : function _match( params ){
+ params = params || {};
+ if( params.matchTo === params.possible ){
+ return {
+ index: params.index,
+ score: 1.0
+ };
+ }
+ return params.bestMatch;
+ }
+ }),
- while( i<fwdList.length ){
- var fwd = fwdList[ i ];
- //TODO: go through the filterFwdFn
- fwdName = fwd.name.replace( this.filters[0], '' );
- //this.debug( i, 'fwd:', fwdName );
- matchFound = false;
+ autopairLevenshtein : autoPairFnBuilder({
+ scoreThreshold: function(){ return this.matchPercentage; },
+ match : function _matches( params ){
+ params = params || {};
+ var distance = levenshteinDistance( params.matchTo, params.possible ),
+ score = 1.0 - ( distance / ( Math.max( params.matchTo.length, params.possible.length ) ) );
+ if( score > params.bestMatch.score ){
+ return {
+ index: params.index,
+ score: score
+ };
+ }
+ return params.bestMatch;
+ }
+ }),
- for( j=0; j<revList.length; j++ ){
- var rev = revList[ j ];
- revName = rev.name.replace( this.filters[1], '' );
- //this.debug( '\t ', j, 'rev:', revName );
-
- if( fwd !== rev && fwdName === revName ){
- matchFound = true;
- // if it is a match, keep i at current, pop fwd, pop rev and break
- //this.debug( '---->', fwdName, revName );
- var pair = this._pair(
- fwdList.splice( i, 1 )[0],
- revList.splice( j, 1 )[0],
- { silent: true }
- );
- paired.push( pair );
- break;
- }
+ autopairLCS : autoPairFnBuilder({
+ scoreThreshold: function(){ return this.matchPercentage; },
+ match : function _matches( params ){
+ params = params || {};
+ var match = this._naiveStartingAndEndingLCS( params.matchTo, params.possible ).length,
+ score = match / ( Math.max( params.matchTo.length, params.possible.length ) );
+ if( score > params.bestMatch.score ){
+ return {
+ index: params.index,
+ score: score
+ };
}
- if( !matchFound ){ i += 1; }
+ return params.bestMatch;
}
- //this.debug( 'remaining Forward:' );
- //this._printList( this.unpairedForward );
- //this.debug( 'remaining Reverse:' );
- //this._printList( this.unpairedReverse );
- //this.debug( '' );
- return paired;
- },
-
- /** attempt to autopair using edit distance between forward and reverse (after removing filters) */
- autoPairLevenshtein : function(){
- //precondition: filters are set, both lists are not empty, and all filenames.length > filters[?].length
- //this.debug( '-- autoPairLevenshtein' );
- var i = 0, j,
- split = this._splitByFilters(),
- fwdList = split[0],
- revList = split[1],
- fwdName, revName,
- distance, bestIndex, bestDist,
- paired = [];
-
- while( i<fwdList.length ){
- var fwd = fwdList[ i ];
- //TODO: go through the filterFwdFn
- fwdName = fwd.name.replace( this.filters[0], '' );
- //this.debug( i, 'fwd:', fwdName );
- bestDist = Number.MAX_VALUE;
-
- for( j=0; j<revList.length; j++ ){
- var rev = revList[ j ];
- revName = rev.name.replace( this.filters[1], '' );
- //this.debug( '\t ', j, 'rev:', revName );
-
- if( fwd !== rev ){
- if( fwdName === revName ){
- //this.debug( '\t\t exactmatch:', fwdName, revName );
- bestIndex = j;
- bestDist = 0;
- break;
- }
- distance = levenshteinDistance( fwdName, revName );
- //this.debug( '\t\t distance:', distance, 'bestDist:', bestDist );
- if( distance < bestDist ){
- bestIndex = j;
- bestDist = distance;
- }
- }
- }
- //this.debug( '---->', fwd.name, bestIndex, bestDist );
- //this.debug( '---->', fwd.name, revList[ bestIndex ].name, bestDist );
-
- var percentage = 1.0 - ( bestDist / ( Math.max( fwdName.length, revName.length ) ) );
- //this.debug( '----> %', percentage * 100 );
-
- if( percentage >= this.matchPercentage ){
- var pair = this._pair(
- fwdList.splice( i, 1 )[0],
- revList.splice( bestIndex, 1 )[0],
- { silent: true }
- );
- paired.push( pair );
- if( fwdList.length <= 0 || revList.length <= 0 ){
- return paired;
- }
- } else {
- i += 1;
- }
- }
- //this.debug( 'remaining Forward:' );
- //this._printList( this.unpairedForward );
- //this.debug( 'remaining Reverse:' );
- //this._printList( this.unpairedReverse );
- //this.debug( '' );
- return paired;
- },
-
- /** attempt to auto pair using common substrings from both front and back (after removing filters) */
- autoPairLCSs : function(){
- //precondition: filters are set, both lists are not empty
- //this.debug( '-- autoPairLCSs' );
- var i = 0, j,
- split = this._splitByFilters(),
- fwdList = split[0],
- revList = split[1],
- fwdName, revName,
- currMatch, bestIndex, bestMatch,
- paired = [];
- if( !fwdList.length || !revList.length ){ return paired; }
- //this.debug( fwdList, revList );
-
- while( i<fwdList.length ){
- var fwd = fwdList[ i ];
- fwdName = fwd.name.replace( this.filters[0], '' );
- //this.debug( i, 'fwd:', fwdName );
- bestMatch = 0;
-
- for( j=0; j<revList.length; j++ ){
- var rev = revList[ j ];
- revName = rev.name.replace( this.filters[1], '' );
- //this.debug( '\t ', j, 'rev:', revName );
-
- if( fwd !== rev ){
- if( fwdName === revName ){
- //this.debug( '\t\t exactmatch:', fwdName, revName );
- bestIndex = j;
- bestMatch = fwdName.length;
- break;
- }
- var match = this._naiveStartingAndEndingLCS( fwdName, revName );
- currMatch = match.length;
- //this.debug( '\t\t match:', match, 'currMatch:', currMatch, 'bestMatch:', bestMatch );
- if( currMatch > bestMatch ){
- bestIndex = j;
- bestMatch = currMatch;
- }
- }
- }
- //this.debug( '---->', i, fwd.name, bestIndex, revList[ bestIndex ].name, bestMatch );
-
- var percentage = bestMatch / ( Math.min( fwdName.length, revName.length ) );
- //this.debug( '----> %', percentage * 100 );
-
- if( percentage >= this.matchPercentage ){
- var pair = this._pair(
- fwdList.splice( i, 1 )[0],
- revList.splice( bestIndex, 1 )[0],
- { silent: true }
- );
- paired.push( pair );
- if( fwdList.length <= 0 || revList.length <= 0 ){
- return paired;
- }
- } else {
- i += 1;
- }
- }
- //this.debug( 'remaining Forward:' );
- //this._printList( this.unpairedForward );
- //this.debug( 'remaining Reverse:' );
- //this._printList( this.unpairedReverse );
- //this.debug( '' );
- return paired;
- },
+ }),
/** return the concat'd longest common prefix and suffix from two strings */
_naiveStartingAndEndingLCS : function( s1, s2 ){
@@ -1338,19 +1290,19 @@
// ........................................................................ paired - drag and drop re-ordering
//_dragenterPairedColumns : function( ev ){
- // console.debug( '_dragenterPairedColumns:', ev );
+ // this.debug( '_dragenterPairedColumns:', ev );
//},
//_dragleavePairedColumns : function( ev ){
- // //console.debug( '_dragleavePairedColumns:', ev );
+ // //this.debug( '_dragleavePairedColumns:', ev );
//},
/** track the mouse drag over the paired list adding a placeholder to show where the drop would occur */
_dragoverPairedColumns : function( ev ){
- //console.debug( '_dragoverPairedColumns:', ev );
+ //this.debug( '_dragoverPairedColumns:', ev );
ev.preventDefault();
var $list = this.$( '.paired-columns .column-datasets' );
this._checkForAutoscroll( $list, ev.originalEvent.clientY );
- //console.debug( ev.originalEvent.clientX, ev.originalEvent.clientY );
+ //this.debug( ev.originalEvent.clientX, ev.originalEvent.clientY );
var $nearest = this._getNearestPairedDatasetLi( ev.originalEvent.clientY );
$( '.paired-drop-placeholder' ).remove();
@@ -1369,7 +1321,7 @@
scrollTop = $element.scrollTop(),
upperDist = y - offset.top,
lowerDist = ( offset.top + $element.outerHeight() ) - y;
- //console.debug( '_checkForAutoscroll:', scrollTop, upperDist, lowerDist );
+ //this.debug( '_checkForAutoscroll:', scrollTop, upperDist, lowerDist );
if( upperDist >= 0 && upperDist < this.autoscrollDist ){
$element.scrollTop( scrollTop - AUTOSCROLL_SPEED );
} else if( lowerDist >= 0 && lowerDist < this.autoscrollDist ){
@@ -1388,7 +1340,7 @@
top = $li.offset().top,
halfHeight = Math.floor( $li.outerHeight() / 2 ) + WIGGLE;
if( top + halfHeight > y && top - halfHeight < y ){
- //console.debug( y, top + halfHeight, top - halfHeight )
+ //this.debug( y, top + halfHeight, top - halfHeight )
return $li;
}
}
@@ -1419,13 +1371,13 @@
this.$( '.paired-columns .dataset.paired' ).each( function(){
newPaired.push( $( this ).data( 'pair' ) );
});
- //console.debug( newPaired );
+ //this.debug( newPaired );
this.paired = newPaired;
this._renderPaired();
},
/** drag communication with pair sub-views: dragstart */
_pairDragstart : function( ev, pair ){
- //console.debug( '_pairDragstart', ev, pair )
+ //this.debug( '_pairDragstart', ev, pair )
// auto select the pair causing the event and move all selected
pair.$el.addClass( 'selected' );
var $selected = this.$( '.paired-columns .dataset.selected' );
@@ -1433,7 +1385,7 @@
},
/** drag communication with pair sub-views: dragend - remove the placeholder */
_pairDragend : function( ev, pair ){
- //console.debug( '_pairDragend', ev, pair )
+ //this.debug( '_pairDragend', ev, pair )
$( '.paired-drop-placeholder' ).remove();
this.$dragging = null;
},
@@ -1736,7 +1688,6 @@
//=============================================================================
/** a modal version of the paired collection creator */
var pairedCollectionCreatorModal = function _pairedCollectionCreatorModal( datasets, options ){
- console.log( datasets );
options = _.defaults( options || {}, {
datasets : datasets,
diff -r cd41c43e857f7db0d21a093f0d59ce8bf82a049e -r 581d871b810205f6a02e994983ffe316e206b746 static/scripts/mvc/collection/paired-collection-creator.js
--- a/static/scripts/mvc/collection/paired-collection-creator.js
+++ b/static/scripts/mvc/collection/paired-collection-creator.js
@@ -3,7 +3,7 @@
"utils/natural-sort",
"mvc/base-mvc",
"utils/localization"
-], function( levelshteinDistance, naturalSort, baseMVC, _l ){
+], function( levenshteinDistance, naturalSort, baseMVC, _l ){
/* ============================================================================
TODO:
_adjPairedOnScrollBar
@@ -28,7 +28,6 @@
className : 'dataset paired',
initialize : function( attributes ){
- //console.debug( 'PairView.initialize:', attributes );
this.pair = attributes.pair || {};
},
@@ -46,9 +45,6 @@
.data( 'pair', this.pair )
.html( this.template({ pair: this.pair }) )
.addClass( 'flex-column-container' );
-
-//TODO: would be good to get the unpair-btn into this view - but haven't found a way with css
-
return this;
},
@@ -61,24 +57,17 @@
/** dragging pairs for re-ordering */
_dragstart : function( ev ){
- //console.debug( this, '_dragstartPair', ev );
ev.currentTarget.style.opacity = '0.4';
if( ev.originalEvent ){ ev = ev.originalEvent; }
ev.dataTransfer.effectAllowed = 'move';
ev.dataTransfer.setData( 'text/plain', JSON.stringify( this.pair ) );
- //ev.dataTransfer.setDragImage( null, 0, 0 );
-
- // the canvas can be used to create the image
- //ev.dataTransfer.setDragImage( canvasCrossHairs(), 25, 25 );
-
- //console.debug( 'ev.dataTransfer:', ev.dataTransfer );
this.$el.parent().trigger( 'pair.dragstart', [ this ] );
},
+
/** dragging pairs for re-ordering */
_dragend : function( ev ){
- //console.debug( this, '_dragendPair', ev );
ev.currentTarget.style.opacity = '1.0';
this.$el.parent().trigger( 'pair.dragend', [ this ] );
},
@@ -92,8 +81,106 @@
toString : function(){
return 'PairView(' + this.pair.name + ')';
}
+});
-});
+
+/** returns an autopair function that uses the provided options.match function */
+function autoPairFnBuilder( options ){
+ options = options || {};
+ options.createPair = options.createPair || function _defaultCreatePair( params ){
+ this.debug( 'creating pair:', params.listA[ params.indexA ].name, params.listB[ params.indexB ].name );
+ params = params || {};
+ return this._pair(
+ params.listA.splice( params.indexA, 1 )[0],
+ params.listB.splice( params.indexB, 1 )[0],
+ { silent: true }
+ );
+ };
+ // compile these here outside of the loop
+ var _regexps = [];
+ function getRegExps(){
+ if( !_regexps.length ){
+ _regexps = [
+ new RegExp( this.filters[0] ),
+ new RegExp( this.filters[1] )
+ ];
+ }
+ return _regexps;
+ }
+ // mangle params as needed
+ options.preprocessMatch = options.preprocessMatch || function _defaultPreprocessMatch( params ){
+ var regexps = getRegExps.call( this );
+ return _.extend( params, {
+ matchTo : params.matchTo.name.replace( regexps[0], '' ),
+ possible : params.possible.name.replace( regexps[1], '' )
+ });
+ };
+
+ return function _strategy( params ){
+ this.debug( 'autopair _strategy ---------------------------' );
+ params = params || {};
+ var listA = params.listA,
+ listB = params.listB,
+ indexA = 0, indexB,
+ bestMatch = {
+ score : 0.0,
+ index : null
+ },
+ paired = [];
+ //console.debug( 'params:', JSON.stringify( params, null, ' ' ) );
+ this.debug( 'starting list lens:', listA.length, listB.length );
+ this.debug( 'bestMatch (starting):', JSON.stringify( bestMatch, null, ' ' ) );
+
+ while( indexA < listA.length ){
+ var matchTo = listA[ indexA ];
+ bestMatch.score = 0.0;
+
+ for( indexB=0; indexB<listB.length; indexB++ ){
+ var possible = listB[ indexB ];
+ this.debug( indexA + ':' + matchTo.name );
+ this.debug( indexB + ':' + possible.name );
+
+ // no matching with self
+ if( listA[ indexA ] !== listB[ indexB ] ){
+ bestMatch = options.match.call( this, options.preprocessMatch.call( this, {
+ matchTo : matchTo,
+ possible: possible,
+ index : indexB,
+ bestMatch : bestMatch
+ }));
+ this.debug( 'bestMatch:', JSON.stringify( bestMatch, null, ' ' ) );
+ if( bestMatch.score === 1.0 ){
+ this.debug( 'breaking early due to perfect match' );
+ break;
+ }
+ }
+ }
+ var scoreThreshold = options.scoreThreshold.call( this );
+ this.debug( 'scoreThreshold:', scoreThreshold );
+ this.debug( 'bestMatch.score:', bestMatch.score );
+
+ if( bestMatch.score >= scoreThreshold ){
+ this.debug( 'creating pair' );
+ paired.push( options.createPair.call( this, {
+ listA : listA,
+ indexA : indexA,
+ listB : listB,
+ indexB : bestMatch.index
+ }));
+ this.debug( 'list lens now:', listA.length, listB.length );
+ } else {
+ indexA += 1;
+ }
+ if( !listA.length || !listB.length ){
+ return paired;
+ }
+ }
+ this.debug( 'paired:', JSON.stringify( paired, null, ' ' ) );
+ this.debug( 'autopair _strategy ---------------------------' );
+ return paired;
+ };
+}
+
/** An interface for building collections of paired datasets.
*/
@@ -108,15 +195,11 @@
attributes = _.defaults( attributes, {
datasets : [],
filters : this.DEFAULT_FILTERS,
- //automaticallyPair : false,
automaticallyPair : true,
- matchPercentage : 1.0,
- //matchPercentage : 0.9,
- //matchPercentage : 0.8,
- //strategy : 'levenshtein'
- strategy : 'lcs'
+ strategy : 'lcs',
+ matchPercentage : 0.9,
+ twoPassAutopairing : true
});
- //this.debug( 'attributes now:', attributes );
/** unordered, original list */
this.initialList = attributes.datasets;
@@ -133,15 +216,18 @@
/** try to auto pair the unpaired datasets on load? */
this.automaticallyPair = attributes.automaticallyPair;
- /** distance/mismatch level allowed for autopairing */
- this.matchPercentage = attributes.matchPercentage;
-
/** what method to use for auto pairing (will be passed aggression level) */
this.strategy = this.strategies[ attributes.strategy ] || this.strategies[ this.DEFAULT_STRATEGY ];
if( _.isFunction( attributes.strategy ) ){
this.strategy = attributes.strategy;
}
+ /** distance/mismatch level allowed for autopairing */
+ this.matchPercentage = attributes.matchPercentage;
+
+ /** try to autopair using simple first, then this.strategy on the remainder */
+ this.twoPassAutopairing = attributes.twoPassAutopairing;
+
/** remove file extensions (\.*) from created pair names? */
this.removeExtensions = true;
//this.removeExtensions = false;
@@ -173,12 +259,12 @@
},
/** which commonFilter to use by default */
DEFAULT_FILTERS : 'illumina',
- //DEFAULT_FILTERS : 'none',
/** map of name->fn for autopairing */
strategies : {
- 'lcs' : 'autoPairLCSs',
- 'levenshtein' : 'autoPairLevenshtein'
+ 'simple' : 'autopairSimple',
+ 'lcs' : 'autopairLCS',
+ 'levenshtein' : 'autopairLevenshtein'
},
/** default autopair strategy name */
DEFAULT_STRATEGY : 'lcs',
@@ -191,8 +277,6 @@
this.paired = [];
this.unpaired = [];
- //this.fwdSelectedIds = [];
- //this.revSelectedIds = [];
this.selectedIds = [];
// sort initial list, add ids if needed, and save new working copy to unpaired
@@ -212,7 +296,6 @@
_sortInitialList : function(){
//this.debug( '-- _sortInitialList' );
this._sortDatasetList( this.initialList );
- //this._printList( this.unpaired );
},
/** sort a list of datasets */
@@ -229,39 +312,31 @@
dataset.id = _.uniqueId();
}
});
- //this._printList( this.unpaired );
return this.initialList;
},
/** split initial list into two lists, those that pass forward filters & those passing reverse */
- _splitByFilters : function( filters ){
- var fwd = [],
- rev = [];
+ _splitByFilters : function(){
+ var regexFilters = this.filters.map( function( stringFilter ){
+ return new RegExp( stringFilter );
+ }),
+ split = [ [], [] ];
- function _addToFwdOrRev( unpaired ){
- if( this._filterFwdFn( unpaired ) ){
- fwd.push( unpaired );
- }
- if( this._filterRevFn( unpaired ) ){
- rev.push( unpaired );
- }
+ function _filter( unpaired, filter ){
+ return filter.test( unpaired.name );
+ //return dataset.name.indexOf( filter ) >= 0;
}
- this.unpaired.forEach( _.bind( _addToFwdOrRev, this ) );
- return [ fwd, rev ];
- },
-
- /** filter fn to apply to forward datasets */
- _filterFwdFn : function( dataset ){
-//TODO: this treats *all* strings as regex which may confuse people
- var regexp = new RegExp( this.filters[0] );
- return regexp.test( dataset.name );
- //return dataset.name.indexOf( this.filters[0] ) >= 0;
- },
-
- /** filter fn to apply to reverse datasets */
- _filterRevFn : function( dataset ){
- var regexp = new RegExp( this.filters[1] );
- return regexp.test( dataset.name );
+ this.unpaired.forEach( function _filterEach( unpaired ){
+ // 90% of the time this seems to work, but:
+ //TODO: this treats *all* strings as regex which may confuse people - possibly check for // surrounding?
+ // would need explanation in help as well
+ regexFilters.forEach( function( filter, i ){
+ if( _filter( unpaired, filter ) ){
+ split[i].push( unpaired );
+ }
+ });
+ });
+ return split;
},
/** add a dataset to the unpaired list in it's proper order */
@@ -288,202 +363,79 @@
},
// ------------------------------------------------------------------------ auto pairing
-//TODO: lots of boiler plate btwn the three auto pair fns
/** two passes to automatically create pairs:
* use both simpleAutoPair, then the fn mentioned in strategy
*/
autoPair : function( strategy ){
+ // split first using exact matching
+ var split = this._splitByFilters(),
+ paired = [];
+ if( this.twoPassAutopairing ){
+ paired = this.autopairSimple({
+ listA : split[0],
+ listB : split[1]
+ });
+ split = this._splitByFilters();
+ }
+
+ // uncomment to see printlns while running tests
+ //this.debug = function(){ console.log.apply( console, arguments ); };
+
+ // then try the remainder with something less strict
strategy = strategy || this.strategy;
- //this.debug( '-- autoPair', strategy );
- var paired = this.simpleAutoPair();
- paired = paired.concat( this[ strategy ].call( this ) );
+ split = this._splitByFilters();
+ paired = paired.concat( this[ strategy ].call( this, {
+ listA : split[0],
+ listB : split[1]
+ }));
return paired;
},
- /** attempts to pair forward with reverse when names exactly match (after removing filters) */
- simpleAutoPair : function(){
- //this.debug( '-- simpleAutoPair' );
- // simplified auto pair that moves down unpaired lists *in order*,
- // removes filters' strings from fwd and rev,
- // and, if names w/o filters *exactly* match, creates a pair
- // possibly good as a first pass
- var i = 0, j,
- split = this._splitByFilters(),
- fwdList = split[0],
- revList = split[1],
- fwdName, revName,
- matchFound = false,
- paired = [];
+ autopairSimple : autoPairFnBuilder({
+ scoreThreshold: function(){ return 1.0; },
+ match : function _match( params ){
+ params = params || {};
+ if( params.matchTo === params.possible ){
+ return {
+ index: params.index,
+ score: 1.0
+ };
+ }
+ return params.bestMatch;
+ }
+ }),
- while( i<fwdList.length ){
- var fwd = fwdList[ i ];
- //TODO: go through the filterFwdFn
- fwdName = fwd.name.replace( this.filters[0], '' );
- //this.debug( i, 'fwd:', fwdName );
- matchFound = false;
+ autopairLevenshtein : autoPairFnBuilder({
+ scoreThreshold: function(){ return this.matchPercentage; },
+ match : function _matches( params ){
+ params = params || {};
+ var distance = levenshteinDistance( params.matchTo, params.possible ),
+ score = 1.0 - ( distance / ( Math.max( params.matchTo.length, params.possible.length ) ) );
+ if( score > params.bestMatch.score ){
+ return {
+ index: params.index,
+ score: score
+ };
+ }
+ return params.bestMatch;
+ }
+ }),
- for( j=0; j<revList.length; j++ ){
- var rev = revList[ j ];
- revName = rev.name.replace( this.filters[1], '' );
- //this.debug( '\t ', j, 'rev:', revName );
-
- if( fwd !== rev && fwdName === revName ){
- matchFound = true;
- // if it is a match, keep i at current, pop fwd, pop rev and break
- //this.debug( '---->', fwdName, revName );
- var pair = this._pair(
- fwdList.splice( i, 1 )[0],
- revList.splice( j, 1 )[0],
- { silent: true }
- );
- paired.push( pair );
- break;
- }
+ autopairLCS : autoPairFnBuilder({
+ scoreThreshold: function(){ return this.matchPercentage; },
+ match : function _matches( params ){
+ params = params || {};
+ var match = this._naiveStartingAndEndingLCS( params.matchTo, params.possible ).length,
+ score = match / ( Math.max( params.matchTo.length, params.possible.length ) );
+ if( score > params.bestMatch.score ){
+ return {
+ index: params.index,
+ score: score
+ };
}
- if( !matchFound ){ i += 1; }
+ return params.bestMatch;
}
- //this.debug( 'remaining Forward:' );
- //this._printList( this.unpairedForward );
- //this.debug( 'remaining Reverse:' );
- //this._printList( this.unpairedReverse );
- //this.debug( '' );
- return paired;
- },
-
- /** attempt to autopair using edit distance between forward and reverse (after removing filters) */
- autoPairLevenshtein : function(){
- //precondition: filters are set, both lists are not empty, and all filenames.length > filters[?].length
- //this.debug( '-- autoPairLevenshtein' );
- var i = 0, j,
- split = this._splitByFilters(),
- fwdList = split[0],
- revList = split[1],
- fwdName, revName,
- distance, bestIndex, bestDist,
- paired = [];
-
- while( i<fwdList.length ){
- var fwd = fwdList[ i ];
- //TODO: go through the filterFwdFn
- fwdName = fwd.name.replace( this.filters[0], '' );
- //this.debug( i, 'fwd:', fwdName );
- bestDist = Number.MAX_VALUE;
-
- for( j=0; j<revList.length; j++ ){
- var rev = revList[ j ];
- revName = rev.name.replace( this.filters[1], '' );
- //this.debug( '\t ', j, 'rev:', revName );
-
- if( fwd !== rev ){
- if( fwdName === revName ){
- //this.debug( '\t\t exactmatch:', fwdName, revName );
- bestIndex = j;
- bestDist = 0;
- break;
- }
- distance = levenshteinDistance( fwdName, revName );
- //this.debug( '\t\t distance:', distance, 'bestDist:', bestDist );
- if( distance < bestDist ){
- bestIndex = j;
- bestDist = distance;
- }
- }
- }
- //this.debug( '---->', fwd.name, bestIndex, bestDist );
- //this.debug( '---->', fwd.name, revList[ bestIndex ].name, bestDist );
-
- var percentage = 1.0 - ( bestDist / ( Math.max( fwdName.length, revName.length ) ) );
- //this.debug( '----> %', percentage * 100 );
-
- if( percentage >= this.matchPercentage ){
- var pair = this._pair(
- fwdList.splice( i, 1 )[0],
- revList.splice( bestIndex, 1 )[0],
- { silent: true }
- );
- paired.push( pair );
- if( fwdList.length <= 0 || revList.length <= 0 ){
- return paired;
- }
- } else {
- i += 1;
- }
- }
- //this.debug( 'remaining Forward:' );
- //this._printList( this.unpairedForward );
- //this.debug( 'remaining Reverse:' );
- //this._printList( this.unpairedReverse );
- //this.debug( '' );
- return paired;
- },
-
- /** attempt to auto pair using common substrings from both front and back (after removing filters) */
- autoPairLCSs : function(){
- //precondition: filters are set, both lists are not empty
- //this.debug( '-- autoPairLCSs' );
- var i = 0, j,
- split = this._splitByFilters(),
- fwdList = split[0],
- revList = split[1],
- fwdName, revName,
- currMatch, bestIndex, bestMatch,
- paired = [];
- if( !fwdList.length || !revList.length ){ return paired; }
- //this.debug( fwdList, revList );
-
- while( i<fwdList.length ){
- var fwd = fwdList[ i ];
- fwdName = fwd.name.replace( this.filters[0], '' );
- //this.debug( i, 'fwd:', fwdName );
- bestMatch = 0;
-
- for( j=0; j<revList.length; j++ ){
- var rev = revList[ j ];
- revName = rev.name.replace( this.filters[1], '' );
- //this.debug( '\t ', j, 'rev:', revName );
-
- if( fwd !== rev ){
- if( fwdName === revName ){
- //this.debug( '\t\t exactmatch:', fwdName, revName );
- bestIndex = j;
- bestMatch = fwdName.length;
- break;
- }
- var match = this._naiveStartingAndEndingLCS( fwdName, revName );
- currMatch = match.length;
- //this.debug( '\t\t match:', match, 'currMatch:', currMatch, 'bestMatch:', bestMatch );
- if( currMatch > bestMatch ){
- bestIndex = j;
- bestMatch = currMatch;
- }
- }
- }
- //this.debug( '---->', i, fwd.name, bestIndex, revList[ bestIndex ].name, bestMatch );
-
- var percentage = bestMatch / ( Math.min( fwdName.length, revName.length ) );
- //this.debug( '----> %', percentage * 100 );
-
- if( percentage >= this.matchPercentage ){
- var pair = this._pair(
- fwdList.splice( i, 1 )[0],
- revList.splice( bestIndex, 1 )[0],
- { silent: true }
- );
- paired.push( pair );
- if( fwdList.length <= 0 || revList.length <= 0 ){
- return paired;
- }
- } else {
- i += 1;
- }
- }
- //this.debug( 'remaining Forward:' );
- //this._printList( this.unpairedForward );
- //this.debug( 'remaining Reverse:' );
- //this._printList( this.unpairedReverse );
- //this.debug( '' );
- return paired;
- },
+ }),
/** return the concat'd longest common prefix and suffix from two strings */
_naiveStartingAndEndingLCS : function( s1, s2 ){
@@ -1338,19 +1290,19 @@
// ........................................................................ paired - drag and drop re-ordering
//_dragenterPairedColumns : function( ev ){
- // console.debug( '_dragenterPairedColumns:', ev );
+ // this.debug( '_dragenterPairedColumns:', ev );
//},
//_dragleavePairedColumns : function( ev ){
- // //console.debug( '_dragleavePairedColumns:', ev );
+ // //this.debug( '_dragleavePairedColumns:', ev );
//},
/** track the mouse drag over the paired list adding a placeholder to show where the drop would occur */
_dragoverPairedColumns : function( ev ){
- //console.debug( '_dragoverPairedColumns:', ev );
+ //this.debug( '_dragoverPairedColumns:', ev );
ev.preventDefault();
var $list = this.$( '.paired-columns .column-datasets' );
this._checkForAutoscroll( $list, ev.originalEvent.clientY );
- //console.debug( ev.originalEvent.clientX, ev.originalEvent.clientY );
+ //this.debug( ev.originalEvent.clientX, ev.originalEvent.clientY );
var $nearest = this._getNearestPairedDatasetLi( ev.originalEvent.clientY );
$( '.paired-drop-placeholder' ).remove();
@@ -1369,7 +1321,7 @@
scrollTop = $element.scrollTop(),
upperDist = y - offset.top,
lowerDist = ( offset.top + $element.outerHeight() ) - y;
- //console.debug( '_checkForAutoscroll:', scrollTop, upperDist, lowerDist );
+ //this.debug( '_checkForAutoscroll:', scrollTop, upperDist, lowerDist );
if( upperDist >= 0 && upperDist < this.autoscrollDist ){
$element.scrollTop( scrollTop - AUTOSCROLL_SPEED );
} else if( lowerDist >= 0 && lowerDist < this.autoscrollDist ){
@@ -1388,7 +1340,7 @@
top = $li.offset().top,
halfHeight = Math.floor( $li.outerHeight() / 2 ) + WIGGLE;
if( top + halfHeight > y && top - halfHeight < y ){
- //console.debug( y, top + halfHeight, top - halfHeight )
+ //this.debug( y, top + halfHeight, top - halfHeight )
return $li;
}
}
@@ -1419,13 +1371,13 @@
this.$( '.paired-columns .dataset.paired' ).each( function(){
newPaired.push( $( this ).data( 'pair' ) );
});
- //console.debug( newPaired );
+ //this.debug( newPaired );
this.paired = newPaired;
this._renderPaired();
},
/** drag communication with pair sub-views: dragstart */
_pairDragstart : function( ev, pair ){
- //console.debug( '_pairDragstart', ev, pair )
+ //this.debug( '_pairDragstart', ev, pair )
// auto select the pair causing the event and move all selected
pair.$el.addClass( 'selected' );
var $selected = this.$( '.paired-columns .dataset.selected' );
@@ -1433,7 +1385,7 @@
},
/** drag communication with pair sub-views: dragend - remove the placeholder */
_pairDragend : function( ev, pair ){
- //console.debug( '_pairDragend', ev, pair )
+ //this.debug( '_pairDragend', ev, pair )
$( '.paired-drop-placeholder' ).remove();
this.$dragging = null;
},
@@ -1736,7 +1688,6 @@
//=============================================================================
/** a modal version of the paired collection creator */
var pairedCollectionCreatorModal = function _pairedCollectionCreatorModal( datasets, options ){
- console.log( datasets );
options = _.defaults( options || {}, {
datasets : datasets,
diff -r cd41c43e857f7db0d21a093f0d59ce8bf82a049e -r 581d871b810205f6a02e994983ffe316e206b746 static/scripts/packed/mvc/collection/paired-collection-creator.js
--- a/static/scripts/packed/mvc/collection/paired-collection-creator.js
+++ b/static/scripts/packed/mvc/collection/paired-collection-creator.js
@@ -1,1 +1,1 @@
-define(["utils/levenshtein","utils/natural-sort","mvc/base-mvc","utils/localization"],function(h,g,a,d){var f=Backbone.View.extend(a.LoggableMixin).extend({tagName:"li",className:"dataset paired",initialize:function(i){this.pair=i.pair||{}},template:_.template(['<span class="forward-dataset-name flex-column"><%= pair.forward.name %></span>','<span class="pair-name-column flex-column">','<span class="pair-name"><%= pair.name %></span>',"</span>",'<span class="reverse-dataset-name flex-column"><%= pair.reverse.name %></span>'].join("")),render:function(){this.$el.attr("draggable",true).data("pair",this.pair).html(this.template({pair:this.pair})).addClass("flex-column-container");return this},events:{dragstart:"_dragstart",dragend:"_dragend",dragover:"_sendToParent",drop:"_sendToParent"},_dragstart:function(i){i.currentTarget.style.opacity="0.4";if(i.originalEvent){i=i.originalEvent}i.dataTransfer.effectAllowed="move";i.dataTransfer.setData("text/plain",JSON.stringify(this.pair));this.$el.parent().trigger("pair.dragstart",[this])},_dragend:function(i){i.currentTarget.style.opacity="1.0";this.$el.parent().trigger("pair.dragend",[this])},_sendToParent:function(i){this.$el.parent().trigger(i)},toString:function(){return"PairView("+this.pair.name+")"}});var e=Backbone.View.extend(a.LoggableMixin).extend({className:"collection-creator flex-row-container",initialize:function(i){i=_.defaults(i,{datasets:[],filters:this.DEFAULT_FILTERS,automaticallyPair:true,matchPercentage:1,strategy:"lcs"});this.initialList=i.datasets;this.historyId=i.historyId;this.filters=this.commonFilters[i.filters]||this.commonFilters[this.DEFAULT_FILTERS];if(_.isArray(i.filters)){this.filters=i.filters}this.automaticallyPair=i.automaticallyPair;this.matchPercentage=i.matchPercentage;this.strategy=this.strategies[i.strategy]||this.strategies[this.DEFAULT_STRATEGY];if(_.isFunction(i.strategy)){this.strategy=i.strategy}this.removeExtensions=true;this.oncancel=i.oncancel;this.oncreate=i.oncreate;this.autoscrollDist=i.autoscrollDist||24;this.unpairedPanelHidden=false;this.pairedPanelHidden=false;this.$dragging=null;this._setUpBehaviors();this._dataSetUp()},commonFilters:{none:["",""],illumina:["_1","_2"]},DEFAULT_FILTERS:"illumina",strategies:{lcs:"autoPairLCSs",levenshtein:"autoPairLevenshtein"},DEFAULT_STRATEGY:"lcs",_dataSetUp:function(){this.paired=[];this.unpaired=[];this.selectedIds=[];this._sortInitialList();this._ensureIds();this.unpaired=this.initialList.slice(0);if(this.automaticallyPair){this.autoPair();this.once("rendered:initial",function(){this.trigger("autopair")})}},_sortInitialList:function(){this._sortDatasetList(this.initialList)},_sortDatasetList:function(i){i.sort(function(k,j){return g(k.name,j.name)});return i},_ensureIds:function(){this.initialList.forEach(function(i){if(!i.hasOwnProperty("id")){i.id=_.uniqueId()}});return this.initialList},_splitByFilters:function(l){var k=[],i=[];function j(m){if(this._filterFwdFn(m)){k.push(m)}if(this._filterRevFn(m)){i.push(m)}}this.unpaired.forEach(_.bind(j,this));return[k,i]},_filterFwdFn:function(j){var i=new RegExp(this.filters[0]);return i.test(j.name)},_filterRevFn:function(j){var i=new RegExp(this.filters[1]);return i.test(j.name)},_addToUnpaired:function(j){var i=function(k,m){if(k===m){return k}var l=Math.floor((m-k)/2)+k,n=g(j.name,this.unpaired[l].name);if(n<0){return i(k,l)}else{if(n>0){return i(l+1,m)}}while(this.unpaired[l]&&this.unpaired[l].name===j.name){l++}return l}.bind(this);this.unpaired.splice(i(0,this.unpaired.length),0,j)},autoPair:function(j){j=j||this.strategy;var i=this.simpleAutoPair();i=i.concat(this[j].call(this));return i},simpleAutoPair:function(){var p=0,n,t=this._splitByFilters(),k=t[0],s=t[1],r,v,l=false,u=[];while(p<k.length){var o=k[p];r=o.name.replace(this.filters[0],"");l=false;for(n=0;n<s.length;n++){var q=s[n];v=q.name.replace(this.filters[1],"");if(o!==q&&r===v){l=true;var m=this._pair(k.splice(p,1)[0],s.splice(n,1)[0],{silent:true});u.push(m);break}}if(!l){p+=1}}return u},autoPairLevenshtein:function(){var q=0,o,v=this._splitByFilters(),k=v[0],t=v[1],s,y,l,u,m,w=[];while(q<k.length){var p=k[q];s=p.name.replace(this.filters[0],"");m=Number.MAX_VALUE;for(o=0;o<t.length;o++){var r=t[o];y=r.name.replace(this.filters[1],"");if(p!==r){if(s===y){u=o;m=0;break}l=levenshteinDistance(s,y);if(l<m){u=o;m=l}}}var x=1-(m/(Math.max(s.length,y.length)));if(x>=this.matchPercentage){var n=this._pair(k.splice(q,1)[0],t.splice(u,1)[0],{silent:true});w.push(n);if(k.length<=0||t.length<=0){return w}}else{q+=1}}return w},autoPairLCSs:function(){var o=0,m,v=this._splitByFilters(),k=v[0],t=v[1],s,z,y,u,q,w=[];if(!k.length||!t.length){return w}while(o<k.length){var n=k[o];s=n.name.replace(this.filters[0],"");q=0;for(m=0;m<t.length;m++){var r=t[m];z=r.name.replace(this.filters[1],"");if(n!==r){if(s===z){u=m;q=s.length;break}var p=this._naiveStartingAndEndingLCS(s,z);y=p.length;if(y>q){u=m;q=y}}}var x=q/(Math.min(s.length,z.length));if(x>=this.matchPercentage){var l=this._pair(k.splice(o,1)[0],t.splice(u,1)[0],{silent:true});w.push(l);if(k.length<=0||t.length<=0){return w}}else{o+=1}}return w},_naiveStartingAndEndingLCS:function(n,l){var o="",p="",m=0,k=0;while(m<n.length&&m<l.length){if(n[m]!==l[m]){break}o+=n[m];m+=1}if(m===n.length){return n}if(m===l.length){return l}m=(n.length-1);k=(l.length-1);while(m>=0&&k>=0){if(n[m]!==l[k]){break}p=[n[m],p].join("");m-=1;k-=1}return o+p},_pair:function(k,i,j){j=j||{};var l=this._createPair(k,i,j.name);this.paired.push(l);this.unpaired=_.without(this.unpaired,k,i);if(!j.silent){this.trigger("pair:new",l)}return l},_createPair:function(k,i,j){if(!(k&&i)||(k===i)){throw new Error("Bad pairing: "+[JSON.stringify(k),JSON.stringify(i)])}j=j||this._guessNameForPair(k,i);return{forward:k,name:j,reverse:i}},_guessNameForPair:function(k,i,l){l=(l!==undefined)?(l):(this.removeExtensions);var j=this._naiveStartingAndEndingLCS(k.name.replace(this.filters[0],""),i.name.replace(this.filters[1],""));if(l){var m=j.lastIndexOf(".");if(m>0){j=j.slice(0,m)}}return j||(k.name+" & "+i.name)},_unpair:function(j,i){i=i||{};if(!j){throw new Error("Bad pair: "+JSON.stringify(j))}this.paired=_.without(this.paired,j);this._addToUnpaired(j.forward);this._addToUnpaired(j.reverse);if(!i.silent){this.trigger("pair:unpair",[j])}return j},unpairAll:function(){var i=[];while(this.paired.length){i.push(this._unpair(this.paired[0],{silent:true}))}this.trigger("pair:unpair",i)},_pairToJSON:function(i){return{collection_type:"paired",src:"new_collection",name:i.name,element_identifiers:[{name:"forward",id:i.forward.id,src:"hda"},{name:"reverse",id:i.reverse.id,src:"hda"}]}},createList:function(k){var l=this,j;if(l.historyId){j="/api/histories/"+this.historyId+"/contents/dataset_collections"}var i={type:"dataset_collection",collection_type:"list:paired",name:_.escape(k||l.$(".collection-name").val()),element_identifiers:l.paired.map(function(m){return l._pairToJSON(m)})};return jQuery.ajax(j,{type:"POST",contentType:"application/json",dataType:"json",data:JSON.stringify(i)}).fail(function(o,m,n){l._ajaxErrHandler(o,m,n)}).done(function(m,n,o){l.trigger("collection:created",m,n,o);if(typeof l.oncreate==="function"){l.oncreate.call(this,m,n,o)}})},_ajaxErrHandler:function(l,i,k){this.error(l,i,k);var j=d("An error occurred while creating this collection");if(l){if(l.readyState===0&&l.status===0){j+=": "+d("Galaxy could not be reached and may be updating.")+d(" Try again in a few minutes.")}else{if(l.responseJSON){j+="<br /><pre>"+JSON.stringify(l.responseJSON)+"</pre>"}else{j+=": "+k}}}creator._showAlert(j,"alert-danger")},render:function(i,j){this.$el.empty().html(e.templates.main());this._renderHeader(i);this._renderMiddle(i);this._renderFooter(i);this._addPluginComponents();this.trigger("rendered",this);return this},_renderHeader:function(j,k){var i=this.$(".header").empty().html(e.templates.header()).find(".help-content").prepend($(e.templates.helpContent()));this._renderFilters();return i},_renderFilters:function(){return this.$(".forward-column .column-header input").val(this.filters[0]).add(this.$(".reverse-column .column-header input").val(this.filters[1]))},_renderMiddle:function(j,k){var i=this.$(".middle").empty().html(e.templates.middle());if(this.unpairedPanelHidden){this.$(".unpaired-columns").hide()}else{if(this.pairedPanelHidden){this.$(".paired-columns").hide()}}this._renderUnpaired();this._renderPaired();return i},_renderUnpaired:function(n,o){var l=this,m,j,i=[],k=this._splitByFilters();this.$(".forward-column .title").text([k[0].length,d("unpaired forward")].join(" "));this.$(".forward-column .unpaired-info").text(this._renderUnpairedDisplayStr(this.unpaired.length-k[0].length));this.$(".reverse-column .title").text([k[1].length,d("unpaired reverse")].join(" "));this.$(".reverse-column .unpaired-info").text(this._renderUnpairedDisplayStr(this.unpaired.length-k[1].length));this.$(".unpaired-columns .column-datasets").empty();this.$(".autopair-link").toggle(this.unpaired.length!==0);if(this.unpaired.length===0){this._renderUnpairedEmpty();return}j=k[1].map(function(q,p){if((k[0][p]!==undefined)&&(k[0][p]!==q)){i.push(l._renderPairButton())}return l._renderUnpairedDataset(q)});m=k[0].map(function(p){return l._renderUnpairedDataset(p)});if(!m.length&&!j.length){this._renderUnpairedNotShown();return}this.$(".unpaired-columns .forward-column .column-datasets").append(m).add(this.$(".unpaired-columns .paired-column .column-datasets").append(i)).add(this.$(".unpaired-columns .reverse-column .column-datasets").append(j));this._adjUnpairedOnScrollbar()},_renderUnpairedDisplayStr:function(i){return["(",i," ",d("filtered out"),")"].join("")},_renderUnpairedDataset:function(i){return $("<li/>").attr("id","dataset-"+i.id).addClass("dataset unpaired").attr("draggable",true).addClass(i.selected?"selected":"").append($("<span/>").addClass("dataset-name").text(i.name)).data("dataset",i)},_renderPairButton:function(){return $("<li/>").addClass("dataset unpaired").append($("<span/>").addClass("dataset-name").text(d("Pair these datasets")))},_renderUnpairedEmpty:function(){var i=$('<div class="empty-message"></div>').text("("+d("no remaining unpaired datasets")+")");this.$(".unpaired-columns .paired-column .column-datasets").empty().prepend(i);return i},_renderUnpairedNotShown:function(){var i=$('<div class="empty-message"></div>').text("("+d("no datasets were found matching the current filters")+")");this.$(".unpaired-columns .paired-column .column-datasets").empty().prepend(i);return i},_adjUnpairedOnScrollbar:function(){var l=this.$(".unpaired-columns").last(),m=this.$(".unpaired-columns .reverse-column .dataset").first();if(!m.size()){return}var i=l.offset().left+l.outerWidth(),k=m.offset().left+m.outerWidth(),j=Math.floor(i)-Math.floor(k);this.$(".unpaired-columns .forward-column").css("margin-left",(j>0)?j:0)},_renderPaired:function(j,k){this.$(".paired-column-title .title").text([this.paired.length,d("paired")].join(" "));this.$(".unpair-all-link").toggle(this.paired.length!==0);if(this.paired.length===0){this._renderPairedEmpty();return}else{this.$(".remove-extensions-link").show()}this.$(".paired-columns .column-datasets").empty();var i=this;this.paired.forEach(function(n,l){var m=new f({pair:n});i.$(".paired-columns .column-datasets").append(m.render().$el).append(['<button class="unpair-btn">','<span class="fa fa-unlink" title="',d("Unpair"),'"></span>',"</button>"].join(""))})},_renderPairedEmpty:function(){var i=$('<div class="empty-message"></div>').text("("+d("no paired datasets yet")+")");this.$(".paired-columns .column-datasets").empty().prepend(i);return i},_renderFooter:function(j,k){var i=this.$(".footer").empty().html(e.templates.footer());this.$(".remove-extensions").prop("checked",this.removeExtensions);if(typeof this.oncancel==="function"){this.$(".cancel-create.btn").show()}return i},_addPluginComponents:function(){this._chooseFiltersPopover(".choose-filters-link");this.$(".help-content i").hoverhighlight(".collection-creator","rgba( 64, 255, 255, 1.0 )")},_chooseFiltersPopover:function(i){function j(m,l){return['<button class="filter-choice btn" ','data-forward="',m,'" data-reverse="',l,'">',d("Forward"),": ",m,", ",d("Reverse"),": ",l,"</button>"].join("")}var k=$(_.template(['<div class="choose-filters">','<div class="help">',d("Choose from the following filters to change which unpaired reads are shown in the display"),":</div>",j("_1","_2"),j("_R1","_R2"),"</div>"].join(""))({}));return this.$(i).popover({container:".collection-creator",placement:"bottom",html:true,content:k})},_validationWarning:function(j,i){var k="validation-warning";if(j==="name"){j=this.$(".collection-name").add(this.$(".collection-name-prompt"));this.$(".collection-name").focus().select()}if(i){j=j||this.$("."+k);j.removeClass(k)}else{j.addClass(k)}},_setUpBehaviors:function(){this.once("rendered",function(){this.trigger("rendered:initial",this)});this.on("pair:new",function(){this._renderUnpaired();this._renderPaired();this.$(".paired-columns").scrollTop(8000000)});this.on("pair:unpair",function(i){this._renderUnpaired();this._renderPaired();this.splitView()});this.on("filter-change",function(){this.filters=[this.$(".forward-unpaired-filter input").val(),this.$(".reverse-unpaired-filter input").val()];this._renderFilters();this._renderUnpaired()});this.on("autopair",function(){this._renderUnpaired();this._renderPaired();var i,j=null;if(this.paired.length){j="alert-success";i=this.paired.length+" "+d("pairs created");if(!this.unpaired.length){i+=": "+d("all datasets have been successfully paired");this.hideUnpaired();this.$(".collection-name").focus()}}else{i=d("Could not automatically create any pairs from the given dataset names")}this._showAlert(i,j)});return this},events:{"click .more-help":"_clickMoreHelp","click .less-help":"_clickLessHelp","click .header .alert button":"_hideAlert","click .forward-column .column-title":"_clickShowOnlyUnpaired","click .reverse-column .column-title":"_clickShowOnlyUnpaired","click .unpair-all-link":"_clickUnpairAll","change .forward-unpaired-filter input":function(i){this.trigger("filter-change")},"focus .forward-unpaired-filter input":function(i){$(i.currentTarget).select()},"click .autopair-link":"_clickAutopair","click .choose-filters .filter-choice":"_clickFilterChoice","click .clear-filters-link":"_clearFilters","change .reverse-unpaired-filter input":function(i){this.trigger("filter-change")},"focus .reverse-unpaired-filter input":function(i){$(i.currentTarget).select()},"click .forward-column .dataset.unpaired":"_clickUnpairedDataset","click .reverse-column .dataset.unpaired":"_clickUnpairedDataset","click .paired-column .dataset.unpaired":"_clickPairRow","click .unpaired-columns":"clearSelectedUnpaired","mousedown .unpaired-columns .dataset":"_mousedownUnpaired","click .paired-column-title":"_clickShowOnlyPaired","mousedown .flexible-partition-drag":"_startPartitionDrag","click .paired-columns .dataset.paired":"selectPair","click .paired-columns":"clearSelectedPaired","click .paired-columns .pair-name":"_clickPairName","click .unpair-btn":"_clickUnpair","dragover .paired-columns .column-datasets":"_dragoverPairedColumns","drop .paired-columns .column-datasets":"_dropPairedColumns","pair.dragstart .paired-columns .column-datasets":"_pairDragstart","pair.dragend .paired-columns .column-datasets":"_pairDragend","change .remove-extensions":function(i){this.toggleExtensions()},"change .collection-name":"_changeName","keydown .collection-name":"_nameCheckForEnter","click .cancel-create":function(i){if(typeof this.oncancel==="function"){this.oncancel.call(this)}},"click .create-collection":"_clickCreate"},_clickMoreHelp:function(i){this.$(".main-help").addClass("expanded");this.$(".more-help").hide()},_clickLessHelp:function(i){this.$(".main-help").removeClass("expanded");this.$(".more-help").show()},_showAlert:function(j,i){i=i||"alert-danger";this.$(".main-help").hide();this.$(".header .alert").attr("class","alert alert-dismissable").addClass(i).show().find(".alert-message").html(j)},_hideAlert:function(i){this.$(".main-help").show();this.$(".header .alert").hide()},_clickShowOnlyUnpaired:function(i){if(this.$(".paired-columns").is(":visible")){this.hidePaired()}else{this.splitView()}},_clickShowOnlyPaired:function(i){if(this.$(".unpaired-columns").is(":visible")){this.hideUnpaired()}else{this.splitView()}},hideUnpaired:function(i,j){this.unpairedPanelHidden=true;this.pairedPanelHidden=false;this._renderMiddle(i,j)},hidePaired:function(i,j){this.unpairedPanelHidden=false;this.pairedPanelHidden=true;this._renderMiddle(i,j)},splitView:function(i,j){this.unpairedPanelHidden=this.pairedPanelHidden=false;this._renderMiddle(i,j);return this},_clickUnpairAll:function(i){this.unpairAll()},_clickAutopair:function(i){this.autoPair();this.trigger("autopair")},_clickFilterChoice:function(j){var i=$(j.currentTarget);this.$(".forward-unpaired-filter input").val(i.data("forward"));this.$(".reverse-unpaired-filter input").val(i.data("reverse"));this._hideChooseFilters();this.trigger("filter-change")},_hideChooseFilters:function(){this.$(".choose-filters-link").popover("hide");this.$(".popover").css("display","none")},_clearFilters:function(i){this.$(".forward-unpaired-filter input").val("");this.$(".reverse-unpaired-filter input").val("");this.trigger("filter-change")},_clickUnpairedDataset:function(i){i.stopPropagation();return this.toggleSelectUnpaired($(i.currentTarget))},toggleSelectUnpaired:function(k,j){j=j||{};var l=k.data("dataset"),i=j.force!==undefined?j.force:!k.hasClass("selected");if(!k.size()||l===undefined){return k}if(i){k.addClass("selected");if(!j.waitToPair){this.pairAllSelected()}}else{k.removeClass("selected")}return k},pairAllSelected:function(j){j=j||{};var k=this,l=[],i=[],m=[];k.$(".unpaired-columns .forward-column .dataset.selected").each(function(){l.push($(this).data("dataset"))});k.$(".unpaired-columns .reverse-column .dataset.selected").each(function(){i.push($(this).data("dataset"))});l.length=i.length=Math.min(l.length,i.length);l.forEach(function(o,n){try{m.push(k._pair(o,i[n],{silent:true}))}catch(p){k.error(p)}});if(m.length&&!j.silent){this.trigger("pair:new",m)}return m},clearSelectedUnpaired:function(){this.$(".unpaired-columns .dataset.selected").removeClass("selected")},_mousedownUnpaired:function(k){if(k.shiftKey){var j=this,i=$(k.target).addClass("selected"),l=function(m){j.$(m.target).filter(".dataset").addClass("selected")};i.parent().on("mousemove",l);$(document).one("mouseup",function(m){i.parent().off("mousemove",l);j.pairAllSelected()})}},_clickPairRow:function(k){var l=$(k.currentTarget).index(),j=$(".unpaired-columns .forward-column .dataset").eq(l).data("dataset"),i=$(".unpaired-columns .reverse-column .dataset").eq(l).data("dataset");this._pair(j,i)},_startPartitionDrag:function(j){var i=this,m=j.pageY;$("body").css("cursor","ns-resize");i.$(".flexible-partition-drag").css("color","black");function l(n){i.$(".flexible-partition-drag").css("color","");$("body").css("cursor","").unbind("mousemove",k)}function k(n){var o=n.pageY-m;if(!i.adjPartition(o)){$("body").trigger("mouseup")}i._adjUnpairedOnScrollbar();m+=o}$("body").mousemove(k);$("body").one("mouseup",l)},adjPartition:function(j){var i=this.$(".unpaired-columns"),k=this.$(".paired-columns"),l=parseInt(i.css("height"),10),m=parseInt(k.css("height"),10);l=Math.max(10,l+j);m=m-j;var n=j<0;if(n){if(this.unpairedPanelHidden){return false}else{if(l<=10){this.hideUnpaired();return false}}}else{if(this.unpairedPanelHidden){i.show();this.unpairedPanelHidden=false}}if(!n){if(this.pairedPanelHidden){return false}else{if(m<=15){this.hidePaired();return false}}}else{if(this.pairedPanelHidden){k.show();this.pairedPanelHidden=false}}i.css({height:l+"px",flex:"0 0 auto"});return true},selectPair:function(i){i.stopPropagation();$(i.currentTarget).toggleClass("selected")},clearSelectedPaired:function(i){this.$(".paired-columns .dataset.selected").removeClass("selected")},_clickPairName:function(l){l.stopPropagation();var n=$(l.currentTarget),k=n.parent().parent(),j=k.index(".dataset.paired"),m=this.paired[j],i=prompt("Enter a new name for the pair:",m.name);if(i){m.name=i;m.customizedName=true;n.text(m.name)}},_clickUnpair:function(j){var i=Math.floor($(j.currentTarget).index(".unpair-btn"));this._unpair(this.paired[i])},_dragoverPairedColumns:function(l){l.preventDefault();var j=this.$(".paired-columns .column-datasets");this._checkForAutoscroll(j,l.originalEvent.clientY);var k=this._getNearestPairedDatasetLi(l.originalEvent.clientY);$(".paired-drop-placeholder").remove();var i=$('<div class="paired-drop-placeholder"></div>');if(!k.size()){j.append(i)}else{k.before(i)}},_checkForAutoscroll:function(i,o){var m=2;var n=i.offset(),l=i.scrollTop(),j=o-n.top,k=(n.top+i.outerHeight())-o;if(j>=0&&j<this.autoscrollDist){i.scrollTop(l-m)}else{if(k>=0&&k<this.autoscrollDist){i.scrollTop(l+m)}}},_getNearestPairedDatasetLi:function(p){var m=4,k=this.$(".paired-columns .column-datasets li").toArray();for(var l=0;l<k.length;l++){var o=$(k[l]),n=o.offset().top,j=Math.floor(o.outerHeight()/2)+m;if(n+j>p&&n-j<p){return o}}return $()},_dropPairedColumns:function(j){j.preventDefault();j.dataTransfer.dropEffect="move";var i=this._getNearestPairedDatasetLi(j.originalEvent.clientY);if(i.size()){this.$dragging.insertBefore(i)}else{this.$dragging.insertAfter(this.$(".paired-columns .unpair-btn").last())}this._syncPairsToDom();return false},_syncPairsToDom:function(){var i=[];this.$(".paired-columns .dataset.paired").each(function(){i.push($(this).data("pair"))});this.paired=i;this._renderPaired()},_pairDragstart:function(j,k){k.$el.addClass("selected");var i=this.$(".paired-columns .dataset.selected");this.$dragging=i},_pairDragend:function(i,j){$(".paired-drop-placeholder").remove();this.$dragging=null},toggleExtensions:function(j){var i=this;i.removeExtensions=(j!==undefined)?(j):(!i.removeExtensions);_.each(i.paired,function(k){if(k.customizedName){return}k.name=i._guessNameForPair(k.forward,k.reverse)});i._renderPaired();i._renderFooter()},_changeName:function(i){this._validationWarning("name",!!this._getName())},_nameCheckForEnter:function(i){if(i.keyCode===13){this._clickCreate()}},_getName:function(){return _.escape(this.$(".collection-name").val())},_clickCreate:function(j){var i=this._getName();if(!i){this._validationWarning("name")}else{this.createList()}},_printList:function(j){var i=this;_.each(j,function(k){if(j===i.paired){i._printPair(k)}else{}})},_printPair:function(i){this.debug(i.forward.name,i.reverse.name,": ->",i.name)},toString:function(){return"PairedCollectionCreator"}});e.templates=e.templates||{main:_.template(['<div class="header flex-row no-flex"></div>','<div class="middle flex-row flex-row-container"></div>','<div class="footer flex-row no-flex">'].join("")),header:_.template(['<div class="main-help well clear">','<a class="more-help" href="javascript:void(0);">',d("More help"),"</a>",'<div class="help-content">','<a class="less-help" href="javascript:void(0);">',d("Less"),"</a>","</div>","</div>",'<div class="alert alert-dismissable">','<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>','<span class="alert-message"></span>',"</div>",'<div class="column-headers vertically-spaced flex-column-container">','<div class="forward-column flex-column column">','<div class="column-header">','<div class="column-title">','<span class="title">',d("Unpaired forward"),"</span>",'<span class="title-info unpaired-info"></span>',"</div>",'<div class="unpaired-filter forward-unpaired-filter pull-left">','<input class="search-query" placeholder="',d("Filter this list"),'" />',"</div>","</div>","</div>",'<div class="paired-column flex-column no-flex column">','<div class="column-header">','<a class="choose-filters-link" href="javascript:void(0)">',d("Choose filters"),"</a>",'<a class="clear-filters-link" href="javascript:void(0);">',d("Clear filters"),"</a><br />",'<a class="autopair-link" href="javascript:void(0);">',d("Auto-pair"),"</a>","</div>","</div>",'<div class="reverse-column flex-column column">','<div class="column-header">','<div class="column-title">','<span class="title">',d("Unpaired reverse"),"</span>",'<span class="title-info unpaired-info"></span>',"</div>",'<div class="unpaired-filter reverse-unpaired-filter pull-left">','<input class="search-query" placeholder="',d("Filter this list"),'" />',"</div>","</div>","</div>","</div>"].join("")),middle:_.template(['<div class="unpaired-columns flex-column-container scroll-container flex-row">','<div class="forward-column flex-column column">','<ol class="column-datasets"></ol>',"</div>",'<div class="paired-column flex-column no-flex column">','<ol class="column-datasets"></ol>',"</div>",'<div class="reverse-column flex-column column">','<ol class="column-datasets"></ol>',"</div>","</div>",'<div class="flexible-partition">','<div class="flexible-partition-drag" title="',d("Drag to change"),'"></div>','<div class="column-header">','<div class="column-title paired-column-title">','<span class="title"></span>',"</div>",'<a class="unpair-all-link" href="javascript:void(0);">',d("Unpair all"),"</a>","</div>","</div>",'<div class="paired-columns flex-column-container scroll-container flex-row">','<ol class="column-datasets"></ol>',"</div>"].join("")),footer:_.template(['<div class="attributes clear">','<div class="clear">','<label class="remove-extensions-prompt pull-right">',d("Remove file extensions from pair names"),"?",'<input class="remove-extensions pull-right" type="checkbox" />',"</label>","</div>",'<div class="clear">','<input class="collection-name form-control pull-right" ','placeholder="',d("Enter a name for your new list"),'" />','<div class="collection-name-prompt pull-right">',d("Name"),":</div>","</div>","</div>",'<div class="actions clear vertically-spaced">','<div class="other-options pull-left">','<button class="cancel-create btn" tabindex="-1">',d("Cancel"),"</button>",'<div class="create-other btn-group dropup">','<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">',d("Create a different kind of collection"),' <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">','<li><a href="#">',d("Create a <i>single</i> pair"),"</a></li>",'<li><a href="#">',d("Create a list of <i>unpaired</i> datasets"),"</a></li>","</ul>","</div>","</div>",'<div class="main-options pull-right">','<button class="create-collection btn btn-primary">',d("Create list"),"</button>","</div>","</div>"].join("")),helpContent:_.template(["<p>",d(["Collections of paired datasets are ordered lists of dataset pairs (often forward and reverse reads). ","These collections can be passed to tools and workflows in order to have analyses done on each member of ","the entire group. This interface allows you to create a collection, choose which datasets are paired, ","and re-order the final collection."].join("")),"</p>","<p>",d(['Unpaired datasets are shown in the <i data-target=".unpaired-columns">unpaired section</i> ',"(hover over the underlined words to highlight below). ",'Paired datasets are shown in the <i data-target=".paired-columns">paired section</i>.',"<ul>To pair datasets, you can:","<li>Click a dataset in the ",'<i data-target=".unpaired-columns .forward-column .column-datasets,','.unpaired-columns .forward-column">forward column</i> ',"to select it then click a dataset in the ",'<i data-target=".unpaired-columns .reverse-column .column-datasets,','.unpaired-columns .reverse-column">reverse column</i>.',"</li>",'<li>Click one of the "Pair these datasets" buttons in the ','<i data-target=".unpaired-columns .paired-column .column-datasets,','.unpaired-columns .paired-column">middle column</i> ',"to pair the datasets in a particular row.","</li>",'<li>Click <i data-target=".autopair-link">"Auto-pair"</i> ',"to have your datasets automatically paired based on name.","</li>","</ul>"].join("")),"</p>","<p>",d(["<ul>You can filter what is shown in the unpaired sections by:","<li>Entering partial dataset names in either the ",'<i data-target=".forward-unpaired-filter input">forward filter</i> or ','<i data-target=".reverse-unpaired-filter input">reverse filter</i>.',"</li>","<li>Choosing from a list of preset filters by clicking the ",'<i data-target=".choose-filters-link">"Choose filters" link</i>.',"</li>","<li>Entering regular expressions to match dataset names. See: ",'<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expre…"',' target="_blank">MDN\'s JavaScript Regular Expression Tutorial</a>. ',"Note: forward slashes (\\) are not needed.","</li>","<li>Clearing the filters by clicking the ",'<i data-target=".clear-filters-link">"Clear filters" link</i>.',"</li>","</ul>"].join("")),"</p>","<p>",d(["To unpair individual dataset pairs, click the ",'<i data-target=".unpair-btn">unpair buttons ( <span class="fa fa-unlink"></span> )</i>. ','Click the <i data-target=".unpair-all-link">"Unpair all" link</i> to unpair all pairs.'].join("")),"</p>","<p>",d(['You can include or remove the file extensions (e.g. ".fastq") from your pair names by toggling the ','<i data-target=".remove-extensions-prompt">"Remove file extensions from pair names?"</i> control.'].join("")),"</p>","<p>",d(['Once your collection is complete, enter a <i data-target=".collection-name">name</i> and ','click <i data-target=".create-collection">"Create list"</i>. ',"(Note: you do not have to pair all unpaired datasets to finish.)"].join("")),"</p>"].join(""))};(function(){jQuery.fn.extend({hoverhighlight:function i(k,j){k=k||"body";if(!this.size()){return this}$(this).each(function(){var m=$(this),l=m.data("target");if(l){m.mouseover(function(n){$(l,k).css({background:j})}).mouseout(function(n){$(l).css({background:""})})}});return this}})}());var b=function c(k,i){console.log(k);i=_.defaults(i||{},{datasets:k,oncancel:function(){Galaxy.modal.hide()},oncreate:function(){Galaxy.modal.hide();Galaxy.currHistoryPanel.refreshContents()}});if(!window.Galaxy||!Galaxy.modal){throw new Error("Galaxy or Galaxy.modal not found")}var j=new e(i).render();Galaxy.modal.show({title:"Create a collection of paired datasets",body:j.$el,width:"80%",height:"800px",closing_events:true});window.PCC=j;return j};return{PairedCollectionCreator:e,pairedCollectionCreatorModal:b}});
\ No newline at end of file
+define(["utils/levenshtein","utils/natural-sort","mvc/base-mvc","utils/localization"],function(h,b,f,c){var i=Backbone.View.extend(f.LoggableMixin).extend({tagName:"li",className:"dataset paired",initialize:function(l){this.pair=l.pair||{}},template:_.template(['<span class="forward-dataset-name flex-column"><%= pair.forward.name %></span>','<span class="pair-name-column flex-column">','<span class="pair-name"><%= pair.name %></span>',"</span>",'<span class="reverse-dataset-name flex-column"><%= pair.reverse.name %></span>'].join("")),render:function(){this.$el.attr("draggable",true).data("pair",this.pair).html(this.template({pair:this.pair})).addClass("flex-column-container");return this},events:{dragstart:"_dragstart",dragend:"_dragend",dragover:"_sendToParent",drop:"_sendToParent"},_dragstart:function(l){l.currentTarget.style.opacity="0.4";if(l.originalEvent){l=l.originalEvent}l.dataTransfer.effectAllowed="move";l.dataTransfer.setData("text/plain",JSON.stringify(this.pair));this.$el.parent().trigger("pair.dragstart",[this])},_dragend:function(l){l.currentTarget.style.opacity="1.0";this.$el.parent().trigger("pair.dragend",[this])},_sendToParent:function(l){this.$el.parent().trigger(l)},toString:function(){return"PairView("+this.pair.name+")"}});function g(m){m=m||{};m.createPair=m.createPair||function l(r){this.debug("creating pair:",r.listA[r.indexA].name,r.listB[r.indexB].name);r=r||{};return this._pair(r.listA.splice(r.indexA,1)[0],r.listB.splice(r.indexB,1)[0],{silent:true})};var o=[];function q(){if(!o.length){o=[new RegExp(this.filters[0]),new RegExp(this.filters[1])]}return o}m.preprocessMatch=m.preprocessMatch||function n(s){var r=q.call(this);return _.extend(s,{matchTo:s.matchTo.name.replace(r[0],""),possible:s.possible.name.replace(r[1],"")})};return function p(t){this.debug("autopair _strategy ---------------------------");t=t||{};var r=t.listA,A=t.listB,z=0,y,v={score:0,index:null},x=[];this.debug("starting list lens:",r.length,A.length);this.debug("bestMatch (starting):",JSON.stringify(v,null," "));while(z<r.length){var w=r[z];v.score=0;for(y=0;y<A.length;y++){var u=A[y];this.debug(z+":"+w.name);this.debug(y+":"+u.name);if(r[z]!==A[y]){v=m.match.call(this,m.preprocessMatch.call(this,{matchTo:w,possible:u,index:y,bestMatch:v}));this.debug("bestMatch:",JSON.stringify(v,null," "));if(v.score===1){this.debug("breaking early due to perfect match");break}}}var s=m.scoreThreshold.call(this);this.debug("scoreThreshold:",s);this.debug("bestMatch.score:",v.score);if(v.score>=s){this.debug("creating pair");x.push(m.createPair.call(this,{listA:r,indexA:z,listB:A,indexB:v.index}));this.debug("list lens now:",r.length,A.length)}else{z+=1}if(!r.length||!A.length){return x}}this.debug("paired:",JSON.stringify(x,null," "));this.debug("autopair _strategy ---------------------------");return x}}var k=Backbone.View.extend(f.LoggableMixin).extend({className:"collection-creator flex-row-container",initialize:function(l){l=_.defaults(l,{datasets:[],filters:this.DEFAULT_FILTERS,automaticallyPair:true,strategy:"lcs",matchPercentage:0.9,twoPassAutopairing:true});this.initialList=l.datasets;this.historyId=l.historyId;this.filters=this.commonFilters[l.filters]||this.commonFilters[this.DEFAULT_FILTERS];if(_.isArray(l.filters)){this.filters=l.filters}this.automaticallyPair=l.automaticallyPair;this.strategy=this.strategies[l.strategy]||this.strategies[this.DEFAULT_STRATEGY];if(_.isFunction(l.strategy)){this.strategy=l.strategy}this.matchPercentage=l.matchPercentage;this.twoPassAutopairing=l.twoPassAutopairing;this.removeExtensions=true;this.oncancel=l.oncancel;this.oncreate=l.oncreate;this.autoscrollDist=l.autoscrollDist||24;this.unpairedPanelHidden=false;this.pairedPanelHidden=false;this.$dragging=null;this._setUpBehaviors();this._dataSetUp()},commonFilters:{none:["",""],illumina:["_1","_2"]},DEFAULT_FILTERS:"illumina",strategies:{simple:"autopairSimple",lcs:"autopairLCS",levenshtein:"autopairLevenshtein"},DEFAULT_STRATEGY:"lcs",_dataSetUp:function(){this.paired=[];this.unpaired=[];this.selectedIds=[];this._sortInitialList();this._ensureIds();this.unpaired=this.initialList.slice(0);if(this.automaticallyPair){this.autoPair();this.once("rendered:initial",function(){this.trigger("autopair")})}},_sortInitialList:function(){this._sortDatasetList(this.initialList)},_sortDatasetList:function(l){l.sort(function(n,m){return b(n.name,m.name)});return l},_ensureIds:function(){this.initialList.forEach(function(l){if(!l.hasOwnProperty("id")){l.id=_.uniqueId()}});return this.initialList},_splitByFilters:function(){var o=this.filters.map(function(p){return new RegExp(p)}),m=[[],[]];function n(p,q){return q.test(p.name)}this.unpaired.forEach(function l(p){o.forEach(function(r,q){if(n(p,r)){m[q].push(p)}})});return m},_addToUnpaired:function(m){var l=function(n,p){if(n===p){return n}var o=Math.floor((p-n)/2)+n,q=b(m.name,this.unpaired[o].name);if(q<0){return l(n,o)}else{if(q>0){return l(o+1,p)}}while(this.unpaired[o]&&this.unpaired[o].name===m.name){o++}return o}.bind(this);this.unpaired.splice(l(0,this.unpaired.length),0,m)},autoPair:function(n){var m=this._splitByFilters(),l=[];if(this.twoPassAutopairing){l=this.autopairSimple({listA:m[0],listB:m[1]});m=this._splitByFilters()}n=n||this.strategy;m=this._splitByFilters();l=l.concat(this[n].call(this,{listA:m[0],listB:m[1]}));return l},autopairSimple:g({scoreThreshold:function(){return 1},match:function j(l){l=l||{};if(l.matchTo===l.possible){return{index:l.index,score:1}}return l.bestMatch}}),autopairLevenshtein:g({scoreThreshold:function(){return this.matchPercentage},match:function e(m){m=m||{};var n=h(m.matchTo,m.possible),l=1-(n/(Math.max(m.matchTo.length,m.possible.length)));if(l>m.bestMatch.score){return{index:m.index,score:l}}return m.bestMatch}}),autopairLCS:g({scoreThreshold:function(){return this.matchPercentage},match:function e(n){n=n||{};var l=this._naiveStartingAndEndingLCS(n.matchTo,n.possible).length,m=l/(Math.max(n.matchTo.length,n.possible.length));if(m>n.bestMatch.score){return{index:n.index,score:m}}return n.bestMatch}}),_naiveStartingAndEndingLCS:function(o,m){var p="",q="",n=0,l=0;while(n<o.length&&n<m.length){if(o[n]!==m[n]){break}p+=o[n];n+=1}if(n===o.length){return o}if(n===m.length){return m}n=(o.length-1);l=(m.length-1);while(n>=0&&l>=0){if(o[n]!==m[l]){break}q=[o[n],q].join("");n-=1;l-=1}return p+q},_pair:function(n,l,m){m=m||{};var o=this._createPair(n,l,m.name);this.paired.push(o);this.unpaired=_.without(this.unpaired,n,l);if(!m.silent){this.trigger("pair:new",o)}return o},_createPair:function(n,l,m){if(!(n&&l)||(n===l)){throw new Error("Bad pairing: "+[JSON.stringify(n),JSON.stringify(l)])}m=m||this._guessNameForPair(n,l);return{forward:n,name:m,reverse:l}},_guessNameForPair:function(n,l,o){o=(o!==undefined)?(o):(this.removeExtensions);var m=this._naiveStartingAndEndingLCS(n.name.replace(this.filters[0],""),l.name.replace(this.filters[1],""));if(o){var p=m.lastIndexOf(".");if(p>0){m=m.slice(0,p)}}return m||(n.name+" & "+l.name)},_unpair:function(m,l){l=l||{};if(!m){throw new Error("Bad pair: "+JSON.stringify(m))}this.paired=_.without(this.paired,m);this._addToUnpaired(m.forward);this._addToUnpaired(m.reverse);if(!l.silent){this.trigger("pair:unpair",[m])}return m},unpairAll:function(){var l=[];while(this.paired.length){l.push(this._unpair(this.paired[0],{silent:true}))}this.trigger("pair:unpair",l)},_pairToJSON:function(l){return{collection_type:"paired",src:"new_collection",name:l.name,element_identifiers:[{name:"forward",id:l.forward.id,src:"hda"},{name:"reverse",id:l.reverse.id,src:"hda"}]}},createList:function(n){var o=this,m;if(o.historyId){m="/api/histories/"+this.historyId+"/contents/dataset_collections"}var l={type:"dataset_collection",collection_type:"list:paired",name:_.escape(n||o.$(".collection-name").val()),element_identifiers:o.paired.map(function(p){return o._pairToJSON(p)})};return jQuery.ajax(m,{type:"POST",contentType:"application/json",dataType:"json",data:JSON.stringify(l)}).fail(function(r,p,q){o._ajaxErrHandler(r,p,q)}).done(function(p,q,r){o.trigger("collection:created",p,q,r);if(typeof o.oncreate==="function"){o.oncreate.call(this,p,q,r)}})},_ajaxErrHandler:function(o,l,n){this.error(o,l,n);var m=c("An error occurred while creating this collection");if(o){if(o.readyState===0&&o.status===0){m+=": "+c("Galaxy could not be reached and may be updating.")+c(" Try again in a few minutes.")}else{if(o.responseJSON){m+="<br /><pre>"+JSON.stringify(o.responseJSON)+"</pre>"}else{m+=": "+n}}}creator._showAlert(m,"alert-danger")},render:function(l,m){this.$el.empty().html(k.templates.main());this._renderHeader(l);this._renderMiddle(l);this._renderFooter(l);this._addPluginComponents();this.trigger("rendered",this);return this},_renderHeader:function(m,n){var l=this.$(".header").empty().html(k.templates.header()).find(".help-content").prepend($(k.templates.helpContent()));this._renderFilters();return l},_renderFilters:function(){return this.$(".forward-column .column-header input").val(this.filters[0]).add(this.$(".reverse-column .column-header input").val(this.filters[1]))},_renderMiddle:function(m,n){var l=this.$(".middle").empty().html(k.templates.middle());if(this.unpairedPanelHidden){this.$(".unpaired-columns").hide()}else{if(this.pairedPanelHidden){this.$(".paired-columns").hide()}}this._renderUnpaired();this._renderPaired();return l},_renderUnpaired:function(q,r){var o=this,p,m,l=[],n=this._splitByFilters();this.$(".forward-column .title").text([n[0].length,c("unpaired forward")].join(" "));this.$(".forward-column .unpaired-info").text(this._renderUnpairedDisplayStr(this.unpaired.length-n[0].length));this.$(".reverse-column .title").text([n[1].length,c("unpaired reverse")].join(" "));this.$(".reverse-column .unpaired-info").text(this._renderUnpairedDisplayStr(this.unpaired.length-n[1].length));this.$(".unpaired-columns .column-datasets").empty();this.$(".autopair-link").toggle(this.unpaired.length!==0);if(this.unpaired.length===0){this._renderUnpairedEmpty();return}m=n[1].map(function(t,s){if((n[0][s]!==undefined)&&(n[0][s]!==t)){l.push(o._renderPairButton())}return o._renderUnpairedDataset(t)});p=n[0].map(function(s){return o._renderUnpairedDataset(s)});if(!p.length&&!m.length){this._renderUnpairedNotShown();return}this.$(".unpaired-columns .forward-column .column-datasets").append(p).add(this.$(".unpaired-columns .paired-column .column-datasets").append(l)).add(this.$(".unpaired-columns .reverse-column .column-datasets").append(m));this._adjUnpairedOnScrollbar()},_renderUnpairedDisplayStr:function(l){return["(",l," ",c("filtered out"),")"].join("")},_renderUnpairedDataset:function(l){return $("<li/>").attr("id","dataset-"+l.id).addClass("dataset unpaired").attr("draggable",true).addClass(l.selected?"selected":"").append($("<span/>").addClass("dataset-name").text(l.name)).data("dataset",l)},_renderPairButton:function(){return $("<li/>").addClass("dataset unpaired").append($("<span/>").addClass("dataset-name").text(c("Pair these datasets")))},_renderUnpairedEmpty:function(){var l=$('<div class="empty-message"></div>').text("("+c("no remaining unpaired datasets")+")");this.$(".unpaired-columns .paired-column .column-datasets").empty().prepend(l);return l},_renderUnpairedNotShown:function(){var l=$('<div class="empty-message"></div>').text("("+c("no datasets were found matching the current filters")+")");this.$(".unpaired-columns .paired-column .column-datasets").empty().prepend(l);return l},_adjUnpairedOnScrollbar:function(){var o=this.$(".unpaired-columns").last(),p=this.$(".unpaired-columns .reverse-column .dataset").first();if(!p.size()){return}var l=o.offset().left+o.outerWidth(),n=p.offset().left+p.outerWidth(),m=Math.floor(l)-Math.floor(n);this.$(".unpaired-columns .forward-column").css("margin-left",(m>0)?m:0)},_renderPaired:function(m,n){this.$(".paired-column-title .title").text([this.paired.length,c("paired")].join(" "));this.$(".unpair-all-link").toggle(this.paired.length!==0);if(this.paired.length===0){this._renderPairedEmpty();return}else{this.$(".remove-extensions-link").show()}this.$(".paired-columns .column-datasets").empty();var l=this;this.paired.forEach(function(q,o){var p=new i({pair:q});l.$(".paired-columns .column-datasets").append(p.render().$el).append(['<button class="unpair-btn">','<span class="fa fa-unlink" title="',c("Unpair"),'"></span>',"</button>"].join(""))})},_renderPairedEmpty:function(){var l=$('<div class="empty-message"></div>').text("("+c("no paired datasets yet")+")");this.$(".paired-columns .column-datasets").empty().prepend(l);return l},_renderFooter:function(m,n){var l=this.$(".footer").empty().html(k.templates.footer());this.$(".remove-extensions").prop("checked",this.removeExtensions);if(typeof this.oncancel==="function"){this.$(".cancel-create.btn").show()}return l},_addPluginComponents:function(){this._chooseFiltersPopover(".choose-filters-link");this.$(".help-content i").hoverhighlight(".collection-creator","rgba( 64, 255, 255, 1.0 )")},_chooseFiltersPopover:function(l){function m(p,o){return['<button class="filter-choice btn" ','data-forward="',p,'" data-reverse="',o,'">',c("Forward"),": ",p,", ",c("Reverse"),": ",o,"</button>"].join("")}var n=$(_.template(['<div class="choose-filters">','<div class="help">',c("Choose from the following filters to change which unpaired reads are shown in the display"),":</div>",m("_1","_2"),m("_R1","_R2"),"</div>"].join(""))({}));return this.$(l).popover({container:".collection-creator",placement:"bottom",html:true,content:n})},_validationWarning:function(m,l){var n="validation-warning";if(m==="name"){m=this.$(".collection-name").add(this.$(".collection-name-prompt"));this.$(".collection-name").focus().select()}if(l){m=m||this.$("."+n);m.removeClass(n)}else{m.addClass(n)}},_setUpBehaviors:function(){this.once("rendered",function(){this.trigger("rendered:initial",this)});this.on("pair:new",function(){this._renderUnpaired();this._renderPaired();this.$(".paired-columns").scrollTop(8000000)});this.on("pair:unpair",function(l){this._renderUnpaired();this._renderPaired();this.splitView()});this.on("filter-change",function(){this.filters=[this.$(".forward-unpaired-filter input").val(),this.$(".reverse-unpaired-filter input").val()];this._renderFilters();this._renderUnpaired()});this.on("autopair",function(){this._renderUnpaired();this._renderPaired();var l,m=null;if(this.paired.length){m="alert-success";l=this.paired.length+" "+c("pairs created");if(!this.unpaired.length){l+=": "+c("all datasets have been successfully paired");this.hideUnpaired();this.$(".collection-name").focus()}}else{l=c("Could not automatically create any pairs from the given dataset names")}this._showAlert(l,m)});return this},events:{"click .more-help":"_clickMoreHelp","click .less-help":"_clickLessHelp","click .header .alert button":"_hideAlert","click .forward-column .column-title":"_clickShowOnlyUnpaired","click .reverse-column .column-title":"_clickShowOnlyUnpaired","click .unpair-all-link":"_clickUnpairAll","change .forward-unpaired-filter input":function(l){this.trigger("filter-change")},"focus .forward-unpaired-filter input":function(l){$(l.currentTarget).select()},"click .autopair-link":"_clickAutopair","click .choose-filters .filter-choice":"_clickFilterChoice","click .clear-filters-link":"_clearFilters","change .reverse-unpaired-filter input":function(l){this.trigger("filter-change")},"focus .reverse-unpaired-filter input":function(l){$(l.currentTarget).select()},"click .forward-column .dataset.unpaired":"_clickUnpairedDataset","click .reverse-column .dataset.unpaired":"_clickUnpairedDataset","click .paired-column .dataset.unpaired":"_clickPairRow","click .unpaired-columns":"clearSelectedUnpaired","mousedown .unpaired-columns .dataset":"_mousedownUnpaired","click .paired-column-title":"_clickShowOnlyPaired","mousedown .flexible-partition-drag":"_startPartitionDrag","click .paired-columns .dataset.paired":"selectPair","click .paired-columns":"clearSelectedPaired","click .paired-columns .pair-name":"_clickPairName","click .unpair-btn":"_clickUnpair","dragover .paired-columns .column-datasets":"_dragoverPairedColumns","drop .paired-columns .column-datasets":"_dropPairedColumns","pair.dragstart .paired-columns .column-datasets":"_pairDragstart","pair.dragend .paired-columns .column-datasets":"_pairDragend","change .remove-extensions":function(l){this.toggleExtensions()},"change .collection-name":"_changeName","keydown .collection-name":"_nameCheckForEnter","click .cancel-create":function(l){if(typeof this.oncancel==="function"){this.oncancel.call(this)}},"click .create-collection":"_clickCreate"},_clickMoreHelp:function(l){this.$(".main-help").addClass("expanded");this.$(".more-help").hide()},_clickLessHelp:function(l){this.$(".main-help").removeClass("expanded");this.$(".more-help").show()},_showAlert:function(m,l){l=l||"alert-danger";this.$(".main-help").hide();this.$(".header .alert").attr("class","alert alert-dismissable").addClass(l).show().find(".alert-message").html(m)},_hideAlert:function(l){this.$(".main-help").show();this.$(".header .alert").hide()},_clickShowOnlyUnpaired:function(l){if(this.$(".paired-columns").is(":visible")){this.hidePaired()}else{this.splitView()}},_clickShowOnlyPaired:function(l){if(this.$(".unpaired-columns").is(":visible")){this.hideUnpaired()}else{this.splitView()}},hideUnpaired:function(l,m){this.unpairedPanelHidden=true;this.pairedPanelHidden=false;this._renderMiddle(l,m)},hidePaired:function(l,m){this.unpairedPanelHidden=false;this.pairedPanelHidden=true;this._renderMiddle(l,m)},splitView:function(l,m){this.unpairedPanelHidden=this.pairedPanelHidden=false;this._renderMiddle(l,m);return this},_clickUnpairAll:function(l){this.unpairAll()},_clickAutopair:function(l){this.autoPair();this.trigger("autopair")},_clickFilterChoice:function(m){var l=$(m.currentTarget);this.$(".forward-unpaired-filter input").val(l.data("forward"));this.$(".reverse-unpaired-filter input").val(l.data("reverse"));this._hideChooseFilters();this.trigger("filter-change")},_hideChooseFilters:function(){this.$(".choose-filters-link").popover("hide");this.$(".popover").css("display","none")},_clearFilters:function(l){this.$(".forward-unpaired-filter input").val("");this.$(".reverse-unpaired-filter input").val("");this.trigger("filter-change")},_clickUnpairedDataset:function(l){l.stopPropagation();return this.toggleSelectUnpaired($(l.currentTarget))},toggleSelectUnpaired:function(n,m){m=m||{};var o=n.data("dataset"),l=m.force!==undefined?m.force:!n.hasClass("selected");if(!n.size()||o===undefined){return n}if(l){n.addClass("selected");if(!m.waitToPair){this.pairAllSelected()}}else{n.removeClass("selected")}return n},pairAllSelected:function(m){m=m||{};var n=this,o=[],l=[],p=[];n.$(".unpaired-columns .forward-column .dataset.selected").each(function(){o.push($(this).data("dataset"))});n.$(".unpaired-columns .reverse-column .dataset.selected").each(function(){l.push($(this).data("dataset"))});o.length=l.length=Math.min(o.length,l.length);o.forEach(function(r,q){try{p.push(n._pair(r,l[q],{silent:true}))}catch(s){n.error(s)}});if(p.length&&!m.silent){this.trigger("pair:new",p)}return p},clearSelectedUnpaired:function(){this.$(".unpaired-columns .dataset.selected").removeClass("selected")},_mousedownUnpaired:function(n){if(n.shiftKey){var m=this,l=$(n.target).addClass("selected"),o=function(p){m.$(p.target).filter(".dataset").addClass("selected")};l.parent().on("mousemove",o);$(document).one("mouseup",function(p){l.parent().off("mousemove",o);m.pairAllSelected()})}},_clickPairRow:function(n){var o=$(n.currentTarget).index(),m=$(".unpaired-columns .forward-column .dataset").eq(o).data("dataset"),l=$(".unpaired-columns .reverse-column .dataset").eq(o).data("dataset");this._pair(m,l)},_startPartitionDrag:function(m){var l=this,p=m.pageY;$("body").css("cursor","ns-resize");l.$(".flexible-partition-drag").css("color","black");function o(q){l.$(".flexible-partition-drag").css("color","");$("body").css("cursor","").unbind("mousemove",n)}function n(q){var r=q.pageY-p;if(!l.adjPartition(r)){$("body").trigger("mouseup")}l._adjUnpairedOnScrollbar();p+=r}$("body").mousemove(n);$("body").one("mouseup",o)},adjPartition:function(m){var l=this.$(".unpaired-columns"),n=this.$(".paired-columns"),o=parseInt(l.css("height"),10),p=parseInt(n.css("height"),10);o=Math.max(10,o+m);p=p-m;var q=m<0;if(q){if(this.unpairedPanelHidden){return false}else{if(o<=10){this.hideUnpaired();return false}}}else{if(this.unpairedPanelHidden){l.show();this.unpairedPanelHidden=false}}if(!q){if(this.pairedPanelHidden){return false}else{if(p<=15){this.hidePaired();return false}}}else{if(this.pairedPanelHidden){n.show();this.pairedPanelHidden=false}}l.css({height:o+"px",flex:"0 0 auto"});return true},selectPair:function(l){l.stopPropagation();$(l.currentTarget).toggleClass("selected")},clearSelectedPaired:function(l){this.$(".paired-columns .dataset.selected").removeClass("selected")},_clickPairName:function(o){o.stopPropagation();var q=$(o.currentTarget),n=q.parent().parent(),m=n.index(".dataset.paired"),p=this.paired[m],l=prompt("Enter a new name for the pair:",p.name);if(l){p.name=l;p.customizedName=true;q.text(p.name)}},_clickUnpair:function(m){var l=Math.floor($(m.currentTarget).index(".unpair-btn"));this._unpair(this.paired[l])},_dragoverPairedColumns:function(o){o.preventDefault();var m=this.$(".paired-columns .column-datasets");this._checkForAutoscroll(m,o.originalEvent.clientY);var n=this._getNearestPairedDatasetLi(o.originalEvent.clientY);$(".paired-drop-placeholder").remove();var l=$('<div class="paired-drop-placeholder"></div>');if(!n.size()){m.append(l)}else{n.before(l)}},_checkForAutoscroll:function(l,r){var p=2;var q=l.offset(),o=l.scrollTop(),m=r-q.top,n=(q.top+l.outerHeight())-r;if(m>=0&&m<this.autoscrollDist){l.scrollTop(o-p)}else{if(n>=0&&n<this.autoscrollDist){l.scrollTop(o+p)}}},_getNearestPairedDatasetLi:function(r){var o=4,m=this.$(".paired-columns .column-datasets li").toArray();for(var n=0;n<m.length;n++){var q=$(m[n]),p=q.offset().top,l=Math.floor(q.outerHeight()/2)+o;if(p+l>r&&p-l<r){return q}}return $()},_dropPairedColumns:function(m){m.preventDefault();m.dataTransfer.dropEffect="move";var l=this._getNearestPairedDatasetLi(m.originalEvent.clientY);if(l.size()){this.$dragging.insertBefore(l)}else{this.$dragging.insertAfter(this.$(".paired-columns .unpair-btn").last())}this._syncPairsToDom();return false},_syncPairsToDom:function(){var l=[];this.$(".paired-columns .dataset.paired").each(function(){l.push($(this).data("pair"))});this.paired=l;this._renderPaired()},_pairDragstart:function(m,n){n.$el.addClass("selected");var l=this.$(".paired-columns .dataset.selected");this.$dragging=l},_pairDragend:function(l,m){$(".paired-drop-placeholder").remove();this.$dragging=null},toggleExtensions:function(m){var l=this;l.removeExtensions=(m!==undefined)?(m):(!l.removeExtensions);_.each(l.paired,function(n){if(n.customizedName){return}n.name=l._guessNameForPair(n.forward,n.reverse)});l._renderPaired();l._renderFooter()},_changeName:function(l){this._validationWarning("name",!!this._getName())},_nameCheckForEnter:function(l){if(l.keyCode===13){this._clickCreate()}},_getName:function(){return _.escape(this.$(".collection-name").val())},_clickCreate:function(m){var l=this._getName();if(!l){this._validationWarning("name")}else{this.createList()}},_printList:function(m){var l=this;_.each(m,function(n){if(m===l.paired){l._printPair(n)}else{}})},_printPair:function(l){this.debug(l.forward.name,l.reverse.name,": ->",l.name)},toString:function(){return"PairedCollectionCreator"}});k.templates=k.templates||{main:_.template(['<div class="header flex-row no-flex"></div>','<div class="middle flex-row flex-row-container"></div>','<div class="footer flex-row no-flex">'].join("")),header:_.template(['<div class="main-help well clear">','<a class="more-help" href="javascript:void(0);">',c("More help"),"</a>",'<div class="help-content">','<a class="less-help" href="javascript:void(0);">',c("Less"),"</a>","</div>","</div>",'<div class="alert alert-dismissable">','<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>','<span class="alert-message"></span>',"</div>",'<div class="column-headers vertically-spaced flex-column-container">','<div class="forward-column flex-column column">','<div class="column-header">','<div class="column-title">','<span class="title">',c("Unpaired forward"),"</span>",'<span class="title-info unpaired-info"></span>',"</div>",'<div class="unpaired-filter forward-unpaired-filter pull-left">','<input class="search-query" placeholder="',c("Filter this list"),'" />',"</div>","</div>","</div>",'<div class="paired-column flex-column no-flex column">','<div class="column-header">','<a class="choose-filters-link" href="javascript:void(0)">',c("Choose filters"),"</a>",'<a class="clear-filters-link" href="javascript:void(0);">',c("Clear filters"),"</a><br />",'<a class="autopair-link" href="javascript:void(0);">',c("Auto-pair"),"</a>","</div>","</div>",'<div class="reverse-column flex-column column">','<div class="column-header">','<div class="column-title">','<span class="title">',c("Unpaired reverse"),"</span>",'<span class="title-info unpaired-info"></span>',"</div>",'<div class="unpaired-filter reverse-unpaired-filter pull-left">','<input class="search-query" placeholder="',c("Filter this list"),'" />',"</div>","</div>","</div>","</div>"].join("")),middle:_.template(['<div class="unpaired-columns flex-column-container scroll-container flex-row">','<div class="forward-column flex-column column">','<ol class="column-datasets"></ol>',"</div>",'<div class="paired-column flex-column no-flex column">','<ol class="column-datasets"></ol>',"</div>",'<div class="reverse-column flex-column column">','<ol class="column-datasets"></ol>',"</div>","</div>",'<div class="flexible-partition">','<div class="flexible-partition-drag" title="',c("Drag to change"),'"></div>','<div class="column-header">','<div class="column-title paired-column-title">','<span class="title"></span>',"</div>",'<a class="unpair-all-link" href="javascript:void(0);">',c("Unpair all"),"</a>","</div>","</div>",'<div class="paired-columns flex-column-container scroll-container flex-row">','<ol class="column-datasets"></ol>',"</div>"].join("")),footer:_.template(['<div class="attributes clear">','<div class="clear">','<label class="remove-extensions-prompt pull-right">',c("Remove file extensions from pair names"),"?",'<input class="remove-extensions pull-right" type="checkbox" />',"</label>","</div>",'<div class="clear">','<input class="collection-name form-control pull-right" ','placeholder="',c("Enter a name for your new list"),'" />','<div class="collection-name-prompt pull-right">',c("Name"),":</div>","</div>","</div>",'<div class="actions clear vertically-spaced">','<div class="other-options pull-left">','<button class="cancel-create btn" tabindex="-1">',c("Cancel"),"</button>",'<div class="create-other btn-group dropup">','<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">',c("Create a different kind of collection"),' <span class="caret"></span>',"</button>",'<ul class="dropdown-menu" role="menu">','<li><a href="#">',c("Create a <i>single</i> pair"),"</a></li>",'<li><a href="#">',c("Create a list of <i>unpaired</i> datasets"),"</a></li>","</ul>","</div>","</div>",'<div class="main-options pull-right">','<button class="create-collection btn btn-primary">',c("Create list"),"</button>","</div>","</div>"].join("")),helpContent:_.template(["<p>",c(["Collections of paired datasets are ordered lists of dataset pairs (often forward and reverse reads). ","These collections can be passed to tools and workflows in order to have analyses done on each member of ","the entire group. This interface allows you to create a collection, choose which datasets are paired, ","and re-order the final collection."].join("")),"</p>","<p>",c(['Unpaired datasets are shown in the <i data-target=".unpaired-columns">unpaired section</i> ',"(hover over the underlined words to highlight below). ",'Paired datasets are shown in the <i data-target=".paired-columns">paired section</i>.',"<ul>To pair datasets, you can:","<li>Click a dataset in the ",'<i data-target=".unpaired-columns .forward-column .column-datasets,','.unpaired-columns .forward-column">forward column</i> ',"to select it then click a dataset in the ",'<i data-target=".unpaired-columns .reverse-column .column-datasets,','.unpaired-columns .reverse-column">reverse column</i>.',"</li>",'<li>Click one of the "Pair these datasets" buttons in the ','<i data-target=".unpaired-columns .paired-column .column-datasets,','.unpaired-columns .paired-column">middle column</i> ',"to pair the datasets in a particular row.","</li>",'<li>Click <i data-target=".autopair-link">"Auto-pair"</i> ',"to have your datasets automatically paired based on name.","</li>","</ul>"].join("")),"</p>","<p>",c(["<ul>You can filter what is shown in the unpaired sections by:","<li>Entering partial dataset names in either the ",'<i data-target=".forward-unpaired-filter input">forward filter</i> or ','<i data-target=".reverse-unpaired-filter input">reverse filter</i>.',"</li>","<li>Choosing from a list of preset filters by clicking the ",'<i data-target=".choose-filters-link">"Choose filters" link</i>.',"</li>","<li>Entering regular expressions to match dataset names. See: ",'<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expre…"',' target="_blank">MDN\'s JavaScript Regular Expression Tutorial</a>. ',"Note: forward slashes (\\) are not needed.","</li>","<li>Clearing the filters by clicking the ",'<i data-target=".clear-filters-link">"Clear filters" link</i>.',"</li>","</ul>"].join("")),"</p>","<p>",c(["To unpair individual dataset pairs, click the ",'<i data-target=".unpair-btn">unpair buttons ( <span class="fa fa-unlink"></span> )</i>. ','Click the <i data-target=".unpair-all-link">"Unpair all" link</i> to unpair all pairs.'].join("")),"</p>","<p>",c(['You can include or remove the file extensions (e.g. ".fastq") from your pair names by toggling the ','<i data-target=".remove-extensions-prompt">"Remove file extensions from pair names?"</i> control.'].join("")),"</p>","<p>",c(['Once your collection is complete, enter a <i data-target=".collection-name">name</i> and ','click <i data-target=".create-collection">"Create list"</i>. ',"(Note: you do not have to pair all unpaired datasets to finish.)"].join("")),"</p>"].join(""))};(function(){jQuery.fn.extend({hoverhighlight:function l(n,m){n=n||"body";if(!this.size()){return this}$(this).each(function(){var p=$(this),o=p.data("target");if(o){p.mouseover(function(q){$(o,n).css({background:m})}).mouseout(function(q){$(o).css({background:""})})}});return this}})}());var d=function a(n,l){l=_.defaults(l||{},{datasets:n,oncancel:function(){Galaxy.modal.hide()},oncreate:function(){Galaxy.modal.hide();Galaxy.currHistoryPanel.refreshContents()}});if(!window.Galaxy||!Galaxy.modal){throw new Error("Galaxy or Galaxy.modal not found")}var m=new k(l).render();Galaxy.modal.show({title:"Create a collection of paired datasets",body:m.$el,width:"80%",height:"800px",closing_events:true});window.PCC=m;return m};return{PairedCollectionCreator:k,pairedCollectionCreatorModal:d}});
\ No newline at end of file
diff -r cd41c43e857f7db0d21a093f0d59ce8bf82a049e -r 581d871b810205f6a02e994983ffe316e206b746 test/qunit/tests/paired-collection-creator.js
--- a/test/qunit/tests/paired-collection-creator.js
+++ b/test/qunit/tests/paired-collection-creator.js
@@ -22,7 +22,7 @@
ok( pcc.hasOwnProperty( 'options' ) && typeof pcc.options === 'object' );
deepEqual( pcc.options.filters, pcc.DEFAULT_FILTERS );
ok( pcc.options.automaticallyPair );
- equal( pcc.options.matchPercentage, 1.0 );
+ equal( pcc.options.matchPercentage, 0.9 );
equal( pcc.options.strategy, 'lcs' );
});
@@ -44,6 +44,36 @@
equal( pcc.paired.length, pcc.initialList.length / 2 );
});
+ test( "Try easy autopairing with simple exact matching", function() {
+ var pcc = new PCC({
+ datasets : DATA._1,
+ strategy : 'simple',
+ twoPassAutopairing : false
+ });
+ equal( pcc.unpaired.length, 0 );
+ equal( pcc.paired.length, pcc.initialList.length / 2 );
+ });
+
+ test( "Try easy autopairing with LCS", function() {
+ var pcc = new PCC({
+ datasets : DATA._1,
+ strategy : 'lcs',
+ twoPassAutopairing : false
+ });
+ equal( pcc.unpaired.length, 0 );
+ equal( pcc.paired.length, pcc.initialList.length / 2 );
+ });
+
+ test( "Try easy autopairing with Levenshtein", function() {
+ var pcc = new PCC({
+ datasets : DATA._1,
+ strategy : 'levenshtein',
+ twoPassAutopairing : false
+ });
+ equal( pcc.unpaired.length, 0 );
+ equal( pcc.paired.length, pcc.initialList.length / 2 );
+ });
+
//TODO:
// filters: clearing, setting via popover, regex
// partition: maximize paired, maximize unpaired, split evenly
@@ -69,10 +99,9 @@
);
});
- console.debug( 'requestBody:', JSON.stringify( requestJSON, null, ' ' ) );
+ //console.debug( 'requestBody:', JSON.stringify( requestJSON, null, ' ' ) );
pcc.createList( 'Heres a collection' );
server.respond();
deepEqual( requestJSON, DATA._1requestJSON );
});
-
});
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.
1
0