From f7717aa02a0fc755df4671a7c8134e33f9bbc9d9 Mon Sep 17 00:00:00 2001 From: Adrian Missy Date: Tue, 26 Apr 2022 12:34:29 -0500 Subject: [PATCH] feat: #2906 add card ID badge - adds vscode settings file to gitingore - adds new badge for card ID - adds card ID to board filter - adds settings to disable card ID badge Signed-off-by: Adrian Missy --- .gitignore | 1 + docs/API.md | 3 ++ lib/Service/ConfigService.php | 20 +++++++++ src/components/cards/CardBadges.vue | 10 ++++- src/components/cards/CardItem.vue | 1 + src/components/cards/badges/CardId.vue | 46 +++++++++++++++++++++ src/components/navigation/AppNavigation.vue | 18 ++++++++ src/store/card.js | 2 +- 8 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 src/components/cards/badges/CardId.vue diff --git a/.gitignore b/.gitignore index 577b6d38c..9f2f521a4 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ tests/.phpunit.result.cache vendor/ .php_cs.cache \.idea/ +settings.json diff --git a/docs/API.md b/docs/API.md index e81553e3b..9f96b5162 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1066,6 +1066,7 @@ Deck stores user and app configuration values globally and per board. The GET en | --- | --- | | calendar | Determines if the calendar/tasks integration through the CalDAV backend is enabled for the user (boolean) | | cardDetailsInModal | Determines if the bigger view is used (boolean) | +| cardIdBadge | Determines if the ID badges are displayed on cards (boolean) | | groupLimit | Determines if creating new boards is limited to certain groups of the instance. The resulting output is an array of group objects with the id and the displayname (Admin only)| ``` @@ -1079,6 +1080,7 @@ Deck stores user and app configuration values globally and per board. The GET en "data": { "calendar": true, "cardDetailsInModal": true, + "cardIdBadge": true, "groupLimit": [ { "id": "admin", @@ -1109,6 +1111,7 @@ Deck stores user and app configuration values globally and per board. The GET en | notify-due | `off`, `assigned` or `all` | | calendar | Boolean | | cardDetailsInModal | Boolean | +| cardIdBadge | Boolean | #### Example request diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index b5296a691..37121e5e7 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -71,6 +71,7 @@ public function getAll(): array { $data = [ 'calendar' => $this->isCalendarEnabled(), 'cardDetailsInModal' => $this->isCardDetailsInModal(), + 'cardIdBadge' => $this->isCardIdBadgeEnabled() ]; if ($this->groupManager->isAdmin($this->getUserId())) { $data['groupLimit'] = $this->get('groupLimit'); @@ -100,6 +101,11 @@ public function get(string $key) { return false; } return (bool)$this->config->getUserValue($this->getUserId(), Application::APP_ID, 'cardDetailsInModal', true); + case 'cardIdBadge': + if ($this->getUserId() === null) { + return false; + } + return (bool)$this->config->getUserValue($this->getUserId(), Application::APP_ID, 'cardIdBadge', false); } return false; } @@ -131,6 +137,16 @@ public function isCardDetailsInModal(int $boardId = null): bool { return (bool)$this->config->getUserValue($this->getUserId(), Application::APP_ID, 'board:' . $boardId . ':cardDetailsInModal', $defaultState); } + public function isCardIdBadgeEnabled(): bool { + if ($this->getUserId() === null) { + return false; + } + $appConfigState = $this->config->getAppValue(Application::APP_ID, 'cardIdBadge', 'yes') === 'no'; + $defaultState = (bool)$this->config->getUserValue($this->getUserId(), Application::APP_ID, 'cardIdBadge', $appConfigState); + + return (bool)$this->config->getUserValue($this->getUserId(), Application::APP_ID, 'cardIdBadge', $defaultState); + } + public function set($key, $value) { if ($this->getUserId() === null) { throw new NoPermissionException('Must be logged in to set user config'); @@ -153,6 +169,10 @@ public function set($key, $value) { $this->config->setUserValue($this->getUserId(), Application::APP_ID, 'cardDetailsInModal', (string)$value); $result = $value; break; + case 'cardIdBadge': + $this->config->setUserValue($this->getUserId(), Application::APP_ID, 'cardIdBadge', (string)$value); + $result = $value; + break; case 'board': [$boardId, $boardConfigKey] = explode(':', $key); if ($boardConfigKey === 'notify-due' && !in_array($value, [self::SETTING_BOARD_NOTIFICATION_DUE_ALL, self::SETTING_BOARD_NOTIFICATION_DUE_ASSIGNED, self::SETTING_BOARD_NOTIFICATION_DUE_OFF], true)) { diff --git a/src/components/cards/CardBadges.vue b/src/components/cards/CardBadges.vue index d45c96f2d..28fe4b523 100644 --- a/src/components/cards/CardBadges.vue +++ b/src/components/cards/CardBadges.vue @@ -22,6 +22,7 @@