From 104ac2db33f7cdb1129076fde2c48bd3a20b4a0e Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Wed, 20 Sep 2017 16:50:41 -0400 Subject: [PATCH] New SOGoMailComposeWindow default --- SoObjects/SOGo/SOGoUserDefaults.h | 3 ++ SoObjects/SOGo/SOGoUserDefaults.m | 10 +++++ .../English.lproj/Localizable.strings | 3 ++ UI/PreferencesUI/UIxJSONPreferences.m | 3 ++ .../MailerUI/UIxMailFolderTemplate.wox | 11 ++++++ UI/Templates/MailerUI/UIxMailViewTemplate.wox | 2 +- UI/Templates/PreferencesUI/UIxPreferences.wox | 23 +++++++++++ .../js/Mailer/MailboxController.js | 10 +++-- .../js/Mailer/Mailer.popup.js | 12 +++--- .../js/Mailer/MessageController.js | 39 +++++++++++++------ .../js/Preferences/Preferences.service.js | 6 +++ 11 files changed, 99 insertions(+), 23 deletions(-) diff --git a/SoObjects/SOGo/SOGoUserDefaults.h b/SoObjects/SOGo/SOGoUserDefaults.h index ff7baf84d..d52b277d1 100644 --- a/SoObjects/SOGo/SOGoUserDefaults.h +++ b/SoObjects/SOGo/SOGoUserDefaults.h @@ -133,6 +133,9 @@ extern NSString *SOGoWeekStartFirstFullWeek; - (void) setAnimationMode: (NSString *) newValue; - (NSString *) animationMode; +- (void) setMailComposeWindow: (NSString *) newValue; +- (NSString *) mailComposeWindow; + - (void) setMailComposeMessageType: (NSString *) newValue; - (NSString *) mailComposeMessageType; diff --git a/SoObjects/SOGo/SOGoUserDefaults.m b/SoObjects/SOGo/SOGoUserDefaults.m index f32a1b8cd..24c518189 100644 --- a/SoObjects/SOGo/SOGoUserDefaults.m +++ b/SoObjects/SOGo/SOGoUserDefaults.m @@ -542,6 +542,16 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; return [self stringForKey: @"SOGoAnimationMode"]; } +- (void) setMailComposeWindow: (NSString *) newValue +{ + [self setObject: newValue forKey: @"SOGoMailComposeWindow"]; +} + +- (NSString *) mailComposeWindow +{ + return [self stringForKey: @"SOGoMailComposeWindow"]; +} + - (void) setMailComposeMessageType: (NSString *) newValue { [self setObject: newValue forKey: @"SOGoMailComposeMessageType"]; diff --git a/UI/PreferencesUI/English.lproj/Localizable.strings b/UI/PreferencesUI/English.lproj/Localizable.strings index d1dff2b4d..87c6c26d5 100644 --- a/UI/PreferencesUI/English.lproj/Localizable.strings +++ b/UI/PreferencesUI/English.lproj/Localizable.strings @@ -151,6 +151,9 @@ "Show subscribed mailboxes only" = "Show subscribed mailboxes only"; "Synchronize only default mail folders (EAS)" = "Synchronize only default mail folders (EAS)"; "Sort messages by threads" = "Sort messages by threads"; +"Always show mail composer" = "Always show mail composer"; +"Inside current window" = "Inside current window"; +"In a popup window" = "In a popup window"; "When sending mail, add unknown recipients to my" = "When sending mail, add unknown recipients to my"; "Address Book" = "Address Book"; "Forward messages" = "Forward messages"; diff --git a/UI/PreferencesUI/UIxJSONPreferences.m b/UI/PreferencesUI/UIxJSONPreferences.m index 6a51f093e..9a10f99cd 100644 --- a/UI/PreferencesUI/UIxJSONPreferences.m +++ b/UI/PreferencesUI/UIxJSONPreferences.m @@ -274,6 +274,9 @@ static SoProduct *preferencesProduct = nil; // // Default Mail preferences // + if (![[defaults source] objectForKey: @"SOGoMailComposeWindow"]) + [[defaults source] setObject: [defaults mailComposeWindow] forKey: @"SOGoMailComposeWindow"]; + if (![[defaults source] objectForKey: @"SOGoSelectedAddressBook"]) [[defaults source] setObject: [defaults selectedAddressBook] forKey: @"SOGoSelectedAddressBook"]; diff --git a/UI/Templates/MailerUI/UIxMailFolderTemplate.wox b/UI/Templates/MailerUI/UIxMailFolderTemplate.wox index 5df08c980..7e0badcb3 100644 --- a/UI/Templates/MailerUI/UIxMailFolderTemplate.wox +++ b/UI/Templates/MailerUI/UIxMailFolderTemplate.wox @@ -322,6 +322,7 @@ @@ -344,6 +345,16 @@ + + + edit + +
+ ng-click="viewer.openInPopup()"> open_in_new diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox index 70f75b7d2..6526d63ce 100644 --- a/UI/Templates/PreferencesUI/UIxPreferences.wox +++ b/UI/Templates/PreferencesUI/UIxPreferences.wox @@ -566,6 +566,29 @@
+
+ + + + + + + + + + + + + + + +
+
', + controller: 'MessageEditorControllerPopup' } }, resolve: { @@ -84,10 +83,9 @@ .state('mail.account.mailbox.message.action', { url: '/{actionName:(?:reply|replyall|forward)}', views: { - message: { - templateUrl: 'UIxMailEditor', // UI/Templates/MailerUI/UIxMailEditor.wox - controller: 'MessageEditorController', - controllerAs: 'editor' + 'message@': { + template: '', + controller: 'MessageEditorControllerPopup' } } }); diff --git a/UI/WebServerResources/js/Mailer/MessageController.js b/UI/WebServerResources/js/Mailer/MessageController.js index 7ef67368f..b92b65b2c 100644 --- a/UI/WebServerResources/js/Mailer/MessageController.js +++ b/UI/WebServerResources/js/Mailer/MessageController.js @@ -6,8 +6,8 @@ /** * @ngInject */ - MessageController.$inject = ['$window', '$scope', '$state', '$mdMedia', '$mdDialog', 'sgConstant', 'stateAccounts', 'stateAccount', 'stateMailbox', 'stateMessage', 'sgHotkeys', 'encodeUriFilter', 'sgSettings', 'ImageGallery', 'sgFocus', 'Dialog', 'Calendar', 'Component', 'Account', 'Mailbox', 'Message']; - function MessageController($window, $scope, $state, $mdMedia, $mdDialog, sgConstant, stateAccounts, stateAccount, stateMailbox, stateMessage, sgHotkeys, encodeUriFilter, sgSettings, ImageGallery, focus, Dialog, Calendar, Component, Account, Mailbox, Message) { + MessageController.$inject = ['$window', '$scope', '$state', '$mdMedia', '$mdDialog', 'sgConstant', 'stateAccounts', 'stateAccount', 'stateMailbox', 'stateMessage', 'sgHotkeys', 'encodeUriFilter', 'sgSettings', 'ImageGallery', 'sgFocus', 'Dialog', 'Preferences', 'Calendar', 'Component', 'Account', 'Mailbox', 'Message']; + function MessageController($window, $scope, $state, $mdMedia, $mdDialog, sgConstant, stateAccounts, stateAccount, stateMailbox, stateMessage, sgHotkeys, encodeUriFilter, sgSettings, ImageGallery, focus, Dialog, Preferences, Calendar, Component, Account, Mailbox, Message) { var vm = this, popupWindow = null, hotkeys = []; this.$onInit = function() { @@ -284,6 +284,15 @@ } } + this._showMailEditorInPopup = function(action) { + if (!sgSettings.isPopup && + Preferences.defaults.SOGoMailComposeWindow == 'popup') { + this.openInPopup(action); + return true; + } + return false; + }; + this.close = function() { $state.go('mail.account.mailbox').then(function() { vm.message = null; @@ -292,27 +301,32 @@ }; this.reply = function($event) { - var message = this.message.$reply(); - _showMailEditor($event, message); + if (!this._showMailEditorInPopup('reply')) { + _showMailEditor($event, this.message.$reply()); + } }; this.replyAll = function($event) { - var message = this.message.$replyAll(); - _showMailEditor($event, message); + if (!this._showMailEditorInPopup('replyall')) { + _showMailEditor($event, this.message.$replyAll()); + } }; this.forward = function($event) { - var message = this.message.$forward(); - _showMailEditor($event, message); + if (!this._showMailEditorInPopup('forward')) { + _showMailEditor($event, this.message.$forward()); + } }; this.edit = function($event) { - this.message.$editableContent().then(function() { - _showMailEditor($event, vm.message); - }); + if (!this._showMailEditorInPopup('edit')) { + this.message.$editableContent().then(function() { + _showMailEditor($event, vm.message); + }); + } }; - this.openPopup = function() { + this.openInPopup = function(action) { var url = [sgSettings.baseURL(), 'UIxMailPopupView#!/Mail', this.message.accountId, @@ -321,6 +335,7 @@ this.message.uid] .join('/'), wId = this.message.$absolutePath(); + if (action) url += '/' + action; popupWindow = $window.open(url, wId, ["width=680", "height=520", diff --git a/UI/WebServerResources/js/Preferences/Preferences.service.js b/UI/WebServerResources/js/Preferences/Preferences.service.js index 83192eb7b..81f253961 100644 --- a/UI/WebServerResources/js/Preferences/Preferences.service.js +++ b/UI/WebServerResources/js/Preferences/Preferences.service.js @@ -44,6 +44,8 @@ // Mail editor autosave is a number of minutes or 0 if disabled data.SOGoMailAutoSave = parseInt(data.SOGoMailAutoSave) || 0; + data.SOGoMailComposeWindowEnabled = angular.isDefined(data.SOGoMailComposeWindow); + // Specify a base font size for HTML messages when SOGoMailComposeFontSize is not zero data.SOGoMailComposeFontSizeEnabled = parseInt(data.SOGoMailComposeFontSize) > 0; @@ -286,6 +288,10 @@ }); }); + if (!preferences.defaults.SOGoMailComposeWindowEnabled) + delete preferences.defaults.SOGoMailComposeWindow; + delete preferences.defaults.SOGoMailComposeWindowEnabled; + if (!preferences.defaults.SOGoMailComposeFontSizeEnabled) preferences.defaults.SOGoMailComposeFontSize = 0; delete preferences.defaults.SOGoMailComposeFontSizeEnabled;