update selectize

This commit is contained in:
Yuri Kuznetsov
2021-03-02 11:37:07 +02:00
parent dd8e55c2ac
commit 011e83fac6
8 changed files with 69 additions and 22 deletions
+3 -3
View File
File diff suppressed because one or more lines are too long
+19 -3
View File
@@ -283,19 +283,27 @@ define('views/fields/array', ['views/fields/base', 'lib!Selectize'], function (D
var $element = this.$element = this.$el.find('.main-element');
var valueList = this.getSearchParamsData().valueList || this.searchParams.valueFront || [];
this.$element.val(valueList.join(':,:'));
var data = [];
(this.params.options || []).forEach(function (value) {
var label = this.getLanguage().translateOption(value, this.name, this.scope);
if (this.translatedOptions) {
if (value in this.translatedOptions) {
label = this.translatedOptions[value];
}
}
if (label === '') {
return;
};
data.push({
value: value,
label: label
label: label,
});
}, this);
@@ -312,11 +320,14 @@ define('views/fields/array', ['views/fields/base', 'lib!Selectize'], function (D
if (!this.matchAnyWord) {
selectizeOptions.score = function (search) {
var score = this.getScoreFunction(search);
search = search.toLowerCase();
return function (item) {
if (item.label.toLowerCase().indexOf(search) === 0) {
return score(item);
}
return 0;
};
};
@@ -324,16 +335,17 @@ define('views/fields/array', ['views/fields/base', 'lib!Selectize'], function (D
if (this.allowCustomOptions) {
selectizeOptions.persist = false;
selectizeOptions.create = function (input) {
return {
value: input,
label: input
label: input,
}
};
selectizeOptions.render = {
option_create: function (data, escape) {
return '<div class="create"><strong>' + escape(data.input) + '</strong>&hellip;</div>';
}
},
};
}
@@ -342,6 +354,7 @@ define('views/fields/array', ['views/fields/base', 'lib!Selectize'], function (D
this.$el.find('.selectize-dropdown-content').addClass('small');
var type = this.$el.find('select.search-type').val();
this.handleSearchType(type);
this.$el.find('select.search-type').on('change', function () {
@@ -355,10 +368,13 @@ define('views/fields/array', ['views/fields/base', 'lib!Selectize'], function (D
fetchFromDom: function () {
var selected = [];
this.$el.find('.list-group .list-group-item').each(function (i, el) {
var value = $(el).data('value').toString();
selected.push(value);
});
this.selected = selected;
},
+14 -2
View File
@@ -220,22 +220,31 @@ define('views/fields/enum', ['views/fields/base', 'lib!Selectize'], function (De
var $element = this.$element = this.$el.find('.main-element');
var type = this.$el.find('select.search-type').val();
this.handleSearchType(type);
var valueList = this.getSearchParamsData().valueList || this.searchParams.value || [];
this.$element.val(valueList.join(':,:'));
var data = [];
(this.params.options || []).forEach(function (value) {
var label = this.getLanguage().translateOption(value, this.name, this.scope);
if (this.translatedOptions) {
if (value in this.translatedOptions) {
label = this.translatedOptions[value];
}
}
if (label === '') {
return;
}
data.push({
value: value,
label: label
label: label,
});
}, this);
@@ -249,14 +258,17 @@ define('views/fields/enum', ['views/fields/base', 'lib!Selectize'], function (De
plugins: ['remove_button'],
score: function (search) {
var score = this.getScoreFunction(search);
search = search.toLowerCase();
return function (item) {
if (item.label.toLowerCase().indexOf(search) === 0) {
return score(item);
}
return 0;
};
}
},
});
this.$el.find('.selectize-dropdown-content').addClass('small');
+1
View File
@@ -1,4 +1,5 @@
@import "misc/selectize/selectize.less";
@import "misc/selectize/custom.less";
@import "misc/selectize/selectize.bootstrap3.less";
@import "misc/summernote/summernote.less";
@import "misc/summernote/icons.less";
@@ -0,0 +1,8 @@
.filter > .form-group .field {
.selectize-control {
.selectize-input {
font-size: @font-size-small;
padding: 4px 5px 0px;
}
}
}
@@ -34,4 +34,10 @@
.disabled [data-value] .remove {
border-left-color: lighten(desaturate(@selectize-color-item-border, 100%), @selectize-lighten-disabled-item-border);
}
}
.remove-single {
position: absolute;
right: 0;
top: 0;
font-size: 23px;
}
}
@@ -1,6 +1,7 @@
/**
* selectize.bootstrap3.css (v0.12.1) - Bootstrap 3 Theme
* selectize.css (v0.13.3)
* Copyright (c) 20132015 Brian Reavis & contributors
* Copyright (c) 2020 Selectize Team & contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
@@ -12,11 +13,12 @@
* governing permissions and limitations under the License.
*
* @author Brian Reavis <brian@thirdroute.com>
* @author Ris Adams <selectize@risadams.com>
*/
@import "selectize";
@selectize-fonts-family: inherit;
@selectize-font-family: inherit;
@selectize-font-size: inherit;
@selectize-line-height: @line-height-computed;
@@ -147,4 +149,4 @@
background: none;
.selectize-box-shadow(none);
.selectize-border-radius(0);
}
}
@@ -187,6 +187,9 @@
-webkit-user-select: auto !important;
.selectize-box-shadow(none) !important;
&:focus { outline: none !important; }
&[placeholder] {
box-sizing: initial;
}
}
}
@@ -226,9 +229,16 @@
.selectize-border-radius(1px);
}
}
[data-selectable], .optgroup-header {
.option, .optgroup-header {
padding: @selectize-padding-dropdown-item-y @selectize-padding-dropdown-item-x;
}
.option, [data-disabled], [data-disabled] [data-selectable].option {
cursor: inherit;
opacity: 0.5;
}
[data-selectable].option {
opacity: 1;
}
.optgroup:first-child .optgroup-header {
border-top: 0 none;
}
@@ -253,6 +263,7 @@
overflow-y: auto;
overflow-x: hidden;
max-height: @selectize-max-height-dropdown;
-webkit-overflow-scrolling: touch;
}
.selectize-control.single .selectize-input {
@@ -293,12 +304,3 @@
opacity: @selectize-opacity-disabled;
background-color: @selectize-color-disabled;
}
.filter > .form-group .field {
.selectize-control {
.selectize-input {
font-size: @font-size-small;
padding: 4px 5px 0px;
}
}
}