Skip to content

Commit

Permalink
Added byday recurrence feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian1998 authored and DeepDiver1975 committed Jun 11, 2018
1 parent e021af0 commit 86e9895
Show file tree
Hide file tree
Showing 13 changed files with 546 additions and 52 deletions.
411 changes: 411 additions & 0 deletions css/app/angularBootstrap.css

Large diffs are not rendered by default.

23 changes: 0 additions & 23 deletions css/app/calendarlist.css
Original file line number Diff line number Diff line change
Expand Up @@ -471,29 +471,6 @@ li.calendar-share-item span {
white-space: nowrap;
}

ul.dropdown-menu {
max-height: 200px;
overflow-y: scroll;
overflow-x: hidden;
border: 1px #ddd solid;
border-radius: 0 0 4px 4px;
margin-top: -7px;
margin-left: 6px;
width: 89%;
}

ul.dropdown-menu li:last-child {
border-bottom: none !important;
}

#app-navigation ul.dropdown-menu a {
padding: 6px;
}

ul.dropdown-menu li > a:hover {
background-color: grey !important;
}

/* Fullcalendar modifications */

.fc th,
Expand Down
22 changes: 2 additions & 20 deletions css/app/eventdialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
width: 450px;
background: #fff;
box-shadow: 0 0 3px #999;
overflow: hidden;
overflow: visible;
margin-left: 0 !important;
padding-bottom: 12px;
}
Expand All @@ -74,7 +74,7 @@

.events .events--fieldset textarea {
height: 4.5em;
width: 96%;
width: 97% !important;
resize: vertical;
}

Expand Down Expand Up @@ -309,25 +309,7 @@ button.delete:focus {
display: inline;
}

.dropdown-menu,
.attendeename {
width: 100%;
max-width: 470px;
}

.dropdown-menu li {
border-bottom: 1px solid #ddd;
background: #f8f8f8;
}

.dropdown-menu li a {
display: block;
padding: 5px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.dropdown-menu li a:hover {
background: #eee;
}
22 changes: 22 additions & 0 deletions js/app/controllers/calcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@ app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEven
});
}

function deleteOccurence(vevent, fcEvent) {
var exdate = fcEvent.event.getFirstProperty('exdate');
if(exdate !== null) {
exdate = exdate.getValues();
}
else {
exdate = [];
}
exdate.push(ICAL.Time.fromJSDate(fcEvent.start.toDate(), true));
const exdateProp = new ICAL.Property('exdate', fcEvent.event);
exdateProp.setValues(exdate);

fcEvent.event.removeAllProperties('exdate');
fcEvent.event.addProperty(exdateProp);
VEventService.update(vevent).then(function() {
fc.elm.fullCalendar('refetchEventSources', vevent.calendar.fcEventSource);
});
}

$scope.$watchCollection('calendars', function(newCalendars, oldCalendars) {
newCalendars.filter(function(calendar) {
return oldCalendars.indexOf(calendar) === -1;
Expand Down Expand Up @@ -239,6 +258,9 @@ app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEven
if (reason === 'delete') {
deleteAndRemoveEvent(vevent, fcEvent);
}
else if(reason === 'deleteOccurrence') {
deleteOccurence(vevent, fcEvent);
}
});
},
eventResize: function (fcEvent, delta, revertFunc) {
Expand Down
8 changes: 8 additions & 0 deletions js/app/controllers/editorcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ app.controller('EditorController', ['$scope', 'TimezoneService', 'AutoCompletion
});
};

$scope.isRecurring = function() {
return $scope.properties.repeating;
};

$scope.cancel = function() {
$uibModalInstance.dismiss('cancel');
};
Expand All @@ -157,6 +161,10 @@ app.controller('EditorController', ['$scope', 'TimezoneService', 'AutoCompletion
$uibModalInstance.dismiss('delete');
};

$scope.deleteOccurrence = function() {
$uibModalInstance.dismiss('deleteOccurrence');
};

$scope.export = function() {
$window.open($scope.oldCalendar.url + vevent.uri);
};
Expand Down
57 changes: 52 additions & 5 deletions js/app/controllers/recurrencecontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
app.controller('RecurrenceController', function($scope) {
'use strict';

var ctrl = this;
ctrl.loading = true;

$scope.rruleNotSupported = false;

$scope.repeat_options_simple = [
Expand All @@ -42,15 +45,31 @@ app.controller('RecurrenceController', function($scope) {
{val: 'UNTIL', displayname: t('calendar', 'on date')}
];

$scope.byDay = {
SU: false,
MO: false,
TU: false,
WE: false,
TH: false,
FR: false,
SA: false
};

$scope.weekdays = moment.weekdaysMin();

$scope.$parent.registerPreHook(function() {
if ($scope.properties.rrule.freq !== 'NONE') {
var unsupportedFREQs = ['SECONDLY', 'MINUTELY', 'HOURLY'];
if (unsupportedFREQs.indexOf($scope.properties.rrule.freq) !== -1) {
$scope.rruleNotSupported = true;
}

if (typeof $scope.properties.rrule.parameters !== 'undefined') {
if (angular.isDefined($scope.properties.rrule.parameters)) {
var partIds = Object.getOwnPropertyNames($scope.properties.rrule.parameters);
if(partIds.indexOf('BYDAY') !== -1) {
partIds.splice(partIds.indexOf('BYDAY'), 1);
$scope.properties.rrule.byday = $scope.properties.rrule.parameters.BYDAY.slice();
}
if (partIds.length > 0) {
$scope.rruleNotSupported = true;
}
Expand All @@ -62,14 +81,18 @@ app.controller('RecurrenceController', function($scope) {
$scope.selected_repeat_end = 'UNTIL';
}

/*if (!moment.isMoment($scope.properties.rrule.until)) {
$scope.properties.rrule.until = moment();
}*/
if(angular.isDefined($scope.properties.rrule.byday)) {
angular.forEach($scope.properties.rrule.byday, function(value) {
$scope.byDay[value] = true;
});
}

if ($scope.properties.rrule.interval === null) {
$scope.properties.rrule.interval = 1;
}
}

ctrl.loading = false;
});

$scope.$parent.registerPostHook(function() {
Expand All @@ -86,10 +109,34 @@ app.controller('RecurrenceController', function($scope) {
$scope.properties.rrule.freq = 'NONE';
$scope.properties.rrule.count = null;
$scope.properties.rrule.until = null;
$scope.properties.rrule.byday = null;
$scope.properties.rrule.interval = 1;
$scope.rruleNotSupported = false;
$scope.properties.rrule.parameters = {};
};

$scope.$watch('byDay', function (newValue) {
if(!ctrl.loading) {
ctrl.transferDaysToByDay(newValue);
}
}, true);

});
ctrl.transferDaysToByDay = function(newDays) {
angular.forEach(newDays, function(value, key) {
if(angular.isUndefined($scope.properties.rrule.byday)) {
if(value) {
$scope.properties.rrule.byday = [key];
}
}
else {
var i = $scope.properties.rrule.byday.indexOf(key);
if(value && i === -1) {
$scope.properties.rrule.byday.push(key);
}
else if(!value && i !== -1) {
$scope.properties.rrule.byday.splice(i, 1);
}
}
});
};
});
7 changes: 7 additions & 0 deletions js/app/models/simpleEventModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,13 @@ app.factory('SimpleEvent', function () {
}
}

if(newSimpleData.rrule.byday) {
params.byday = newSimpleData.rrule.byday;
}
else if(angular.isDefined(newSimpleData.rrule.parameters) && angular.isDefined(newSimpleData.rrule.parameters.BYDAY)) {
params.byday = newSimpleData.rrule.parameters.BYDAY;
}

const rrule = new ICAL.Recur(params);
vevent.updatePropertyWithValue('rrule', rrule);
}
Expand Down
2 changes: 2 additions & 0 deletions js/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"name": "nextcloud-calendar",
"dependencies": {
"angular": "1.6.4",
"angular-animate": "1.6.4",
"angular-sanitize": "1.6.4",
"angular-bootstrap": "2.5.0",
"jquery-timepicker": "883bb2cd94",
"jstzdetect": "https://github.com/georgehrke/jstimezonedetect.git",
Expand Down
2 changes: 2 additions & 0 deletions js/config/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@
*/

var app = angular.module('Calendar', [
'ngAnimate',
'ngSanitize',
'ui.bootstrap'
]);
2 changes: 2 additions & 0 deletions js/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ const cssSources = [
];
const vendorSources = [
'vendor/angular/angular.js',
'vendor/angular-animate/angular-animate.js',
'vendor/angular-sanitize/angular-sanitize.js',
'vendor/angular-bootstrap/ui-bootstrap-tpls.js',
'vendor/fullcalendar/dist/fullcalendar.js',
'vendor/fullcalendar/dist/locale-all.js',
Expand Down
13 changes: 11 additions & 2 deletions templates/editor.popover.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,20 @@ class="checkbox"
<label for="alldayeventcheckbox"><?php p($l->t('All day Event'))?></label>
</div>
</fieldset>

<fieldset class="events--fieldset pull-left" ng-if="!readOnly">
<button ng-click="delete()" ng-if="!is_new" class="events--button button btn delete" type="button" tabindex="110">
<button ng-click="delete()" ng-if="!is_new && !isRecurring()" class="events--button button btn delete" type="button" tabindex="110">
<?php p($l->t('Delete')); ?>
</button>
<div class="btn-group" uib-dropdown ng-if="!is_new && isRecurring()">
<button id="single-button" type="button" class="btn delete" tabindex="110" uib-dropdown-toggle>
<?php p($l->t('Delete')); ?>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="single-button">
<li role="menuitem"><a ng-click="delete()" href="#"><?php p($l->t('Delete all')); ?></a></li>
<li role="menuitem"><a ng-click="deleteOccurrence()" href="#"><?php p($l->t('Delete just occurrence')); ?></a></li>
</ul>
</div>
<button ng-click="cancel()" class="events--button button btn" type="button" tabindex="111">
<?php p($l->t('Cancel')); ?>
</button>
Expand Down
14 changes: 12 additions & 2 deletions templates/editor.sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,23 @@ class="checkbox"
<button
class="events--button button btn delete btn-half pull-left"
ng-click="delete()"
ng-if="!is_new"
ng-if="!is_new && !isRecurring()"
type="button"
tabindex="280">
<?php p($l->t('Delete')); ?>
</button>
<div class="btn-group btn-half pull-left" uib-dropdown ng-if="!is_new && isRecurring()">
<button id="single-button" type="button" class="events--button button btn delete single-button-sidebar" tabindex="280" uib-dropdown-toggle>
<?php p($l->t('Delete')); ?>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="single-button">
<li role="menuitem"><a ng-click="delete()" href="#"><?php p($l->t('Delete all')); ?></a></li>
<li role="menuitem"><a ng-click="deleteOccurrence()" href="#"><?php p($l->t('Delete just occurrence')); ?></a></li>
</ul>
</div>
<button
class="evens--button button btn btn-half pull-right"
class="evens--button button btn btn-half pull-right cancel-button-sidebar"
ng-click="cancel()"
ng-if="!is_new"
type="button"
Expand Down
15 changes: 15 additions & 0 deletions templates/part.eventsrepeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ class="pull-right pull-half"
min="1"
ng-model="properties.rrule.interval">
<div class="clear-both"></div>
<label class="pull-left inline">
<?php p($l->t('Repeat on every ...')); ?>
</label>
<div class="pull-right pull-half">
<div class="btn-group">
<label class="btn btn-default weekdays" ng-model="byDay.SU" uib-btn-checkbox>{{ weekdays[0] }}</label>
<label class="btn btn-default weekdays" ng-model="byDay.MO" uib-btn-checkbox>{{ weekdays[1] }}</label>
<label class="btn btn-default weekdays" ng-model="byDay.TU" uib-btn-checkbox>{{ weekdays[2] }}</label>
<label class="btn btn-default weekdays" ng-model="byDay.WE" uib-btn-checkbox>{{ weekdays[3] }}</label>
<label class="btn btn-default weekdays" ng-model="byDay.TH" uib-btn-checkbox>{{ weekdays[4] }}</label>
<label class="btn btn-default weekdays" ng-model="byDay.FR" uib-btn-checkbox>{{ weekdays[5] }}</label>
<label class="btn btn-default weekdays" ng-model="byDay.SA" uib-btn-checkbox>{{ weekdays[6] }}</label>
</div>
</div>
<div class="clear-both"></div>
<label class="pull-left inline">
<?php p($l->t('end repeat ...')); ?>
</label>
Expand Down

0 comments on commit 86e9895

Please sign in to comment.