mirror of
https://github.com/nextcloud/calendar.git
synced 2024-10-07 16:40:09 +02:00
remove legacy code
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
This commit is contained in:
parent
d949d73a13
commit
683a2e34cc
136 changed files with 2 additions and 32391 deletions
45
js/.jshintrc
45
js/.jshintrc
|
@ -1,45 +0,0 @@
|
|||
{
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"immed": true,
|
||||
"indent": 4,
|
||||
"latedef": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nonew": true,
|
||||
"plusplus": false,
|
||||
"node": true,
|
||||
"undef": true,
|
||||
"unused": false,
|
||||
"strict": true,
|
||||
"maxparams": false,
|
||||
"maxdepth": 4,
|
||||
"esversion": 6,
|
||||
"browser": true,
|
||||
"devel": true,
|
||||
"jquery": true,
|
||||
"jasmine": true,
|
||||
"globals": {
|
||||
"jQuery": true,
|
||||
"ICAL": true,
|
||||
"jstz": true,
|
||||
"moment": true,
|
||||
"angular": true,
|
||||
"app": true,
|
||||
"OC": true,
|
||||
"oc_current_user":true,
|
||||
"oc_requesttoken": true,
|
||||
"requestToken": true,
|
||||
"inject": true,
|
||||
"module": true,
|
||||
"t": true,
|
||||
"it": true,
|
||||
"exports": true,
|
||||
"escapeHTML": true,
|
||||
"possible": true,
|
||||
"dav": true,
|
||||
"hslToRgb": true,
|
||||
"autosize": true,
|
||||
"_": true
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"extends": "stylelint-config-standard",
|
||||
"rules": {
|
||||
"indentation": "tab",
|
||||
"number-leading-zero": "never",
|
||||
"no-descending-specificity": null,
|
||||
"no-duplicate-selectors": null,
|
||||
"comment-empty-line-before": ["always", {
|
||||
"except": ["first-nested"]
|
||||
}]
|
||||
}
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
/**
|
||||
* Calendar App
|
||||
*
|
||||
* @author Raghu Nayyar
|
||||
* @author Georg Ehrke
|
||||
* @copyright 2016 Raghu Nayyar <hey@raghunayyar.com>
|
||||
* @copyright 2016 Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
app.controller('AttendeeController', function($scope, AutoCompletionService) {
|
||||
'use strict';
|
||||
|
||||
$scope.newAttendeeGroup = -1;
|
||||
$scope.nameofattendee = '';
|
||||
|
||||
$scope.cutstats = [
|
||||
{displayname: t('calendar', 'Individual'), val: 'INDIVIDUAL'},
|
||||
{displayname: t('calendar', 'Group'), val: 'GROUP'},
|
||||
{displayname: t('calendar', 'Resource'), val: 'RESOURCE'},
|
||||
{displayname: t('calendar', 'Room'), val: 'ROOM'},
|
||||
{displayname: t('calendar', 'Unknown'), val: 'UNKNOWN'}
|
||||
];
|
||||
|
||||
$scope.partstats = [
|
||||
{displayname: t('calendar', 'Required'), val: 'REQ-PARTICIPANT'},
|
||||
{displayname: t('calendar', 'Optional'), val: 'OPT-PARTICIPANT'},
|
||||
{displayname: t('calendar', 'Does not attend'), val: 'NON-PARTICIPANT'}
|
||||
];
|
||||
|
||||
$scope.$parent.registerPostHook(function() {
|
||||
$scope.properties.attendee = $scope.properties.attendee || [];
|
||||
if ($scope.properties.attendee.length > 0 && $scope.properties.organizer === null) {
|
||||
$scope.properties.organizer = {
|
||||
value: 'mailto:' + $scope.$parent.emailAddress,
|
||||
parameters: {
|
||||
cn: OC.getCurrentUser().displayName
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
$scope.add = function (email) {
|
||||
if (email !== '') {
|
||||
$scope.properties.attendee = $scope.properties.attendee || [];
|
||||
$scope.properties.attendee.push({
|
||||
value: 'mailto:' + email,
|
||||
group: $scope.newAttendeeGroup--,
|
||||
parameters: {
|
||||
'role': 'REQ-PARTICIPANT',
|
||||
'rsvp': 'TRUE',
|
||||
'partstat': 'NEEDS-ACTION',
|
||||
'cutype': 'INDIVIDUAL'
|
||||
}
|
||||
});
|
||||
}
|
||||
$scope.attendeeoptions = false;
|
||||
$scope.nameofattendee = '';
|
||||
};
|
||||
|
||||
$scope.$on('save-contents', function() {
|
||||
$scope.add($scope.nameofattendee);
|
||||
});
|
||||
|
||||
$scope.remove = function (attendee) {
|
||||
$scope.properties.attendee = $scope.properties.attendee.filter(function(elem) {
|
||||
return elem.group !== attendee.group;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.search = function (value) {
|
||||
return AutoCompletionService.searchAttendee(value).then((attendees) => {
|
||||
const arr = [];
|
||||
|
||||
attendees.forEach((attendee) => {
|
||||
const emailCount = attendee.email.length;
|
||||
attendee.email.forEach((email) => {
|
||||
let displayname;
|
||||
if (emailCount === 1) {
|
||||
displayname = _.escape(attendee.name);
|
||||
} else {
|
||||
displayname = t('calendar', '{name} ({email})', {
|
||||
name: attendee.name,
|
||||
email: email
|
||||
});
|
||||
}
|
||||
|
||||
arr.push({
|
||||
displayname: displayname,
|
||||
email: email,
|
||||
name: attendee.name
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return arr;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.selectFromTypeahead = function (item) {
|
||||
$scope.properties.attendee = $scope.properties.attendee || [];
|
||||
$scope.properties.attendee.push({
|
||||
value: 'mailto:' + item.email,
|
||||
parameters: {
|
||||
cn: item.name,
|
||||
role: 'REQ-PARTICIPANT',
|
||||
rsvp: 'TRUE',
|
||||
partstat: 'NEEDS-ACTION',
|
||||
cutype: 'INDIVIDUAL'
|
||||
}
|
||||
});
|
||||
$scope.nameofattendee = '';
|
||||
};
|
||||
});
|
|
@ -1,306 +0,0 @@
|
|||
/**
|
||||
* Calendar App
|
||||
*
|
||||
* @author Raghu Nayyar
|
||||
* @author Georg Ehrke
|
||||
* @copyright 2016 Raghu Nayyar <hey@raghunayyar.com>
|
||||
* @copyright 2016 Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Controller: CalController
|
||||
* Description: The fullcalendar controller.
|
||||
*/
|
||||
|
||||
app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEventService', 'SettingsService', 'TimezoneService', 'VEvent', 'is', 'fc', 'EventsEditorDialogService', 'PopoverPositioningUtility', '$window', 'isPublic', 'constants', 'settings',
|
||||
function ($scope, Calendar, CalendarService, VEventService, SettingsService, TimezoneService, VEvent, is, fc, EventsEditorDialogService, PopoverPositioningUtility, $window, isPublic, constants, settings) {
|
||||
'use strict';
|
||||
|
||||
is.loading = true;
|
||||
|
||||
$scope.calendars = [];
|
||||
$scope.eventSource = {};
|
||||
$scope.eventModal = null;
|
||||
var switcher = [];
|
||||
|
||||
if (settings.timezone === 'automatic') {
|
||||
$scope.defaulttimezone = TimezoneService.getDetected();
|
||||
} else {
|
||||
$scope.defaulttimezone = settings.timezone;
|
||||
}
|
||||
|
||||
function showCalendar(url) {
|
||||
if (switcher.indexOf(url) === -1 && $scope.eventSource[url].isRendering === false) {
|
||||
switcher.push(url);
|
||||
fc.elm.fullCalendar(
|
||||
'removeEventSource',
|
||||
$scope.eventSource[url]);
|
||||
fc.elm.fullCalendar(
|
||||
'addEventSource',
|
||||
$scope.eventSource[url]);
|
||||
}
|
||||
}
|
||||
|
||||
function hideCalendar(url) {
|
||||
fc.elm.fullCalendar(
|
||||
'removeEventSource',
|
||||
$scope.eventSource[url]);
|
||||
if (switcher.indexOf(url) !== -1) {
|
||||
switcher.splice(switcher.indexOf(url), 1);
|
||||
}
|
||||
}
|
||||
|
||||
function createAndRenderEvent(calendar, data, start, end, tz) {
|
||||
VEventService.create(calendar, data).then(function(vevent) {
|
||||
if (calendar.enabled) {
|
||||
fc.elm.fullCalendar('refetchEventSources', calendar.fcEventSource);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteAndRemoveEvent(vevent, fcEvent) {
|
||||
VEventService.delete(vevent).then(function() {
|
||||
fc.elm.fullCalendar('removeEvents', fcEvent.id);
|
||||
});
|
||||
}
|
||||
|
||||
$scope.$watchCollection('calendars', function(newCalendars, oldCalendars) {
|
||||
newCalendars.filter(function(calendar) {
|
||||
return oldCalendars.indexOf(calendar) === -1;
|
||||
}).forEach(function(calendar) {
|
||||
$scope.eventSource[calendar.url] = calendar.fcEventSource;
|
||||
if (calendar.enabled) {
|
||||
showCalendar(calendar.url);
|
||||
}
|
||||
|
||||
calendar.register(Calendar.hookEnabledChanged, function(enabled) {
|
||||
if (enabled) {
|
||||
showCalendar(calendar.url);
|
||||
} else {
|
||||
hideCalendar(calendar.url);
|
||||
//calendar.list.loading = false;
|
||||
}
|
||||
});
|
||||
|
||||
calendar.register(Calendar.hookColorChanged, function() {
|
||||
if (calendar.enabled) {
|
||||
hideCalendar(calendar.url);
|
||||
showCalendar(calendar.url);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
oldCalendars.filter(function(calendar) {
|
||||
return newCalendars.indexOf(calendar) === -1;
|
||||
}).forEach(function(calendar) {
|
||||
var url = calendar.url;
|
||||
hideCalendar(calendar.url);
|
||||
|
||||
delete $scope.eventSource[url];
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
TimezoneService.get($scope.defaulttimezone).then(function(timezone) {
|
||||
if (timezone) {
|
||||
ICAL.TimezoneService.register($scope.defaulttimezone, timezone.jCal);
|
||||
}
|
||||
}).catch(function() {
|
||||
OC.Notification.showTemporary(
|
||||
t('calendar', 'You are in an unknown timezone ({tz}), falling back to UTC', {
|
||||
tz: $scope.defaulttimezone
|
||||
})
|
||||
);
|
||||
|
||||
$scope.defaulttimezone = 'UTC';
|
||||
$scope.fcConfig.timezone = 'UTC';
|
||||
fc.elm.fullCalendar('option', 'timezone', 'UTC');
|
||||
});
|
||||
|
||||
if (!isPublic) {
|
||||
$scope.calendarsPromise = CalendarService.getAll().then(function (calendars) {
|
||||
$scope.calendars = calendars;
|
||||
is.loading = false;
|
||||
// TODO - scope.apply should not be necessary here
|
||||
$scope.$apply();
|
||||
});
|
||||
} else {
|
||||
$scope.calendarsPromise = CalendarService.getPublicCalendar(constants.publicSharingToken).then(function(calendar) {
|
||||
$scope.calendars = [calendar];
|
||||
is.loading = false;
|
||||
// TODO - scope.apply should not be necessary here
|
||||
$scope.$apply();
|
||||
}).catch((reason) => {
|
||||
angular.element('#header-right').css('display', 'none');
|
||||
angular.element('#emptycontent-container').css('display', 'block');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calendar UI Configuration.
|
||||
*/
|
||||
$scope.fcConfig = {
|
||||
timezone: $scope.defaulttimezone,
|
||||
select: function (start, end, jsEvent, view) {
|
||||
var writableCalendars = $scope.calendars.filter(function(elem) {
|
||||
return elem.isWritable();
|
||||
});
|
||||
|
||||
if (writableCalendars.length === 0) {
|
||||
if (!isPublic) {
|
||||
OC.Notification.showTemporary(t('calendar', 'Please create a calendar first.'));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
start.add(start.toDate().getTimezoneOffset(), 'minutes');
|
||||
end.add(end.toDate().getTimezoneOffset(), 'minutes');
|
||||
|
||||
var vevent = VEvent.fromStartEnd(start, end, $scope.defaulttimezone);
|
||||
vevent.calendar = writableCalendars[0];
|
||||
|
||||
var timestamp = Date.now();
|
||||
var fcEventClass = 'new-event-dummy-' + timestamp;
|
||||
|
||||
vevent.getFcEvent(view.start, view.end, $scope.defaulttimezone).then((fcEvents) => {
|
||||
const fcEvent = fcEvents[0];
|
||||
|
||||
fcEvent.title = t('calendar', 'New event');
|
||||
fcEvent.className.push(fcEventClass);
|
||||
fcEvent.editable = false;
|
||||
fc.elm.fullCalendar('renderEvent', fcEvent);
|
||||
|
||||
EventsEditorDialogService.open($scope, fcEvent, function() {
|
||||
const elements = angular.element('.' + fcEventClass);
|
||||
const isHidden = angular.element(elements[0]).parents('.fc-limited').length !== 0;
|
||||
if (isHidden) {
|
||||
return PopoverPositioningUtility.calculate(jsEvent.clientX, jsEvent.clientY, jsEvent.clientX, jsEvent.clientY, view);
|
||||
} else {
|
||||
return PopoverPositioningUtility.calculateByTarget(elements[0], view);
|
||||
}
|
||||
}, function() {
|
||||
return null;
|
||||
}, function() {
|
||||
fc.elm.fullCalendar('removeEvents', function(fcEventToCheck) {
|
||||
if (Array.isArray(fcEventToCheck.className)) {
|
||||
return (fcEventToCheck.className.indexOf(fcEventClass) !== -1);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}).then(function(result) {
|
||||
createAndRenderEvent(result.calendar, result.vevent.data, view.start, view.end, $scope.defaulttimezone);
|
||||
}).catch(function(reason) {
|
||||
//fcEvent is removed by unlock callback
|
||||
//no need to anything
|
||||
return null;
|
||||
});
|
||||
});
|
||||
},
|
||||
eventClick: function(fcEvent, jsEvent, view) {
|
||||
var vevent = fcEvent.vevent;
|
||||
var oldCalendar = vevent.calendar;
|
||||
var fcEvt = fcEvent;
|
||||
|
||||
EventsEditorDialogService.open($scope, fcEvent, function() {
|
||||
return PopoverPositioningUtility.calculateByTarget(jsEvent.currentTarget, view);
|
||||
}, function() {
|
||||
fcEvt.editable = false;
|
||||
fc.elm.fullCalendar('updateEvent', fcEvt);
|
||||
}, function() {
|
||||
fcEvt.editable = fcEvent.calendar.writable;
|
||||
fc.elm.fullCalendar('updateEvent', fcEvt);
|
||||
}).then(function(result) {
|
||||
// was the event moved to another calendar?
|
||||
if (result.calendar === oldCalendar) {
|
||||
VEventService.update(vevent).then(function() {
|
||||
fc.elm.fullCalendar('removeEvents', fcEvent.id);
|
||||
|
||||
if (result.calendar.enabled) {
|
||||
fc.elm.fullCalendar('refetchEventSources', result.calendar.fcEventSource);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
deleteAndRemoveEvent(vevent, fcEvent);
|
||||
createAndRenderEvent(result.calendar, result.vevent.data, view.start, view.end, $scope.defaulttimezone);
|
||||
}
|
||||
}).catch(function(reason) {
|
||||
if (reason === 'delete') {
|
||||
deleteAndRemoveEvent(vevent, fcEvent);
|
||||
}
|
||||
});
|
||||
},
|
||||
eventResize: function (fcEvent, delta, revertFunc) {
|
||||
fcEvent.resize(delta);
|
||||
VEventService.update(fcEvent.vevent).catch(function() {
|
||||
revertFunc();
|
||||
});
|
||||
},
|
||||
eventDrop: function (fcEvent, delta, revertFunc) {
|
||||
const isAllDay = !fcEvent.start.hasTime();
|
||||
|
||||
const defaultAllDayEventDuration = fc.elm.fullCalendar('option', 'defaultAllDayEventDuration');
|
||||
const defaultAllDayEventMomentDuration = moment.duration(defaultAllDayEventDuration);
|
||||
|
||||
const defaultTimedEventDuration = fc.elm.fullCalendar('option', 'defaultTimedEventDuration');
|
||||
const defaultTimedEventMomentDuration = moment.duration(defaultTimedEventDuration);
|
||||
|
||||
const timezone = $scope.defaulttimezone;
|
||||
|
||||
fcEvent.drop(delta, isAllDay, timezone, defaultTimedEventMomentDuration, defaultAllDayEventMomentDuration);
|
||||
VEventService.update(fcEvent.vevent).catch(function() {
|
||||
revertFunc();
|
||||
});
|
||||
},
|
||||
viewRender: function (view, element) {
|
||||
angular.element('#firstrow').find('.datepicker_current').html(view.title).text();
|
||||
angular.element('#datecontrol_date').datepicker('setDate', element.fullCalendar('getDate'));
|
||||
var newView = view.name;
|
||||
if (newView !== $scope.defaultView && !isPublic) {
|
||||
SettingsService.setView(newView);
|
||||
$scope.defaultView = newView;
|
||||
}
|
||||
if (newView === 'agendaDay') {
|
||||
angular.element('td.fc-state-highlight').css('background-color', '#ffffff');
|
||||
} else {
|
||||
angular.element('.fc-bg td.fc-state-highlight').css('background-color', '#ffa');
|
||||
}
|
||||
if (newView ==='agendaWeek') {
|
||||
element.fullCalendar('option', 'aspectRatio', 0.1);
|
||||
} else {
|
||||
element.fullCalendar('option', 'aspectRatio', 1.35);
|
||||
}
|
||||
},
|
||||
eventRender: function(event, element) {
|
||||
var status = event.getSimpleEvent().status;
|
||||
if (status !== null) {
|
||||
if (status.value === 'TENTATIVE') {
|
||||
element.css({'opacity': 0.5});
|
||||
}
|
||||
else if (status.value === 'CANCELLED') {
|
||||
element.css({
|
||||
'text-decoration': 'line-through',
|
||||
'opacity': 0.5
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
]);
|
|
@ -1,409 +0,0 @@
|
|||
/**
|
||||
* Calendar App
|
||||
*
|
||||
* @author Raghu Nayyar
|
||||
* @author Georg Ehrke
|
||||
* @author Vinicius Cubas Brand
|
||||
* @author Daniel Tygel
|
||||
* @copyright 2016 Raghu Nayyar <hey@raghunayyar.com>
|
||||
* @copyright 2016 Georg Ehrke <oc.list@georgehrke.com>
|
||||
* @copyright 2017 Vinicius Cubas Brand <vinicius@eita.org.br>
|
||||
* @copyright 2017 Daniel Tygel <dtygel@eita.org.br>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Controller: CalendarListController
|
||||
* Description: Takes care of CalendarList in App Navigation.
|
||||
*/
|
||||
|
||||
app.controller('CalendarListController', ['$scope', '$rootScope', '$window', 'HashService', 'CalendarService', 'WebCalService', 'is', 'CalendarListItem', 'Calendar', 'MailerService', 'ColorUtility', 'isSharingAPI', 'constants',
|
||||
function ($scope, $rootScope, $window, HashService, CalendarService, WebCalService, is, CalendarListItem, Calendar, MailerService, ColorUtility, isSharingAPI, constants) {
|
||||
'use strict';
|
||||
|
||||
$scope.calendarListItems = [];
|
||||
$scope.is = is;
|
||||
$scope.newCalendarInputVal = '';
|
||||
$scope.newCalendarColorVal = '';
|
||||
$scope.addingCal = false;
|
||||
$scope.addingCalRequest = false;
|
||||
$scope.addingSub = false;
|
||||
$scope.addingSubRequest = false;
|
||||
|
||||
$scope.subscription = {};
|
||||
$scope.subscription.newSubscriptionUrl = '';
|
||||
$scope.subscription.newSubscriptionLocked = false;
|
||||
$scope.publicdav = 'CalDAV';
|
||||
$scope.publicdavdesc = t('calendar', 'CalDAV address for clients');
|
||||
$scope.warningLabel = t('calendar', 'Some events in this calendar are broken. Please check the JS console for more info.');
|
||||
$scope.shareLabel = t('calendar', 'Share Calendar');
|
||||
$scope.sharedLabel = t('calendar', 'Shared');
|
||||
|
||||
$scope.isSharingAPI = isSharingAPI;
|
||||
$scope.canSharePublicLink = constants.canSharePublicLink;
|
||||
|
||||
$scope.$watchCollection('calendars', function(newCalendars, oldCalendars) {
|
||||
newCalendars = newCalendars || [];
|
||||
oldCalendars = oldCalendars || [];
|
||||
|
||||
newCalendars.filter(function(calendar) {
|
||||
return oldCalendars.indexOf(calendar) === -1;
|
||||
}).forEach(function(calendar) {
|
||||
const item = CalendarListItem(calendar);
|
||||
if (item) {
|
||||
$scope.calendarListItems.push(item);
|
||||
$scope.publicdavurl = $scope.$parent.calendars[0].caldav;
|
||||
calendar.register(Calendar.hookFinishedRendering, function() {
|
||||
if (!$scope.$$phase) {
|
||||
$scope.$apply();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
oldCalendars.filter(function(calendar) {
|
||||
return newCalendars.indexOf(calendar) === -1;
|
||||
}).forEach(function(calendar) {
|
||||
$scope.calendarListItems = $scope.calendarListItems.filter(function(itemToCheck) {
|
||||
return itemToCheck.calendar !== calendar;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$scope.openNewCalendarForm = () => {
|
||||
$scope.addingCal = true;
|
||||
};
|
||||
|
||||
$scope.dismissNewCalendar = () => {
|
||||
$scope.newCalendarInputVal = '';
|
||||
$scope.newCalendarColorVal = '';
|
||||
$scope.addingCal = false;
|
||||
};
|
||||
|
||||
$scope.create = function (name) {
|
||||
$scope.addingCalRequest = true;
|
||||
const color = ColorUtility.randomColor();
|
||||
CalendarService.create(name, color).then(function(calendar) {
|
||||
$scope.calendars.push(calendar);
|
||||
$rootScope.$broadcast('createdCalendar', calendar);
|
||||
|
||||
$scope.newCalendarInputVal = '';
|
||||
$scope.newCalendarColorVal = '';
|
||||
$scope.addingCal = false;
|
||||
$scope.addingCalRequest = false;
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.openNewSubscriptionForm = () => {
|
||||
$scope.addingSub = true;
|
||||
};
|
||||
|
||||
$scope.dismissNewSubscription = () => {
|
||||
$scope.subscription.newSubscriptionUrl = '';
|
||||
$scope.addingSub = false;
|
||||
};
|
||||
|
||||
$scope.createSubscription = function(url) {
|
||||
$scope.subscription.newSubscriptionLocked = true;
|
||||
WebCalService.get(url).then(function(splittedICal) {
|
||||
const color = splittedICal.color || ColorUtility.randomColor();
|
||||
let name = splittedICal.name || url;
|
||||
|
||||
if (name.length > 100) {
|
||||
name = name.substr(0, 100);
|
||||
}
|
||||
|
||||
CalendarService.createWebCal(name, color, url)
|
||||
.then(function(calendar) {
|
||||
angular.element('#new-subscription-button').click();
|
||||
$scope.calendars.push(calendar);
|
||||
$scope.subscription.newSubscriptionUrl = '';
|
||||
$scope.$digest();
|
||||
$scope.$parent.$digest();
|
||||
$scope.subscription.newSubscriptionLocked = false;
|
||||
$scope.addingSub = false;
|
||||
})
|
||||
.catch(function() {
|
||||
OC.Notification.showTemporary(t('calendar', 'Could not save WebCal-calendar'));
|
||||
$scope.subscription.newSubscriptionLocked = false;
|
||||
});
|
||||
}).catch(function(reason) {
|
||||
if (reason.error) {
|
||||
OC.Notification.showTemporary(reason.message);
|
||||
$scope.subscription.newSubscriptionLocked = false;
|
||||
} else if(reason.redirect) {
|
||||
$scope.createSubscription(reason.new_url);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.download = function (item) {
|
||||
$window.open(item.calendar.downloadUrl);
|
||||
};
|
||||
|
||||
$scope.integration = function (item) {
|
||||
return '<iframe width="400" height="215" src="' + item.publicEmbedURL + '"></iframe>';
|
||||
};
|
||||
|
||||
$scope.$watch('publicdav', function (newvalue) {
|
||||
if ($scope.$parent.calendars[0]) {
|
||||
if (newvalue === 'CalDAV') { // CalDAV address
|
||||
$scope.publicdavurl = $scope.$parent.calendars[0].caldav;
|
||||
$scope.publicdavdesc = t('calendar', 'CalDAV address for clients');
|
||||
} else { // WebDAV address
|
||||
var url = $scope.$parent.calendars[0].url;
|
||||
// cut off last slash to have a fancy name for the ics
|
||||
if (url.slice(url.length - 1) === '/') {
|
||||
url = url.slice(0, url.length - 1);
|
||||
}
|
||||
url += '?export';
|
||||
$scope.publicdavurl = $window.location.origin + url;
|
||||
$scope.publicdavdesc = t('calendar', 'WebDAV address for subscriptions');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$scope.sendMail = function (item) {
|
||||
item.toggleSendingMail();
|
||||
MailerService.sendMail(item.email, item.publicSharingURL, item.calendar.displayname).then(function (response) {
|
||||
if (response.status === 200) {
|
||||
item.email = '';
|
||||
OC.Notification.showTemporary(t('calendar', 'Email sent.'));
|
||||
} else {
|
||||
OC.Notification.showTemporary(t('calendar', 'Could not send your email.'));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.goPublic = function (item) {
|
||||
$window.open(item.publicSharingURL);
|
||||
};
|
||||
|
||||
$scope.toggleSharesEditor = function (calendar) {
|
||||
calendar.toggleSharesEditor();
|
||||
};
|
||||
|
||||
$scope.togglePublish = function(item) {
|
||||
if (item.calendar.published) {
|
||||
item.calendar.publish().then(function (response) {
|
||||
if (response) {
|
||||
CalendarService.get(item.calendar.url).then(function (calendar) {
|
||||
item.calendar.publicToken = calendar.publicToken;
|
||||
item.calendar.published = true;
|
||||
});
|
||||
}
|
||||
$scope.$apply();
|
||||
});
|
||||
} else {
|
||||
item.calendar.unpublish().then(function (response) {
|
||||
if (response) {
|
||||
item.calendar.published = false;
|
||||
}
|
||||
$scope.$apply();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.prepareUpdate = function (calendar) {
|
||||
calendar.prepareUpdate();
|
||||
};
|
||||
|
||||
$scope.onSelectSharee = function (item, model, label, calendarItem) {
|
||||
const calendar = calendarItem.calendar;
|
||||
// Create a default share with the user/group/circle, read only
|
||||
calendar.share(item.type, item.identifier, item.displayname, false, false).then(function() {
|
||||
// Remove content from text box
|
||||
calendarItem.selectedSharee = '';
|
||||
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.updateExistingUserShare = function(calendar, userId, displayname, writable) {
|
||||
calendar.share(constants.SHARE_TYPE_USER, userId, displayname, writable, true).then(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.updateExistingGroupShare = function(calendar, groupId, displayname, writable) {
|
||||
calendar.share(constants.SHARE_TYPE_GROUP, groupId, displayname, writable, true).then(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.updateExistingCircleShare = function(calendar, circleId, displayname, writable) {
|
||||
calendar.share(constants.SHARE_TYPE_CIRCLE, circleId, displayname, writable, true).then(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.unshareFromUser = function(calendar, userId) {
|
||||
calendar.unshare(constants.SHARE_TYPE_USER, userId).then(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.unshareFromGroup = function(calendar, groupId) {
|
||||
calendar.unshare(constants.SHARE_TYPE_GROUP, groupId).then(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.unshareFromCircle = function(calendar, circleId) {
|
||||
calendar.unshare(constants.SHARE_TYPE_CIRCLE, circleId).then(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.findSharee = function (val, calendar) {
|
||||
return $.get(
|
||||
OC.linkToOCS('apps/files_sharing/api/v1') + 'sharees',
|
||||
{
|
||||
format: 'json',
|
||||
search: val.trim(),
|
||||
perPage: 200,
|
||||
itemType: 'principals'
|
||||
}
|
||||
).then(function(result) {
|
||||
var users = result.ocs.data.exact.users.concat(result.ocs.data.users);
|
||||
var groups = result.ocs.data.exact.groups.concat(result.ocs.data.groups);
|
||||
var circles = result.ocs.data.exact.circles.concat(result.ocs.data.circles);
|
||||
|
||||
var userShares = calendar.shares.users;
|
||||
var groupShares = calendar.shares.groups;
|
||||
var circleShares = calendar.shares.circles;
|
||||
var userSharesLength = userShares.length;
|
||||
var groupSharesLength = groupShares.length;
|
||||
var circleSharesLength = circleShares.length;
|
||||
var i, j;
|
||||
|
||||
// Filter out current user
|
||||
var usersLength = users.length;
|
||||
for (i = 0 ; i < usersLength; i++) {
|
||||
if (users[i].value.shareWith === OC.currentUser) {
|
||||
users.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Now filter out all sharees that are already shared with
|
||||
for (i = 0; i < userSharesLength; i++) {
|
||||
var share = userShares[i];
|
||||
usersLength = users.length;
|
||||
for (j = 0; j < usersLength; j++) {
|
||||
if (users[j].value.shareWith === share.id) {
|
||||
users.splice(j, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Combine users, groups and circles
|
||||
users = users.map(function(item){
|
||||
return {
|
||||
display: _.escape(item.label),
|
||||
displayname: item.label,
|
||||
type: constants.SHARE_TYPE_USER,
|
||||
identifier: item.value.shareWith
|
||||
};
|
||||
});
|
||||
|
||||
groups = groups.map(function(item){
|
||||
return {
|
||||
display: _.escape(item.label + ' (' + t('calendar', 'group') + ')'),
|
||||
displayname: item.label,
|
||||
type: constants.SHARE_TYPE_GROUP,
|
||||
identifier: item.value.shareWith
|
||||
};
|
||||
});
|
||||
|
||||
circles = circles.map(function(item){
|
||||
return {
|
||||
display: item.label + ' (' + t('calendar', 'circle') + ')',
|
||||
displayname: item.label,
|
||||
type: constants.SHARE_TYPE_CIRCLE,
|
||||
identifier: item.value.shareWith
|
||||
};
|
||||
});
|
||||
|
||||
return circles.concat(groups).concat(users);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.performUpdate = function (item) {
|
||||
item.saveEditor();
|
||||
item.calendar.update().then(function() {
|
||||
$rootScope.$broadcast('updatedCalendar', item.calendar);
|
||||
$rootScope.$broadcast('reloadCalendarList');
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the shares of the calendar
|
||||
*/
|
||||
$scope.performUpdateShares = function (calendar) {
|
||||
calendar.update().then(function() {
|
||||
calendar.dropPreviousState();
|
||||
calendar.list.edit = false;
|
||||
$rootScope.$broadcast('updatedCalendar', calendar);
|
||||
$rootScope.$broadcast('reloadCalendarList');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.triggerEnable = function(item) {
|
||||
item.calendar.toggleEnabled();
|
||||
|
||||
item.calendar.update().then(function() {
|
||||
$rootScope.$broadcast('updatedCalendarsVisibility', item.calendar);
|
||||
$rootScope.$broadcast('reloadCalendarList');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.remove = function (item) {
|
||||
item.calendar.delete().then(function() {
|
||||
$scope.$parent.calendars = $scope.$parent.calendars.filter(function(elem) {
|
||||
return elem !== item.calendar;
|
||||
});
|
||||
if (!$scope.$$phase) {
|
||||
$scope.$apply();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$rootScope.$on('reloadCalendarList', function() {
|
||||
if (!$scope.$$phase) {
|
||||
$scope.$apply();
|
||||
}
|
||||
});
|
||||
|
||||
HashService.runIfApplicable('subscribe_to_webcal', (map) => {
|
||||
if (map.has('url')) {
|
||||
const url = map.get('url');
|
||||
|
||||
$scope.subscription.newSubscriptionUrl = url;
|
||||
$scope.subscription.newSubscriptionLocked = true;
|
||||
angular.element('#new-subscription-button').click();
|
||||
|
||||
// wait for calendars to be initialized
|
||||
// needed for creating a proper URL
|
||||
$scope.calendarsPromise.then(() => {
|
||||
$scope.createSubscription(url);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
]);
|
|
@ -1,113 +0,0 @@
|
|||
/**
|
||||
* Calendar App
|
||||
*
|
||||
* @author Raghu Nayyar
|
||||
* @author Georg Ehrke
|
||||
* @copyright 2016 Raghu Nayyar <hey@raghunayyar.com>
|
||||
* @copyright 2016 Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Controller: Date Picker Controller
|
||||
* Description: Takes care for pushing dates from app navigation date picker and fullcalendar.
|
||||
*/
|
||||
app.controller('DatePickerController', ['$scope', 'fc', 'uibDatepickerConfig', 'constants',
|
||||
function ($scope, fc, uibDatepickerConfig, constants) {
|
||||
'use strict';
|
||||
|
||||
function getDayClass(data) {
|
||||
if (moment(data.date).isSame(new Date(), 'day')) {
|
||||
return 'highlight-today';
|
||||
}
|
||||
|
||||
if (data.date.getDay() === 0 || data.date.getDay() === 6) {
|
||||
return 'highlight-weekend';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
$scope.datepickerOptions = {
|
||||
formatDay: 'd',
|
||||
customClass: getDayClass
|
||||
};
|
||||
|
||||
$scope.dt = new Date();
|
||||
$scope.visibility = false;
|
||||
|
||||
$scope.selectedView = constants.initialView;
|
||||
|
||||
angular.extend(uibDatepickerConfig, {
|
||||
showWeeks: false,
|
||||
startingDay: parseInt(moment().startOf('week').format('d'))
|
||||
});
|
||||
|
||||
$scope.today = function () {
|
||||
$scope.dt = new Date();
|
||||
};
|
||||
|
||||
function changeView(index) {
|
||||
switch($scope.selectedView) {
|
||||
case 'agendaDay':
|
||||
return moment($scope.dt)
|
||||
.add(index, 'day')
|
||||
.toDate();
|
||||
|
||||
case 'agendaWeek':
|
||||
return moment($scope.dt)
|
||||
.add(index, 'week')
|
||||
.startOf('week')
|
||||
.toDate();
|
||||
|
||||
case 'month':
|
||||
return moment($scope.dt)
|
||||
.add(index, 'month')
|
||||
.startOf('month')
|
||||
.toDate();
|
||||
}
|
||||
}
|
||||
|
||||
$scope.prev = function() {
|
||||
$scope.dt = changeView(-1);
|
||||
};
|
||||
|
||||
$scope.next = function() {
|
||||
$scope.dt = changeView(1);
|
||||
};
|
||||
|
||||
$scope.toggle = function() {
|
||||
$scope.visibility = !$scope.visibility;
|
||||
};
|
||||
|
||||
$scope.$watch('dt', function(newValue) {
|
||||
if (fc) {
|
||||
fc.elm.fullCalendar(
|
||||
'gotoDate',
|
||||
newValue
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$watch('selectedView', function(newValue) {
|
||||
if (fc) {
|
||||
fc.elm.fullCalendar(
|
||||
'changeView',
|
||||
newValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
]);
|
|
@ -1,337 +0,0 @@
|
|||
/**
|
||||
* Calendar App
|
||||
*
|
||||
* @author Raghu Nayyar
|
||||
* @author Georg Ehrke
|
||||
* @copyright 2016 Raghu Nayyar <hey@raghunayyar.com>
|
||||
* @copyright 2016 Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Controller: Events Dialog Controller
|
||||
* Description: Takes care of anything inside the Events Modal.
|
||||
*/
|
||||
|
||||
app.controller('EditorController', ['$scope', 'TimezoneService', 'AutoCompletionService', '$timeout', '$window', '$uibModalInstance', 'vevent', 'simpleEvent', 'calendar', 'isNew', 'emailAddress',
|
||||
function($scope, TimezoneService, AutoCompletionService, $timeout, $window, $uibModalInstance, vevent, simpleEvent, calendar, isNew, emailAddress) {
|
||||
'use strict';
|
||||
|
||||
$scope.properties = simpleEvent;
|
||||
$scope.is_new = isNew;
|
||||
$scope.calendar = calendar;
|
||||
$scope.oldCalendar = isNew ? calendar : vevent.calendar;
|
||||
$scope.readOnly = !vevent.calendar.isWritable();
|
||||
$scope.accessibleViaCalDAV = vevent.calendar.eventsAccessibleViaCalDAV();
|
||||
$scope.selected = 0;
|
||||
$scope.timezones = [];
|
||||
$scope.emailAddress = emailAddress;
|
||||
$scope.edittimezone = ((
|
||||
$scope.properties.dtstart.parameters.zone !== 'floating' &&
|
||||
$scope.properties.dtstart.parameters.zone !== $scope.defaulttimezone) || (
|
||||
$scope.properties.dtend.parameters.zone !== 'floating' &&
|
||||
$scope.properties.dtend.parameters.zone !== $scope.defaulttimezone
|
||||
));
|
||||
|
||||
$scope.preEditingHooks = [];
|
||||
$scope.postEditingHooks = [];
|
||||
|
||||
$scope.tabs = [
|
||||
{title: t('calendar', 'Details'), value: 0},
|
||||
{title: t('calendar', 'Attendees'), value: 1},
|
||||
{title: t('calendar', 'Reminders'), value: 2},
|
||||
{title: t('calendar', 'Repeating'), value: 3}
|
||||
];
|
||||
|
||||
$scope.classSelect = [
|
||||
{displayname: t('calendar', 'When shared show full event'), type: 'PUBLIC'},
|
||||
{displayname: t('calendar', 'When shared show only busy'), type: 'CONFIDENTIAL'},
|
||||
{displayname: t('calendar', 'When shared hide this event'), type: 'PRIVATE'}
|
||||
];
|
||||
|
||||
$scope.statusSelect = [
|
||||
{displayname: t('calendar', 'Confirmed'), type: 'CONFIRMED'},
|
||||
{displayname: t('calendar', 'Tentative'), type: 'TENTATIVE'},
|
||||
{displayname: t('calendar', 'Cancelled'), type: 'CANCELLED'}
|
||||
];
|
||||
|
||||
$scope.registerPreHook = function(callback) {
|
||||
$scope.preEditingHooks.push(callback);
|
||||
};
|
||||
|
||||
$uibModalInstance.rendered.then(function() {
|
||||
if ($scope.properties.allDay) {
|
||||
$scope.properties.dtend.value = moment($scope.properties.dtend.value.subtract(1, 'days'));
|
||||
}
|
||||
|
||||
autosize($('.advanced--textarea'));
|
||||
autosize($('.events--textarea'));
|
||||
|
||||
$timeout(() => {
|
||||
autosize.update($('.advanced--textarea'));
|
||||
autosize.update($('.events--textarea'));
|
||||
}, 50);
|
||||
|
||||
angular.forEach($scope.preEditingHooks, function(callback) {
|
||||
callback();
|
||||
});
|
||||
|
||||
$scope.tabopener(0);
|
||||
});
|
||||
|
||||
$scope.registerPostHook = function(callback) {
|
||||
$scope.postEditingHooks.push(callback);
|
||||
};
|
||||
|
||||
$scope.proceed = function() {
|
||||
$scope.prepareClose();
|
||||
$uibModalInstance.close({
|
||||
action: 'proceed',
|
||||
calendar: $scope.calendar,
|
||||
simple: $scope.properties,
|
||||
vevent: vevent
|
||||
});
|
||||
};
|
||||
|
||||
$scope.save = function() {
|
||||
if (!$scope.validate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.prepareClose();
|
||||
$scope.properties.patch();
|
||||
$uibModalInstance.close({
|
||||
action: 'save',
|
||||
calendar: $scope.calendar,
|
||||
simple: $scope.properties,
|
||||
vevent: vevent
|
||||
});
|
||||
};
|
||||
|
||||
$scope.keypress = function(event) {
|
||||
var code = event.keyCode || event.which;
|
||||
if((event.metaKey === true || event.ctrlKey === true) && code === 13) {
|
||||
$scope.$broadcast('save-contents');
|
||||
$scope.save();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.validate = function() {
|
||||
var error = false;
|
||||
if ($scope.properties.summary === null || $scope.properties.summary.value.trim() === '') {
|
||||
OC.Notification.showTemporary(t('calendar', 'Please add a title.'));
|
||||
error = true;
|
||||
}
|
||||
if ($scope.calendar === null || typeof $scope.calendar === 'undefined') {
|
||||
OC.Notification.showTemporary(t('calendar', 'Please select a calendar.'));
|
||||
error = true;
|
||||
}
|
||||
if (!$scope.properties.checkDtStartBeforeDtEnd()) {
|
||||
OC.Notification.showTemporary(t('calendar', 'The event can not end before it starts.'));
|
||||
error = true;
|
||||
}
|
||||
|
||||
return !error;
|
||||
};
|
||||
|
||||
$scope.prepareClose = function() {
|
||||
if ($scope.properties.allDay) {
|
||||
$scope.properties.dtend.value.add(1, 'days');
|
||||
}
|
||||
|
||||
angular.forEach($scope.postEditingHooks, function(callback) {
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
$uibModalInstance.dismiss('cancel');
|
||||
};
|
||||
|
||||
$scope.delete = function() {
|
||||
$uibModalInstance.dismiss('delete');
|
||||
};
|
||||
|
||||
$scope.export = function() {
|
||||
$window.open($scope.oldCalendar.url + vevent.uri);
|
||||
};
|
||||
|
||||
/**
|
||||
* Everything tabs
|
||||
*/
|
||||
$scope.tabopener = function (val) {
|
||||
$scope.selected = val;
|
||||
if (val === 0) {
|
||||
$scope.eventsdetailsview = true;
|
||||
$scope.eventsattendeeview = false;
|
||||
$scope.eventsalarmview = false;
|
||||
$scope.eventsrepeatview = false;
|
||||
} else if (val === 1) {
|
||||
$scope.eventsdetailsview = false;
|
||||
$scope.eventsattendeeview = true;
|
||||
$scope.eventsalarmview = false;
|
||||
$scope.eventsrepeatview = false;
|
||||
} else if (val === 2) {
|
||||
$scope.eventsdetailsview = false;
|
||||
$scope.eventsattendeeview = false;
|
||||
$scope.eventsalarmview = true;
|
||||
$scope.eventsrepeatview = false;
|
||||
} else if (val === 3) {
|
||||
$scope.eventsdetailsview = false;
|
||||
$scope.eventsattendeeview = false;
|
||||
$scope.eventsalarmview = false;
|
||||
$scope.eventsrepeatview = true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Everything calendar select
|
||||
*/
|
||||
$scope.selectedCalendarChanged = () => {
|
||||
if ($scope.calendar.enabled === false) {
|
||||
$scope.calendar.enabled = true;
|
||||
$scope.calendar.update();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.showCalendarSelection = function() {
|
||||
// always show selection if it's a readonly calendar
|
||||
if (!$scope.calendar.isWritable()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const writableCalendars = $scope.calendars.filter(function (c) {
|
||||
return c.isWritable();
|
||||
});
|
||||
|
||||
return writableCalendars.length > 1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Everything date and time
|
||||
*/
|
||||
$scope.$watch('properties.dtstart.value', function(nv, ov) {
|
||||
var diff = nv.diff(ov, 'seconds');
|
||||
if (diff !== 0) {
|
||||
$scope.properties.dtend.value = moment($scope.properties.dtend.value.add(diff, 'seconds'));
|
||||
}
|
||||
});
|
||||
|
||||
$scope.toggledAllDay = function() {
|
||||
if ($scope.properties.allDay) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($scope.properties.dtstart.value.isSame($scope.properties.dtend.value)) {
|
||||
$scope.properties.dtend.value = moment($scope.properties.dtend.value.add(1, 'hours'));
|
||||
}
|
||||
|
||||
if ($scope.properties.dtstart.parameters.zone === 'floating' &&
|
||||
$scope.properties.dtend.parameters.zone === 'floating') {
|
||||
$scope.properties.dtstart.parameters.zone = $scope.defaulttimezone;
|
||||
$scope.properties.dtend.parameters.zone = $scope.defaulttimezone;
|
||||
}
|
||||
};
|
||||
$scope.$watch('properties.allDay', $scope.toggledAllDay);
|
||||
|
||||
/**
|
||||
* Everything timezones
|
||||
*/
|
||||
TimezoneService.listAll().then(function(list) {
|
||||
if ($scope.properties.dtstart.parameters.zone !== 'floating' &&
|
||||
list.indexOf($scope.properties.dtstart.parameters.zone) === -1) {
|
||||
list.push($scope.properties.dtstart.parameters.zone);
|
||||
}
|
||||
if ($scope.properties.dtend.parameters.zone !== 'floating' &&
|
||||
list.indexOf($scope.properties.dtend.parameters.zone) === -1) {
|
||||
list.push($scope.properties.dtend.parameters.zone);
|
||||
}
|
||||
|
||||
angular.forEach(list, function(timezone) {
|
||||
if(timezone === 'GMT' || timezone === 'Z') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (timezone.split('/').length === 1) {
|
||||
$scope.timezones.push({
|
||||
displayname: timezone,
|
||||
group: t('calendar', 'Global'),
|
||||
value: timezone
|
||||
});
|
||||
} else {
|
||||
$scope.timezones.push({
|
||||
displayname: timezone.split('/').slice(1).join('/'),
|
||||
group: timezone.split('/', 1),
|
||||
value: timezone
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$scope.timezones.push({
|
||||
displayname: t('calendar', 'None'),
|
||||
group: t('calendar', 'Global'),
|
||||
value: 'floating'
|
||||
});
|
||||
});
|
||||
|
||||
$scope.loadTimezone = function(tzId) {
|
||||
TimezoneService.get(tzId).then(function(timezone) {
|
||||
ICAL.TimezoneService.register(tzId, timezone.jCal);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Everything location
|
||||
*/
|
||||
$scope.searchLocation = function(value) {
|
||||
return AutoCompletionService.searchLocation(value).then(function(locations) {
|
||||
locations = locations.map(function(location){
|
||||
return {
|
||||
label: _.escape(location.name) + "\n" + location.label,
|
||||
name: _.escape(location.name)
|
||||
};
|
||||
});
|
||||
|
||||
return locations;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.selectLocationFromTypeahead = function(item) {
|
||||
$scope.properties.location.value = item.label;
|
||||
};
|
||||
|
||||
/**
|
||||
* Everything access class
|
||||
*/
|
||||
$scope.setClassToDefault = function() {
|
||||
if ($scope.properties.class === null) {
|
||||
$scope.properties.class = {
|
||||
type: 'string',
|
||||
value: 'PUBLIC'
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
$scope.setStatusToDefault = function() {
|
||||
if ($scope.properties.status === null) {
|
||||
$scope.properties.status = {
|
||||
type: 'string',
|
||||
value: 'CONFIRMED'
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
]);
|
|
@ -1,183 +0,0 @@
|
|||
/**
|
||||
* Calendar App
|
||||
*
|
||||
* @author Raghu Nayyar
|
||||
* @author Georg Ehrke
|
||||
* @copyright 2016 Raghu Nayyar <hey@raghunayyar.com>
|
||||
* @copyright 2016 Georg Ehrke <oc.list@georgehrke.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Controller: ImportController
|
||||
* Description: Takes care of importing calendars
|
||||
*/
|
||||
|
||||
app.controller('ImportController', ['$scope', '$filter', 'CalendarService', 'VEventService', '$uibModalInstance', 'files', 'ImportFileWrapper', 'ColorUtility',
|
||||
function($scope, $filter, CalendarService, VEventService, $uibModalInstance, files, ImportFileWrapper, ColorUtility) {
|
||||
'use strict';
|
||||
|
||||
$scope.nameSize = 25;
|
||||
|
||||
$scope.rawFiles = files;
|
||||
$scope.files = [];
|
||||
|
||||
$scope.showCloseButton = false;
|
||||
$scope.writableCalendars = $scope.calendars.filter(function(elem) {
|
||||
return elem.isWritable();
|
||||
});
|
||||
|
||||
$scope.import = function (fileWrapper) {
|
||||
fileWrapper.state = ImportFileWrapper.stateScheduled;
|
||||
|
||||
var importCalendar = function(calendar) {
|
||||
const objects = fileWrapper.splittedICal.objects;
|
||||
|
||||
angular.forEach(objects, function(object) {
|
||||
VEventService.create(calendar, object, false).then(function(response) {
|
||||
|