From d4898552ada979f1ff8fd3ad8564b7f4e67a2a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakob=20R=C3=B6hrl?= Date: Fri, 5 Mar 2021 14:47:43 +0100 Subject: [PATCH 1/4] cover images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakob Röhrl --- lib/Controller/BoardController.php | 5 ++-- lib/Db/Board.php | 2 ++ lib/Migration/Version10400Date20210305.php | 27 +++++++++++++++++++ lib/Service/BoardService.php | 8 +++++- src/components/cards/CardItem.vue | 5 ++++ .../navigation/AppNavigationBoard.vue | 12 +++++++-- src/store/main.js | 11 ++++++++ 7 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 lib/Migration/Version10400Date20210305.php diff --git a/lib/Controller/BoardController.php b/lib/Controller/BoardController.php index 9d0b9fcaf4..f33d08e419 100644 --- a/lib/Controller/BoardController.php +++ b/lib/Controller/BoardController.php @@ -73,10 +73,11 @@ public function create($title, $color) { * @param $title * @param $color * @param $archived + * @param $coverImages * @return \OCP\AppFramework\Db\Entity */ - public function update($id, $title, $color, $archived) { - return $this->boardService->update($id, $title, $color, $archived); + public function update($id, $title, $color, $archived, $coverImages) { + return $this->boardService->update($id, $title, $color, $archived, $coverImages); } /** diff --git a/lib/Db/Board.php b/lib/Db/Board.php index 6cf3c32068..0cdecf5533 100644 --- a/lib/Db/Board.php +++ b/lib/Db/Board.php @@ -38,6 +38,7 @@ class Board extends RelationalEntity { protected $stacks = []; protected $deletedAt = 0; protected $lastModified = 0; + protected $coverImages = true; protected $settings = []; @@ -47,6 +48,7 @@ public function __construct() { $this->addType('archived', 'boolean'); $this->addType('deletedAt', 'integer'); $this->addType('lastModified', 'integer'); + $this->addType('coverImages', 'boolean'); $this->addRelation('labels'); $this->addRelation('acl'); $this->addRelation('shared'); diff --git a/lib/Migration/Version10400Date20210305.php b/lib/Migration/Version10400Date20210305.php new file mode 100644 index 0000000000..3e298add81 --- /dev/null +++ b/lib/Migration/Version10400Date20210305.php @@ -0,0 +1,27 @@ +getTable('deck_boards'); + if (!$table->hasColumn('coverImages')) { + $table->addColumn('coverImages', 'boolean', [ + 'notnull' => false, + 'default' => true, + ]); + } + return $schema; + } +} diff --git a/lib/Service/BoardService.php b/lib/Service/BoardService.php index 1ee0a0cf29..2e49c4aa3e 100644 --- a/lib/Service/BoardService.php +++ b/lib/Service/BoardService.php @@ -408,13 +408,14 @@ public function deleteForce($id) { * @param $title * @param $color * @param $archived + * @param $coverImages * @return \OCP\AppFramework\Db\Entity * @throws DoesNotExistException * @throws \OCA\Deck\NoPermissionException * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException * @throws BadRequestException */ - public function update($id, $title, $color, $archived) { + public function update($id, $title, $color, $archived, $coverImages) { if (is_numeric($id) === false) { throw new BadRequestException('board id must be a number'); } @@ -431,12 +432,17 @@ public function update($id, $title, $color, $archived) { throw new BadRequestException('archived must be a boolean'); } + if (is_bool($coverImages) === false) { + throw new BadRequestException('coverImages must be a boolean'); + } + $this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE); $board = $this->find($id); $changes = new ChangeSet($board); $board->setTitle($title); $board->setColor($color); $board->setArchived($archived); + $board->setCoverImages($coverImages); $changes->setAfter($board); $this->boardMapper->update($board); // operate on clone so we can check for updated fields $this->boardMapper->mapOwner($board); diff --git a/src/components/cards/CardItem.vue b/src/components/cards/CardItem.vue index 3a06757921..2aba014dc9 100644 --- a/src/components/cards/CardItem.vue +++ b/src/components/cards/CardItem.vue @@ -36,6 +36,7 @@

+ {{ attachments }} {{ card.title }}

@@ -121,6 +122,7 @@ export default { }), ...mapGetters([ 'isArchived', + ]), board() { return this.$store.getters.boardById(this?.stack?.boardId) @@ -128,6 +130,9 @@ export default { stack() { return this.$store.getters.stackById(this?.card?.stackId) }, + attachments() { + return [...this.$store.getters.attachmentsByCard(this.currentCard.id)].filter(attachment => attachment.deletedAt >= 0) + }, canEdit() { if (this.currentBoard) { return !this.currentBoard.archived && this.$store.getters.canEdit diff --git a/src/components/navigation/AppNavigationBoard.vue b/src/components/navigation/AppNavigationBoard.vue index e5ceaedf65..ddf77e6b23 100644 --- a/src/components/navigation/AppNavigationBoard.vue +++ b/src/components/navigation/AppNavigationBoard.vue @@ -111,7 +111,11 @@ @click="isDueSubmenuActive=true"> {{ dueDateReminderText }} - + + {{ t('deck', 'Show cover images') }} + diff --git a/src/store/main.js b/src/store/main.js index c157423bf0..88676d4645 100644 --- a/src/store/main.js +++ b/src/store/main.js @@ -311,6 +311,9 @@ export default new Vuex.Store({ Vue.delete(state.currentBoard.acl, removeIndex) } }, + toggleCoverImages(state) { + state.coverImages = !state.coverImages + }, }, actions: { @@ -497,5 +500,13 @@ export default new Vuex.Store({ dispatch('loadBoardById', acl.boardId) }) }, + toggleCoverImages({ commit }, board) { + const boardCopy = JSON.parse(JSON.stringify(board)) + boardCopy.coverImages = !boardCopy.coverImages + apiClient.updateBoard(boardCopy) + .then((board) => { + commit('toggleCoverImages', board) + }) + }, }, }) From abd0deefab79df2be6861dbe5c9928d492ffbea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakob=20R=C3=B6hrl?= Date: Mon, 8 Mar 2021 14:49:04 +0100 Subject: [PATCH 2/4] show the images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakob Röhrl --- ...0305.php => Version010400Date20210305.php} | 11 +++--- src/components/cards/CardItem.vue | 34 ++++++++++++++++++- .../navigation/AppNavigationBoard.vue | 3 +- src/store/main.js | 8 +++-- 4 files changed, 46 insertions(+), 10 deletions(-) rename lib/Migration/{Version10400Date20210305.php => Version010400Date20210305.php} (71%) diff --git a/lib/Migration/Version10400Date20210305.php b/lib/Migration/Version010400Date20210305.php similarity index 71% rename from lib/Migration/Version10400Date20210305.php rename to lib/Migration/Version010400Date20210305.php index 3e298add81..9b2e25f9b0 100644 --- a/lib/Migration/Version10400Date20210305.php +++ b/lib/Migration/Version010400Date20210305.php @@ -9,19 +9,20 @@ use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; -class Version10400Date20210305 extends SimpleMigrationStep { +class Version010400Date20210305 extends SimpleMigrationStep { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); // Add cover image database field $table = $schema->getTable('deck_boards'); - if (!$table->hasColumn('coverImages')) { - $table->addColumn('coverImages', 'boolean', [ + if (!$table->hasColumn('cover_images')) { + $table->addColumn('cover_images', 'boolean', [ 'notnull' => false, 'default' => true, ]); + return $schema; } - return $schema; + return null; } -} +} \ No newline at end of file diff --git a/src/components/cards/CardItem.vue b/src/components/cards/CardItem.vue index 2aba014dc9..b590106daf 100644 --- a/src/components/cards/CardItem.vue +++ b/src/components/cards/CardItem.vue @@ -37,6 +37,11 @@

{{ attachments }} +
+ +
+
+

{{ card.title }}

@@ -86,6 +91,7 @@ import labelStyle from '../../mixins/labelStyle' import AttachmentDragAndDrop from '../AttachmentDragAndDrop' import CardMenu from './CardMenu' import DueDate from './badges/DueDate' +import { generateUrl } from '@nextcloud/router' export default { name: 'CardItem', @@ -131,7 +137,7 @@ export default { return this.$store.getters.stackById(this?.card?.stackId) }, attachments() { - return [...this.$store.getters.attachmentsByCard(this.currentCard.id)].filter(attachment => attachment.deletedAt >= 0) + return [...this.$store.getters.attachmentsByCard(this.id)].filter(attachment => attachment.deletedAt >= 0) }, canEdit() { if (this.currentBoard) { @@ -149,6 +155,21 @@ export default { labelsSorted() { return [...this.card.labels].sort((a, b) => (a.title < b.title) ? -1 : 1) }, + mimetypeForAttachment() { + return (attachment) => { + if (!attachment) { + return {} + } + const url = attachment.extendedData.hasPreview ? this.attachmentPreview(attachment) : OC.MimeType.getIconUrl(attachment.extendedData.mimetype) + const styles = { + 'background-image': `url("${url}")`, + } + return styles + } + }, + attachmentPreview() { + return (attachment) => (attachment.extendedData.fileid ? generateUrl(`/core/preview?fileId=${attachment.extendedData.fileid}&x=260&y=260&a=true`) : null) + }, }, watch: { currentCard(newValue) { @@ -209,6 +230,17 @@ export default { box-shadow: 0 0 5px 1px var(--color-box-shadow); } + .fileicon { + display: flex; + width: 260px; + height: 260px; + background-size: contain; + background-repeat: no-repeat; + margin-left: auto; + margin-right: auto; + border-radius: var(--border-radius-large); + } + .card-upper { display: flex; min-height: 44px; diff --git a/src/components/navigation/AppNavigationBoard.vue b/src/components/navigation/AppNavigationBoard.vue index ddf77e6b23..a740b8e915 100644 --- a/src/components/navigation/AppNavigationBoard.vue +++ b/src/components/navigation/AppNavigationBoard.vue @@ -32,7 +32,6 @@ slot="counter" class="icon-shared" style="opacity: 0.5" /> -