mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-16 02:38:51 +00:00
Added calendar sharing capability
This commit is contained in:
committed by
Francis Lachapelle
parent
0d62ec0bea
commit
feee156c0a
@@ -90,9 +90,9 @@
|
||||
User.$$resource.fetch(folderId, 'userRights', param).then(function(data) {
|
||||
_this.rights = data;
|
||||
// Convert numbers (0|1) to boolean values
|
||||
angular.forEach(_.keys(_this.rights), function(key) {
|
||||
_this.rights[key] = _this.rights[key] ? true : false;
|
||||
});
|
||||
//angular.forEach(_.keys(_this.rights), function(key) {
|
||||
// _this.rights[key] = _this.rights[key] ? true : false;
|
||||
//});
|
||||
// console.debug('rights ' + _this.uid + ' => ' + JSON.stringify(data, undefined, 2));
|
||||
// Keep a copy of the server's version
|
||||
_this.$shadowRights = angular.copy(data);
|
||||
|
||||
@@ -84,7 +84,8 @@
|
||||
})
|
||||
})
|
||||
|
||||
.controller('CalendarsController', ['$scope', '$rootScope', '$stateParams', '$state', '$timeout', '$log', 'sgFocus', 'encodeUriFilter', 'sgDialog', 'sgSettings', 'sgCalendar', 'stateCalendars', function($scope, $rootScope, $stateParams, $state, $timeout, $log, focus, encodeUriFilter, Dialog, Settings, Calendar, stateCalendars) {
|
||||
|
||||
.controller('CalendarsController', ['$scope', '$rootScope', '$stateParams', '$state', '$timeout', '$q', '$mdDialog', '$log', 'sgFocus', 'encodeUriFilter', 'sgDialog', 'sgSettings', 'sgCalendar', 'sgUser', 'stateCalendars', function($scope, $rootScope, $stateParams, $state, $timeout, $q, $mdDialog, $log, focus, encodeUriFilter, Dialog, Settings, Calendar, User, stateCalendars) {
|
||||
var vm = this;
|
||||
|
||||
vm.activeUser = Settings.activeUser;
|
||||
@@ -115,6 +116,77 @@
|
||||
true // compare for object equality
|
||||
);
|
||||
|
||||
$scope.share = function(calendar) {
|
||||
$mdDialog.show({
|
||||
templateUrl: calendar.id + '/UIxAclEditor', // UI/Templates/UIxAclEditor.wox
|
||||
controller: CalendarACLController,
|
||||
clickOutsideToClose: true,
|
||||
escapeToClose: true,
|
||||
locals: {
|
||||
usersWithACL: calendar.$acl.$users(),
|
||||
User: User,
|
||||
stateCalendar: calendar,
|
||||
q: $q
|
||||
}
|
||||
});
|
||||
function CalendarACLController($scope, $mdDialog, usersWithACL, User, stateCalendar, q) {
|
||||
$scope.users = usersWithACL; // ACL users
|
||||
$scope.stateCalendar = stateCalendar;
|
||||
$scope.userToAdd = '';
|
||||
$scope.searchText = '';
|
||||
$scope.userFilter = function($query) {
|
||||
var deferred = q.defer();
|
||||
User.$filter($query).then(function(results) {
|
||||
deferred.resolve(results)
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
$scope.closeModal = function() {
|
||||
stateCalendar.$acl.$resetUsersRights(); // cancel changes
|
||||
$mdDialog.hide();
|
||||
};
|
||||
$scope.saveModal = function() {
|
||||
stateCalendar.$acl.$saveUsersRights().then(function() {
|
||||
$mdDialog.hide();
|
||||
}, function(data, status) {
|
||||
Dialog.alert(l('Warning'), l('An error occured please try again.'));
|
||||
});
|
||||
};
|
||||
$scope.confirmChange = function(user) {
|
||||
var confirmation = user.$confirmRights();
|
||||
if (confirmation) {
|
||||
Dialog.confirm(l('Warning'), confirmation).then(function(res) {
|
||||
if (!res)
|
||||
user.$resetRights(true);
|
||||
});
|
||||
}
|
||||
};
|
||||
$scope.removeUser = function(user) {
|
||||
stateCalendar.$acl.$removeUser(user.uid).then(function() {
|
||||
if (user.uid == $scope.selectedUser.uid) {
|
||||
$scope.selectedUser = null;
|
||||
}
|
||||
}, function(data, status) {
|
||||
Dialog.alert(l('Warning'), l('An error occured please try again.'))
|
||||
});
|
||||
};
|
||||
$scope.addUser = function(data) {
|
||||
stateCalendar.$acl.$addUser(data).then(function() {
|
||||
$scope.userToAdd = '';
|
||||
$scope.searchText = '';
|
||||
}, function(error) {
|
||||
Dialog.alert(l('Warning'), error);
|
||||
});
|
||||
};
|
||||
$scope.selectUser = function(user) {
|
||||
// Check if it is a different user
|
||||
if ($scope.selectedUser != user) {
|
||||
$scope.selectedUser = user;
|
||||
$scope.selectedUser.$rights();
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
/**
|
||||
* subscribeToFolder - Callback of sgSubscribe directive
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user