diff --git a/cypress/e2e/tables-archive.cy.js b/cypress/e2e/tables-archive.cy.js index 0db3988b1..dff1a1032 100644 --- a/cypress/e2e/tables-archive.cy.js +++ b/cypress/e2e/tables-archive.cy.js @@ -20,12 +20,12 @@ describe('Archive tables/views', () => { cy.get('@tutorialTable').should('contain.text', 'Tutorial') cy.get('@tutorialTable').find('[aria-haspopup="menu"]').click({ force: true }) - cy.intercept({ method: 'PUT', url: '**/apps/tables/table/*'}).as('archiveTableReq') + cy.intercept({ method: 'PUT', url: '**/apps/tables/api/2/tables/*'}).as('archiveTableReq') cy.contains('Archive table').click({ force: true }) cy.wait('@archiveTableReq').then(request => { expect(request.response.statusCode).to.equal(200) - expect(request.response.body.archived).to.equal(true) + expect(request.response.body.ocs.data.archived).to.equal(true) }) cy.get('@tutorialTable').parent().parent().should('contain.text', 'Archived tables') @@ -37,12 +37,12 @@ describe('Archive tables/views', () => { cy.get('@tutorialTable').should('contain.text', 'Tutorial') cy.get('@tutorialTable').find('[aria-haspopup="menu"]').click({ force: true }) - cy.intercept({ method: 'PUT', url: '**/apps/tables/table/*' }).as('unarchiveTableReq') + cy.intercept({ method: 'PUT', url: '**/apps/tables/api/2/tables/*' }).as('unarchiveTableReq') cy.contains('Unarchive table').click({ force: true }) cy.wait('@unarchiveTableReq').then(request => { expect(request.response.statusCode).to.equal(200) - expect(request.response.body.archived).to.equal(false) + expect(request.response.body.ocs.data.archived).to.equal(false) }) cy.get('@tutorialTable').parent().should('contain.text', 'Tables') diff --git a/cypress/e2e/tables-table.cy.js b/cypress/e2e/tables-table.cy.js index 7e5faaa92..ce9ab1bb6 100644 --- a/cypress/e2e/tables-table.cy.js +++ b/cypress/e2e/tables-table.cy.js @@ -23,24 +23,28 @@ describe('Manage a table', () => { cy.get('.tile').contains('ToDo').click({ force: true }) cy.get('.modal__content').should('be.visible') cy.get('.modal__content input[type="text"]').clear().type('to do list') + cy.get('.modal__content #description-editor .tiptap.ProseMirror').type('to Do List description') cy.contains('button', 'Create table').click() cy.contains('button', 'Create row').should('be.visible') cy.contains('h1', 'to do list').should('be.visible') cy.contains('table th', 'Task').should('exist') + cy.contains('.paragraph-content', 'to Do List description').should('be.visible') }) - it('Update title', () => { + it('Update title And Description', () => { cy.get('.app-navigation__list').contains('to do list').click({ force: true }) cy.get('[data-cy="customTableAction"] button').click() cy.get('.action-button__text').contains('Edit table').click() cy.get('.modal__content').should('be.visible') cy.get('.modal-container input').last().clear().type('ToDo list') + cy.get('.modal__content #description-editor .tiptap.ProseMirror').type('Updated ToDo List description') cy.get('.modal-container button').contains('Save').click() cy.wait(10).get('.toastify.toast-success').should('be.visible') cy.get('.app-navigation__list').contains('ToDo list').should('exist') + cy.contains('.paragraph-content', 'Updated ToDo List description').should('be.visible') }) it('Delete', () => { diff --git a/lib/Command/RenameTable.php b/lib/Command/RenameTable.php index 3a41153b5..d492cec77 100644 --- a/lib/Command/RenameTable.php +++ b/lib/Command/RenameTable.php @@ -82,9 +82,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $title = $input->getArgument('title'); $emoji = $input->getOption('emoji'); $archived = $input->getOption('archived'); + $description = $input->getOption('description'); try { - $table = $this->tableService->update($id, $title, $emoji, $archived, ''); + $table = $this->tableService->update($id, $title, $emoji, $description, $archived, ''); $arr = $table->jsonSerialize(); unset($arr['hasShares']); diff --git a/lib/Controller/Api1Controller.php b/lib/Controller/Api1Controller.php index f9614349b..438cad369 100644 --- a/lib/Controller/Api1Controller.php +++ b/lib/Controller/Api1Controller.php @@ -181,7 +181,7 @@ public function getTable(int $tableId): DataResponse { */ public function updateTable(int $tableId, string $title = null, string $emoji = null, ?bool $archived = false): DataResponse { try { - return new DataResponse($this->tableService->update($tableId, $title, $emoji, $archived, $this->userId)->jsonSerialize()); + return new DataResponse($this->tableService->update($tableId, $title, $emoji, null, $archived, $this->userId)->jsonSerialize()); } catch (PermissionError $e) { $this->logger->warning('A permission error occurred: ' . $e->getMessage()); $message = ['message' => $e->getMessage()]; diff --git a/lib/Controller/ApiTablesController.php b/lib/Controller/ApiTablesController.php index 6748d109f..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); } @@ -101,15 +102,16 @@ public function create(string $title, ?string $emoji, string $template = 'custom * @param string|null $title New table title * @param string|null $emoji New table emoji * @param bool $archived whether the table is archived + * @param string $description the tables description * @return DataResponse|DataResponse * * 200: Tables returned * 403: No permissions * 404: Not found */ - public function update(int $id, ?string $title = null, ?string $emoji = null, ?bool $archived = null): DataResponse { + public function update(int $id, ?string $title = null, ?string $emoji = null, ?string $description = null, ?bool $archived = null): DataResponse { try { - return new DataResponse($this->service->update($id, $title, $emoji, $archived, $this->userId)->jsonSerialize()); + return new DataResponse($this->service->update($id, $title, $emoji, $description, $archived, $this->userId)->jsonSerialize()); } catch (PermissionError $e) { return $this->handlePermissionError($e); } catch (InternalError $e) { diff --git a/lib/Controller/TableController.php b/lib/Controller/TableController.php index 65d4e7fd0..0c2e2fa23 100644 --- a/lib/Controller/TableController.php +++ b/lib/Controller/TableController.php @@ -72,7 +72,7 @@ public function destroy(int $id): DataResponse { */ public function update(int $id, string $title = null, string $emoji = null, ?bool $archived = null): DataResponse { return $this->handleError(function () use ($id, $title, $emoji, $archived) { - return $this->service->update($id, $title, $emoji, $archived, $this->userId); + return $this->service->update($id, $title, $emoji, null, $archived, $this->userId); }); } } diff --git a/lib/Db/Table.php b/lib/Db/Table.php index 242496fe7..8877d04bb 100644 --- a/lib/Db/Table.php +++ b/lib/Db/Table.php @@ -18,6 +18,7 @@ * @method setEmoji(string $emoji) * @method getArchived(): bool * @method setArchived(bool $archived) + * @method setDescription(string $description) * @method getOwnership(): string * @method setOwnership(string $ownership) * @method getOwnerDisplayName(): string @@ -66,6 +67,7 @@ class Table extends Entity implements JsonSerializable { protected ?int $columnsCount = 0; protected ?array $views = null; protected ?array $columns = null; + protected ?string $description = null; public function __construct() { $this->addType('id', 'integer'); @@ -94,6 +96,7 @@ public function jsonSerialize(): array { 'rowsCount' => $this->rowsCount ?: 0, 'columnsCount' => $this->columnsCount ?: 0, 'views' => $this->getViewsArray(), + 'description' => $this->description ?:'', ]; } 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 new file mode 100644 index 000000000..10e3ff8a0 --- /dev/null +++ b/lib/Migration/Version000900Date20240314000000.php @@ -0,0 +1,40 @@ +hasTable('tables_tables')) { + $table = $schema->getTable('tables_tables'); + 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 e28fe5fcb..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); } @@ -431,7 +432,7 @@ public function delete(int $id, ?string $userId = null): Table { * @throws NotFoundError * @throws PermissionError */ - public function update(int $id, ?string $title, ?string $emoji, ?bool $archived = null, ?string $userId = null): Table { + public function update(int $id, ?string $title, ?string $emoji, ?string $description, ?bool $archived = null, ?string $userId = null): Table { $userId = $this->permissionsService->preCheckUserId($userId); try { @@ -459,6 +460,9 @@ public function update(int $id, ?string $title, ?string $emoji, ?bool $archived if ($archived !== null) { $table->setArchived($archived); } + if ($description !== null) { + $table->setDescription($description); + } $table->setLastEditBy($userId); $table->setLastEditAt($time->format('Y-m-d H:i:s')); try { diff --git a/openapi.json b/openapi.json index 5a96f7ff9..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", @@ -5386,6 +5395,14 @@ "nullable": true } }, + { + "name": "description", + "in": "query", + "description": "the tables description", + "schema": { + "type": "string" + } + }, { "name": "archived", "in": "query", diff --git a/src/modules/main/sections/ElementDescription.vue b/src/modules/main/sections/ElementTitle.vue similarity index 98% rename from src/modules/main/sections/ElementDescription.vue rename to src/modules/main/sections/ElementTitle.vue index 5946c9cd4..da7cf87a9 100644 --- a/src/modules/main/sections/ElementDescription.vue +++ b/src/modules/main/sections/ElementTitle.vue @@ -34,7 +34,7 @@ import FilterRemove from 'vue-material-design-icons/FilterRemove.vue' import NcSmallButton from '../../../shared/components/ncSmallButton/NcSmallButton.vue' export default { - name: 'ElementDescription', + name: 'ElementTitle', components: { NcUserBubble, diff --git a/src/modules/main/sections/Table.vue b/src/modules/main/sections/Table.vue index 28dbe5e82..27322bce6 100644 --- a/src/modules/main/sections/Table.vue +++ b/src/modules/main/sections/Table.vue @@ -1,6 +1,7 @@