mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-24 02:04:04 +08:00
Merge pull request #26 from dannon/max_select2_length
Fix a minor bug, a little bit of cleanup.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user