(Calendar) Button to expand invited LDAP groups

Fixes #2506
This commit is contained in:
Francis Lachapelle
2019-08-27 16:33:10 -04:00
parent 9db406a18b
commit 8822c8cd07
9 changed files with 123 additions and 16 deletions
@@ -143,6 +143,8 @@
this.categories = [];
this.c_screenname = null;
angular.extend(this, data);
if (!this.pid)
this.pid = this.container;
if (!this.$$fullname)
this.$$fullname = this.$fullname();
if (!this.$$email)
@@ -211,12 +213,12 @@
/**
* @function $reload
* @memberof Message.prototype
* @desc Fetch the viewable message body along with other metadata such as the list of attachments.
* @memberof Card.prototype
* @desc Fetch all available attributes of the contact.
* @returns a promise of the HTTP operation
*/
Card.prototype.$reload = function() {
var futureCardData;
var _this = this, futureCardData;
if (this.$futureCardData)
return this;
@@ -226,6 +228,28 @@
return this.$unwrap(futureCardData);
};
/**
* @function $members
* @memberof Card.prototype
* @desc Fetch members of the LDAP group.
* @returns a promise that resolves with the members
*/
Card.prototype.$members = function() {
var _this = this;
if (this.members)
return Card.$q.when(this.members);
if (this.isgroup) {
return Card.$$resource.fetch([this.pid, this.id].join('/'), 'members').then(function(data) {
_this.members = _.map(data.members, function(member) {
return new Card(member);
});
return _this.members;
});
}
};
/**
* @function $save
* @memberof Card.prototype
@@ -383,7 +407,7 @@
};
Card.prototype.$isList = function(options) {
// isGroup attribute means it's a group of a LDAP source (not expandable on the client-side)
// isGroup attribute means it's a group of a LDAP source (not automatically expanded on the client-side)
var condition = (!options || !options.expandable || options.expandable && !this.isgroup);
return this.c_component == 'vlist' && condition;
};
@@ -181,6 +181,12 @@
if (!_.find(this.attendees, function(o) {
return o.email == attendee.email;
})) {
if (card.$isList()) {
// LDAP list -- preload members
card.$members().then(function(members) {
attendee.members = members;
});
}
attendee.image = Attendees.$gravatar(attendee.email, 32);
if (this.component.attendees)
this.component.attendees.push(attendee);
@@ -325,11 +325,26 @@
};
function scrollToStart() {
var dayElement = $element[0].querySelector('#freebusy_day_' + vm.component.start.getDayString());
var scrollLeft = dayElement.offsetLeft - vm.attendeesEditor.containerElement.offsetLeft;
vm.attendeesEditor.containerElement.scrollLeft = scrollLeft;
var dayElement, scrollLeft;
if (!vm.attendeesEditor.containerElement) {
vm.attendeesEditor.containerElement = $element[0].querySelector('#freebusy');
}
if (vm.attendeesEditor.containerElement) {
dayElement = $element[0].querySelector('#freebusy_day_' + vm.component.start.getDayString());
scrollLeft = dayElement.offsetLeft - vm.attendeesEditor.containerElement.offsetLeft;
vm.attendeesEditor.containerElement.scrollLeft = scrollLeft;
}
}
this.expandAttendee = function (attendee) {
if (attendee.members.length > 0) {
this.component.$attendees.remove(attendee);
_.forEach(attendee.members, function (member) {
vm.component.$attendees.add(member);
});
}
};
this.removeAttendee = function (attendee, form) {
this.component.$attendees.remove(attendee);
if (this.component.$attendees.getLength() === 0)
@@ -31,11 +31,15 @@
$scope.$watch(
function() {
return $ctrl.component? [ _.pick($ctrl.component, watchedAttrs) ] : null;
return $ctrl.component? {
start: $ctrl.component.start,
end: $ctrl.component.end,
attendees: _.map($ctrl.component.attendees, 'email')
} : null;
},
function(newId, oldId) {
if ($ctrl.component) {
// Component has changed
function(newAttrs, oldAttrs) {
if (newAttrs.attendees) {
// Attendees have changed
$q.all(_.values($ctrl.component.$attendees.$futureFreebusyData)).then(function() {
$ctrl.onUpdate();
});
@@ -76,7 +76,7 @@
});
this.parentController.onUpdate = function () {
var freebusys = $ctrl.attendee.freebusy[$ctrl.day];
var freebusys = $ctrl.attendee.uid ? $ctrl.attendee.freebusy[$ctrl.day] : null;
if (!$ctrl.attendee.uid) {
_.forEach(hours, function(div) {
@@ -92,7 +92,7 @@
} else {
quarters[index].classList.remove('event');
}
if (freebusys[hour][quarter]) {
if (freebusys && freebusys[hour][quarter]) {
busys[index].classList.remove('ng-hide');
} else {
busys[index].classList.add('ng-hide');