From a1337eff1420b5a47161814d89e68c2dbfc825bf Mon Sep 17 00:00:00 2001 From: will Date: Wed, 22 May 2019 14:47:04 -0400 Subject: [PATCH 1/7] Fix ellipses showing too soon --- client/galaxy/scripts/mvc/tool/tool-form.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/client/galaxy/scripts/mvc/tool/tool-form.js b/client/galaxy/scripts/mvc/tool/tool-form.js index eb720d453b3..b8ebc1270a5 100644 --- a/client/galaxy/scripts/mvc/tool/tool-form.js +++ b/client/galaxy/scripts/mvc/tool/tool-form.js @@ -347,21 +347,18 @@ var View = Backbone.View.extend({ return inputs; }, - _templateRow: function(list, title, max = 3) { - var blurb = ""; - list.sort(function(a, b) { - return b.hid - a.hid; - }); + _templateRow: function(list, title) { + let blurb = ""; if (list.length > 0) { blurb += `

${title}:

`; - for (const item of list) { - const rowString = max > 0 ? `${item.hid}: ${_.escape(item.name)}` : "..."; + list.sort((a, b) => { b.hid - a.hid; }); + const numRows = Math.min(list.length, 4); + for (let i = 0; i < numRows; i++) { + //use ellipses if it is the final row (last loop iteration) and the list length is larger than the number of rows + const rowString = (i === numRows - 1 && list.length > numRows) ? "..." : `${list[i].hid}: ${_.escape(list[i].name)}`; blurb += `

${rowString}

`; - if (max-- <= 0) { - break; - } } } return blurb; From ed69f0053d9e28bb6e7d80b5718d72bbc8ebb430 Mon Sep 17 00:00:00 2001 From: will Date: Wed, 22 May 2019 14:48:02 -0400 Subject: [PATCH 2/7] Fix formatting --- client/galaxy/scripts/mvc/tool/tool-form.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/client/galaxy/scripts/mvc/tool/tool-form.js b/client/galaxy/scripts/mvc/tool/tool-form.js index b8ebc1270a5..04a52ad1107 100644 --- a/client/galaxy/scripts/mvc/tool/tool-form.js +++ b/client/galaxy/scripts/mvc/tool/tool-form.js @@ -68,15 +68,15 @@ var View = Backbone.View.extend({ ); } else { Galaxy.modal && - Galaxy.modal.show({ - title: _l("Tool request failed"), - body: error_message, - buttons: { - Close: function() { - Galaxy.modal.hide(); - } + Galaxy.modal.show({ + title: _l("Tool request failed"), + body: error_message, + buttons: { + Close: function() { + Galaxy.modal.hide(); } - }); + } + }); } Galaxy.emit.debug( "tool-form-base::_buildModel()", @@ -395,7 +395,7 @@ var View = Backbone.View.extend({ .append( $("

").text( `The server could not complete the request. Please contact the Galaxy Team if this error persists. ${err_msg || - ""}` + ""}` ) ) .append($("

").text(JSON.stringify(response, null, 4)));

From f1158b9dcc233567adb6e5336e93f217669efd51 Mon Sep 17 00:00:00 2001
From: will 
Date: Wed, 22 May 2019 15:27:09 -0400
Subject: [PATCH 3/7] Use arrow functions and remove references to self = this

---
 client/galaxy/scripts/mvc/tool/tool-form.js | 49 ++++++++++-----------
 1 file changed, 23 insertions(+), 26 deletions(-)

diff --git a/client/galaxy/scripts/mvc/tool/tool-form.js b/client/galaxy/scripts/mvc/tool/tool-form.js
index 04a52ad1107..b3f3b76539f 100644
--- a/client/galaxy/scripts/mvc/tool/tool-form.js
+++ b/client/galaxy/scripts/mvc/tool/tool-form.js
@@ -15,14 +15,13 @@ import Webhooks from "mvc/webhooks";
 var View = Backbone.View.extend({
     initialize: function(options) {
         const Galaxy = getGalaxyInstance();
-        const self = this;
         this.modal = Galaxy.modal || new Modal.View();
         this.form = new ToolFormBase(
             Utils.merge(
                 {
                     listen_to_history: true,
                     always_refresh: false,
-                    buildmodel: function(process, form) {
+                    buildmodel: (process, form) => {
                         var options = form.model.attributes;
 
                         // build request url
@@ -42,17 +41,17 @@ var View = Backbone.View.extend({
                         Utils.get({
                             url: build_url,
                             data: build_data,
-                            success: function(data) {
+                            success: data => {
                                 if (!data.display) {
                                     window.location = getAppRoot();
                                     return;
                                 }
                                 form.model.set(data);
-                                self._customize(form);
+                                this._customize(form);
                                 Galaxy.emit.debug("tool-form-base::_buildModel()", "Initial tool model ready.", data);
                                 process.resolve();
                             },
-                            error: function(response, status) {
+                            error: (response, status) => {
                                 var error_message = (response && response.err_msg) || "Uncaught error.";
                                 if (status == 401) {
                                     window.location = `${getAppRoot()}user/login?${$.param({
@@ -72,7 +71,7 @@ var View = Backbone.View.extend({
                                         title: _l("Tool request failed"),
                                         body: error_message,
                                         buttons: {
-                                            Close: function() {
+                                            Close: () => {
                                                 Galaxy.modal.hide();
                                             }
                                         }
@@ -87,7 +86,7 @@ var View = Backbone.View.extend({
                             }
                         });
                     },
-                    postchange: function(process, form) {
+                    postchange: (process, form) => {
                         var current_state = {
                             tool_id: form.model.get("id"),
                             tool_version: form.model.get("version"),
@@ -99,13 +98,13 @@ var View = Backbone.View.extend({
                             type: "POST",
                             url: `${getAppRoot()}api/tools/${form.model.get("id")}/build`,
                             data: current_state,
-                            success: function(data) {
+                            success: data => {
                                 form.update(data);
                                 form.wait(false);
                                 Galaxy.emit.debug("tool-form::postchange()", "Received new model.", data);
                                 process.resolve();
                             },
-                            error: function(response) {
+                            error: response => {
                                 Galaxy.emit.debug("tool-form::postchange()", "Refresh request failed.", response);
                                 process.reject();
                             }
@@ -121,7 +120,6 @@ var View = Backbone.View.extend({
     },
 
     _customize: function(form) {
-        var self = this;
         var options = form.model.attributes;
         // build execute button
         var execute_button = new Ui.Button({
@@ -130,10 +128,10 @@ var View = Backbone.View.extend({
             title: _l("Execute"),
             cls: "btn btn-primary",
             wait_cls: "btn btn-info",
-            onclick: function() {
+            onclick: () => {
                 execute_button.wait();
                 form.portlet.disable();
-                self.submit(options, () => {
+                this.submit(options, () => {
                     execute_button.unwait();
                     form.portlet.enable();
                 });
@@ -196,7 +194,6 @@ var View = Backbone.View.extend({
     submit: function(options, callback) {
         const Galaxy = getGalaxyInstance();
         const history_id = Galaxy.currHistoryPanel && Galaxy.currHistoryPanel.model.id;
-        const self = this;
         const job_def = {
             history_id: history_id,
             tool_id: options.id,
@@ -204,7 +201,7 @@ var View = Backbone.View.extend({
             inputs: this.form.data.create()
         };
         this.form.trigger("reset");
-        if (!self.validate(job_def)) {
+        if (!this.validate(job_def)) {
             Galaxy.emit.debug("tool-form::submit()", "Submission canceled. Validation failed.");
             callback && callback();
             return;
@@ -230,42 +227,42 @@ var View = Backbone.View.extend({
             type: "POST",
             url: `${getAppRoot()}api/tools`,
             data: job_def,
-            success: function(response) {
+            success: response => {
                 callback && callback();
-                self.$el.children().hide();
-                self.$el.append(self._templateSuccess(response, job_def));
+                this.$el.children().hide();
+                this.$el.append(this._templateSuccess(response, job_def));
                 // Show Webhook if job is running
                 if (response.jobs && response.jobs.length > 0) {
-                    self.$el.append($("
", { id: "webhook-view" })); + this.$el.append($("
", { id: "webhook-view" })); new Webhooks.WebhookView({ type: "tool", toolId: job_def.tool_id }); } if (Galaxy.currHistoryPanel) { - self.form.stopListening(Galaxy.currHistoryPanel.collection); + this.form.stopListening(Galaxy.currHistoryPanel.collection); Galaxy.currHistoryPanel.refreshContents(); } }, - error: function(response) { + error: response => { callback && callback(); Galaxy.emit.debug("tool-form::submit", "Submission failed.", response); let input_found = false; if (response && response.err_data) { - const error_messages = self.form.data.matchResponse(response.err_data); + const error_messages = this.form.data.matchResponse(response.err_data); for (const input_id in error_messages) { - self.form.highlight(input_id, error_messages[input_id]); + this.form.highlight(input_id, error_messages[input_id]); input_found = true; break; } } if (!input_found) { - self.modal.show({ + this.modal.show({ title: _l("Job submission failed"), - body: self._templateError(job_def, response && response.err_msg), + body: this._templateError(job_def, response && response.err_msg), buttons: { - Close: function() { - self.modal.hide(); + Close: () => { + this.modal.hide(); } } }); From fc6a122545fc89723d5d7948d53a0936b52b9d5a Mon Sep 17 00:00:00 2001 From: will Date: Wed, 22 May 2019 15:40:07 -0400 Subject: [PATCH 4/7] prefer const and let over var --- client/galaxy/scripts/mvc/tool/tool-form.js | 64 ++++++++++----------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/client/galaxy/scripts/mvc/tool/tool-form.js b/client/galaxy/scripts/mvc/tool/tool-form.js index b3f3b76539f..75f5a67f148 100644 --- a/client/galaxy/scripts/mvc/tool/tool-form.js +++ b/client/galaxy/scripts/mvc/tool/tool-form.js @@ -12,7 +12,7 @@ import Modal from "mvc/ui/ui-modal"; import ToolFormBase from "mvc/tool/tool-form-base"; import Webhooks from "mvc/webhooks"; -var View = Backbone.View.extend({ +const View = Backbone.View.extend({ initialize: function(options) { const Galaxy = getGalaxyInstance(); this.modal = Galaxy.modal || new Modal.View(); @@ -22,12 +22,12 @@ var View = Backbone.View.extend({ listen_to_history: true, always_refresh: false, buildmodel: (process, form) => { - var options = form.model.attributes; + const options = form.model.attributes; // build request url - var build_url = ""; - var build_data = {}; - var job_id = options.job_id; + let build_url = ""; + let build_data = {}; + const job_id = options.job_id; if (job_id) { build_url = `${getAppRoot()}api/jobs/${job_id}/build_for_rerun`; } else { @@ -52,7 +52,7 @@ var View = Backbone.View.extend({ process.resolve(); }, error: (response, status) => { - var error_message = (response && response.err_msg) || "Uncaught error."; + const error_message = (response && response.err_msg) || "Uncaught error."; if (status == 401) { window.location = `${getAppRoot()}user/login?${$.param({ redirect: `${getAppRoot()}?tool_id=${options.id}` @@ -87,7 +87,7 @@ var View = Backbone.View.extend({ }); }, postchange: (process, form) => { - var current_state = { + const current_state = { tool_id: form.model.get("id"), tool_version: form.model.get("version"), inputs: $.extend(true, {}, form.data.create()) @@ -120,9 +120,9 @@ var View = Backbone.View.extend({ }, _customize: function(form) { - var options = form.model.attributes; + const options = form.model.attributes; // build execute button - var execute_button = new Ui.Button({ + const execute_button = new Ui.Button({ icon: "fa-check", tooltip: `Execute: ${options.name} (${options.version})`, title: _l("Execute"), @@ -141,7 +141,7 @@ var View = Backbone.View.extend({ // remap feature if (options.job_id && options.job_remap) { - var label, help; + let label, help; if (options.job_remap === "job_produced_collection_elements") { label = "Replace elements in collection ?"; help = @@ -165,11 +165,11 @@ var View = Backbone.View.extend({ // Job Re-use Options const Galaxy = getGalaxyInstance(); - var extra_user_preferences = {}; + let extra_user_preferences = {}; if (Galaxy.user.attributes.preferences && "extra_user_preferences" in Galaxy.user.attributes.preferences) { extra_user_preferences = JSON.parse(Galaxy.user.attributes.preferences.extra_user_preferences); } - var use_cached_job = + const use_cached_job = "use_cached_job|use_cached_job_checkbox" in extra_user_preferences ? extra_user_preferences["use_cached_job|use_cached_job_checkbox"] : false; @@ -276,14 +276,14 @@ var View = Backbone.View.extend({ */ validate: function(job_def) { const Galaxy = getGalaxyInstance(); - var job_inputs = job_def.inputs; - var batch_n = -1; - var batch_src = null; - for (var job_input_id in job_inputs) { - var input_value = job_inputs[job_input_id]; - var input_id = this.form.data.match(job_input_id); - var input_field = this.form.field_list[input_id]; - var input_def = this.form.input_list[input_id]; + const job_inputs = job_def.inputs; + let batch_n = -1; + let batch_src = null; + for (const job_input_id in job_inputs) { + const input_value = job_inputs[job_input_id]; + const input_id = this.form.data.match(job_input_id); + const input_field = this.form.field_list[input_id]; + const input_def = this.form.input_list[input_id]; if (!input_id || !input_def || !input_field) { Galaxy.emit.debug("tool-form::validate()", "Retrieving input objects failed."); continue; @@ -300,8 +300,8 @@ var View = Backbone.View.extend({ } } if (input_value && input_value.batch) { - var n = input_value.values.length; - var src = n > 0 && input_value.values[0] && input_value.values[0].src; + const n = input_value.values.length; + const src = n > 0 && input_value.values[0] && input_value.values[0].src; if (src) { if (batch_src === null) { batch_src = src; @@ -328,8 +328,8 @@ var View = Backbone.View.extend({ }, _getInputs: function(job_def) { - var inputs = []; - var index = {}; + const inputs = []; + const index = {}; for (const i in job_def.inputs) { const input = job_def.inputs[i]; if (input && $.isArray(input.values)) { @@ -362,15 +362,15 @@ var View = Backbone.View.extend({ }, _templateSuccess: function(response, job_def) { - var njobs = response && response.jobs ? response.jobs.length : 0; + const njobs = response && response.jobs ? response.jobs.length : 0; if (njobs > 0) { - var inputs = this._getInputs(job_def); - var ninputs = inputs.length; - var noutputs = response.outputs.length; - var njobsText = njobs > 1 ? `${njobs} jobs` : `1 job`; - var ninputsText = ninputs > 1 ? `${ninputs} inputs` : `this input`; - var noutputsText = noutputs > 1 ? `${noutputs} outputs` : `this output`; - var tool_name = this.form.model.get("name"); + const inputs = this._getInputs(job_def); + const ninputs = inputs.length; + const noutputs = response.outputs.length; + const njobsText = njobs > 1 ? `${njobs} jobs` : `1 job`; + const ninputsText = ninputs > 1 ? `${ninputs} inputs` : `this input`; + const noutputsText = noutputs > 1 ? `${noutputs} outputs` : `this output`; + const tool_name = this.form.model.get("name"); return `

Executed ${tool_name} and successfully added ${njobsText} to the queue. From c4b31da7970f0d65f25d1257526bd6733122d5e2 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Fri, 24 May 2019 13:43:14 -0400 Subject: [PATCH 5/7] Rerun prettier --- client/galaxy/scripts/mvc/tool/tool-form.js | 25 ++++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/client/galaxy/scripts/mvc/tool/tool-form.js b/client/galaxy/scripts/mvc/tool/tool-form.js index 75f5a67f148..2ec48fbd648 100644 --- a/client/galaxy/scripts/mvc/tool/tool-form.js +++ b/client/galaxy/scripts/mvc/tool/tool-form.js @@ -67,15 +67,15 @@ const View = Backbone.View.extend({ ); } else { Galaxy.modal && - Galaxy.modal.show({ - title: _l("Tool request failed"), - body: error_message, - buttons: { - Close: () => { - Galaxy.modal.hide(); + Galaxy.modal.show({ + title: _l("Tool request failed"), + body: error_message, + buttons: { + Close: () => { + Galaxy.modal.hide(); + } } - } - }); + }); } Galaxy.emit.debug( "tool-form-base::_buildModel()", @@ -348,11 +348,14 @@ const View = Backbone.View.extend({ let blurb = ""; if (list.length > 0) { blurb += `

${title}:

`; - list.sort((a, b) => { b.hid - a.hid; }); + list.sort((a, b) => { + b.hid - a.hid; + }); const numRows = Math.min(list.length, 4); for (let i = 0; i < numRows; i++) { //use ellipses if it is the final row (last loop iteration) and the list length is larger than the number of rows - const rowString = (i === numRows - 1 && list.length > numRows) ? "..." : `${list[i].hid}: ${_.escape(list[i].name)}`; + const rowString = + i === numRows - 1 && list.length > numRows ? "..." : `${list[i].hid}: ${_.escape(list[i].name)}`; blurb += `

${rowString}

`; @@ -392,7 +395,7 @@ const View = Backbone.View.extend({ .append( $("

").text( `The server could not complete the request. Please contact the Galaxy Team if this error persists. ${err_msg || - ""}` + ""}` ) ) .append($("

").text(JSON.stringify(response, null, 4)));

From f2a7f8c6bb39482104a0d29018b69f82d2fc1662 Mon Sep 17 00:00:00 2001
From: will 
Date: Thu, 6 Jun 2019 12:57:25 -0400
Subject: [PATCH 6/7] make tool form print all inputs/outputs and scroll to top

---
 client/galaxy/scripts/mvc/tool/tool-form.js | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/client/galaxy/scripts/mvc/tool/tool-form.js b/client/galaxy/scripts/mvc/tool/tool-form.js
index 2ec48fbd648..a015b004791 100644
--- a/client/galaxy/scripts/mvc/tool/tool-form.js
+++ b/client/galaxy/scripts/mvc/tool/tool-form.js
@@ -231,6 +231,7 @@ const View = Backbone.View.extend({
                 callback && callback();
                 this.$el.children().hide();
                 this.$el.append(this._templateSuccess(response, job_def));
+                this.$el.parent().scrollTop(0);
                 // Show Webhook if job is running
                 if (response.jobs && response.jobs.length > 0) {
                     this.$el.append($("
", { id: "webhook-view" })); @@ -351,11 +352,8 @@ const View = Backbone.View.extend({ list.sort((a, b) => { b.hid - a.hid; }); - const numRows = Math.min(list.length, 4); - for (let i = 0; i < numRows; i++) { - //use ellipses if it is the final row (last loop iteration) and the list length is larger than the number of rows - const rowString = - i === numRows - 1 && list.length > numRows ? "..." : `${list[i].hid}: ${_.escape(list[i].name)}`; + for (const item of list) { + const rowString = `${item.hid}: ${_.escape(item.name)}`; blurb += `

${rowString}

`; From 320655337b7f550ef8412c4c3cb30ea1720cda04 Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Thu, 6 Jun 2019 13:40:25 -0400 Subject: [PATCH 7/7] improve styling of inpouts and outputs lists on after-execution page --- client/galaxy/scripts/mvc/tool/tool-form.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/galaxy/scripts/mvc/tool/tool-form.js b/client/galaxy/scripts/mvc/tool/tool-form.js index a015b004791..2eda949c313 100644 --- a/client/galaxy/scripts/mvc/tool/tool-form.js +++ b/client/galaxy/scripts/mvc/tool/tool-form.js @@ -352,12 +352,12 @@ const View = Backbone.View.extend({ list.sort((a, b) => { b.hid - a.hid; }); + blurb += `
    `; for (const item of list) { const rowString = `${item.hid}: ${_.escape(item.name)}`; - blurb += `

    - ${rowString} -

    `; + blurb += `
  • ${rowString}
  • `; } + blurb += `
`; } return blurb; },