Skip to content

Commit

Permalink
fix(calendar): don't allow RDATE unless already defined
Browse files Browse the repository at this point in the history
Since RDATE are not properly supported in EAS, hide the possibility to
specify recurring dates unless the component being edited already
contains RDATE(s).
  • Loading branch information
cgx committed Oct 30, 2019
1 parent 42bb3b2 commit f6ca946
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
18 changes: 17 additions & 1 deletion UI/Scheduler/UIxCalMainView.m
@@ -1,6 +1,6 @@
/* UIxCalMainView.m - this file is part of SOGo
*
* Copyright (C) 2006-2018 Inverse inc.
* Copyright (C) 2006-2019 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -339,6 +339,22 @@ - (NSString *) currentView
return (view ? view : @"weekview");
}

- (NSArray *) repeatFrequencies
{
NSArray *repeatFrequencies;

repeatFrequencies = [NSArray arrayWithObjects:
[NSArray arrayWithObjects: @"never", [self labelForKey: @"repeat_NEVER"], nil],
[NSArray arrayWithObjects: @"daily",[self labelForKey: @"repeat_DAILY"], nil],
[NSArray arrayWithObjects: @"weekly",[self labelForKey: @"repeat_WEEKLY"], nil],
[NSArray arrayWithObjects: @"monthly",[self labelForKey: @"repeat_MONTHLY"], nil],
[NSArray arrayWithObjects: @"yearly", [self labelForKey: @"repeat_YEARLY"], nil],
[NSArray arrayWithObjects: @"custom", [self labelForKey: @"repeat_CUSTOM"], nil],
nil];

return repeatFrequencies;
}

@end

/* Component Viewer, parent class of Appointment Viewer and Task Viewer */
Expand Down
4 changes: 1 addition & 3 deletions UI/Templates/SchedulerUI/UIxAppointmentEditorTemplate.wox
Expand Up @@ -199,9 +199,7 @@
ng-model="editor.component.repeat.frequency"
ng-change="editor.changeFrequency($event)"
ng-disabled="editor.component.occurrenceId">
<var:foreach list="repeatList" item="item">
<md-option var:value="item"><var:string var:value="itemRepeatText"/></md-option>
</var:foreach>
<md-option ng-value="frequency[0]" ng-repeat="frequency in ::editor.frequencies()">{{ frequency[1] }}</md-option>
</md-select>
</md-input-container>
<md-button type="button" class="sg-icon-button"
Expand Down
1 change: 1 addition & 0 deletions UI/Templates/SchedulerUI/UIxCalMainView.wox
Expand Up @@ -14,6 +14,7 @@
var dayStartHour = <var:string value="dayStartHour"/>;
var currentView = '<var:string value="currentView"/>';
var localeCode = '<var:string value="localeCode" />';
var repeatFrequencies = <var:string value="repeatFrequencies.jsonRepresentation" />;
var centerIsClose = <var:string value="listIsCollapsed.jsonRepresentation" />;
</script>
<var:component className="UIxCalendarSelector" />
Expand Down
4 changes: 1 addition & 3 deletions UI/Templates/SchedulerUI/UIxTaskEditorTemplate.wox
Expand Up @@ -196,9 +196,7 @@
<md-input-container class="md-block md-flex">
<label><var:string label:value="Repeat"/></label>
<md-select ng-model="editor.component.repeat.frequency" ng-disabled="editor.component.occurrenceId">
<var:foreach list="repeatList" item="item">
<md-option var:value="item"><var:string var:value="itemRepeatText"/></md-option>
</var:foreach>
<md-option ng-value="frequency[0]" ng-repeat="frequency in ::editor.frequencies()">{{ frequency[1] }}</md-option>
</md-select>
</md-input-container>
<md-button type="button" class="sg-icon-button"
Expand Down
10 changes: 8 additions & 2 deletions UI/WebServerResources/js/Scheduler/ComponentController.js
Expand Up @@ -205,8 +205,8 @@
/**
* @ngInject
*/
ComponentEditorController.$inject = ['$rootScope', '$scope', '$log', '$timeout', '$element', '$mdDialog', 'sgFocus', 'User', 'CalendarSettings', 'Calendar', 'Component', 'Attendees', 'AddressBook', 'Card', 'Alarm', 'Preferences', 'stateComponent'];
function ComponentEditorController($rootScope, $scope, $log, $timeout, $element, $mdDialog, focus, User, CalendarSettings, Calendar, Component, Attendees, AddressBook, Card, Alarm, Preferences, stateComponent) {
ComponentEditorController.$inject = ['$rootScope', '$scope', '$log', '$timeout', '$window', '$element', '$mdDialog', 'sgFocus', 'User', 'CalendarSettings', 'Calendar', 'Component', 'Attendees', 'AddressBook', 'Card', 'Alarm', 'Preferences', 'stateComponent'];
function ComponentEditorController($rootScope, $scope, $log, $timeout, $window, $element, $mdDialog, focus, User, CalendarSettings, Calendar, Component, Attendees, AddressBook, Card, Alarm, Preferences, stateComponent) {
var vm = this, component, oldStartDate, oldEndDate, oldDueDate, dayStartTime, dayEndTime;

this.$onInit = function () {
Expand Down Expand Up @@ -264,6 +264,12 @@
this.component.repeat.month.type == 'bymonthday';
};

this.frequencies = function () {
return _.filter($window.repeatFrequencies, function (frequency) {
return frequency[0] != 'custom' || vm.component.repeat.frequency == 'custom';
});
};

this.changeFrequency = function () {
if (this.component.repeat.frequency == 'custom')
this.showRecurrenceEditor = true;
Expand Down

0 comments on commit f6ca946

Please sign in to comment.