Skip to content
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
2 changes: 2 additions & 0 deletions appinfo/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public function __construct (array $urlParams=array()) {
$container->registerService('Settings', function($c) {
return $c->query('ServerContainer')->getConfig();
});

\OC::$server->getSearch()->registerProvider('OCA\Tasks\Controller\SearchController', array('apps' => array('tasks')));

}

Expand Down
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

// tasks
array('name' => 'tasks#getTasks', 'url' => '/tasks/{type}/{listID}', 'verb' => 'GET'),
array('name' => 'tasks#getTask', 'url' => '/task/{taskID}', 'verb' => 'GET'),
array('name' => 'tasks#starTask', 'url' => '/tasks/{taskID}/star', 'verb' => 'POST'),
array('name' => 'tasks#unstarTask', 'url' => '/tasks/{taskID}/unstar', 'verb' => 'POST'),
array('name' => 'tasks#completeTask', 'url' => '/tasks/{taskID}/complete', 'verb' => 'POST'),
Expand Down
88 changes: 88 additions & 0 deletions controller/searchcontroller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

/**
* ownCloud
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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 library. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Tasks\Controller;

/**
* Tasks search provider
*/
class SearchController extends \OCP\Search\Provider {

/**
* Search for query in tasks
*
* @param string $query
* @return array list of \OCA\Tasks\Controller\Task
*/
function search($query) {
$calendars = \OC_Calendar_Calendar::allCalendars(\OCP\USER::getUser(), true);
// check if the calenar is enabled
if (count($calendars) == 0 || !\OCP\App::isEnabled('tasks')) {
return array();
}
$results = array();
foreach ($calendars as $calendar) {
// $calendar_entries = \OC_Calendar_Object::all($calendar['id']);
$objects = \OC_Calendar_Object::all($calendar['id']);
// $date = strtotime($query);
// // search all calendar objects, one by one
foreach ($objects as $object) {
// skip non-events
if ($object['objecttype'] != 'VTODO') {
continue;
}
$vtodo = Helper::parseVTODO($object['calendardata']);
$id = $object['id'];
$calendarId = $object['calendarid'];

// check these properties
$properties = ['SUMMARY', 'DESCRIPTION', 'LOCATION', 'CATEGORIES'];

foreach ($properties as $property) {
$string = $vtodo->getAsString($property);
if (stripos($string, $query) !== false) {
$results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,$property,$query);
continue 2;
}
}
$comments = $vtodo->COMMENT;
if($comments) {
foreach($comments as $com) {
if (stripos($com->value, $query) !== false) {
$results[] = new \OCA\Tasks\Controller\Task($id,$calendarId,$vtodo,'COMMENTS',$query);
continue 2;
}
}
}
}
}
usort($results, array($this, 'sort_completed'));
return $results;
}

private static function sort_completed($a, $b){
$t1 = $a->completed;
$t2 = $b->completed;
if ($t1 == $t2) {
return 0;
}
return $t1 > $t2 ? 1 : -1;
}
}
105 changes: 105 additions & 0 deletions controller/task.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php

/**
* ownCloud
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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 library. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Tasks\Controller;

/**
* A task
*/
class Task extends \OCP\Search\Result {

/**
* Type name; translated in templates
*
* @var string
*/
public $type = 'task';

/**
* CalendarID
*
* @var string
*/
public $calendarID;

/**
* Is Task completed
*
* @var boolean
*/
public $completed;

/**
* Used by the client JS to display additional information under the event summary
*
* @var string
*/
public $text = '';

/**
* Start time for the event
*
* @var string human-readable string in RFC2822 format
*/
public $start_time;

/**
* End time for the event
*
* @var string human-readable string in RFC2822 format
*/
public $end_time;

/**
* Constructor
*
* @param array $data
* @return \OCA\Tasks\Controller\Task
*/
public function __construct($taskId, $calendarId, $vtodo, $reason, $query) {
// set default properties
$this->id = $taskId;
$this->calendarID = $calendarId;
$this->name = $vtodo->getAsString('SUMMARY');
$this->completed = $vtodo->COMPLETED ? true : false;
$this->link = \OCP\Util::linkToRoute('tasks.page.index') . '#/lists/' . $calendarId . '/tasks/' . $taskId;
$l = new \OC_l10n('tasks');
switch($reason){
case 'SUMMARY':
$this->text = '"' . $query .'" '. $l->t('found in task title.');
break;
case 'DESCRIPTION':
$this->text = '"' . $query .'" '. $l->t('found in task note.');
break;
case 'LOCATION':
$this->text = '"' . $query .'" '. $l->t('found in task location.');
break;
case 'CATEGORIES':
$this->text = '"' . $query .'" '. $l->t('found in task categories.');
break;
case 'COMMENTS':
$this->text = '"' . $query .'" '. $l->t('found in task comments.');
break;
default:
$this->text = '';
break;
}
}
}
24 changes: 24 additions & 0 deletions controller/taskscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,30 @@ public function getTasks($listID = 'all', $type = 'all'){
return $response;
}

public function getTask($taskID){
$object = \OC_Calendar_App::getEventObject($taskID);
$user_timezone = \OC_Calendar_App::getTimezone();
$task = array();
if($object['objecttype']=='VTODO' && !is_null($object['summary'])) {
$vtodo = Helper::parseVTODO($object['calendardata']);
try {
$task_data = Helper::arrayForJSON($object['id'], $vtodo, $user_timezone);
$task_data['calendarid'] = $object['calendarid'];
$task[] = $task_data;
} catch(\Exception $e) {
\OCP\Util::writeLog('tasks', $e->getMessage(), \OCP\Util::ERROR);
}
}
$result = array(
'data' => array(
'tasks' => $task
)
);
$response = new JSONResponse();
$response->setData($result);
return $response;
}

private static function sort_completed($a, $b){
$t1 = \DateTime::createFromFormat('Ymd\THis', $a['completed_date']);
$t2 = \DateTime::createFromFormat('Ymd\THis', $b['completed_date']);
Expand Down
8 changes: 8 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,14 @@
height: 100%;
position: relative;
}
#task-details div.content-wrapper div.notice {
color: #888;
font-size: 16px;
position: absolute;
text-align: center;
top: 50%;
width: 100%;
}
#task-details div.content-wrapper div.footer {
background: url("../img/bgTask.png") repeat scroll 0 0 #ffffff;
border-top: 1px solid #D3D3D3;
Expand Down
8 changes: 8 additions & 0 deletions css/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,14 @@
height: 100%;
position: relative;
}
div.notice{
color: #888;
font-size: 16px;
position: absolute;
text-align: center;
top: 50%;
width: 100%;
}
div.footer{
background: url("../img/bgTask.png") repeat scroll 0 0 #FFFFFF;
border-top: 1px solid #D3D3D3;
Expand Down
Binary file added img/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 27 additions & 6 deletions js/app/controllers/detailscontroller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,32 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
angular.module('Tasks').controller 'DetailsController',
['$scope', '$window', 'TasksModel', 'TasksBusinessLayer',
'$route', '$location', '$timeout', '$routeParams',
'SettingsModel',
'SettingsModel', 'Loading',
($scope, $window, TasksModel, TasksBusinessLayer, $route, $location,
$timeout, $routeParams, SettingsModel) ->
$timeout, $routeParams, SettingsModel, Loading) ->

class DetailsController

constructor: (@_$scope, @_$window, @_$tasksmodel,
@_tasksbusinesslayer, @_$route, @_$location, @_$timeout,
@_$routeparams, @_$settingsmodel) ->
@_$routeparams, @_$settingsmodel, @_Loading) ->

@_$scope.task = _$tasksmodel.getById(_$scope.route.taskID)

@_$scope.found = true

@_$scope.$on('$routeChangeSuccess', () ->
task = _$tasksmodel.getById(_$scope.route.taskID)
if !(angular.isUndefined(task) || task == null)
_$scope.task = task
_$scope.found = true
else if (_$scope.route.taskID != undefined)
_$scope.found = false
_tasksbusinesslayer.getTask _$scope.route.taskID
, (data) =>
_$scope.loadTask(_$scope.route.taskID)
)

@_$scope.settingsmodel = @_$settingsmodel

@_$scope.isAddingComment = false
Expand Down Expand Up @@ -69,7 +77,20 @@ $timeout, $routeParams, SettingsModel) ->
id: 'second'}
]

# console.log(_$settingsmodel.getById('various').firstDay)
@_$scope.loadTask = (taskID) ->
task = _$tasksmodel.getById(_$scope.route.taskID)
if !(angular.isUndefined(task) || task == null)
_$scope.task = task
_$scope.found = true

@_$scope.TaskState = () ->
if _$scope.found
return 'found'
else
if _Loading.isLoading()
return 'loading'
else
return null

@_$scope.params = (task) ->
params = [
Expand Down Expand Up @@ -329,5 +350,5 @@ $timeout, $routeParams, SettingsModel) ->

return new DetailsController($scope, $window, TasksModel,
TasksBusinessLayer, $route, $location, $timeout, $routeParams,
SettingsModel)
SettingsModel, Loading)
]
5 changes: 5 additions & 0 deletions js/app/services/businesslayer/tasksbusinesslayer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ angular.module('Tasks').factory 'TasksBusinessLayer',
onSuccess(response.data)
@_persistence.addTask(task, success)

getTask: (taskID, onSuccess=null, onFailure=null) ->
onSuccess or= ->

@_persistence.getTask(taskID, onSuccess, true)

starTask: (taskID) ->
@_$tasksmodel.star(taskID)
@_persistence.starTask(taskID)
Expand Down
22 changes: 22 additions & 0 deletions js/app/services/persistence.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,28 @@ angular.module('Tasks').factory 'Persistence',

@_request.get '/apps/tasks/tasks/{type}/{listID}', params

getTask: (taskID, onSuccess, showLoading=true) ->
onSuccess or= ->

if showLoading
@_Loading.increase()
successCallbackWrapper = () =>
onSuccess()
@_Loading.decrease()
failureCallbackWrapper = () =>
@_Loading.decrease()
else
successCallbackWrapper = () =>
onSuccess()
failureCallbackWrapper = () =>
params =
onSuccess: successCallbackWrapper
onFailure: failureCallbackWrapper
routeParams:
taskID: taskID

@_request.get '/apps/tasks/task/{taskID}', params

starTask: (taskID) ->
params =
routeParams:
Expand Down
Loading