2015-05-06 04:06:13 +02:00
|
|
|
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ngInject
|
|
|
|
*/
|
2017-09-20 22:50:41 +02:00
|
|
|
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) {
|
2017-01-07 00:26:12 +01:00
|
|
|
var vm = this, popupWindow = null, hotkeys = [];
|
2015-07-13 21:22:58 +02:00
|
|
|
|
2017-06-15 22:04:47 +02:00
|
|
|
this.$onInit = function() {
|
|
|
|
// Expose controller
|
|
|
|
$window.$messageController = vm;
|
|
|
|
|
|
|
|
// Initialize image gallery service
|
|
|
|
ImageGallery.setMessage(stateMessage);
|
|
|
|
|
|
|
|
this.$state = $state;
|
|
|
|
this.accounts = stateAccounts;
|
|
|
|
this.account = stateAccount;
|
|
|
|
this.mailbox = stateMailbox;
|
|
|
|
this.message = stateMessage;
|
|
|
|
this.service = Message;
|
|
|
|
this.tags = { searchText: '', selected: '' };
|
|
|
|
this.showFlags = stateMessage.flags && stateMessage.flags.length > 0;
|
|
|
|
this.$showDetailedRecipients = false;
|
2018-06-20 20:51:03 +02:00
|
|
|
this.showRawSource = false;
|
2017-06-15 22:04:47 +02:00
|
|
|
|
|
|
|
_registerHotkeys(hotkeys);
|
|
|
|
|
|
|
|
// One-way refresh of the parent window when modifying the message from a popup window.
|
2018-06-20 20:51:03 +02:00
|
|
|
if ($window.opener &&
|
|
|
|
'$mailboxController' in $window.opener) {
|
2017-06-15 22:04:47 +02:00
|
|
|
// Update the message flags. The message must be displayed in the parent window.
|
|
|
|
$scope.$watchCollection(function() { return vm.message.flags; }, function(newTags, oldTags) {
|
|
|
|
var ctrls;
|
|
|
|
if (newTags || oldTags) {
|
|
|
|
ctrls = $parentControllers();
|
|
|
|
if (ctrls.messageCtrl) {
|
|
|
|
ctrls.messageCtrl.service.$timeout(function() {
|
|
|
|
ctrls.messageCtrl.showFlags = true;
|
|
|
|
ctrls.messageCtrl.message.flags = newTags;
|
|
|
|
});
|
|
|
|
}
|
2016-01-07 21:43:26 +01:00
|
|
|
}
|
2017-06-15 22:04:47 +02:00
|
|
|
});
|
|
|
|
// Update the "isflagged" (star icon) of the message. The mailbox must be displayed in the parent window.
|
|
|
|
$scope.$watch(function() { return vm.message.isflagged; }, function(isflagged, wasflagged) {
|
|
|
|
var ctrls = $parentControllers();
|
|
|
|
if (ctrls.mailboxCtrl) {
|
|
|
|
ctrls.mailboxCtrl.service.$timeout(function() {
|
|
|
|
var message = _.find(ctrls.mailboxCtrl.selectedFolder.$messages, { uid: vm.message.uid });
|
|
|
|
message.isflagged = isflagged;
|
2016-03-28 16:42:40 +02:00
|
|
|
});
|
|
|
|
}
|
2017-06-15 22:04:47 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Flatten new tags when coming from the predefined list of tags (Message.$tags) and
|
|
|
|
// sync tags with server when adding or removing a tag.
|
|
|
|
$scope.$watchCollection(function() { return vm.message.flags; }, function(_newTags, _oldTags) {
|
|
|
|
var newTags, oldTags, tags;
|
|
|
|
if (_newTags || _oldTags) {
|
|
|
|
newTags = _newTags || [];
|
|
|
|
oldTags = _oldTags || [];
|
|
|
|
_.forEach(newTags, function(tag, i) {
|
|
|
|
if (angular.isObject(tag))
|
|
|
|
newTags[i] = tag.name;
|
2016-03-28 16:42:40 +02:00
|
|
|
});
|
2017-06-15 22:04:47 +02:00
|
|
|
if (newTags.length > oldTags.length) {
|
|
|
|
tags = _.difference(newTags, oldTags);
|
|
|
|
_.forEach(tags, function(tag) {
|
|
|
|
vm.message.addTag(tag);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else if (newTags.length < oldTags.length) {
|
|
|
|
tags = _.difference(oldTags, newTags);
|
|
|
|
_.forEach(tags, function(tag) {
|
|
|
|
vm.message.removeTag(tag);
|
|
|
|
});
|
|
|
|
}
|
2016-03-28 16:42:40 +02:00
|
|
|
}
|
2017-06-15 22:04:47 +02:00
|
|
|
});
|
|
|
|
}
|
2016-01-07 21:43:26 +01:00
|
|
|
|
2017-06-15 22:04:47 +02:00
|
|
|
$scope.$on('$destroy', function() {
|
|
|
|
// Deregister hotkeys
|
|
|
|
_.forEach(hotkeys, function(key) {
|
|
|
|
sgHotkeys.deregisterHotkey(key);
|
|
|
|
});
|
2016-09-23 23:17:25 +02:00
|
|
|
});
|
2017-06-15 22:04:47 +02:00
|
|
|
|
|
|
|
}; // $onInit
|
2016-09-23 23:17:25 +02:00
|
|
|
|
|
|
|
|
2017-01-07 00:26:12 +01:00
|
|
|
/**
|
|
|
|
* To keep track of the currently active dialog, we share a common variable with the parent controller.
|
|
|
|
*/
|
|
|
|
function _messageDialog() {
|
2017-01-17 22:19:07 +01:00
|
|
|
if ($scope.mailbox) {
|
|
|
|
if (arguments.length > 0)
|
|
|
|
$scope.mailbox.messageDialog = arguments[0];
|
|
|
|
return $scope.mailbox.messageDialog;
|
|
|
|
}
|
|
|
|
return null;
|
2017-01-07 00:26:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function _unlessInDialog(callback) {
|
|
|
|
return function() {
|
|
|
|
// Check if a dialog is opened either from the current controller or the parent controller
|
|
|
|
if (_messageDialog() === null)
|
|
|
|
return callback.apply(vm, arguments);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-09-23 23:17:25 +02:00
|
|
|
function _registerHotkeys(keys) {
|
2016-10-17 21:10:40 +02:00
|
|
|
keys.push(sgHotkeys.createHotkey({
|
|
|
|
key: l('hotkey_reply'),
|
|
|
|
description: l('Reply to the message'),
|
2017-06-15 22:04:47 +02:00
|
|
|
callback: _unlessInDialog(angular.bind(vm, vm.reply))
|
2016-10-17 21:10:40 +02:00
|
|
|
}));
|
|
|
|
keys.push(sgHotkeys.createHotkey({
|
|
|
|
key: l('hotkey_replyall'),
|
|
|
|
description: l('Reply to sender and all recipients'),
|
2017-06-15 22:04:47 +02:00
|
|
|
callback: _unlessInDialog(angular.bind(vm, vm.replyAll))
|
2016-10-17 21:10:40 +02:00
|
|
|
}));
|
|
|
|
keys.push(sgHotkeys.createHotkey({
|
|
|
|
key: l('hotkey_forward'),
|
|
|
|
description: l('Forward selected message'),
|
2017-06-15 22:04:47 +02:00
|
|
|
callback: _unlessInDialog(angular.bind(vm, vm.forward))
|
2016-10-17 21:10:40 +02:00
|
|
|
}));
|
2016-09-30 18:15:37 +02:00
|
|
|
keys.push(sgHotkeys.createHotkey({
|
|
|
|
key: l('hotkey_flag'),
|
2016-10-17 21:10:40 +02:00
|
|
|
description: l('Flagged'),
|
2017-01-07 00:26:12 +01:00
|
|
|
callback: _unlessInDialog(angular.bind(stateMessage, stateMessage.toggleFlag))
|
2016-09-30 18:15:37 +02:00
|
|
|
}));
|
2017-06-14 19:37:13 +02:00
|
|
|
_.forEach(['backspace', 'delete'], function(hotkey) {
|
|
|
|
keys.push(sgHotkeys.createHotkey({
|
|
|
|
key: hotkey,
|
|
|
|
callback: _unlessInDialog(function($event) {
|
|
|
|
if (vm.mailbox.$selectedCount() === 0)
|
2017-06-15 22:04:47 +02:00
|
|
|
vm.deleteMessage();
|
2017-06-14 19:37:13 +02:00
|
|
|
$event.preventDefault();
|
|
|
|
}),
|
|
|
|
}));
|
|
|
|
});
|
2016-09-23 23:17:25 +02:00
|
|
|
|
|
|
|
// Register the hotkeys
|
2016-09-27 21:19:24 +02:00
|
|
|
_.forEach(keys, function(key) {
|
2016-09-23 23:17:25 +02:00
|
|
|
sgHotkeys.registerHotkey(key);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-01-07 21:43:26 +01:00
|
|
|
/**
|
|
|
|
* If this is a popup window, retrieve the matching controllers (mailbox and message) of the parent window.
|
|
|
|
*/
|
|
|
|
function $parentControllers() {
|
|
|
|
var message, mailbox, ctrls = {};
|
|
|
|
if ($window.opener) {
|
|
|
|
// Deleting the message from a popup window
|
2018-06-20 20:51:03 +02:00
|
|
|
if ('$mailboxController' in $window.opener &&
|
|
|
|
'selectedFolder' in $window.opener.$mailboxController &&
|
2016-01-07 21:43:26 +01:00
|
|
|
$window.opener.$mailboxController.selectedFolder.$id() == stateMailbox.$id()) {
|
|
|
|
// The message mailbox is opened in the parent window
|
|
|
|
mailbox = $window.opener.$mailboxController;
|
|
|
|
ctrls.mailboxCtrl = mailbox;
|
2018-06-20 20:51:03 +02:00
|
|
|
if ('$messageController' in $window.opener &&
|
2016-01-07 21:43:26 +01:00
|
|
|
$window.opener.$messageController.message.uid == stateMessage.uid) {
|
|
|
|
// The message is opened in the parent window
|
|
|
|
message = $window.opener.$messageController;
|
|
|
|
ctrls.messageCtrl = message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ctrls;
|
|
|
|
}
|
2015-07-13 21:22:58 +02:00
|
|
|
|
2017-06-15 22:04:47 +02:00
|
|
|
this.addFlags = function($event) {
|
2018-05-15 05:18:30 +02:00
|
|
|
$event.stopPropagation();
|
|
|
|
$event.preventDefault();
|
2017-06-15 22:04:47 +02:00
|
|
|
this.showFlags = true;
|
|
|
|
focus("flags");
|
|
|
|
};
|
|
|
|
|
|
|
|
this.toggleDetailedRecipients = function($event) {
|
|
|
|
this.$showDetailedRecipients = !this.$showDetailedRecipients;
|
2015-12-07 20:07:48 +01:00
|
|
|
$event.stopPropagation();
|
|
|
|
$event.preventDefault();
|
2017-06-15 22:04:47 +02:00
|
|
|
};
|
2015-12-07 20:07:48 +01:00
|
|
|
|
2017-06-15 22:04:47 +02:00
|
|
|
this.filterMailtoLinks = function($event) {
|
2016-05-11 03:29:18 +02:00
|
|
|
var href, match, to, cc, bcc, subject, body, data;
|
|
|
|
if ($event.target.tagName == 'A' && 'href' in $event.target.attributes) {
|
|
|
|
href = $event.target.attributes.href.value;
|
|
|
|
match = /^mailto:([^\?]+)/.exec(href);
|
|
|
|
if (match) {
|
2017-08-29 17:45:24 +02:00
|
|
|
delete $event.target.attributes.target;
|
|
|
|
this.newMessage($event, href); // will stop event propagation
|
2016-05-11 03:29:18 +02:00
|
|
|
}
|
|
|
|
}
|
2017-06-15 22:04:47 +02:00
|
|
|
};
|
2016-05-11 03:29:18 +02:00
|
|
|
|
2017-06-15 22:04:47 +02:00
|
|
|
this.deleteMessage = function() {
|
2016-01-08 22:31:06 +01:00
|
|
|
var mailbox, message, state, nextMessage, previousMessage,
|
|
|
|
parentCtrls = $parentControllers();
|
2016-01-07 21:43:26 +01:00
|
|
|
|
|
|
|
if (parentCtrls.messageCtrl) {
|
|
|
|
mailbox = parentCtrls.mailboxCtrl.selectedFolder;
|
|
|
|
message = parentCtrls.messageCtrl.message;
|
|
|
|
state = parentCtrls.messageCtrl.$state;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mailbox = stateMailbox;
|
|
|
|
message = stateMessage;
|
|
|
|
state = $state;
|
|
|
|
}
|
2018-06-15 04:20:24 +02:00
|
|
|
if (Mailbox.$virtualMode) {
|
|
|
|
mailbox = Mailbox.selectedFolder; // the VirtualMailbox instance
|
|
|
|
}
|
2016-01-07 21:43:26 +01:00
|
|
|
|
2016-01-08 22:31:06 +01:00
|
|
|
mailbox.$deleteMessages([message]).then(function(index) {
|
|
|
|
var nextIndex = index;
|
2015-05-08 21:47:09 +02:00
|
|
|
// Remove message object from scope
|
2016-01-07 21:43:26 +01:00
|
|
|
message = null;
|
|
|
|
if (angular.isDefined(state)) {
|
2016-01-08 22:31:06 +01:00
|
|
|
// Select either the next or previous message
|
|
|
|
if (index > 0) {
|
|
|
|
nextIndex -= 1;
|
2018-06-15 04:20:24 +02:00
|
|
|
nextMessage = mailbox.getItemAtIndex(nextIndex);
|
2016-01-08 22:31:06 +01:00
|
|
|
}
|
2018-06-15 04:20:24 +02:00
|
|
|
if (index < mailbox.getLength())
|
|
|
|
previousMessage = mailbox.getItemAtIndex(index);
|
2016-01-08 22:31:06 +01:00
|
|
|
|
|
|
|
if (nextMessage) {
|
|
|
|
if (nextMessage.isread && previousMessage && !previousMessage.isread) {
|
|
|
|
nextIndex = index;
|
|
|
|
nextMessage = previousMessage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (previousMessage) {
|
|
|
|
nextIndex = index;
|
|
|
|
nextMessage = previousMessage;
|
|
|
|
}
|
|
|
|
|
2016-01-07 21:43:26 +01:00
|
|
|
try {
|
2016-05-18 20:35:24 +02:00
|
|
|
if (nextMessage && $mdMedia(sgConstant['gt-md'])) {
|
2018-06-15 04:20:24 +02:00
|
|
|
if (Mailbox.$virtualMode)
|
|
|
|
state.go('mail.account.virtualMailbox.message', {mailboxId: encodeUriFilter(nextMessage.$mailbox.path), messageId: nextMessage.uid});
|
|
|
|
else
|
|
|
|
state.go('mail.account.mailbox.message', {messageId: nextMessage.uid});
|
2016-02-03 16:51:59 +01:00
|
|
|
if (nextIndex < mailbox.$topIndex)
|
|
|
|
mailbox.$topIndex = nextIndex;
|
|
|
|
else if (nextIndex > mailbox.$lastVisibleIndex)
|
|
|
|
mailbox.$topIndex = nextIndex - (mailbox.$lastVisibleIndex - mailbox.$topIndex);
|
2016-01-08 22:31:06 +01:00
|
|
|
}
|
|
|
|
else {
|
2016-05-17 22:39:12 +02:00
|
|
|
state.go('mail.account.mailbox').then(function() {
|
|
|
|
message = null;
|
|
|
|
delete mailbox.selectedMessage;
|
|
|
|
});
|
2016-01-08 22:31:06 +01:00
|
|
|
}
|
2016-01-07 21:43:26 +01:00
|
|
|
}
|
|
|
|
catch (error) {}
|
|
|
|
}
|
2017-06-15 22:04:47 +02:00
|
|
|
vm.closePopup();
|
2015-05-06 04:06:13 +02:00
|
|
|
});
|
2017-06-15 22:04:47 +02:00
|
|
|
};
|
2015-08-02 19:25:38 +02:00
|
|
|
|
2017-06-15 22:04:47 +02:00
|
|
|
function _showMailEditor($event, message) {
|
2017-01-07 00:26:12 +01:00
|
|
|
if (_messageDialog() === null) {
|
|
|
|
_messageDialog(
|
|
|
|
$mdDialog
|
|
|
|
.show({
|
2017-01-19 18:23:55 +01:00
|
|
|
parent: angular.element(document.body),
|
|
|
|
targetEvent: $event,
|
|
|
|
clickOutsideToClose: false,
|
|
|
|
escapeToClose: false,
|
|
|
|
templateUrl: 'UIxMailEditor',
|
|
|
|
controller: 'MessageEditorController',
|
|
|
|
controllerAs: 'editor',
|
|
|
|
locals: {
|
|
|
|
stateAccount: vm.account,
|
|
|
|
stateMessage: message
|
|
|
|
}
|
|
|
|
})
|
2018-02-05 21:48:09 +01:00
|
|
|
.catch(_.noop) // Cancel
|
2017-01-19 18:23:55 +01:00
|
|
|
.finally(function() {
|
|
|
|
_messageDialog(null);
|
2017-06-15 22:04:47 +02:00
|
|
|
vm.closePopup();
|
2017-01-19 18:23:55 +01:00
|
|
|
})
|
2017-01-07 00:26:12 +01:00
|
|
|
);
|
2015-08-27 03:22:39 +02:00
|
|
|
}
|
2015-08-02 19:25:38 +02:00
|
|
|
}
|
|
|
|
|
2017-09-20 22:50:41 +02:00
|
|
|
this._showMailEditorInPopup = function(action) {
|
|
|
|
if (!sgSettings.isPopup &&
|
|
|
|
Preferences.defaults.SOGoMailComposeWindow == 'popup') {
|
|
|
|
this.openInPopup(action);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2017-06-15 22:04:47 +02:00
|
|
|
this.close = function() {
|
2018-06-28 16:45:11 +02:00
|
|
|
var destination = Mailbox.$virtualMode ? 'mail.account.virtualMailbox' : 'mail.account.mailbox';
|
|
|
|
$state.go(destination).then(function() {
|
2015-08-26 23:28:03 +02:00
|
|
|
vm.message = null;
|
|
|
|
delete stateMailbox.selectedMessage;
|
|
|
|
});
|
2017-06-15 22:04:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
this.reply = function($event) {
|
2017-09-20 22:50:41 +02:00
|
|
|
if (!this._showMailEditorInPopup('reply')) {
|
|
|
|
_showMailEditor($event, this.message.$reply());
|
|
|
|
}
|
2017-06-15 22:04:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
this.replyAll = function($event) {
|
2017-09-20 22:50:41 +02:00
|
|
|
if (!this._showMailEditorInPopup('replyall')) {
|
|
|
|
_showMailEditor($event, this.message.$replyAll());
|
|
|
|
}
|
2017-06-15 22:04:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
this.forward = function($event) {
|
2017-09-20 22:50:41 +02:00
|
|
|
if (!this._showMailEditorInPopup('forward')) {
|
|
|
|
_showMailEditor($event, this.message.$forward());
|
|
|
|
}
|
2017-06-15 22:04:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
this.edit = function($event) {
|
2017-09-20 22:50:41 +02:00
|
|
|
if (!this._showMailEditorInPopup('edit')) {
|
|
|
|
this.message.$editableContent().then(function() {
|
|
|
|
_showMailEditor($event, vm.message);
|
|
|
|
});
|
|
|
|
}
|
2017-06-15 22:04:47 +02:00
|
|
|
};
|
2015-08-04 22:51:33 +02:00
|
|
|
|
2017-09-20 22:50:41 +02:00
|
|
|
this.openInPopup = function(action) {
|
2015-09-04 23:31:16 +02:00
|
|
|
var url = [sgSettings.baseURL(),
|
2017-01-17 22:19:07 +01:00
|
|
|
'UIxMailPopupView#!/Mail',
|
2017-06-15 22:04:47 +02:00
|
|
|
this.message.accountId,
|
2015-09-04 23:31:16 +02:00
|
|
|
// The double-encoding is necessary
|
2017-06-15 22:04:47 +02:00
|
|
|
encodeUriFilter(encodeUriFilter(this.message.$mailbox.path)),
|
|
|
|
this.message.uid]
|
2015-09-04 23:31:16 +02:00
|
|
|
.join('/'),
|
2017-06-15 22:04:47 +02:00
|
|
|
wId = this.message.$absolutePath();
|
2017-09-20 22:50:41 +02:00
|
|
|
if (action) url += '/' + action;
|
2015-09-04 23:31:16 +02:00
|
|
|
popupWindow = $window.open(url, wId,
|
|
|
|
["width=680",
|
|
|
|
"height=520",
|
|
|
|
"resizable=1",
|
|
|
|
"scrollbars=1",
|
|
|
|
"toolbar=0",
|
|
|
|
"location=0",
|
|
|
|
"directories=0",
|
|
|
|
"status=0",
|
|
|
|
"menubar=0",
|
|
|
|
"copyhistory=0"]
|
|
|
|
.join(','));
|
2017-06-15 22:04:47 +02:00
|
|
|
};
|
2015-09-04 23:31:16 +02:00
|
|
|
|
2017-06-15 22:04:47 +02:00
|
|
|
this.closePopup = function() {
|
2018-01-31 16:02:47 +01:00
|
|
|
if ($window.document.body.classList.contains('popup'))
|
2016-01-07 21:43:26 +01:00
|
|
|
$window.close();
|
2017-06-15 22:04:47 +02:00
|
|
|
};
|
2015-09-04 23:31:16 +02:00
|
|
|
|
2017-08-29 17:45:24 +02:00
|
|
|
this.newMessage = function($event, mailto) {
|
2015-12-07 20:07:48 +01:00
|
|
|
$event.stopPropagation();
|
|
|
|
$event.preventDefault();
|
2017-08-29 17:45:24 +02:00
|
|
|
this.account.$newMessage({ mailto: mailto }).then(function(message) {
|
|
|
|
_showMailEditor($event, message);
|
|
|
|
});
|
2017-06-15 22:04:47 +02:00
|
|
|
};
|
2015-08-09 16:36:54 +02:00
|
|
|
|
2017-06-15 22:04:47 +02:00
|
|
|
this.toggleRawSource = function($event) {
|
|
|
|
if (!this.showRawSource && !this.message.$rawSource) {
|
|
|
|
Message.$$resource.post(this.message.id, "viewsource").then(function(data) {
|
2016-05-11 03:23:15 +02:00
|
|
|
vm.message.$rawSource = data;
|
2015-12-04 21:00:58 +01:00
|
|
|
vm.showRawSource = true;
|
2015-08-04 22:51:33 +02:00
|
|
|
});
|
2015-12-04 21:00:58 +01:00
|
|
|
}
|
|
|
|
else {
|
2017-06-15 22:04:47 +02:00
|
|
|
this.showRawSource = !this.showRawSource;
|
2015-12-04 21:00:58 +01:00
|
|
|
}
|
2017-06-15 22:04:47 +02:00
|
|
|
};
|
2016-02-10 22:15:00 +01:00
|
|
|
|
2017-06-15 22:04:47 +02:00
|
|
|
this.print = function($event) {
|
2016-02-26 21:41:53 +01:00
|
|
|
$window.print();
|
2017-06-15 22:04:47 +02:00
|
|
|
};
|
2016-02-26 21:41:53 +01:00
|
|
|
|
2017-06-15 22:04:47 +02:00
|
|
|
this.convertToEvent = function($event) {
|
|
|
|
return _convertToComponent($event, 'appointment');
|
|
|
|
};
|
2016-02-10 22:15:00 +01:00
|
|
|
|
2017-06-15 22:04:47 +02:00
|
|
|
this.convertToTask = function($event) {
|
|
|
|
return _convertToComponent($event, 'task');
|
|
|
|
};
|
2016-02-10 22:15:00 +01:00
|
|
|
|
2017-06-15 22:04:47 +02:00
|
|
|
function _convertToComponent($event, type) {
|
2016-02-10 22:15:00 +01:00
|
|
|
vm.message.$plainContent().then(function(data) {
|
|
|
|
var componentData = {
|
|
|
|
pid: Calendar.$defaultCalendar(),
|
|
|
|
type: type,
|
|
|
|
summary: data.subject,
|
|
|
|
comment: data.content
|
|
|
|
};
|
|
|
|
var component = new Component(componentData);
|
|
|
|
// UI/Templates/SchedulerUI/UIxAppointmentEditorTemplate.wox or
|
|
|
|
// UI/Templates/SchedulerUI/UIxTaskEditorTemplate.wox
|
|
|
|
var templateUrl = [
|
|
|
|
sgSettings.activeUser('folderURL'),
|
|
|
|
'Calendar',
|
|
|
|
'UIx' + type.capitalize() + 'EditorTemplate'
|
|
|
|
].join('/');
|
|
|
|
return $mdDialog.show({
|
|
|
|
parent: angular.element(document.body),
|
|
|
|
targetEvent: $event,
|
|
|
|
clickOutsideToClose: true,
|
|
|
|
escapeToClose: true,
|
|
|
|
templateUrl: templateUrl,
|
|
|
|
controller: 'ComponentEditorController',
|
|
|
|
controllerAs: 'editor',
|
|
|
|
locals: {
|
|
|
|
stateComponent: component
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2015-05-06 04:06:13 +02:00
|
|
|
}
|
2017-05-29 20:03:59 +02:00
|
|
|
|
2015-05-06 04:06:13 +02:00
|
|
|
angular
|
2017-05-29 20:03:59 +02:00
|
|
|
.module('SOGo.MailerUI')
|
|
|
|
.controller('MessageController', MessageController);
|
2015-05-06 04:06:13 +02:00
|
|
|
})();
|