feat(mail(web)): Templates folder for pre-defined drafts

To create a template, the user needs to:

 - define a mailbox as the Templates folder;
 - move a draft to this special folder.

Fixes #4320
Fixes #5363
This commit is contained in:
Francis Lachapelle
2022-02-11 10:06:57 -05:00
parent 02b0a41567
commit c986422a3d
25 changed files with 230 additions and 9 deletions
+4 -2
View File
@@ -134,8 +134,10 @@ String.prototype.formatted = function() {
return newString;
};
String.prototype.isValidEmail = function() {
var emailRE = /^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i;
String.prototype.isValidEmail = function(strict) {
var emailRE = strict ?
/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i : /([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)/i;
return emailRE.test(this);
};
@@ -203,6 +203,10 @@
this.$displayName = l('JunkFolderName');
this.$icon = 'thumb_down';
}
else if (this.type == 'templates') {
this.$displayName = l('TemplatesFolderName');
this.$icon = 'mail_outline';
}
else if (this.type == 'additional') {
this.$icon = 'folder';
}
@@ -776,10 +776,20 @@
return this.$newDraft('forward');
};
/**
* @function $compose
* @memberof Message.prototype
* @desc Prepare a new Message object as a new draft from a copy of this message.
* @returns a promise of the HTTP operations
*/
Message.prototype.$compose = function() {
return this.$newDraft('compose');
};
/**
* @function $newDraft
* @memberof Message.prototype
* @desc Prepare a new Message object as a reply or a forward of the current message and associated
* @desc Prepare a new Message object as a reply, a forward or a copy of the current message and associated
* to the draft mailbox.
* @see {@link Account.$newMessage}
* @see {@link Message.$editableContent}
@@ -479,6 +479,12 @@
}
};
this.compose = function($event) {
if (!this._showMailEditorInPopup('compose')) {
_showMailEditor($event, this.message.$compose());
}
};
this.openInPopup = function(action) {
var url = [sgSettings.baseURL(),
'UIxMailPopupView#!/Mail',
@@ -304,7 +304,6 @@
this.addRecipient = function (contact, field) {
var recipients, recipient, list, i, address;
var emailRE = /([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)/i;
recipients = this.message.editable[field];
@@ -319,7 +318,7 @@
contact.charCodeAt(i) == 32 || // space
contact.charCodeAt(i) == 44 || // ,
contact.charCodeAt(i) == 59) && // ;
emailRE.test(address) &&
address.isValidEmail() &&
recipients.indexOf(address) < 0) {
recipients.push(address);
address = '';
@@ -33,7 +33,7 @@
// this.service = Message;
this.MailboxService = Mailbox;
if (Mailbox.selectedFolder.type == 'draft')
if (Mailbox.selectedFolder.type == 'draft' || Mailbox.selectedFolder.type == 'templates')
watchedAttrs.push('subject');
$scope.$watch(