From 51bcbdb87d55601371eb70cfd98909df5c48d9cc Mon Sep 17 00:00:00 2001 From: Dmitriy Ivanko Date: Wed, 17 Nov 2021 20:14:34 +0300 Subject: [PATCH] Store cardDetailsInModal in config instead of state Signed-off-by: Dmitriy Ivanko --- docs/API.md | 3 +++ lib/Service/ConfigService.php | 25 ++++++++++++++++++- src/App.vue | 9 ++++++- src/components/board/Stack.vue | 9 ++++++- src/components/card/CardSidebar.vue | 16 +++++++++--- src/components/card/CardSidebarTabDetails.vue | 9 ++++++- src/components/card/Description.vue | 1 - src/components/navigation/AppNavigation.vue | 4 +-- src/store/main.js | 11 -------- 9 files changed, 66 insertions(+), 21 deletions(-) diff --git a/docs/API.md b/docs/API.md index 376720a50..00cb8f987 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1004,6 +1004,7 @@ Deck stores user and app configuration values globally and per board. The GET en | Config key | Description | | --- | --- | | 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) | | 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)| ``` @@ -1016,6 +1017,7 @@ Deck stores user and app configuration values globally and per board. The GET en }, "data": { "calendar": true, + "cardDetailsInModal": true, "groupLimit": [ { "id": "admin", @@ -1045,6 +1047,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 | #### Example request diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index e6b0d4b95..d7bae6390 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -66,7 +66,8 @@ class ConfigService { } $data = [ - 'calendar' => $this->isCalendarEnabled() + 'calendar' => $this->isCalendarEnabled(), + 'cardDetailsInModal' => $this->isCardDetailsInModal(), ]; if ($this->groupManager->isAdmin($this->getUserId())) { $data['groupLimit'] = $this->get('groupLimit'); @@ -88,6 +89,11 @@ class ConfigService { return false; } return (bool)$this->config->getUserValue($this->getUserId(), Application::APP_ID, 'calendar', true); + case 'cardDetailsInModal': + if ($this->getUserId() === null) { + return false; + } + return (bool)$this->config->getUserValue($this->getUserId(), Application::APP_ID, 'cardDetailsInModal', true); } } @@ -104,6 +110,19 @@ class ConfigService { return (bool)$this->config->getUserValue($this->getUserId(), Application::APP_ID, 'board:' . $boardId . ':calendar', $defaultState); } + public function isCardDetailsInModal(int $boardId = null): bool { + if ($this->getUserId() === null) { + return false; + } + + $defaultState = (bool)$this->config->getUserValue($this->getUserId(), Application::APP_ID, 'cardDetailsInModal', true); + if ($boardId === null) { + return $defaultState; + } + + return (bool)$this->config->getUserValue($this->getUserId(), Application::APP_ID, 'board:' . $boardId . ':cardDetailsInModal', $defaultState); + } + public function set($key, $value) { if ($this->getUserId() === null) { throw new NoPermissionException('Must be logged in to set user config'); @@ -122,6 +141,10 @@ class ConfigService { $this->config->setUserValue($this->getUserId(), Application::APP_ID, 'calendar', (string)$value); $result = $value; break; + case 'cardDetailsInModal': + $this->config->setUserValue($this->getUserId(), Application::APP_ID, 'cardDetailsInModal', (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/App.vue b/src/App.vue index e9c884fcc..81854078e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -88,7 +88,6 @@ export default { navShown: state => state.navShown, sidebarShownState: state => state.sidebarShown, currentBoard: state => state.currentBoard, - cardDetailsInModal: state => state.cardDetailsInModal, }), // TODO: properly handle sidebar showing for route subview and board sidebar sidebarRouterView() { @@ -98,6 +97,14 @@ export default { sidebarShown() { return this.sidebarRouterView || this.sidebarShownState }, + cardDetailsInModal: { + get() { + return this.$store.getters.config('cardDetailsInModal') + }, + set(newValue) { + this.$store.dispatch('setConfig', { cardDetailsInModal: newValue }) + }, + }, }, created() { this.$store.dispatch('loadBoards') diff --git a/src/components/board/Stack.vue b/src/components/board/Stack.vue index 231e91305..830e70061 100644 --- a/src/components/board/Stack.vue +++ b/src/components/board/Stack.vue @@ -162,7 +162,6 @@ export default { ]), ...mapState({ showArchived: state => state.showArchived, - cardDetailsInModal: state => state.cardDetailsInModal, }), cardsByStack() { return this.$store.getters.cardsByStack(this.stack.id).filter((card) => { @@ -175,6 +174,14 @@ export default { dragHandleSelector() { return this.canEdit ? null : '.no-drag' }, + cardDetailsInModal: { + get() { + return this.$store.getters.config('cardDetailsInModal') + }, + set(newValue) { + this.$store.dispatch('setConfig', { cardDetailsInModal: newValue }) + }, + }, }, methods: { diff --git a/src/components/card/CardSidebar.vue b/src/components/card/CardSidebar.vue index 4028efa25..bae175cd1 100644 --- a/src/components/card/CardSidebar.vue +++ b/src/components/card/CardSidebar.vue @@ -31,7 +31,7 @@ @submit-title="handleSubmitTitle" @close="closeSidebar">