(js) Respect SOGoDefaultCalendar
parent
c7068b11a7
commit
5a8d986cad
|
@ -26,12 +26,13 @@
|
|||
* @desc The factory we'll use to register with Angular
|
||||
* @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, {
|
||||
$q: $q,
|
||||
$timeout: $timeout,
|
||||
$log: $log,
|
||||
$$resource: new Resource(Settings.activeUser('folderURL') + 'Calendar', Settings.activeUser()),
|
||||
$Preferences: Preferences,
|
||||
$Component: Component,
|
||||
$$Acl: Acl,
|
||||
activeUser: Settings.activeUser(),
|
||||
|
@ -58,6 +59,26 @@
|
|||
})
|
||||
.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
|
||||
* @desc Add a new calendar to the static list of calendars
|
||||
|
|
|
@ -122,10 +122,9 @@
|
|||
type = baseComponent.type;
|
||||
}
|
||||
else {
|
||||
// TODO respect SOGoDefaultCalendar
|
||||
if (vm.componentType == 'tasks')
|
||||
type = 'task';
|
||||
component = new Component({ pid: 'personal', type: type });
|
||||
component = new Component({ pid: Calendar.$defaultCalendar(), type: type });
|
||||
}
|
||||
|
||||
// UI/Templates/SchedulerUI/UIxAppointmentEditorTemplate.wox or
|
||||
|
|
|
@ -130,7 +130,7 @@
|
|||
calendarDayCtrl.dayString.substring(11,16));
|
||||
newData = {
|
||||
type: 'appointment',
|
||||
pid: 'personal', // TODO respect SOGoDefaultCalendar
|
||||
pid: Calendar.$defaultCalendar(),
|
||||
summary: l('New Event'),
|
||||
startDate: startDate,
|
||||
isAllDay: isHourCell? 0 : 1
|
||||
|
|
Loading…
Reference in New Issue