From c5ab87ee5909e0871fb62fcb2e82cdaecf5f8166 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Mon, 14 May 2018 13:07:13 -0400 Subject: [PATCH] Fix repeated additions of the separator, define vars. --- client/galaxy/scripts/mvc/ui/ui-select.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client/galaxy/scripts/mvc/ui/ui-select.js b/client/galaxy/scripts/mvc/ui/ui-select.js index b69eaa0c2bd..0b629e12bf4 100644 --- a/client/galaxy/scripts/mvc/ui/ui-select.js +++ b/client/galaxy/scripts/mvc/ui/ui-select.js @@ -1,4 +1,5 @@ -// dependencies +import * as Backbone from "backbone"; +import * as _ from "underscore"; import Utils from "utils/utils"; /** * A plugin for initializing select2 input items. @@ -147,6 +148,7 @@ var View = Backbone.View.extend({ // refresh _refresh: function() { + let select_opt; // add select2 data based on type of input if (!this.options.multiple) { if (this.select_data) { @@ -155,12 +157,13 @@ var View = Backbone.View.extend({ if (value.text && value.text.length > mx) { let pos = value.text.indexOf(`(${value.id})`); pos = pos != -1 && pos < mx ? pos : mx; - value.text = `${value.text.substring(0, pos)}...(${value.id})`; + let sub = value.text.substring(0, pos).replace(/[\ \.]*$/, ""); + value.text = `${sub}...(${value.id})`; } }); } var selected = this._getValue(); - var select_opt = { + select_opt = { data: this.select_data, containerCssClass: this.options.css, placeholder: this.options.placeholder, @@ -170,7 +173,7 @@ var View = Backbone.View.extend({ // select previous value (if exists) this._setValue(selected); } else { - var select_opt = { + select_opt = { multiple: this.options.multiple, containerCssClass: this.options.css, placeholder: this.options.placeholder,