(js) Respect SOGoDefaultCalendar
This commit is contained in:
parent
c7068b11a7
commit
5a8d986cad
|
@ -26,12 +26,13 @@
|
||||||
* @desc The factory we'll use to register with Angular
|
* @desc The factory we'll use to register with Angular
|
||||||
* @returns the Calendar constructor
|
* @returns the Calendar constructor
|
||||||
*/
|
*/
|
||||||
Calendar.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Resource', 'Component', 'Acl', function($q, $timeout, $log, Settings, Resource, Component, Acl) {
|
Calendar.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Resource', 'Preferences', 'Component', 'Acl', function($q, $timeout, $log, Settings, Resource, Preferences, Component, Acl) {
|
||||||
angular.extend(Calendar, {
|
angular.extend(Calendar, {
|
||||||
$q: $q,
|
$q: $q,
|
||||||
$timeout: $timeout,
|
$timeout: $timeout,
|
||||||
$log: $log,
|
$log: $log,
|
||||||
$$resource: new Resource(Settings.activeUser('folderURL') + 'Calendar', Settings.activeUser()),
|
$$resource: new Resource(Settings.activeUser('folderURL') + 'Calendar', Settings.activeUser()),
|
||||||
|
$Preferences: Preferences,
|
||||||
$Component: Component,
|
$Component: Component,
|
||||||
$$Acl: Acl,
|
$$Acl: Acl,
|
||||||
activeUser: Settings.activeUser(),
|
activeUser: Settings.activeUser(),
|
||||||
|
@ -58,6 +59,26 @@
|
||||||
})
|
})
|
||||||
.factory('Calendar', Calendar.$factory);
|
.factory('Calendar', Calendar.$factory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @memberof Calendar
|
||||||
|
* @desc Return the default calendar id according to the user's defaults.
|
||||||
|
* @returns a calendar id
|
||||||
|
*/
|
||||||
|
Calendar.$defaultCalendar = function() {
|
||||||
|
var defaultCalendar = Calendar.$Preferences.defaults.SOGoDefaultCalendar,
|
||||||
|
calendar;
|
||||||
|
|
||||||
|
if (defaultCalendar == 'first') {
|
||||||
|
calendar = _.find(Calendar.$findAll(null, true), function(calendar) {
|
||||||
|
return calendar.active;
|
||||||
|
});
|
||||||
|
if (calendar)
|
||||||
|
return calendar.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'personal';
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @memberof Calendar
|
* @memberof Calendar
|
||||||
* @desc Add a new calendar to the static list of calendars
|
* @desc Add a new calendar to the static list of calendars
|
||||||
|
|
|
@ -122,10 +122,9 @@
|
||||||
type = baseComponent.type;
|
type = baseComponent.type;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO respect SOGoDefaultCalendar
|
|
||||||
if (vm.componentType == 'tasks')
|
if (vm.componentType == 'tasks')
|
||||||
type = 'task';
|
type = 'task';
|
||||||
component = new Component({ pid: 'personal', type: type });
|
component = new Component({ pid: Calendar.$defaultCalendar(), type: type });
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI/Templates/SchedulerUI/UIxAppointmentEditorTemplate.wox or
|
// UI/Templates/SchedulerUI/UIxAppointmentEditorTemplate.wox or
|
||||||
|
|
|
@ -130,7 +130,7 @@
|
||||||
calendarDayCtrl.dayString.substring(11,16));
|
calendarDayCtrl.dayString.substring(11,16));
|
||||||
newData = {
|
newData = {
|
||||||
type: 'appointment',
|
type: 'appointment',
|
||||||
pid: 'personal', // TODO respect SOGoDefaultCalendar
|
pid: Calendar.$defaultCalendar(),
|
||||||
summary: l('New Event'),
|
summary: l('New Event'),
|
||||||
startDate: startDate,
|
startDate: startDate,
|
||||||
isAllDay: isHourCell? 0 : 1
|
isAllDay: isHourCell? 0 : 1
|
||||||
|
|
Loading…
Reference in a new issue