Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix creating new tasks, closes 233 #234

Merged
merged 1 commit into from
Jan 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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