(html,js) Add reminder/alarm to event editor

This commit is contained in:
Francis Lachapelle
2015-06-22 15:49:27 -04:00
parent bb8c32a77e
commit b41828a7f1
3 changed files with 90 additions and 54 deletions
@@ -245,6 +245,7 @@
this.categories = [];
this.repeat = {};
this.alarm = { action: 'display', quantity: 5, unit: 'MINUTES', reference: 'BEFORE', relation: 'START' };
angular.extend(this, data);
if (this.startDate)
@@ -291,6 +292,8 @@
this.repeat.end = 'never';
this.$hasCustomRepeat = this.hasCustomRepeat();
this.$hasAlarm = angular.isDefined(data.alarm);
// Allow the event to be moved to a different calendar
this.destinationCalendar = this.pid;
@@ -471,7 +474,7 @@
/**
* @function hasAttendee
* @memberof Component.prototype
* @desc Verify if one of the email addresses of a Card instance matches an attendee
* @desc Verify if one of the email addresses of a Card instance matches an attendee.
* @param {Object} card - an Card object instance
* @returns true if the Card matches an attendee
*/
@@ -482,7 +485,18 @@
});
});
return angular.isDefined(attendee);
}
};
/**
* @function canRemindAttendeesByEmail
* @memberof Component.prototype
* @desc Verify if the component's reminder must be send by email and if it has at least one attendee.
* @returns true if attendees can receive a reminder by email
*/
Component.prototype.canRemindAttendeesByEmail = function() {
return this.alarm.action == 'email' &&
this.attendees && this.attendees.length > 0;
};
/**
* @function $reset
@@ -591,6 +605,17 @@
delete component.repeat;
}
if (this.$hasAlarm) {
if (this.alarm.action == 'email' && !(this.attendees && this.attendees.length > 0)) {
// No attendees; email reminder must be sent to organizer only
this.alarm.attendees = 0;
this.alarm.organizer = 1;
}
}
else {
component.alarm = {};
}
function formatTime(dateString) {
// YYYY-MM-DDTHH:MM-ZZ:00 => YYYY-MM-DD HH:MM
var date = new Date(dateString.substring(0,10) + ' ' + dateString.substring(11,16)),