enum: show none

This commit is contained in:
yuri
2016-12-16 12:14:16 +02:00
parent cb0321aa20
commit 3def2ef0da
7 changed files with 43 additions and 7 deletions

View File

@@ -1 +1,5 @@
<span class="text-{{style}}">{{translateOption value scope=scope field=name}}</span>
{{#if isNotEmpty}}
<span class="text-{{style}}">{{translateOption value scope=scope field=name}}</span>
{{else}}
{{translate 'None'}}
{{/if}}

View File

@@ -0,0 +1,3 @@
{{#if isNotEmpty}}
<span class="text-{{style}}">{{translateOption value scope=scope field=name}}</span>
{{/if}}

View File

@@ -1 +1,5 @@
{{translateOption value scope=scope field=name translatedOptions=translatedOptions}}
{{#if isNotEmpty}}
{{translateOption value scope=scope field=name translatedOptions=translatedOptions}}
{{else}}
{{translate 'None'}}
{{/if}}

View File

@@ -0,0 +1,3 @@
{{#if isNotEmpty}}
{{translateOption value scope=scope field=name translatedOptions=translatedOptions}}
{{/if}}

View File

@@ -26,13 +26,13 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('Views.Fields.EnumStyled', 'Views.Fields.Enum', function (Dep) {
Espo.define('views/fields/enum-styled', 'views/fields/enum', function (Dep) {
return Dep.extend({
listTemplate: 'fields.enum-styled.detail',
listTemplate: 'fields/enum-styled/list',
detailTemplate: 'fields.enum-styled.detail',
detailTemplate: 'fields/enum-styled/detail',
data: function () {
var value = this.model.get(this.name);
@@ -49,7 +49,7 @@ Espo.define('Views.Fields.EnumStyled', 'Views.Fields.Enum', function (Dep) {
Dep.prototype.setup.call(this);
this.styleHash = this.model.getFieldParam(this.name, 'style') || {};
},
}
});
});

View File

@@ -32,7 +32,7 @@ Espo.define('views/fields/enum', ['views/fields/base', 'lib!Selectize'], functio
type: 'enum',
listTemplate: 'fields/enum/detail',
listTemplate: 'fields/enum/list',
detailTemplate: 'fields/enum/detail',
@@ -45,6 +45,16 @@ Espo.define('views/fields/enum', ['views/fields/base', 'lib!Selectize'], functio
data: function () {
var data = Dep.prototype.data.call(this);
data.translatedOptions = this.translatedOptions;
var value = this.model.get(this.name);
if (
value !== null
&&
value !== ''
||
value === '' && (value in (this.translatedOptions || {}))
) {
data.isNotEmpty = true;
}
return data;
},

View File

@@ -45,6 +45,18 @@ Espo.define('views/fields/varchar', 'views/fields/base', function (Dep) {
}, this.events || {});
},
data: function () {
var data = Dep.prototype.data.call(this);
if (
this.model.get(this.name) !== null
&&
this.model.get(this.name) !== ''
) {
data.isNotEmpty = true;
}
return data;
},
handleSearchType: function (type) {
if (~['isEmpty', 'isNotEmpty'].indexOf(type)) {
this.$el.find('input.main-element').addClass('hidden');