fix(calendar(js)): conditional display of edit and delete buttons

This commit is contained in:
Francis Lachapelle
2022-08-15 15:31:19 -04:00
parent 3f7fef0788
commit 16459c7b3d
11 changed files with 57 additions and 40 deletions
@@ -116,7 +116,7 @@
* @param {bool} [writable] - if true, returns only the list of writable calendars
* @returns the list of calendars
*/
Calendar.$findAll = function(data, writable) {
Calendar.$findAll = function(data, writable, contextId) {
var _this = this;
if (data) {
this.$calendars = [];
@@ -144,7 +144,7 @@
if (writable) {
return _.union(this.$calendars, _.filter(this.$subscriptions, function(calendar) {
return calendar.isOwned || calendar.acls.objectCreator;
return calendar.isOwned || calendar.acls.objectCreator || calendar.id == contextId;
}));
}
@@ -672,8 +672,8 @@
* @desc Check if the component is editable and not an occurrence of a recurrent component
* @returns true or false
*/
Component.prototype.isEditable = function() {
return (!this.occurrenceId && !this.isReadOnly);
Component.prototype.isActionable = function() {
return (!this.occurrenceId && !this.userHasRSVP && (this.isEditable || this.isErasable));
};
/**
@@ -682,8 +682,8 @@
* @desc Check if the component is editable and an occurrence of a recurrent component
* @returns true or false
*/
Component.prototype.isEditableOccurrence = function() {
return (this.occurrenceId && !this.isReadOnly);
Component.prototype.isActionableOccurrence = function() {
return (this.occurrenceId && !this.userHasRSVP && (this.isEditable || this.isErasable));
};
/**
@@ -706,18 +706,6 @@
return (this.occurrenceId && this.userHasRSVP);
};
/**
* @function isMovable
* @memberof Component.prototype
* @desc Return true if the component can be moved to a different calendar which occurs in two cases:
* - the component is editable, ie is owned by the current user;
* - the component is an invitation and the current user is an attendee.
* @returns true or false
*/
Component.prototype.isMovable = function() {
return (!this.isReadOnly || this.userHasRSVP);
};
/**
* @function showPercentComplete
* @memberof Component.prototype
@@ -810,7 +798,7 @@
*/
Component.prototype.canRemindAttendeesByEmail = function() {
return this.alarm.action == 'email' &&
!this.isReadOnly &&
this.isEditable &&
this.attendees && this.attendees.length > 0;
};
@@ -278,6 +278,13 @@
this.showRecurrenceEditor = true;
};
this.destinationCalendars = function () {
if (this.component.isErasable)
return Calendar.$findAll(null, true, this.component.pid);
else
return [Calendar.$get(this.component.pid)];
};
this.changeCalendar = function () {
var updateRequired = (this.component.attendees && this.component.attendees.length > 0);
if (updateRequired)