diff --git a/js/app/controllers/calendarlistcontroller.js b/js/app/controllers/calendarlistcontroller.js index a116918762..7c31467817 100644 --- a/js/app/controllers/calendarlistcontroller.js +++ b/js/app/controllers/calendarlistcontroller.js @@ -3,8 +3,12 @@ * * @author Raghu Nayyar * @author Georg Ehrke + * @author Vinicius Cubas Brand + * @author Daniel Tygel * @copyright 2016 Raghu Nayyar * @copyright 2016 Georg Ehrke + * @copyright 2017 Vinicius Cubas Brand + * @copyright 2017 Daniel Tygel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE @@ -220,7 +224,7 @@ app.controller('CalendarListController', ['$scope', '$rootScope', '$window', 'Ha $scope.onSelectSharee = function (item, model, label, calendarItem) { const calendar = calendarItem.calendar; - // Create a default share with the user/group, read only + // Create a default share with the user/group/circle, read only calendar.share(item.type, item.identifier, item.displayname, false, false).then(function() { // Remove content from text box calendarItem.selectedSharee = ''; @@ -241,6 +245,12 @@ app.controller('CalendarListController', ['$scope', '$rootScope', '$window', 'Ha }); }; + $scope.updateExistingCircleShare = function(calendar, circleId, displayname, writable) { + calendar.share(constants.SHARE_TYPE_CIRCLE, circleId, displayname, writable, true).then(function() { + $scope.$apply(); + }); + }; + $scope.unshareFromUser = function(calendar, userId) { calendar.unshare(constants.SHARE_TYPE_USER, userId).then(function() { $scope.$apply(); @@ -253,6 +263,12 @@ app.controller('CalendarListController', ['$scope', '$rootScope', '$window', 'Ha }); }; + $scope.unshareFromCircle = function(calendar, circleId) { + calendar.unshare(constants.SHARE_TYPE_CIRCLE, circleId).then(function() { + $scope.$apply(); + }); + }; + $scope.findSharee = function (val, calendar) { return $.get( OC.linkToOCS('apps/files_sharing/api/v1') + 'sharees', @@ -265,11 +281,14 @@ app.controller('CalendarListController', ['$scope', '$rootScope', '$window', 'Ha ).then(function(result) { var users = result.ocs.data.exact.users.concat(result.ocs.data.users); var groups = result.ocs.data.exact.groups.concat(result.ocs.data.groups); + var circles = result.ocs.data.exact.circles.concat(result.ocs.data.circles); var userShares = calendar.shares.users; var groupShares = calendar.shares.groups; + var circleShares = calendar.shares.circles; var userSharesLength = userShares.length; var groupSharesLength = groupShares.length; + var circleSharesLength = circleShares.length; var i, j; // Filter out current user @@ -293,7 +312,7 @@ app.controller('CalendarListController', ['$scope', '$rootScope', '$window', 'Ha } } - // Combine users and groups + // Combine users, groups and circles users = users.map(function(item){ return { display: _.escape(item.label), @@ -312,7 +331,16 @@ app.controller('CalendarListController', ['$scope', '$rootScope', '$window', 'Ha }; }); - return groups.concat(users); + circles = circles.map(function(item){ + return { + display: item.label + ' (' + t('calendar', 'circle') + ')', + displayname: item.label, + type: constants.SHARE_TYPE_CIRCLE, + identifier: item.value.shareWith + }; + }); + + return circles.concat(groups).concat(users); }); }; diff --git a/js/app/factory/calendarFactory.js b/js/app/factory/calendarFactory.js index 013a2260c8..3c849322ca 100644 --- a/js/app/factory/calendarFactory.js +++ b/js/app/factory/calendarFactory.js @@ -2,7 +2,11 @@ * Calendar App * * @author Georg Ehrke + * @author Vinicius Cubas Brand + * @author Daniel Tygel * @copyright 2016 Georg Ehrke + * @copyright 2017 Vinicius Cubas Brand + * @copyright 2017 Daniel Tygel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE @@ -26,6 +30,7 @@ app.service('CalendarFactory', function(DavClient, Calendar, WebCal, constants) const SHARE_USER_PREFIX = 'principal:principals/users/'; const SHARE_GROUP_PREFIX = 'principal:principals/groups/'; + const SHARE_CIRCLE_PREFIX = 'principal:principals/circles/'; context.acl = function(props, userPrincipal) { const acl = props['{' + DavClient.NS_DAV + '}acl'] || []; @@ -125,7 +130,8 @@ app.service('CalendarFactory', function(DavClient, Calendar, WebCal, constants) const shareProp = props['{' + DavClient.NS_OWNCLOUD + '}invite']; const shares = { users: [], - groups: [] + groups: [], + circles: [] }; let ownerDisplayname = null; @@ -149,8 +155,10 @@ app.service('CalendarFactory', function(DavClient, Calendar, WebCal, constants) if (displayName.length === 0) { if (href.startsWith(SHARE_USER_PREFIX)) { displayName = href.substr(SHARE_USER_PREFIX.length); - } else { + } else if (href.startsWith(SHARE_GROUP_PREFIX)) { displayName = href.substr(SHARE_GROUP_PREFIX.length); + } else { + displayName = href.substr(SHARE_CIRCLE_PREFIX.length); } } else { displayName = displayName[0].textContent; @@ -184,6 +192,12 @@ app.service('CalendarFactory', function(DavClient, Calendar, WebCal, constants) displayname: displayName, writable: writable }); + } else if (href.startsWith(SHARE_CIRCLE_PREFIX)) { + shares.circles.push({ + id: href.substr(SHARE_CIRCLE_PREFIX.length), + displayname: displayName, + writable: writable + }); } }); diff --git a/js/app/models/calendarmodel.js b/js/app/models/calendarmodel.js index 5f358497a6..e3f4af949b 100644 --- a/js/app/models/calendarmodel.js +++ b/js/app/models/calendarmodel.js @@ -2,7 +2,11 @@ * Nextcloud - Calendar App * * @author Georg Ehrke + * @author Vinicius Cubas Brand + * @author Daniel Tygel * @copyright 2016 Georg Ehrke + * @copyright 2017 Vinicius Cubas Brand + * @copyright 2017 Daniel Tygel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE @@ -297,8 +301,9 @@ app.factory('Calendar', function($window, Hook, VEventService, TimezoneService, }; iface.isShared = function() { - return context.shares.groups.length !== 0 || - context.shares.users.length !== 0; + return context.shares.circles.length !== 0 || + context.shares.groups.length !== 0 || + context.shares.users.length !== 0; }; iface.isPublished = function() { diff --git a/js/app/service/calendarService.js b/js/app/service/calendarService.js index 1c2376aa43..7e552da910 100644 --- a/js/app/service/calendarService.js +++ b/js/app/service/calendarService.js @@ -3,8 +3,12 @@ * * @author Raghu Nayyar * @author Georg Ehrke + * @author Vinicius Cubas Brand + * @author Daniel Tygel * @copyright 2016 Raghu Nayyar * @copyright 2016 Georg Ehrke + * @copyright 2017 Vinicius Cubas Brand + * @copyright 2017 Daniel Tygel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE @@ -73,6 +77,7 @@ app.service('CalendarService', function(DavClient, StringUtility, XMLUtility, Ca const SHARE_USER = constants.SHARE_TYPE_USER; const SHARE_GROUP = constants.SHARE_TYPE_GROUP; + const SHARE_CIRCLE = constants.SHARE_TYPE_CIRCLE; context.bootPromise = (function() { if (isPublic) { @@ -138,15 +143,17 @@ app.service('CalendarService', function(DavClient, StringUtility, XMLUtility, Ca }; context.getShareValue = function(shareType, shareWith) { - if (shareType !== SHARE_USER && shareType !== SHARE_GROUP) { + if (shareType !== SHARE_USER && shareType !== SHARE_GROUP && shareType !== SHARE_CIRCLE) { throw new Error('Unknown shareType given'); } let hrefValue; if (shareType === SHARE_USER) { hrefValue = 'principal:principals/users/'; - } else { + } else if (shareType === SHARE_GROUP) { hrefValue = 'principal:principals/groups/'; + } else { + hrefValue = 'principal:principals/circles/'; } hrefValue += shareWith; @@ -559,12 +566,18 @@ app.service('CalendarService', function(DavClient, StringUtility, XMLUtility, Ca displayname: shareWithDisplayname, writable: writable }); - } else { + } else if (shareType === SHARE_GROUP) { calendar.shares.groups.push({ id: shareWith, displayname: shareWithDisplayname, writable: writable }); + } else { + calendar.shares.circles.push({ + id: shareWith, + displayname: shareWithDisplayname, + writable: writable + }); } }); }; @@ -604,11 +617,16 @@ app.service('CalendarService', function(DavClient, StringUtility, XMLUtility, Ca return user.id === shareWith; }); calendar.shares.users.splice(index, 1); - } else { + } else if (shareType === SHARE_GROUP) { const index = calendar.shares.groups.findIndex(function(group) { return group.id === shareWith; }); calendar.shares.groups.splice(index, 1); + } else { + const index = calendar.shares.circles.findIndex(function(circle) { + return circle.id === shareWith; + }); + calendar.shares.circles.splice(index, 1); } }); }; diff --git a/js/config/config.js b/js/config/config.js index 3e767b4fdc..e66415e0ac 100644 --- a/js/config/config.js +++ b/js/config/config.js @@ -83,7 +83,8 @@ app.config(['$provide', '$httpProvider', shareeCanEditCalendarProperties, canSharePublicLink, SHARE_TYPE_USER: 0, - SHARE_TYPE_GROUP: 1 + SHARE_TYPE_GROUP: 1, + SHARE_TYPE_CIRCLE: 7 }); } ]); diff --git a/templates/part.calendarlist.item.php b/templates/part.calendarlist.item.php index 951350dc06..60cce4129c 100644 --- a/templates/part.calendarlist.item.php +++ b/templates/part.calendarlist.item.php @@ -4,8 +4,12 @@ * * @author Raghu Nayyar * @author Georg Ehrke + * @author Vinicius Cubas Brand + * @author Daniel Tygel * @copyright 2016 Raghu Nayyar * @copyright 2016 Georg Ehrke + * @copyright 2017 Vinicius Cubas Brand + * @copyright 2017 Daniel Tygel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE @@ -127,7 +131,7 @@ class="app-navigation-entry-menu hidden"> +
  • + {{ circleShare.displayname }} (t('circle')); ?>) - + + + + + + + + + + +