Implement due dates for cards
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
committed by
Julius Härtl
parent
58bf51accd
commit
9a77bd7c7c
@@ -90,8 +90,8 @@ class CardController extends Controller {
|
||||
* @param $description
|
||||
* @return \OCP\AppFramework\Db\Entity
|
||||
*/
|
||||
public function update($id, $title, $stackId, $type, $order, $description) {
|
||||
return $this->cardService->update($id, $title, $stackId, $type, $order, $description, $this->userId);
|
||||
public function update($id, $title, $stackId, $type, $order, $description, $duedate) {
|
||||
return $this->cardService->update($id, $title, $stackId, $type, $order, $description, $this->userId, $duedate);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -140,7 +140,6 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
$timeLimit = time()-(60*5);
|
||||
$sql = 'SELECT id, title, owner, color, archived, deleted_at FROM `*PREFIX*deck_boards` ' .
|
||||
'WHERE `deleted_at` > 0 AND `deleted_at` < ?';
|
||||
\OC::$server->getLogger()->error($sql);
|
||||
return $this->findEntities($sql, [$timeLimit]);
|
||||
}
|
||||
|
||||
@@ -216,4 +215,4 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
// db/author.php
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
use DateTime;
|
||||
use JsonSerializable;
|
||||
|
||||
class Card extends RelationalEntity implements JsonSerializable {
|
||||
@@ -39,6 +40,12 @@ class Card extends RelationalEntity implements JsonSerializable {
|
||||
protected $owner;
|
||||
protected $order;
|
||||
protected $archived = false;
|
||||
protected $duedate = null;
|
||||
|
||||
const DUEDATE_FUTURE = 0;
|
||||
const DUEDATE_NEXT = 1;
|
||||
const DUEDATE_NOW = 2;
|
||||
const DUEDATE_OVERDUE = 3;
|
||||
|
||||
public function __construct() {
|
||||
$this->addType('id', 'integer');
|
||||
@@ -51,4 +58,33 @@ class Card extends RelationalEntity implements JsonSerializable {
|
||||
$this->addResolvable('owner');
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
$json = parent::jsonSerialize();
|
||||
$json['overdue'] = self::DUEDATE_FUTURE;
|
||||
$due = strtotime($this->duedate);
|
||||
|
||||
$today = new DateTime();
|
||||
$today->setTime( 0, 0, 0 );
|
||||
|
||||
$match_date = new DateTime($this->duedate);
|
||||
|
||||
$match_date->setTime( 0, 0, 0 );
|
||||
|
||||
$diff = $today->diff( $match_date );
|
||||
$diffDays = (integer)$diff->format( "%R%a" ); // Extract days count in interval
|
||||
|
||||
if($due !== false) {
|
||||
if ($diffDays === 1) {
|
||||
$json['overdue'] = self::DUEDATE_NEXT;
|
||||
}
|
||||
if ($diffDays === 0) {
|
||||
$json['overdue'] = self::DUEDATE_NOW;
|
||||
}
|
||||
if ($diffDays < 0) {
|
||||
$json['overdue'] = self::DUEDATE_OVERDUE;
|
||||
}
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,9 +50,6 @@ class CardService {
|
||||
return $card;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $order
|
||||
*/
|
||||
public function create($title, $stackId, $type, $order, $owner) {
|
||||
$this->permissionService->checkPermission($this->stackMapper, $stackId, Acl::PERMISSION_EDIT);
|
||||
if($this->boardService->isArchived($this->stackMapper, $stackId)) {
|
||||
@@ -76,7 +73,7 @@ class CardService {
|
||||
return $this->cardMapper->delete($this->cardMapper->find($id));
|
||||
}
|
||||
|
||||
public function update($id, $title, $stackId, $type, $order, $description, $owner) {
|
||||
public function update($id, $title, $stackId, $type, $order, $description, $owner, $duedate) {
|
||||
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
||||
if($this->boardService->isArchived($this->cardMapper, $id)) {
|
||||
throw new StatusException('Operation not allowed. This board is archived.');
|
||||
@@ -91,6 +88,7 @@ class CardService {
|
||||
$card->setOrder($order);
|
||||
$card->setOwner($owner);
|
||||
$card->setDescription($description);
|
||||
$card->setDuedate($duedate);
|
||||
return $this->cardMapper->update($card);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user