Skip to content

Commit

Permalink
add selection column description and test it
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Steffens <florian.steffens@nextcloud.com>
  • Loading branch information
Florian Steffens committed Oct 30, 2023
1 parent 6024a97 commit 98ffe2f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/Controller/ApiColumnsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ public function createTextColumn(int $baseNodeId, string $title, ?string $textDe
*
* @param int $baseNodeId Context of the column creation
* @param string $title Title
* @param string $selectionOptions Options that can be selected
* @param string|null $selectionDefault Default selected option(s)
* @param string $selectionOptions Json array{id: int, label: string} with options that can be selected, eg [{"id": 1, "label": "first"},{"id": 2, "label": "second"}]
* @param string|null $selectionDefault Json int|int[] for default selected option(s), eg 5 or ["1", "8"]
* @param 'progress'|'stars'|null $subtype Subtype for the new column
* @param string|null $description Description
* @param int[]|null $selectedViewIds View IDs where this columns should be added
Expand All @@ -225,14 +225,14 @@ public function createTextColumn(int $baseNodeId, string $title, ?string $textDe
* @throws NotFoundError
* @throws PermissionError
*/
public function createSelectionColumn(int $baseNodeId, string $title, string $selectionOptions, ?string $selectionDefault, string $subtype = null, string $description = null, ?array $selectedViewIds = null, bool $mandatory = false, string $baseNodeType = 'table'): DataResponse {
public function createSelectionColumn(int $baseNodeId, string $title, string $selectionOptions, ?string $selectionDefault, string $subtype = null, string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse {
$tableId = $baseNodeType === 'table' ? $baseNodeId : null;
$viewId = $baseNodeType === 'view' ? $baseNodeId : null;
$column = $this->service->create(
$this->userId,
$tableId,
$viewId,
'text',
'selection',
$subtype,
$title,
$mandatory,
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/ColumnService.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function create(
?string $selectionDefault,

?string $datetimeDefault,
?array $selectedViewIds
?array $selectedViewIds = []
):Column {
// security
if ($viewId) {
Expand Down
5 changes: 3 additions & 2 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -6416,7 +6416,7 @@
{
"name": "selectionOptions",
"in": "query",
"description": "Options that can be selected",
"description": "Json array{id: int, label: string} with options that can be selected, eg [{\"id\": 1, \"label\": \"first\"},{\"id\": 2, \"label\": \"second\"}]",
"required": true,
"schema": {
"type": "string"
Expand All @@ -6425,7 +6425,7 @@
{
"name": "selectionDefault",
"in": "query",
"description": "Default selected option(s)",
"description": "Json int|int[] for default selected option(s), eg 5 or [\"1\", \"8\"]",
"schema": {
"type": "string",
"nullable": true
Expand Down Expand Up @@ -6456,6 +6456,7 @@
"schema": {
"type": "array",
"nullable": true,
"default": [],
"items": {
"type": "integer",
"format": "int64"
Expand Down
16 changes: 16 additions & 0 deletions tests/integration/features/APIv2.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,19 @@ Feature: APIv2
Then node with node type "table" and node name "t2" has the following columns via v2
| Beautiful text column | Rich is cool | Counter | Progress | Checking | A single date |
Then print register

@api2selection
Scenario: Create selection columns
Given table "Table 3" with emoji "👋" exists for user "participant1-v2" as "t3" via v2
Then column from main type "selection" for node type "table" and node name "t3" exists with name "sel-c1" and following properties via v2
| title | sel single |
| selectionOptions | [{"id": 1, "label": "first"},{"id": 2, "label": "second"}] |
| selectionDefault | 2 |
Then column from main type "selection" for node type "table" and node name "t3" exists with name "sel-c2" and following properties via v2
| title | sel multi |
| subtype | multi |
| selectionOptions | [{"id": 1, "label": "first"},{"id": 2, "label": "second"}] |
| selectionDefault | ["1","2"] |
Then node with node type "table" and node name "t3" has the following columns via v2
| sel single | sel multi |
Then print register

0 comments on commit 98ffe2f

Please sign in to comment.