mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-22 03:45:25 +00:00
(feat) support for drafts autosaving
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
title="title"
|
||||
const:userDefaultsKeys="SOGoMailMessageCheck,SOGoRefreshViewCheck,SOGoMailSortByThreads,SOGoMailListViewColumnsOrder,SOGoMailDisplayRemoteInlineImages,SOGoMailComposeMessageType,SOGoMailReplyPlacement,SOGoMailLabelsColors"
|
||||
const:userSettingsKeys="Mail"
|
||||
const:jsFiles="Mailer.app.js, Common.js, Contacts.js, Mailer.js, vendor/ckeditor/ckeditor.js, vendor/ckeditor/ck.js, vendor/angular-file-upload.js">
|
||||
const:jsFiles="Mailer.app.js, Common.js, Contacts.js, Mailer.js, Preferences.js, vendor/ckeditor/ckeditor.js, vendor/ckeditor/ck.js, vendor/angular-file-upload.js">
|
||||
<script type="text/javascript">
|
||||
var mailAccounts =<var:string value="mailAccounts" const:escapeHTML="NO" />;
|
||||
var userNames =<var:string value="userNames" const:escapeHTML="NO" />;
|
||||
|
||||
@@ -544,7 +544,7 @@
|
||||
<div layout="row" layout-align="space-around left">
|
||||
<div><var:string label:value="Auto save every"/></div>
|
||||
<md-input-container class="md-input-number">
|
||||
<input type="number" label:aria-label="minutes" ng-model="preferences.defaults.SOGoMailAutoSave"/>
|
||||
<input type="number" min="0" label:aria-label="minutes" ng-model="preferences.defaults.SOGoMailAutoSave"/>
|
||||
</md-input-container>
|
||||
<var:string label:value="minutes"/>
|
||||
</div>
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('SOGo.ContactsUI', []);
|
||||
angular.module('SOGo.PreferencesUI', []);
|
||||
|
||||
angular.module('SOGo.MailerUI', ['ngSanitize', 'ui.router', 'ck', 'angularFileUpload', 'SOGo.Common', 'SOGo.ContactsUI', 'ngAnimate'])
|
||||
angular.module('SOGo.MailerUI', ['ngSanitize', 'ui.router', 'ck', 'angularFileUpload', 'SOGo.Common', 'SOGo.ContactsUI', 'ngAnimate', 'SOGo.PreferencesUI'])
|
||||
|
||||
.constant('sgSettings', {
|
||||
baseURL: ApplicationBaseURL,
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
MessageEditorController.$inject = ['$stateParams', '$state', '$q', 'FileUploader', 'stateAccounts', 'stateMessage', '$timeout', 'encodeUriFilter', 'sgFocus', 'Dialog', 'Account', 'Mailbox', 'AddressBook'];
|
||||
function MessageEditorController($stateParams, $state, $q, FileUploader, stateAccounts, stateMessage, $timeout, encodeUriFilter, focus, Dialog, Account, Mailbox, AddressBook) {
|
||||
MessageEditorController.$inject = ['$stateParams', '$state', '$q', 'FileUploader', 'stateAccounts', 'stateMessage', '$timeout', 'encodeUriFilter', 'sgFocus', 'Dialog', 'Account', 'Mailbox', 'AddressBook', 'Preferences'];
|
||||
function MessageEditorController($stateParams, $state, $q, FileUploader, stateAccounts, stateMessage, $timeout, encodeUriFilter, focus, Dialog, Account, Mailbox, AddressBook, Preferences) {
|
||||
var vm = this;
|
||||
|
||||
vm.autocomplete = {to: {}, cc: {}, bcc: {}};
|
||||
vm.autosave = null;
|
||||
vm.autosaveDrafts = autosaveDrafts;
|
||||
vm.hideCc = true;
|
||||
vm.hideBcc = true;
|
||||
vm.cancel = cancel;
|
||||
@@ -66,6 +68,9 @@
|
||||
|
||||
function cancel() {
|
||||
// TODO: delete draft?
|
||||
if (vm.autosave)
|
||||
$timeout.cancel(vm.autosave);
|
||||
|
||||
if ($state.params.mailboxId)
|
||||
$state.go('mail.account.mailbox', { accountId: $state.params.accountId, mailboxId: $state.params.mailboxId });
|
||||
else
|
||||
@@ -73,6 +78,9 @@
|
||||
}
|
||||
|
||||
function send() {
|
||||
if (vm.autosave)
|
||||
$timeout.cancel(vm.autosave);
|
||||
|
||||
vm.message.$send().then(function(data) {
|
||||
$state.go('mail');
|
||||
}, function(data) {
|
||||
@@ -87,6 +95,19 @@
|
||||
});
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
// Drafts autosaving
|
||||
function autosaveDrafts() {
|
||||
vm.message.$save();
|
||||
if (Preferences.defaults.SOGoMailAutoSave)
|
||||
vm.autosave = $timeout(vm.autosaveDrafts, Preferences.defaults.SOGoMailAutoSave*1000*60);
|
||||
}
|
||||
|
||||
// Select list based on user's settings
|
||||
Preferences.ready().then(function() {
|
||||
if (Preferences.defaults.SOGoMailAutoSave)
|
||||
vm.autosave = $timeout(vm.autosaveDrafts, Preferences.defaults.SOGoMailAutoSave*1000*60);
|
||||
});
|
||||
}
|
||||
|
||||
angular
|
||||
|
||||
Reference in New Issue
Block a user