From 4472313222c0e45502bb041ba2f3cddb21d0eb64 Mon Sep 17 00:00:00 2001 From: grnd-alt Date: Tue, 9 Apr 2024 16:29:06 +0200 Subject: [PATCH] add tables Description to createTable Signed-off-by: grnd-alt --- lib/Controller/ApiTablesController.php | 5 +++-- .../Version000000Date20210921000000.php | 4 ++++ .../Version000900Date20240314000000.php | 11 ++++++----- lib/Service/TableService.php | 3 ++- openapi.json | 9 +++++++++ src/modules/modals/CreateTable.vue | 17 +++++++++++++++++ src/store/store.js | 18 +----------------- src/types/openapi/openapi.ts | 2 ++ 8 files changed, 44 insertions(+), 25 deletions(-) diff --git a/lib/Controller/ApiTablesController.php b/lib/Controller/ApiTablesController.php index 11cf56962..0ee061d20 100644 --- a/lib/Controller/ApiTablesController.php +++ b/lib/Controller/ApiTablesController.php @@ -78,15 +78,16 @@ public function show(int $id): DataResponse { * * @param string $title Title of the table * @param string|null $emoji Emoji for the table + * @param string|null $description Description for the table * @param string $template Template to use if wanted * * @return DataResponse|DataResponse * * 200: Tables returned */ - public function create(string $title, ?string $emoji, string $template = 'custom'): DataResponse { + public function create(string $title, ?string $emoji, ?string $description, string $template = 'custom'): DataResponse { try { - return new DataResponse($this->service->create($title, $template, $emoji)->jsonSerialize()); + return new DataResponse($this->service->create($title, $template, $emoji, $description)->jsonSerialize()); } catch (InternalError|Exception $e) { return $this->handleError($e); } diff --git a/lib/Migration/Version000000Date20210921000000.php b/lib/Migration/Version000000Date20210921000000.php index 630666467..b8fc7013c 100644 --- a/lib/Migration/Version000000Date20210921000000.php +++ b/lib/Migration/Version000000Date20210921000000.php @@ -54,6 +54,10 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt $table->addColumn('last_edit_at', Types::DATETIME, [ 'notnull' => true, ]); + $table->addColumn('description', Types::TEXT, [ + 'default' => '', + 'notnull' => false, + ]); $table->setPrimaryKey(['id']); } diff --git a/lib/Migration/Version000900Date20240314000000.php b/lib/Migration/Version000900Date20240314000000.php index 7dcf5ab3f..10e3ff8a0 100644 --- a/lib/Migration/Version000900Date20240314000000.php +++ b/lib/Migration/Version000900Date20240314000000.php @@ -27,13 +27,14 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt if ($schema->hasTable('tables_tables')) { $table = $schema->getTable('tables_tables'); - $table->addColumn('description', Types::TEXT, [ - 'default' => '', - 'notnull' => false, - ]); + if (!$table->hasColumn('description')) { + $table->addColumn('description', Types::TEXT, [ + 'default' => '', + 'notnull' => false, + ]); + } return $schema; } return null; } - } diff --git a/lib/Service/TableService.php b/lib/Service/TableService.php index 7f6dec1f8..2ee7685d7 100644 --- a/lib/Service/TableService.php +++ b/lib/Service/TableService.php @@ -255,12 +255,13 @@ public function find(int $id, bool $skipTableEnhancement = false, ?string $userI * @throws InternalError * @noinspection DuplicatedCode */ - public function create(string $title, string $template, ?string $emoji, ?string $userId = null): Table { + public function create(string $title, string $template, ?string $emoji, ?string $description = '', ?string $userId = null): Table { $userId = $this->permissionsService->preCheckUserId($userId, false); // we can assume that the $userId is set $time = new DateTime(); $item = new Table(); $item->setTitle($title); + $item->setDescription($description); if($emoji) { $item->setEmoji($emoji); } diff --git a/openapi.json b/openapi.json index 18788f5ec..41d136387 100644 --- a/openapi.json +++ b/openapi.json @@ -5077,6 +5077,15 @@ "nullable": true } }, + { + "name": "description", + "in": "query", + "description": "Description for the table", + "schema": { + "type": "string", + "nullable": true + } + }, { "name": "template", "in": "query", diff --git a/src/modules/modals/CreateTable.vue b/src/modules/modals/CreateTable.vue index 3eceaf1d9..1dcd7801c 100644 --- a/src/modules/modals/CreateTable.vue +++ b/src/modules/modals/CreateTable.vue @@ -28,6 +28,14 @@ @input="titleChangedManually"> +
+
+ {{ t('tables', 'Description') }} +
+
+ +
+