multi enum support empty strings
This commit is contained in:
@@ -261,12 +261,19 @@ Espo.define('views/fields/array', ['views/fields/base', 'lib!Selectize'], functi
|
||||
|
||||
getValueForDisplay: function () {
|
||||
return this.selected.map(function (item) {
|
||||
var label = null;
|
||||
if (this.translatedOptions != null) {
|
||||
if (item in this.translatedOptions) {
|
||||
return this.getHelper().stripTags(this.translatedOptions[item]);
|
||||
label = this.getHelper().stripTags(this.translatedOptions[item]);
|
||||
}
|
||||
}
|
||||
return this.getHelper().stripTags(item);
|
||||
if (label === null) {
|
||||
label = this.getHelper().stripTags(item);
|
||||
}
|
||||
if (label === '') {
|
||||
label = this.translate('None');
|
||||
}
|
||||
return label;
|
||||
}, this).join(', ');
|
||||
},
|
||||
|
||||
|
||||
@@ -65,8 +65,15 @@ Espo.define('views/fields/multi-enum', ['views/fields/array', 'lib!Selectize'],
|
||||
afterRender: function () {
|
||||
if (this.mode == 'edit') {
|
||||
var $element = this.$element = this.$el.find('[name="' + this.name + '"]');
|
||||
this.$element.val(this.selected.join(':,:'));
|
||||
|
||||
var valueList = Espo.Utils.clone(this.selected);
|
||||
for (var i in valueList) {
|
||||
if (valueList[i] === '') {
|
||||
valueList[i] = '__emptystring__';
|
||||
}
|
||||
}
|
||||
|
||||
this.$element.val(valueList.join(':,:'));
|
||||
|
||||
var data = [];
|
||||
(this.params.options || []).forEach(function (value) {
|
||||
@@ -76,6 +83,12 @@ Espo.define('views/fields/multi-enum', ['views/fields/array', 'lib!Selectize'],
|
||||
label = this.translatedOptions[value];
|
||||
}
|
||||
}
|
||||
if (value === '') {
|
||||
value = '__emptystring__';
|
||||
}
|
||||
if (label === '') {
|
||||
label = this.translate('None');
|
||||
}
|
||||
data.push({
|
||||
value: value,
|
||||
label: label
|
||||
@@ -117,6 +130,11 @@ Espo.define('views/fields/multi-enum', ['views/fields/array', 'lib!Selectize'],
|
||||
if (list.length == 1 && list[0] == '') {
|
||||
list = [];
|
||||
}
|
||||
for (var i in list) {
|
||||
if (list[i] === '__emptystring__') {
|
||||
list[i] = '';
|
||||
}
|
||||
}
|
||||
var data = {};
|
||||
data[this.name] = list;
|
||||
return data;
|
||||
|
||||
Reference in New Issue
Block a user