diff --git a/application/Espo/Resources/i18n/en_US/Preferences.json b/application/Espo/Resources/i18n/en_US/Preferences.json index 70e391f879..fd7b43f705 100644 --- a/application/Espo/Resources/i18n/en_US/Preferences.json +++ b/application/Espo/Resources/i18n/en_US/Preferences.json @@ -19,7 +19,8 @@ "smtpEmailAddress": "Email Address", "exportDelimiter": "Export Delimiter", "receiveAssignmentEmailNotifications": "Receive Email Notifications upon Assignment", - "autoFollowEntityTypeList": "Auto-Follow" + "autoFollowEntityTypeList": "Auto-Follow", + "signature": "Email Signature" }, "links": { }, diff --git a/application/Espo/Resources/layouts/Preferences/detail.json b/application/Espo/Resources/layouts/Preferences/detail.json index 77136a121b..6f13f356b3 100644 --- a/application/Espo/Resources/layouts/Preferences/detail.json +++ b/application/Espo/Resources/layouts/Preferences/detail.json @@ -26,7 +26,19 @@ { "label": "Misc", "rows": [ - [{"name": "exportDelimiter"}, {"name":"autoFollowEntityTypeList"}] + [{"name": "exportDelimiter"}, {"name":"autoFollowEntityTypeList"}], + [{ + "name": "signature", + "params": { + "height": 70, + "toolbar": [ + ["style", ["bold", "italic", "underline", "clear"]], + ["color", ["color"]], + ["height", ["height"]], + ["misc",["codeview"]] + ] + } + }] ] }, { diff --git a/application/Espo/Resources/metadata/entityDefs/Preferences.json b/application/Espo/Resources/metadata/entityDefs/Preferences.json index d6ea44784d..adec697b3f 100644 --- a/application/Espo/Resources/metadata/entityDefs/Preferences.json +++ b/application/Espo/Resources/metadata/entityDefs/Preferences.json @@ -94,6 +94,10 @@ "translation": "Global.scopeNamesPlural", "notStorable": true, "tooltip": true + }, + "signature": { + "type": "text", + "view": "Fields.Wysiwyg" } } } diff --git a/frontend/client/src/views/email/record/compose.js b/frontend/client/src/views/email/record/compose.js index d35cd9b447..9ec804e253 100644 --- a/frontend/client/src/views/email/record/compose.js +++ b/frontend/client/src/views/email/record/compose.js @@ -27,6 +27,17 @@ Espo.define('Views.Email.Record.Compose', 'Views.Record.Edit', function (Dep) { sideView: false, + setup: function () { + Dep.prototype.setup.call(this); + + var signature = this.getPreferences().get('signature'); + if (signature) { + var body = this.model.get('body') || ''; + body = '

' + signature + '

' + body; + this.model.set('body', body); + } + }, + }); }); diff --git a/frontend/client/src/views/fields/wysiwyg.js b/frontend/client/src/views/fields/wysiwyg.js index bb90ca7701..19bc14befd 100644 --- a/frontend/client/src/views/fields/wysiwyg.js +++ b/frontend/client/src/views/fields/wysiwyg.js @@ -29,9 +29,22 @@ Espo.define('Views.Fields.Wysiwyg', ['Views.Fields.Text', 'lib!Summernote'], fun editTemplate: 'fields.wysiwyg.edit', + height: 250, + setup: function () { Dep.prototype.setup.call(this); + this.height = this.params.height || this.height; + this.toolbar = this.params.toolbar || [ + ['style', ['style']], + ['style', ['bold', 'italic', 'underline', 'clear']], + ['color', ['color']], + ['para', ['ul', 'ol', 'paragraph']], + ['height', ['height']], + ['table', ['table', 'link', 'picture']], + ['misc',['codeview']] + ]; + this.listenTo(this.model, 'change:isHtml', function (model) { if (!model.has('isHtml') || model.get('isHtml')) { this.enableWysiwygMode(); @@ -97,7 +110,7 @@ Espo.define('Views.Fields.Wysiwyg', ['Views.Fields.Text', 'lib!Summernote'], fun enableWysiwygMode: function () { this.$summernote = this.$element.summernote({ - height: 250, + height: this.height, lang: this.getConfig().get('language'), onImageUpload: function (files, editor, welEditable) { var file = files[0]; @@ -132,20 +145,12 @@ Espo.define('Views.Fields.Wysiwyg', ['Views.Fields.Text', 'lib!Summernote'], fun onblur: function () { this.trigger('change') }.bind(this), - toolbar: [ - ['style', ['style']], - ['style', ['bold', 'italic', 'underline', 'clear']], - ['color', ['color']], - ['para', ['ul', 'ol', 'paragraph']], - ['height', ['height']], - ['table', ['table', 'link', 'picture']], - ['misc',['codeview']] - ] + toolbar: this.toolbar }); }, disableWysiwygMode: function () { - var value = this.model.get(this.name); + var value = this.model.get(this.name).replace(//mg,"\n"); value = $('
').html(value).text(); this.model.set(this.name, value); this.$element.destroy();