Skip to content

Commit

Permalink
Merge pull request #234 from nextcloud/fix-233
Browse files Browse the repository at this point in the history
Fix creating new tasks, closes 233
  • Loading branch information
raimund-schluessler committed Jan 26, 2019
2 parents 8e98e3f + 8689319 commit 862caef
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 14 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Expand Up @@ -12,6 +12,7 @@ module.exports = {
OC: false,
OCA: false,
moment: true,
oca_tasks: true,
},
parserOptions: {
parser: 'babel-eslint'
Expand Down
1 change: 1 addition & 0 deletions appinfo/application.php
Expand Up @@ -45,6 +45,7 @@ public function __construct (array $urlParams=array()) {
return new PageController(
$c->query('AppName'),
$c->query('Request'),
$c->query('UserSession'),
$c->query('UserId'),
$c->query('ServerContainer')->getConfig()
);
Expand Down
35 changes: 22 additions & 13 deletions lib/Controller/PageController.php
Expand Up @@ -26,6 +26,7 @@
use \OCP\AppFramework\Http\TemplateResponse;
use \OCP\AppFramework\Http\NotFoundResponse;
use \OCP\IRequest;
use \OCP\IUserSession;
use \OCP\IConfig;

/**
Expand All @@ -35,12 +36,14 @@ class PageController extends Controller {

/**
* @param string $appName
* @param IUserSession $userSession
* @param IConfig $config
*/
public function __construct($appName, IRequest $request,
public function __construct($appName, IRequest $request, IUserSession $userSession,
$userId, IConfig $config) {
parent::__construct($appName, $request);
$this->config = $config;
$this->userSession = $userSession;
$this->userId = $userId;
}

Expand All @@ -50,18 +53,8 @@ public function __construct($appName, IRequest $request,
* @NoCSRFRequired
*/
public function index() {

$day = new \DateTime('today');
$day = $day->format('d');

$appVersion = $this->config->getAppValue($this->appName, 'installed_version');
$response = new TemplateResponse('tasks', 'main');
$response->setParams(array(
'appVersion' => $appVersion,
'DOM' => $day
));

return $response;
\OCP\Util::connectHook('\OCP\Config', 'js', $this, 'addJavaScriptVariablesForIndex');
return new TemplateResponse('tasks', 'main');
}


Expand All @@ -78,4 +71,20 @@ public function templates($template) {
}
return $response;
}

/**
* Add parameters to javascript for user sites
*
* @param array $array
*/
public function addJavaScriptVariablesForIndex(array $array) {
$user = $this->userSession->getUser();
if ($user === null) {
return;
}
$appversion = $this->config->getAppValue($this->appName, 'installed_version');
$array['array']['oca_tasks'] = \json_encode([
'versionstring' => $appversion,
]);
}
}
30 changes: 30 additions & 0 deletions src/services/productInformationProvider.js
@@ -0,0 +1,30 @@
/**
* @copyright Copyright (c) 2018 Georg Ehrke
*
* @author Georg Ehrke <oc.list@georgehrke.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**
* returns the version string of the calendar app
*
* @returns {String}
*/
export function getAppVersion() {
return oca_tasks.versionstring
}
3 changes: 2 additions & 1 deletion src/store/tasks.js
Expand Up @@ -26,6 +26,7 @@ import Task from '../models/task'
import { isParentInList, momentToICALTime } from './storeHelper'
import ICAL from 'ical.js'
import TaskStatus from '../models/taskStatus'
import { getAppVersion } from '../services/productInformationProvider'

Vue.use(Vuex)

Expand Down Expand Up @@ -524,7 +525,7 @@ const actions = {
taskData.calendar = context.getters.getDefaultCalendar
}

let task = new Task('BEGIN:VCALENDAR\nVERSION:2.0\nEND:VCALENDAR', taskData.calendar)
let task = new Task('BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Nextcloud Tasks v' + getAppVersion() + '\nEND:VCALENDAR', taskData.calendar)

task.created = ICAL.Time.now()
task.summary = taskData.summary
Expand Down

0 comments on commit 862caef

Please sign in to comment.