Sort results by completed

This commit is contained in:
Raimund Schlüßler 2015-02-07 16:55:01 +01:00
parent a46968c2cf
commit b6c6b80ee5
2 changed files with 18 additions and 0 deletions

View file

@ -73,6 +73,16 @@ class SearchController extends \OCP\Search\Provider {
}
}
}
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;
}
}

View file

@ -39,6 +39,13 @@ class Task extends \OCP\Search\Result {
*/
public $calendarID;
/**
* Is Task completed
*
* @var string
*/
public $completed;
/**
* Used by the client JS to display additional information under the event summary
*
@ -71,6 +78,7 @@ class Task extends \OCP\Search\Result {
$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){