Restore next/previous slot suggestion for events

This commit is contained in:
Francis Lachapelle
2019-02-08 08:17:23 -05:00
parent aaf4166c44
commit 540e81b670
8 changed files with 783 additions and 357 deletions
@@ -205,21 +205,27 @@
/**
* @ngInject
*/
ComponentEditorController.$inject = ['$rootScope', '$scope', '$log', '$timeout', '$mdDialog', 'sgFocus', 'User', 'CalendarSettings', 'Calendar', 'Component', 'AddressBook', 'Card', 'Alarm', 'stateComponent'];
function ComponentEditorController($rootScope, $scope, $log, $timeout, $mdDialog, focus, User, CalendarSettings, Calendar, Component, AddressBook, Card, Alarm, stateComponent) {
ComponentEditorController.$inject = ['$rootScope', '$scope', '$log', '$timeout', '$element', '$mdDialog', 'sgFocus', 'User', 'CalendarSettings', 'Calendar', 'Component', 'Attendees', 'AddressBook', 'Card', 'Alarm', 'stateComponent'];
function ComponentEditorController($rootScope, $scope, $log, $timeout, $element, $mdDialog, focus, User, CalendarSettings, Calendar, Component, Attendees, AddressBook, Card, Alarm, stateComponent) {
var vm = this, component, oldStartDate, oldEndDate, oldDueDate;
this.$onInit = function () {
stateComponent.initAttendees();
this.service = Calendar;
this.component = stateComponent;
this.categories = {};
this.updateFreeBusyCoverage =
angular.bind(this.component.$attendees, this.component.$attendees.updateFreeBusyCoverage);
this.coversFreeBusy =
angular.bind(this.component.$attendees, this.component.$attendees.coversFreeBusy);
this.showRecurrenceEditor = this.component.$hasCustomRepeat;
this.showAttendeesEditor = this.component.attendees && this.component.attendees.length;
//this.searchText = null;
this.attendeeConflictError = false;
this.attendeesEditor = {
days: getDays(),
hours: getHours()
days: this.component.$attendees.$days,
hours: getHours(),
containerElement: $element[0].querySelector('#freebusy')
};
if (this.component.start)
@@ -297,7 +303,7 @@
card.charCodeAt(i) == 44 || // ,
card.charCodeAt(i) == 59) && // ;
emailRE.test(address)) {
this.component.addAttendee(createCard(address), options);
this.component.$attendees.add(createCard(address), options);
address = '';
}
else {
@@ -305,21 +311,43 @@
}
}
if (address)
this.component.addAttendee(createCard(address), options);
this.component.$attendees.add(createCard(address), options);
}
else {
this.component.addAttendee(card, options);
this.component.$attendees.add(card, options);
this.showAttendeesEditor |= initOrganizer;
}
$timeout(scrollToStart);
};
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;
}
this.removeAttendee = function (attendee, form) {
this.component.deleteAttendee(attendee);
if (this.component.attendees.length === 0)
this.component.$attendees.remove(attendee);
if (this.component.$attendees.getLength() === 0)
this.showAttendeesEditor = false;
form.$setDirty();
};
this.nextSlot = function () {
findSlot(1);
};
this.previousSlot = function () {
findSlot(-1);
};
function findSlot(direction) {
vm.component.$attendees.findSlot(direction).then(function () {
$timeout(scrollToStart);
});
}
this.priorityLevel = function () {
if (this.component && this.component.priority) {
if (this.component.priority > 5)
@@ -393,18 +421,6 @@
form.$setDirty();
};
function getDays() {
var days = [];
if (vm.component.start && vm.component.end)
days = vm.component.start.daysUpTo(vm.component.end);
return _.map(days, function(date) {
return { stringWithSeparator: date.stringWithSeparator(),
getDayString: date.getDayString() };
});
}
function getHours() {
var hours = [];
for (var i = 0; i <= 23; i++) {
@@ -486,8 +502,9 @@
};
function updateFreeBusy() {
vm.attendeesEditor.days = getDays();
vm.component.updateFreeBusy();
vm.component.$attendees.updateFreeBusyCoverage();
vm.component.$attendees.updateFreeBusy();
scrollToStart();
}
}