change lot of stuff

This commit is contained in:
Julius Haertl
2016-07-30 22:21:12 +02:00
parent d61dcdb614
commit 9abd92c4e4
29 changed files with 864 additions and 204 deletions

View File

@@ -33,7 +33,7 @@ class Board extends \OCA\Deck\Db\Entity implements JsonSerializable {
public function setLabels($labels) {
foreach ($labels as $l) {
$this->labels[$l->id] = $l;
$this->labels[] = $l;
}
}

View File

@@ -22,6 +22,9 @@ class Card extends Entity implements JsonSerializable {
$this->addType('id','integer');
$this->addType('stackId','integer');
$this->addType('order','integer');
$this->addType('lastModified', 'integer');
$this->addType('createdAt', 'integer');
$this->addType('archived','boolean');
$this->addRelation('labels');
}

View File

@@ -51,6 +51,7 @@ class CardMapper extends Mapper {
}
public function findAll($stackId, $limit=null, $offset=null) {
// TODO: Exclude fields like text
$sql = 'SELECT * FROM `*PREFIX*deck_cards`
WHERE `stack_id` = ? AND NOT archived ORDER BY `order`';
$entities = $this->findEntities($sql, [$stackId], $limit, $offset);
@@ -58,9 +59,8 @@ class CardMapper extends Mapper {
}
// TODO: test
public function findAllArchived($boardId, $limit=null, $offset=null) {
$sql = 'SELECT * FROM `*PREFIX*deck_cards` as c, `*PREFIX*deck_stacks` as s
WHERE `s.board_id` = ? AND c.stack_id = s.id AND archived ORDER BY `last_modified`';
public function findAllArchived($stackId, $limit=null, $offset=null) {
$sql = 'SELECT * FROM `*PREFIX*deck_cards` WHERE `stack_id`=? AND archived ORDER BY `last_modified`';
$entities = $this->findEntities($sql, [$stackId], $limit, $offset);
return $entities;
}

View File

@@ -32,6 +32,7 @@ class StackMapper extends Mapper {
$sql = 'SELECT * FROM `*PREFIX*deck_stacks` WHERE `board_id` = ? ORDER BY `order`';
return $this->findEntities($sql, [$boardId], $limit, $offset);
}
public function delete(Entity $entity) {
// FIXME: delete linked elements, because owncloud doesn't support foreign keys for apps