email keep attachments on select template option

This commit is contained in:
yuri
2017-05-03 11:59:12 +03:00
parent c96040edec
commit 2aca6ca28a
2 changed files with 22 additions and 4 deletions
+21 -4
View File
@@ -35,7 +35,7 @@ Espo.define('views/email/record/compose', ['views/record/edit', 'views/email/rec
sideView: false,
setup: function () {
Dep.prototype.setup.call(this);
Dep.prototype.setup.call(this);
if (!this.model.get('isHtml') && this.getPreferences().get('emailReplyForceHtml')) {
var body = (this.model.get('body') || '').replace(/\n/g, '<br>');
@@ -43,10 +43,15 @@ Espo.define('views/email/record/compose', ['views/record/edit', 'views/email/rec
this.model.set('isHtml', true);
}
if (!this.options.signatureDisabled && this.hasSignature()) {
if (!this.options.signatureDisabled && this.hasSignature()) {
var body = this.prependSignature(this.model.get('body') || '', this.model.get('isHtml'));
this.model.set('body', body);
}
this.model.set('body', body);
}
if (this.options.keepAttachmentsOnSelectTemplate) {
this.initialAttachmentsIds = this.model.get('attachmentsIds') || [];
this.initialAttachmentsNames = this.model.get('attachmentsNames') || {};
}
this.listenTo(this.model, 'insert-template', function (data) {
var body = data.body;
@@ -57,6 +62,18 @@ Espo.define('views/email/record/compose', ['views/record/edit', 'views/email/rec
this.model.set('name', data.subject);
this.model.set('body', '');
this.model.set('body', body);
if (this.options.keepAttachmentsOnSelectTemplate) {
this.initialAttachmentsIds.forEach(function (id) {
if (data.attachmentsIds) {
data.attachmentsIds.push(id);
}
if (data.attachmentsNames) {
data.attachmentsNames[id] = this.initialAttachmentsNames[id] || id;
}
}, this);
}
this.model.set({
attachmentsIds: data.attachmentsIds,
attachmentsNames: data.attachmentsNames
+1
View File
@@ -67,6 +67,7 @@ Espo.define('views/modals/compose-email', 'views/modals/edit', function (Dep) {
columnCount: this.columnCount,
buttonsPosition: false,
selectTemplateDisabled: this.options.selectTemplateDisabled,
keepAttachmentsOnSelectTemplate: this.options.keepAttachmentsOnSelectTemplate,
signatureDisabled: this.options.signatureDisabled,
exit: function () {}
};