Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions cypress/e2e/ToDo list.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"usergroupSelectUsers": false,
"usergroupSelectGroups": false,
"usergroupSelectTeams": false,
"showUserStatus": false
"showUserStatus": false,
"customSettings": {}
},
{
"id": 92,
Expand Down Expand Up @@ -68,7 +69,10 @@
"usergroupSelectUsers": false,
"usergroupSelectGroups": false,
"usergroupSelectTeams": false,
"showUserStatus": false
"showUserStatus": false,
"customSettings": {
"width": 300
}
},
{
"id": 93,
Expand Down Expand Up @@ -102,7 +106,8 @@
"usergroupSelectUsers": false,
"usergroupSelectGroups": false,
"usergroupSelectTeams": false,
"showUserStatus": false
"showUserStatus": false,
"customSettings": {}
},
{
"id": 94,
Expand Down Expand Up @@ -136,7 +141,8 @@
"usergroupSelectUsers": false,
"usergroupSelectGroups": false,
"usergroupSelectTeams": false,
"showUserStatus": false
"showUserStatus": false,
"customSettings": {}
},
{
"id": 95,
Expand Down Expand Up @@ -170,7 +176,8 @@
"usergroupSelectUsers": false,
"usergroupSelectGroups": false,
"usergroupSelectTeams": false,
"showUserStatus": false
"showUserStatus": false,
"customSettings": {}
},
{
"id": 96,
Expand Down Expand Up @@ -204,7 +211,8 @@
"usergroupSelectUsers": false,
"usergroupSelectGroups": false,
"usergroupSelectTeams": false,
"showUserStatus": false
"showUserStatus": false,
"customSettings": {}
}
],
"views": [
Expand Down
16 changes: 12 additions & 4 deletions lib/Controller/Api1Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,7 @@ public function indexViewColumns(int $viewId): DataResponse {
* @param bool|null $usergroupSelectTeams Can select teams, if column type is usergroup
* @param bool|null $usergroupShowUserStatus Whether to show the user's status, if column type is usergroup
* @param list<int>|null $selectedViewIds View IDs where this column should be added to be presented
* @param array<string, mixed> $customSettings Custom settings for the column
*
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
Expand Down Expand Up @@ -867,6 +868,7 @@ public function createColumn(
?bool $usergroupShowUserStatus = null,

?array $selectedViewIds = [],
?array $customSettings = [],
): DataResponse {
try {
return new DataResponse($this->columnService->create(
Expand Down Expand Up @@ -897,7 +899,8 @@ public function createColumn(
usergroupSelectUsers: $usergroupSelectUsers,
usergroupSelectGroups: $usergroupSelectGroups,
usergroupSelectTeams: $usergroupSelectTeams,
showUserStatus: $usergroupShowUserStatus
showUserStatus: $usergroupShowUserStatus,
customSettings: json_encode($customSettings),
),
$selectedViewIds
)->jsonSerialize());
Expand Down Expand Up @@ -943,6 +946,7 @@ public function createColumn(
* @param bool|null $usergroupSelectGroups Can select groups, if column type is usergroup
* @param bool|null $usergroupSelectTeams Can select teams, if column type is usergroup
* @param bool|null $usergroupShowUserStatus Whether to show the user's status, if column type is usergroup
* @param array<string, mixed> $customSettings Custom settings for the column
*
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*
Expand Down Expand Up @@ -982,7 +986,7 @@ public function updateColumn(
?bool $usergroupSelectGroups,
?bool $usergroupSelectTeams,
?bool $usergroupShowUserStatus,

?array $customSettings = [],
): DataResponse {
try {
$item = $this->columnService->update(
Expand Down Expand Up @@ -1011,7 +1015,8 @@ public function updateColumn(
usergroupSelectUsers: $usergroupSelectUsers,
usergroupSelectGroups: $usergroupSelectGroups,
usergroupSelectTeams: $usergroupSelectTeams,
showUserStatus: $usergroupShowUserStatus
showUserStatus: $usergroupShowUserStatus,
customSettings: json_encode($customSettings),
)
);
return new DataResponse($item->jsonSerialize());
Expand Down Expand Up @@ -1581,6 +1586,7 @@ public function createTableShare(int $tableId, string $receiver, string $receive
* @param bool|null $usergroupSelectTeams Can select teams, if column type is usergroup
* @param bool|null $usergroupShowUserStatus Whether to show the user's status, if column type is usergroup
* @param list<int>|null $selectedViewIds View IDs where this column should be added to be presented
* @param array<string, mixed> $customSettings Custom settings for the column
*
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
Expand Down Expand Up @@ -1625,6 +1631,7 @@ public function createTableColumn(
?bool $usergroupSelectTeams = null,
?bool $usergroupShowUserStatus = null,
?array $selectedViewIds = [],
array $customSettings = [],
): DataResponse {
try {
$item = $this->columnService->create(
Expand Down Expand Up @@ -1655,7 +1662,8 @@ public function createTableColumn(
usergroupSelectUsers: $usergroupSelectUsers,
usergroupSelectGroups: $usergroupSelectGroups,
usergroupSelectTeams: $usergroupSelectTeams,
showUserStatus: $usergroupShowUserStatus
showUserStatus: $usergroupShowUserStatus,
customSettings: json_encode($customSettings),
),
$selectedViewIds
);
Expand Down
34 changes: 24 additions & 10 deletions lib/Controller/ApiColumnsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public function show(int $id): DataResponse {
* @param 'progress'|'stars'|null $subtype Subtype for the new column
* @param string|null $description Description
* @param list<int>|null $selectedViewIds View IDs where this columns should be added
* @param array<string, mixed> $customSettings Custom settings for the column
*
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
* 200: Column created
Expand All @@ -123,7 +125,7 @@ public function show(int $id): DataResponse {
*/
#[NoAdminRequired]
#[RequirePermission(permission: Application::PERMISSION_MANAGE, typeParam: 'baseNodeType', idParam: 'baseNodeId')]
public function createNumberColumn(int $baseNodeId, string $title, ?float $numberDefault, ?int $numberDecimals, ?string $numberPrefix, ?string $numberSuffix, ?float $numberMin, ?float $numberMax, ?string $subtype = null, ?string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse {
public function createNumberColumn(int $baseNodeId, string $title, ?float $numberDefault, ?int $numberDecimals, ?string $numberPrefix, ?string $numberSuffix, ?float $numberMin, ?float $numberMax, ?string $subtype = null, ?string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table', array $customSettings = []): DataResponse {
$tableId = $baseNodeType === 'table' ? $baseNodeId : null;
$viewId = $baseNodeType === 'view' ? $baseNodeId : null;
$column = $this->service->create(
Expand All @@ -141,7 +143,8 @@ public function createNumberColumn(int $baseNodeId, string $title, ?float $numbe
numberMax: $numberMax,
numberDecimals: $numberDecimals,
numberPrefix: $numberPrefix,
numberSuffix: $numberSuffix
numberSuffix: $numberSuffix,
customSettings: json_encode($customSettings),
),
$selectedViewIds
);
Expand All @@ -164,6 +167,7 @@ public function createNumberColumn(int $baseNodeId, string $title, ?float $numbe
* @param list<int>|null $selectedViewIds View IDs where this columns should be added
* @param boolean $mandatory Is mandatory
* @param 'table'|'view' $baseNodeType Context type of the column creation
* @param array<string, mixed> $customSettings Custom settings for the column
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
* 200: Column created
Expand All @@ -175,7 +179,7 @@ public function createNumberColumn(int $baseNodeId, string $title, ?float $numbe
*/
#[NoAdminRequired]
#[RequirePermission(permission: Application::PERMISSION_MANAGE, typeParam: 'baseNodeType', idParam: 'baseNodeId')]
public function createTextColumn(int $baseNodeId, string $title, ?string $textDefault, ?string $textAllowedPattern, ?int $textMaxLength, ?bool $textUnique = false, ?string $subtype = null, ?string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse {
public function createTextColumn(int $baseNodeId, string $title, ?string $textDefault, ?string $textAllowedPattern, ?int $textMaxLength, ?bool $textUnique = false, ?string $subtype = null, ?string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table', array $customSettings = []): DataResponse {
$tableId = $baseNodeType === 'table' ? $baseNodeId : null;
$viewId = $baseNodeType === 'view' ? $baseNodeId : null;
$column = $this->service->create(
Expand All @@ -191,7 +195,8 @@ public function createTextColumn(int $baseNodeId, string $title, ?string $textDe
textDefault: $textDefault,
textAllowedPattern: $textAllowedPattern,
textMaxLength: $textMaxLength,
textUnique: $textUnique
textUnique: $textUnique,
customSettings: json_encode($customSettings),
),
$selectedViewIds
);
Expand All @@ -212,6 +217,8 @@ public function createTextColumn(int $baseNodeId, string $title, ?string $textDe
* @param list<int>|null $selectedViewIds View IDs where this columns should be added
* @param boolean $mandatory Is mandatory
* @param 'table'|'view' $baseNodeType Context type of the column creation
* @param array<string, mixed> $customSettings Custom settings for the column
*
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
* 200: Column created
Expand All @@ -223,7 +230,7 @@ public function createTextColumn(int $baseNodeId, string $title, ?string $textDe
*/
#[NoAdminRequired]
#[RequirePermission(permission: Application::PERMISSION_MANAGE, typeParam: 'baseNodeType', idParam: 'baseNodeId')]
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 {
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', array $customSettings = []): DataResponse {
$tableId = $baseNodeType === 'table' ? $baseNodeId : null;
$viewId = $baseNodeType === 'view' ? $baseNodeId : null;
$column = $this->service->create(
Expand All @@ -237,7 +244,8 @@ public function createSelectionColumn(int $baseNodeId, string $title, string $se
mandatory: $mandatory,
description: $description,
selectionOptions: $selectionOptions,
selectionDefault: $selectionDefault
selectionDefault: $selectionDefault,
customSettings: json_encode($customSettings),
),
$selectedViewIds
);
Expand All @@ -257,6 +265,8 @@ public function createSelectionColumn(int $baseNodeId, string $title, string $se
* @param list<int>|null $selectedViewIds View IDs where this columns should be added
* @param boolean $mandatory Is mandatory
* @param 'table'|'view' $baseNodeType Context type of the column creation
* @param array<string, mixed> $customSettings Custom settings for the column
*
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
* 200: Column created
Expand All @@ -268,7 +278,7 @@ public function createSelectionColumn(int $baseNodeId, string $title, string $se
*/
#[NoAdminRequired]
#[RequirePermission(permission: Application::PERMISSION_MANAGE, typeParam: 'baseNodeType', idParam: 'baseNodeId')]
public function createDatetimeColumn(int $baseNodeId, string $title, ?string $datetimeDefault, ?string $subtype = null, ?string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse {
public function createDatetimeColumn(int $baseNodeId, string $title, ?string $datetimeDefault, ?string $subtype = null, ?string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table', array $customSettings = []): DataResponse {
$tableId = $baseNodeType === 'table' ? $baseNodeId : null;
$viewId = $baseNodeType === 'view' ? $baseNodeId : null;
$column = $this->service->create(
Expand All @@ -281,7 +291,8 @@ public function createDatetimeColumn(int $baseNodeId, string $title, ?string $da
subtype: $subtype,
mandatory: $mandatory,
description: $description,
datetimeDefault: $datetimeDefault
datetimeDefault: $datetimeDefault,
customSettings: json_encode($customSettings),
),
$selectedViewIds
);
Expand All @@ -303,6 +314,8 @@ public function createDatetimeColumn(int $baseNodeId, string $title, ?string $da
* @param list<int>|null $selectedViewIds View IDs where this columns should be added
* @param boolean $mandatory Is mandatory
* @param 'table'|'view' $baseNodeType Context type of the column creation
* @param array<string, mixed> $customSettings Custom settings for the column
*
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
* 200: Column created
Expand All @@ -314,7 +327,7 @@ public function createDatetimeColumn(int $baseNodeId, string $title, ?string $da
*/
#[NoAdminRequired]
#[RequirePermission(permission: Application::PERMISSION_MANAGE, typeParam: 'baseNodeType', idParam: 'baseNodeId')]
public function createUsergroupColumn(int $baseNodeId, string $title, ?string $usergroupDefault, ?bool $usergroupMultipleItems = null, ?bool $usergroupSelectUsers = null, ?bool $usergroupSelectGroups = null, ?bool $usergroupSelectTeams = null, ?bool $showUserStatus = null, ?string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse {
public function createUsergroupColumn(int $baseNodeId, string $title, ?string $usergroupDefault, ?bool $usergroupMultipleItems = null, ?bool $usergroupSelectUsers = null, ?bool $usergroupSelectGroups = null, ?bool $usergroupSelectTeams = null, ?bool $showUserStatus = null, ?string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table', array $customSettings = []): DataResponse {
$tableId = $baseNodeType === 'table' ? $baseNodeId : null;
$viewId = $baseNodeType === 'view' ? $baseNodeId : null;
$column = $this->service->create(
Expand All @@ -331,7 +344,8 @@ public function createUsergroupColumn(int $baseNodeId, string $title, ?string $u
usergroupSelectUsers: $usergroupSelectUsers,
usergroupSelectGroups: $usergroupSelectGroups,
usergroupSelectTeams: $usergroupSelectTeams,
showUserStatus: $showUserStatus
showUserStatus: $showUserStatus,
customSettings: json_encode($customSettings),
),
$selectedViewIds
);
Expand Down
1 change: 1 addition & 0 deletions lib/Controller/ApiTablesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public function createFromScheme(string $title, string $emoji, string $descripti
usergroupSelectGroups: $column['usergroupSelectGroups'],
usergroupSelectTeams: $column['usergroupSelectTeams'],
showUserStatus: $column['showUserStatus'],
customSettings: empty($column['customSettings']) ? null : json_encode($column['customSettings'])
)
);
$colMap[$column['id']] = $col->getId();
Expand Down
11 changes: 11 additions & 0 deletions lib/Db/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
* @method setUsergroupSelectTeams(?bool $usergroupSelectTeams)
* @method getShowUserStatus(): bool
* @method setShowUserStatus(?bool $showUserStatus)
* @method getCustomSettings(): ?string
* @method setCustomSettings(?string $customSettings)
*/
class Column extends EntitySuper implements JsonSerializable {
// Meta column types
Expand Down Expand Up @@ -143,6 +145,7 @@ class Column extends EntitySuper implements JsonSerializable {
protected ?bool $usergroupSelectGroups = null;
protected ?bool $usergroupSelectTeams = null;
protected ?bool $showUserStatus = null;
protected ?string $customSettings = null;

// virtual properties
protected ?string $createdByDisplayName = null;
Expand Down Expand Up @@ -171,6 +174,8 @@ public function __construct() {
$this->addType('usergroupSelectGroups', 'boolean');
$this->addType('usergroupSelectTeams', 'boolean');
$this->addType('showUserStatus', 'boolean');

$this->addType('customSettings', 'string');
}

public static function isValidMetaTypeId(int $metaTypeId): bool {
Expand Down Expand Up @@ -209,6 +214,7 @@ public static function fromDto(ColumnDto $data): self {
$column->setUsergroupSelectGroups($data->getUsergroupSelectGroups());
$column->setUsergroupSelectTeams($data->getUsergroupSelectTeams());
$column->setShowUserStatus($data->getShowUserStatus());
$column->setCustomSettings($data->getCustomSettings());
return $column;
}

Expand Down Expand Up @@ -287,6 +293,11 @@ public function jsonSerialize(): array {
'usergroupSelectGroups' => $this->usergroupSelectGroups,
'usergroupSelectTeams' => $this->usergroupSelectTeams,
'showUserStatus' => $this->showUserStatus,
'customSettings' => $this->getCustomSettingsArray() ?: new \stdClass(),
];
}

public function getCustomSettingsArray(): array {
return json_decode($this->customSettings, true) ?: [];
}
}
6 changes: 6 additions & 0 deletions lib/Dto/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function __construct(
private ?bool $usergroupSelectGroups = null,
private ?bool $usergroupSelectTeams = null,
private ?bool $showUserStatus = null,
private ?string $customSettings = null,
) {
}

Expand Down Expand Up @@ -62,6 +63,7 @@ public static function createFromArray(array $data): self {
usergroupSelectGroups: $data['usergroupSelectGroups'] ?? null,
usergroupSelectTeams: $data['usergroupSelectTeams'] ?? null,
showUserStatus: $data['showUserStatus'] ?? null,
customSettings: $data['customSettings'] ?? null,
);
}

Expand Down Expand Up @@ -160,4 +162,8 @@ public function getUsergroupSelectTeams(): ?bool {
public function getShowUserStatus(): ?bool {
return $this->showUserStatus;
}

public function getCustomSettings(): ?string {
return $this->customSettings;
}
}
40 changes: 40 additions & 0 deletions lib/Migration/Version001000Date20250720000000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/** @noinspection PhpUnused */

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Tables\Migration;

use Closure;
use OCP\DB\Exception;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version001000Date20250720000000 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
* @throws Exception
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

$table = $schema->getTable('tables_columns');
if (!$table->hasColumn('custom_settings')) {
$table->addColumn('custom_settings', Types::JSON, [
'notnull' => false,
]);
}

return $schema;
}
}
Loading
Loading