diff --git a/lib/Controller/ApiTablesController.php b/lib/Controller/ApiTablesController.php index b94a07d622..0f4ca5dc24 100644 --- a/lib/Controller/ApiTablesController.php +++ b/lib/Controller/ApiTablesController.php @@ -254,6 +254,7 @@ public function createFromScheme(string $title, string $emoji, string $descripti $this->viewService->update($newView->getId(), ViewUpdateInput::fromInputArray( array_merge($inputColumnsArray, [ + 'description' => $view['description'] ?? '', 'sort' => $newSort, 'filter' => $newFilter, ]) diff --git a/lib/Model/ViewUpdateInput.php b/lib/Model/ViewUpdateInput.php index 7fc2686fd5..d4f8837929 100644 --- a/lib/Model/ViewUpdateInput.php +++ b/lib/Model/ViewUpdateInput.php @@ -40,7 +40,7 @@ public function updateDetail(): Generator { if ($this->technicalName !== null) { yield ViewUpdatableParameters::TECHNICAL_NAME => $this->technicalName; } - if ($this->description) { + if ($this->description !== null) { yield ViewUpdatableParameters::DESCRIPTION => $this->description; } if ($this->emoji) { diff --git a/tests/unit/Model/ViewUpdateInputTest.php b/tests/unit/Model/ViewUpdateInputTest.php new file mode 100644 index 0000000000..8df9e05705 --- /dev/null +++ b/tests/unit/Model/ViewUpdateInputTest.php @@ -0,0 +1,40 @@ + 'Imported view description']); + $updates = []; + + foreach ($input->updateDetail() as $parameter => $value) { + $updates[$parameter->value] = $value; + } + + $this->assertSame('Imported view description', $updates[ViewUpdatableParameters::DESCRIPTION->value]); + } + + public function testUpdateDetailIncludesEmptyDescription(): void { + $input = ViewUpdateInput::fromInputArray(['description' => '']); + $updates = []; + + foreach ($input->updateDetail() as $parameter => $value) { + $updates[$parameter->value] = $value; + } + + $this->assertArrayHasKey(ViewUpdatableParameters::DESCRIPTION->value, $updates); + $this->assertSame('', $updates[ViewUpdatableParameters::DESCRIPTION->value]); + } +}