From 8124faa6d4c0f014c0ee349547ee43067d841d39 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 3 Jun 2015 19:42:30 -0400 Subject: [PATCH] (feat) "Materialization" of the IMIP handling template --- UI/MailPartViewers/UIxMailPartICalActions.m | 10 +- UI/MailPartViewers/UIxMailPartICalViewer.h | 34 +- UI/MailPartViewers/UIxMailPartICalViewer.m | 61 ++- UI/MailPartViewers/UIxMailPartViewer.m | 9 + UI/MailPartViewers/product.plist | 5 - .../Appointments/SOGoAptMailDeletion.wox | 11 +- .../Appointments/SOGoAptMailInvitation.wox | 3 +- .../Appointments/SOGoAptMailUpdate.wox | 3 +- .../MailPartViewers/UIxMailPartICalViewer.wox | 411 ++++++++++-------- .../js/Mailer/Message.service.js | 19 + .../js/Mailer/sgIMIP.directive.js | 54 +++ .../autoScrollList/autoScrollList.scss | 25 ++ .../scss/components/list/list.scss | 28 ++ 13 files changed, 453 insertions(+), 220 deletions(-) create mode 100644 UI/WebServerResources/js/Mailer/sgIMIP.directive.js diff --git a/UI/MailPartViewers/UIxMailPartICalActions.m b/UI/MailPartViewers/UIxMailPartICalActions.m index e068ebbe5..388c6e9fa 100644 --- a/UI/MailPartViewers/UIxMailPartICalActions.m +++ b/UI/MailPartViewers/UIxMailPartICalActions.m @@ -1,6 +1,6 @@ /* UIxMailPartICalActions.m - this file is part of SOGo * - * Copyright (C) 2007-2014 Inverse inc. + * Copyright (C) 2007-2015 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -288,12 +288,15 @@ // BOOL receiveUpdates; NSString *delegatedEmail, *delegatedUid; iCalPerson *delegatedAttendee; + NSDictionary *content; SOGoUser *user; WORequest *request; WOResponse *response; request = [context request]; - delegatedEmail = [request formValueForKey: @"to"]; + content = [[request contentAsString] objectFromJSONString]; + delegatedEmail = [content objectForKey: @"delegatedTo"]; + if ([delegatedEmail length]) { user = [context activeUser]; @@ -307,13 +310,14 @@ delegatedUser = [SOGoUser userWithLogin: delegatedUid]; [delegatedAttendee setCn: [delegatedUser cn]]; } + [delegatedAttendee setRole: @"REQ-PARTICIPANT"]; [delegatedAttendee setRsvp: @"TRUE"]; [delegatedAttendee setParticipationStatus: iCalPersonPartStatNeedsAction]; [delegatedAttendee setDelegatedFrom: [NSString stringWithFormat: @"mailto:%@", [[user allEmails] objectAtIndex: 0]]]; -// receiveUpdates = [[request formValueForKey: @"receiveUpdates"] boolValue]; +// receiveUpdates = [[content objectForKey: @"receiveUpdates"] boolValue]; // if (receiveUpdates) // [delegatedAttendee setRole: @"NON-PARTICIPANT"]; diff --git a/UI/MailPartViewers/UIxMailPartICalViewer.h b/UI/MailPartViewers/UIxMailPartICalViewer.h index cd5650f3e..98a2019a0 100644 --- a/UI/MailPartViewers/UIxMailPartICalViewer.h +++ b/UI/MailPartViewers/UIxMailPartICalViewer.h @@ -1,22 +1,20 @@ /* - Copyright (C) 2004-2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. + * Copyright (C) 2007-2015 Inverse inc. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifndef UIXMAILPARTICALVIEWER_H diff --git a/UI/MailPartViewers/UIxMailPartICalViewer.m b/UI/MailPartViewers/UIxMailPartICalViewer.m index f377234db..210ec76b5 100644 --- a/UI/MailPartViewers/UIxMailPartICalViewer.m +++ b/UI/MailPartViewers/UIxMailPartICalViewer.m @@ -1,6 +1,5 @@ /* - Copyright (C) 2004-2005 SKYRIX Software AG - Copyright (C) 2006-2013 Inverse inc. + Copyright (C) 2006-2015 Inverse inc. This file is part of SOGo. @@ -182,6 +181,59 @@ return date; } +/* + In v3.0, we moved the template's logic here to format + the event's start/end date-time. The previous logic was: + +
+ + + + + + + + + + + + + + + + +
+ +*/ +- (NSString *) formattedDateTime +{ + NSMutableString *s; + + s = [NSMutableString string]; + + [s appendString: [self startDate]]; + + if (![[self inEvent] isAllDay]) + [s appendFormat: @" %@", [self startTime]]; + + if ([self isEndDateOnSameDay] && + ![[self inEvent] isAllDay]) + { + [s appendFormat: @" %@", [self labelForKey: @"to"]]; + [s appendFormat: @" %@", [self endTime]]; + } + else if (![self isEndDateOnSameDay]) + { + [s appendFormat: @" %@", [self labelForKey: @"to"]]; + [s appendFormat: @" %@", [self endDate]]; + + if (![[self inEvent] isAllDay]) + [s appendFormat: @" %@", [self endTime]]; + } + + return s; +} + - (NSString *) startDate { return [[self dateFormatter] formattedDate: [self startCalendarDate]]; @@ -388,10 +440,7 @@ cssClass = [[attendee partStatWithDefault] lowercaseString]; - if ([[attendee rfc822Email] isEqualToString: [self loggedInUserEMail]]) - cssClass = [cssClass stringByAppendingString: @" attendeeUser"]; - - return cssClass; + return [NSString stringWithFormat: @"sg-%@", cssClass]; } /* derived fields */ diff --git a/UI/MailPartViewers/UIxMailPartViewer.m b/UI/MailPartViewers/UIxMailPartViewer.m index eb481d6d5..8721e47ef 100644 --- a/UI/MailPartViewers/UIxMailPartViewer.m +++ b/UI/MailPartViewers/UIxMailPartViewer.m @@ -328,6 +328,15 @@ return url; } +- (NSString *) pathToAttachmentFromMessage +{ + SOGoMailBodyPart *bodyPart; + + bodyPart = [self clientPart]; + + return [NSString stringWithFormat: @"%@/%@", [bodyPart nameInContainer], [self _filenameForAttachment: bodyPart]]; +} + - (NSString *) pathToAttachment { return [self _pathForAttachmentOrDownload: NO]; diff --git a/UI/MailPartViewers/product.plist b/UI/MailPartViewers/product.plist index 225c9e7f0..78cedf99d 100644 --- a/UI/MailPartViewers/product.plist +++ b/UI/MailPartViewers/product.plist @@ -43,11 +43,6 @@ actionClass = "UIxMailPartICalActions"; actionName = "updateUserStatus"; }; - /* tentative = { - protectedBy = "View"; - actionClass = "UIxMailPartICalAction"; - actionName = "markTentative"; - }; */ addToCalendar = { protectedBy = "View"; actionClass = "UIxMailPartICalActions"; diff --git a/UI/Templates/Appointments/SOGoAptMailDeletion.wox b/UI/Templates/Appointments/SOGoAptMailDeletion.wox index 544be59bd..c5daf29a6 100644 --- a/UI/Templates/Appointments/SOGoAptMailDeletion.wox +++ b/UI/Templates/Appointments/SOGoAptMailDeletion.wox @@ -14,11 +14,12 @@ th, td { font-family: Lucida Grande, Bitstream VeraSans, Tahoma, sans-serif; fon - - - + + + diff --git a/UI/Templates/Appointments/SOGoAptMailInvitation.wox b/UI/Templates/Appointments/SOGoAptMailInvitation.wox index 1abc71423..1e952739a 100644 --- a/UI/Templates/Appointments/SOGoAptMailInvitation.wox +++ b/UI/Templates/Appointments/SOGoAptMailInvitation.wox @@ -15,7 +15,8 @@ th, td { font-family: Lucida Grande, Bitstream VeraSans, Tahoma, sans-serif; fon

- diff --git a/UI/Templates/Appointments/SOGoAptMailUpdate.wox b/UI/Templates/Appointments/SOGoAptMailUpdate.wox index f47f6afe5..bce368fb7 100644 --- a/UI/Templates/Appointments/SOGoAptMailUpdate.wox +++ b/UI/Templates/Appointments/SOGoAptMailUpdate.wox @@ -15,7 +15,8 @@ th, td { font-family: Lucida Grande, Bitstream VeraSans, Tahoma, sans-serif; fon

- diff --git a/UI/Templates/MailPartViewers/UIxMailPartICalViewer.wox b/UI/Templates/MailPartViewers/UIxMailPartICalViewer.wox index 4a09a2095..c0125be7e 100644 --- a/UI/Templates/MailPartViewers/UIxMailPartICalViewer.wox +++ b/UI/Templates/MailPartViewers/UIxMailPartICalViewer.wox @@ -4,173 +4,219 @@ xmlns:var="http://www.skyrix.com/od/binding" xmlns:label="OGo:label" xmlns:const="http://www.skyrix.com/od/constant" - xmlns:rsrc="OGo:url" - class="linked_attachment_frame" - > - - - - + xmlns:rsrc="OGo:url"> + + -
- Parsing Error - - The SOGo/SOPE iCalendar parser could not parse the body of this MIME part. - -
-
-
- - -
-
    +
    + +
    +

    + SOGo could not parse the body of this calendar MIME part. +

    +
    +
    + +
    +
    -
    - - : - - - - () - - - () - - + + + + + + + +
    + + -
    -

    +

    +

    - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + +

    + + + + {{user.cn}} {{user.c_email}} + + + + +
    + + + + + + + + - - - +

    +
    + + + +

    + + + +

    + + + + +

    + + + + + +

    -

    -
    -
    - -

    - - - -

    -
    - - -

    - - - -

    -
    -
    + + + - -

    +

    + +

    - -
    -
    :
    -
    , + +

    + : + , - . -

    -
    + . +

    +
    + + + +
    + - -
    -
    +

    -
    - -
    -
    + + + +
    + - -
    -
    -
    +

    + - -
    -
    -
    +

    @@ -181,57 +227,60 @@

    - -
    -
    -
    :
    -
    - - - - - - - - - - - - - - - - -
    -
    :
    -
    -
    -
    :
    - -
    - - ( , )
    -
    -
    - -
    :
    -
    -
    -
    + +
    + +
    + +
    -
    - - - +
    + +
    + +
    +
    + + + +
    + +
    + + + + +
    +
    +
    +

    +

    ( , )

    +
    +
    +
    +
    +
    + +
    + + +
    + +
    +

    + +

    +
    +
    +
    +
    + +
    + diff --git a/UI/WebServerResources/js/Mailer/Message.service.js b/UI/WebServerResources/js/Mailer/Message.service.js index 80060a4f0..18b30e85c 100644 --- a/UI/WebServerResources/js/Mailer/Message.service.js +++ b/UI/WebServerResources/js/Mailer/Message.service.js @@ -291,6 +291,25 @@ return Message.$$resource.post(this.$mailbox.$id(), 'addOrRemoveLabel', data); }; + /** + * @function $imipAction + * @memberof Message.prototype + * @desc Perform IMIP actions on the current message. + * @param {string} path - the path of the IMIP calendar part + * @param {string} action - the the IMIP action to perform + * @param {object} data - the delegation info + */ + Message.prototype.$imipAction = function(path, action, data) { + var _this = this; + Message.$$resource.post([this.id, path].join('/'), action, data).then(function(data) { + Message.$timeout(function() { + _this.$reload(); + }, function() { + // TODO: show toast + }); + }); + }; + /** * @function $markAsFlaggedOrUnflagged * @memberof Message.prototype diff --git a/UI/WebServerResources/js/Mailer/sgIMIP.directive.js b/UI/WebServerResources/js/Mailer/sgIMIP.directive.js new file mode 100644 index 000000000..559670eea --- /dev/null +++ b/UI/WebServerResources/js/Mailer/sgIMIP.directive.js @@ -0,0 +1,54 @@ +/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ + +(function() { + 'use strict'; + + /** + * sgIMIP - A directive to handle IMIP actions on emails + * @memberof SOGo.MailerUI + * @ngInject + * @example: + + */ + function sgImip() { + return { + restrict: 'A', + link: link, + controller: controller + }; + + function link(scope, iElement, attrs, ctrl) { + ctrl.pathToAttachment = attrs.sgImipPath; + } + + controller.$inject = ['$scope', 'User']; + + function controller($scope, User) { + var vm = this; + $scope.delegateInvitation = false; + $scope.delegatedTo = ''; + $scope.searchText = ''; + + $scope.userFilter = function($query) { + return User.$filter($query); + }; + + $scope.iCalendarAction = function(action) { + + var data; + + if (action == 'delegate') { + data = {receiveUpdates: false, + delegatedTo: $scope.delegatedTo.c_email}; + } + + $scope.message.$imipAction(vm.pathToAttachment, action, data); + }; + } + } + + angular + .module('SOGo.MailerUI') + .directive('sgImip', sgImip); +})(); + diff --git a/UI/WebServerResources/scss/components/autoScrollList/autoScrollList.scss b/UI/WebServerResources/scss/components/autoScrollList/autoScrollList.scss index febf62ddf..7eee52967 100644 --- a/UI/WebServerResources/scss/components/autoScrollList/autoScrollList.scss +++ b/UI/WebServerResources/scss/components/autoScrollList/autoScrollList.scss @@ -85,3 +85,28 @@ margin-right: 0; margin-left: 0; } +.sg-accepted { + @extend .md-tile-left-accepted; + margin-right: 0; + margin-left: 0; +} +.sg-declined { + @extend .md-tile-left-declined; + margin-right: 0; + margin-left: 0; +} +.sg-delegated { + @extend .md-tile-left-delegated; + margin-right: 0; + margin-left: 0; +} +.sg-needs-action { + @extend .md-tile-left-needs-action; + margin-right: 0; + margin-left: 0; +} +.sg-tentative { + @extend .md-tile-left-tentative; + margin-right: 0; + margin-left: 0; +} \ No newline at end of file diff --git a/UI/WebServerResources/scss/components/list/list.scss b/UI/WebServerResources/scss/components/list/list.scss index 0dace3597..913e28b16 100644 --- a/UI/WebServerResources/scss/components/list/list.scss +++ b/UI/WebServerResources/scss/components/list/list.scss @@ -99,3 +99,31 @@ div.md-tile-left { @extend .md-tile-left; content: "\f299"; } +.md-tile-left-accepted:before { + @extend .md-tile-left; + background-color: rgba(0, 255, 0, 0.3) !important; + content: "\f299"; + color: rgba(0, 0, 0, 0.5); +} +.md-tile-left-declined:before { + @extend .md-tile-left; + background-color: rgba(255, 0, 0, 0.3) !important; + content: "\f111"; + color: rgba(0, 0, 0, 0.5); +} +.md-tile-left-delegated:before { + @extend .md-tile-left; + background-color: rgba(192, 192, 192, 0.3) !important; + content: "\f298"; + color: rgba(0, 0, 0, 0.5); +} +.md-tile-left-needs-action:before { + @extend .md-tile-left; + background-color: rgba(255, 255, 0, 0.3) !important; + content: "?"; +} +.md-tile-left-tentative:before { + @extend .md-tile-left; + background-color: rgba(255, 255, 0, 0.3) !important; + content: "\f2d8"; +}