Skip to content

Commit

Permalink
Merge pull request #26 from dannon/max_select2_length
Browse files Browse the repository at this point in the history
Fix a minor bug, a little bit of cleanup.
  • Loading branch information
guerler authored May 14, 2018
2 parents 616c1b9 + c5ab87e commit 9789aa7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions client/galaxy/scripts/mvc/ui/ui-select.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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) {
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 9789aa7

Please sign in to comment.