diff --git a/client/res/templates/fields/enum-styled/detail.tpl b/client/res/templates/fields/enum-styled/detail.tpl index 5e9de9aedd..da7f568a95 100644 --- a/client/res/templates/fields/enum-styled/detail.tpl +++ b/client/res/templates/fields/enum-styled/detail.tpl @@ -1 +1,5 @@ -{{translateOption value scope=scope field=name}} \ No newline at end of file +{{#if isNotEmpty}} +{{translateOption value scope=scope field=name}} +{{else}} +{{translate 'None'}} +{{/if}} \ No newline at end of file diff --git a/client/res/templates/fields/enum-styled/list.tpl b/client/res/templates/fields/enum-styled/list.tpl new file mode 100644 index 0000000000..d1d8b64cda --- /dev/null +++ b/client/res/templates/fields/enum-styled/list.tpl @@ -0,0 +1,3 @@ +{{#if isNotEmpty}} +{{translateOption value scope=scope field=name}} +{{/if}} \ No newline at end of file diff --git a/client/res/templates/fields/enum/detail.tpl b/client/res/templates/fields/enum/detail.tpl index 638afb78b2..ebafa042ed 100644 --- a/client/res/templates/fields/enum/detail.tpl +++ b/client/res/templates/fields/enum/detail.tpl @@ -1 +1,5 @@ -{{translateOption value scope=scope field=name translatedOptions=translatedOptions}} \ No newline at end of file +{{#if isNotEmpty}} +{{translateOption value scope=scope field=name translatedOptions=translatedOptions}} +{{else}} +{{translate 'None'}} +{{/if}} \ No newline at end of file diff --git a/client/res/templates/fields/enum/list.tpl b/client/res/templates/fields/enum/list.tpl new file mode 100644 index 0000000000..7c02e32281 --- /dev/null +++ b/client/res/templates/fields/enum/list.tpl @@ -0,0 +1,3 @@ +{{#if isNotEmpty}} +{{translateOption value scope=scope field=name translatedOptions=translatedOptions}} +{{/if}} \ No newline at end of file diff --git a/client/src/views/fields/enum-styled.js b/client/src/views/fields/enum-styled.js index f5025e6a27..2bfe91acc4 100644 --- a/client/src/views/fields/enum-styled.js +++ b/client/src/views/fields/enum-styled.js @@ -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') || {}; - }, + } }); }); diff --git a/client/src/views/fields/enum.js b/client/src/views/fields/enum.js index efae3e5667..34cb75bb05 100644 --- a/client/src/views/fields/enum.js +++ b/client/src/views/fields/enum.js @@ -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; }, diff --git a/client/src/views/fields/varchar.js b/client/src/views/fields/varchar.js index 82e8efa0fe..f3edfa9f41 100644 --- a/client/src/views/fields/varchar.js +++ b/client/src/views/fields/varchar.js @@ -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');