Skip to content

Commit

Permalink
Merge 692d12d into b8784a8
Browse files Browse the repository at this point in the history
  • Loading branch information
georgehrke committed Sep 19, 2016
2 parents b8784a8 + 692d12d commit 4a4df55
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
9 changes: 6 additions & 3 deletions controller/viewcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public function __construct($appName, IRequest $request,
*/
public function index() {
$runningOn = $this->config->getSystemValue('version');
$runningOnServer91OrLater = version_compare($runningOn, '9.1', '>=');
$runningOnNextcloud10OrLater = version_compare($runningOn, '9.1', '>=');

$supportsClass = $runningOnServer91OrLater;
$assetPipelineBroken = !$runningOnServer91OrLater;
$supportsClass = $runningOnNextcloud10OrLater;
$assetPipelineBroken = !$runningOnNextcloud10OrLater;

$isAssetPipelineEnabled = $this->config->getSystemValue('asset-pipeline.enabled', false);
if ($isAssetPipelineEnabled && $assetPipelineBroken) {
Expand All @@ -84,6 +84,8 @@ public function index() {
$skipPopover = $this->config->getUserValue($userId, $this->appName, 'skipPopover', 'no');
$weekNumbers = $this->config->getUserValue($userId, $this->appName, 'showWeekNr', 'no');
$defaultColor = $this->config->getAppValue('theming', 'color', '#0082C9');

$webCalWorkaround = $runningOnNextcloud10OrLater ? 'no' : 'yes';

return new TemplateResponse('calendar', 'main', [
'appVersion' => $appVersion,
Expand All @@ -93,6 +95,7 @@ public function index() {
'weekNumbers' => $weekNumbers,
'supportsClass' => $supportsClass,
'defaultColor' => $defaultColor,
'webCalWorkaround' => $webCalWorkaround,
]);
}

Expand Down
15 changes: 14 additions & 1 deletion js/app/service/calendarservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ app.service('CalendarService', function(DavClient, StringUtility, XMLUtility, Ca
});
}

const needsWorkaround = angular.element('#fullcalendar').attr('data-webCalWorkaround') === 'yes';

const [skeleton, dPropChildren] = XMLUtility.getRootSkeleton('d:mkcol', 'd:set', 'd:prop');
dPropChildren.push({
name: 'd:resourcetype',
Expand Down Expand Up @@ -285,7 +287,18 @@ app.service('CalendarService', function(DavClient, StringUtility, XMLUtility, Ca
return DavClient.request('MKCOL', url, headers, xml).then(function(response) {
if (response.status === 201) {
self._takenUrls.push(url);
return self.get(url);

return self.get(url).then(function(webcal) {
if (needsWorkaround) {
webcal.enabled = true;
webcal.displayname = name;
webcal.color = color;

return self.update(webcal);
} else {
return webcal;
}
});
}
});
};
Expand Down
1 change: 1 addition & 0 deletions templates/part.fullcalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class="calendar"
data-emailAddress="<?php p($_['emailAddress']); ?>"
data-skipPopover="<?php p($_['skipPopover']); ?>"
data-weekNumbers="<?php p($_['weekNumbers']); ?>"
data-webCalWorkaround="<?php p($_['webCalWorkaround']); ?>"
fc
id="fullcalendar">
</div>
11 changes: 6 additions & 5 deletions tests/unit/controller/viewcontrollerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function setUp() {
/**
* @dataProvider indexDataProvider
*/
public function testIndex($isAssetPipelineEnabled, $showAssetPipelineError, $serverVersion, $expectsSupportsClass) {
public function testIndex($isAssetPipelineEnabled, $showAssetPipelineError, $serverVersion, $expectsSupportsClass, $expectsWebcalWorkaround) {
$this->config->expects($this->at(0))
->method('getSystemValue')
->with('version')
Expand Down Expand Up @@ -152,6 +152,7 @@ public function testIndex($isAssetPipelineEnabled, $showAssetPipelineError, $ser
'weekNumbers' => 'someShowWeekNrValue',
'supportsClass' => $expectsSupportsClass,
'defaultColor' => '#ff00ff',
'webCalWorkaround' => $expectsWebcalWorkaround
], $actual->getParams());
$this->assertEquals('main', $actual->getTemplateName());
}
Expand All @@ -160,10 +161,10 @@ public function testIndex($isAssetPipelineEnabled, $showAssetPipelineError, $ser

public function indexDataProvider() {
return [
[true, true, '9.0.5.2', false],
[true, false, '9.1.0.0', true],
[false, false, '9.0.5.2', false],
[false, false, '9.1.0.0', true]
[true, true, '9.0.5.2', false, 'yes'],
[true, false, '9.1.0.0', true, 'no'],
[false, false, '9.0.5.2', false, 'yes'],
[false, false, '9.1.0.0', true, 'no']
];
}

Expand Down

0 comments on commit 4a4df55

Please sign in to comment.