Skip to content

Commit 8e9e19a

Browse files
committed
Enhancement: Add column width setting
Signed-off-by: Kostiantyn Miakshyn <[email protected]>
1 parent 288b4f9 commit 8e9e19a

File tree

21 files changed

+359
-39
lines changed

21 files changed

+359
-39
lines changed

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Share your tables and views with users and groups within your cloud.
2626
Have a good time and manage whatever you want.
2727
2828
]]></description>
29-
<version>1.0.0-beta.1</version>
29+
<version>1.0.0-beta.2</version>
3030
<licence>agpl</licence>
3131
<author mail="[email protected]">Florian Steffens</author>
3232
<namespace>Tables</namespace>

cypress/e2e/ToDo list.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"usergroupSelectUsers": false,
3535
"usergroupSelectGroups": false,
3636
"usergroupSelectTeams": false,
37-
"showUserStatus": false
37+
"showUserStatus": false,
38+
"customSettings": {}
3839
},
3940
{
4041
"id": 92,
@@ -68,7 +69,10 @@
6869
"usergroupSelectUsers": false,
6970
"usergroupSelectGroups": false,
7071
"usergroupSelectTeams": false,
71-
"showUserStatus": false
72+
"showUserStatus": false,
73+
"customSettings": {
74+
"width": 300
75+
}
7276
},
7377
{
7478
"id": 93,
@@ -102,7 +106,8 @@
102106
"usergroupSelectUsers": false,
103107
"usergroupSelectGroups": false,
104108
"usergroupSelectTeams": false,
105-
"showUserStatus": false
109+
"showUserStatus": false,
110+
"customSettings": {}
106111
},
107112
{
108113
"id": 94,
@@ -136,7 +141,8 @@
136141
"usergroupSelectUsers": false,
137142
"usergroupSelectGroups": false,
138143
"usergroupSelectTeams": false,
139-
"showUserStatus": false
144+
"showUserStatus": false,
145+
"customSettings": {}
140146
},
141147
{
142148
"id": 95,
@@ -170,7 +176,8 @@
170176
"usergroupSelectUsers": false,
171177
"usergroupSelectGroups": false,
172178
"usergroupSelectTeams": false,
173-
"showUserStatus": false
179+
"showUserStatus": false,
180+
"customSettings": {}
174181
},
175182
{
176183
"id": 96,
@@ -204,7 +211,8 @@
204211
"usergroupSelectUsers": false,
205212
"usergroupSelectGroups": false,
206213
"usergroupSelectTeams": false,
207-
"showUserStatus": false
214+
"showUserStatus": false,
215+
"customSettings": {}
208216
}
209217
],
210218
"views": [

lib/Controller/Api1Controller.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ public function indexViewColumns(int $viewId): DataResponse {
823823
* @param bool|null $usergroupSelectTeams Can select teams, if column type is usergroup
824824
* @param bool|null $usergroupShowUserStatus Whether to show the user's status, if column type is usergroup
825825
* @param list<int>|null $selectedViewIds View IDs where this column should be added to be presented
826+
* @param array<string, mixed> $customSettings Custom settings for the column
826827
*
827828
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
828829
*
@@ -867,6 +868,7 @@ public function createColumn(
867868
?bool $usergroupShowUserStatus = null,
868869

869870
?array $selectedViewIds = [],
871+
?array $customSettings = [],
870872
): DataResponse {
871873
try {
872874
return new DataResponse($this->columnService->create(
@@ -897,7 +899,8 @@ public function createColumn(
897899
usergroupSelectUsers: $usergroupSelectUsers,
898900
usergroupSelectGroups: $usergroupSelectGroups,
899901
usergroupSelectTeams: $usergroupSelectTeams,
900-
showUserStatus: $usergroupShowUserStatus
902+
showUserStatus: $usergroupShowUserStatus,
903+
customSettings: json_encode($customSettings),
901904
),
902905
$selectedViewIds
903906
)->jsonSerialize());
@@ -943,6 +946,7 @@ public function createColumn(
943946
* @param bool|null $usergroupSelectGroups Can select groups, if column type is usergroup
944947
* @param bool|null $usergroupSelectTeams Can select teams, if column type is usergroup
945948
* @param bool|null $usergroupShowUserStatus Whether to show the user's status, if column type is usergroup
949+
* @param array<string, mixed> $customSettings Custom settings for the column
946950
*
947951
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
948952
*
@@ -982,7 +986,7 @@ public function updateColumn(
982986
?bool $usergroupSelectGroups,
983987
?bool $usergroupSelectTeams,
984988
?bool $usergroupShowUserStatus,
985-
989+
?array $customSettings = [],
986990
): DataResponse {
987991
try {
988992
$item = $this->columnService->update(
@@ -1011,7 +1015,8 @@ public function updateColumn(
10111015
usergroupSelectUsers: $usergroupSelectUsers,
10121016
usergroupSelectGroups: $usergroupSelectGroups,
10131017
usergroupSelectTeams: $usergroupSelectTeams,
1014-
showUserStatus: $usergroupShowUserStatus
1018+
showUserStatus: $usergroupShowUserStatus,
1019+
customSettings: json_encode($customSettings),
10151020
)
10161021
);
10171022
return new DataResponse($item->jsonSerialize());
@@ -1581,6 +1586,7 @@ public function createTableShare(int $tableId, string $receiver, string $receive
15811586
* @param bool|null $usergroupSelectTeams Can select teams, if column type is usergroup
15821587
* @param bool|null $usergroupShowUserStatus Whether to show the user's status, if column type is usergroup
15831588
* @param list<int>|null $selectedViewIds View IDs where this column should be added to be presented
1589+
* @param array<string, mixed> $customSettings Custom settings for the column
15841590
*
15851591
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
15861592
*
@@ -1625,6 +1631,7 @@ public function createTableColumn(
16251631
?bool $usergroupSelectTeams = null,
16261632
?bool $usergroupShowUserStatus = null,
16271633
?array $selectedViewIds = [],
1634+
array $customSettings = [],
16281635
): DataResponse {
16291636
try {
16301637
$item = $this->columnService->create(
@@ -1655,7 +1662,8 @@ public function createTableColumn(
16551662
usergroupSelectUsers: $usergroupSelectUsers,
16561663
usergroupSelectGroups: $usergroupSelectGroups,
16571664
usergroupSelectTeams: $usergroupSelectTeams,
1658-
showUserStatus: $usergroupShowUserStatus
1665+
showUserStatus: $usergroupShowUserStatus,
1666+
customSettings: json_encode($customSettings),
16591667
),
16601668
$selectedViewIds
16611669
);

lib/Controller/ApiColumnsController.php

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ public function show(int $id): DataResponse {
112112
* @param 'progress'|'stars'|null $subtype Subtype for the new column
113113
* @param string|null $description Description
114114
* @param list<int>|null $selectedViewIds View IDs where this columns should be added
115+
* @param array<string, mixed> $customSettings Custom settings for the column
116+
*
115117
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
116118
*
117119
* 200: Column created
@@ -123,7 +125,7 @@ public function show(int $id): DataResponse {
123125
*/
124126
#[NoAdminRequired]
125127
#[RequirePermission(permission: Application::PERMISSION_MANAGE, typeParam: 'baseNodeType', idParam: 'baseNodeId')]
126-
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 {
128+
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 {
127129
$tableId = $baseNodeType === 'table' ? $baseNodeId : null;
128130
$viewId = $baseNodeType === 'view' ? $baseNodeId : null;
129131
$column = $this->service->create(
@@ -141,7 +143,8 @@ public function createNumberColumn(int $baseNodeId, string $title, ?float $numbe
141143
numberMax: $numberMax,
142144
numberDecimals: $numberDecimals,
143145
numberPrefix: $numberPrefix,
144-
numberSuffix: $numberSuffix
146+
numberSuffix: $numberSuffix,
147+
customSettings: json_encode($customSettings),
145148
),
146149
$selectedViewIds
147150
);
@@ -164,6 +167,7 @@ public function createNumberColumn(int $baseNodeId, string $title, ?float $numbe
164167
* @param list<int>|null $selectedViewIds View IDs where this columns should be added
165168
* @param boolean $mandatory Is mandatory
166169
* @param 'table'|'view' $baseNodeType Context type of the column creation
170+
* @param array<string, mixed> $customSettings Custom settings for the column
167171
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
168172
*
169173
* 200: Column created
@@ -175,7 +179,7 @@ public function createNumberColumn(int $baseNodeId, string $title, ?float $numbe
175179
*/
176180
#[NoAdminRequired]
177181
#[RequirePermission(permission: Application::PERMISSION_MANAGE, typeParam: 'baseNodeType', idParam: 'baseNodeId')]
178-
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 {
182+
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 {
179183
$tableId = $baseNodeType === 'table' ? $baseNodeId : null;
180184
$viewId = $baseNodeType === 'view' ? $baseNodeId : null;
181185
$column = $this->service->create(
@@ -191,7 +195,8 @@ public function createTextColumn(int $baseNodeId, string $title, ?string $textDe
191195
textDefault: $textDefault,
192196
textAllowedPattern: $textAllowedPattern,
193197
textMaxLength: $textMaxLength,
194-
textUnique: $textUnique
198+
textUnique: $textUnique,
199+
customSettings: json_encode($customSettings),
195200
),
196201
$selectedViewIds
197202
);
@@ -212,6 +217,8 @@ public function createTextColumn(int $baseNodeId, string $title, ?string $textDe
212217
* @param list<int>|null $selectedViewIds View IDs where this columns should be added
213218
* @param boolean $mandatory Is mandatory
214219
* @param 'table'|'view' $baseNodeType Context type of the column creation
220+
* @param array<string, mixed> $customSettings Custom settings for the column
221+
*
215222
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
216223
*
217224
* 200: Column created
@@ -223,7 +230,7 @@ public function createTextColumn(int $baseNodeId, string $title, ?string $textDe
223230
*/
224231
#[NoAdminRequired]
225232
#[RequirePermission(permission: Application::PERMISSION_MANAGE, typeParam: 'baseNodeType', idParam: 'baseNodeId')]
226-
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 {
233+
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 {
227234
$tableId = $baseNodeType === 'table' ? $baseNodeId : null;
228235
$viewId = $baseNodeType === 'view' ? $baseNodeId : null;
229236
$column = $this->service->create(
@@ -237,7 +244,8 @@ public function createSelectionColumn(int $baseNodeId, string $title, string $se
237244
mandatory: $mandatory,
238245
description: $description,
239246
selectionOptions: $selectionOptions,
240-
selectionDefault: $selectionDefault
247+
selectionDefault: $selectionDefault,
248+
customSettings: json_encode($customSettings),
241249
),
242250
$selectedViewIds
243251
);
@@ -257,6 +265,8 @@ public function createSelectionColumn(int $baseNodeId, string $title, string $se
257265
* @param list<int>|null $selectedViewIds View IDs where this columns should be added
258266
* @param boolean $mandatory Is mandatory
259267
* @param 'table'|'view' $baseNodeType Context type of the column creation
268+
* @param array<string, mixed> $customSettings Custom settings for the column
269+
*
260270
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
261271
*
262272
* 200: Column created
@@ -268,7 +278,7 @@ public function createSelectionColumn(int $baseNodeId, string $title, string $se
268278
*/
269279
#[NoAdminRequired]
270280
#[RequirePermission(permission: Application::PERMISSION_MANAGE, typeParam: 'baseNodeType', idParam: 'baseNodeId')]
271-
public function createDatetimeColumn(int $baseNodeId, string $title, ?string $datetimeDefault, ?string $subtype = null, ?string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse {
281+
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 {
272282
$tableId = $baseNodeType === 'table' ? $baseNodeId : null;
273283
$viewId = $baseNodeType === 'view' ? $baseNodeId : null;
274284
$column = $this->service->create(
@@ -281,7 +291,8 @@ public function createDatetimeColumn(int $baseNodeId, string $title, ?string $da
281291
subtype: $subtype,
282292
mandatory: $mandatory,
283293
description: $description,
284-
datetimeDefault: $datetimeDefault
294+
datetimeDefault: $datetimeDefault,
295+
customSettings: json_encode($customSettings),
285296
),
286297
$selectedViewIds
287298
);
@@ -303,6 +314,8 @@ public function createDatetimeColumn(int $baseNodeId, string $title, ?string $da
303314
* @param list<int>|null $selectedViewIds View IDs where this columns should be added
304315
* @param boolean $mandatory Is mandatory
305316
* @param 'table'|'view' $baseNodeType Context type of the column creation
317+
* @param array<string, mixed> $customSettings Custom settings for the column
318+
*
306319
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_FORBIDDEN|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
307320
*
308321
* 200: Column created
@@ -314,7 +327,7 @@ public function createDatetimeColumn(int $baseNodeId, string $title, ?string $da
314327
*/
315328
#[NoAdminRequired]
316329
#[RequirePermission(permission: Application::PERMISSION_MANAGE, typeParam: 'baseNodeType', idParam: 'baseNodeId')]
317-
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 {
330+
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 {
318331
$tableId = $baseNodeType === 'table' ? $baseNodeId : null;
319332
$viewId = $baseNodeType === 'view' ? $baseNodeId : null;
320333
$column = $this->service->create(
@@ -331,7 +344,8 @@ public function createUsergroupColumn(int $baseNodeId, string $title, ?string $u
331344
usergroupSelectUsers: $usergroupSelectUsers,
332345
usergroupSelectGroups: $usergroupSelectGroups,
333346
usergroupSelectTeams: $usergroupSelectTeams,
334-
showUserStatus: $showUserStatus
347+
showUserStatus: $showUserStatus,
348+
customSettings: json_encode($customSettings),
335349
),
336350
$selectedViewIds
337351
);

lib/Controller/ApiTablesController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public function createFromScheme(string $title, string $emoji, string $descripti
169169
usergroupSelectGroups: $column['usergroupSelectGroups'],
170170
usergroupSelectTeams: $column['usergroupSelectTeams'],
171171
showUserStatus: $column['showUserStatus'],
172+
customSettings: empty($column['customSettings']) ? null : json_encode($column['customSettings'])
172173
)
173174
);
174175
$colMap[$column['id']] = $col->getId();

lib/Db/Column.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
* @method setUsergroupSelectTeams(?bool $usergroupSelectTeams)
8080
* @method getShowUserStatus(): bool
8181
* @method setShowUserStatus(?bool $showUserStatus)
82+
* @method getCustomSettings(): ?string
83+
* @method setCustomSettings(?string $customSettings)
8284
*/
8385
class Column extends EntitySuper implements JsonSerializable {
8486
// Meta column types
@@ -143,6 +145,7 @@ class Column extends EntitySuper implements JsonSerializable {
143145
protected ?bool $usergroupSelectGroups = null;
144146
protected ?bool $usergroupSelectTeams = null;
145147
protected ?bool $showUserStatus = null;
148+
protected ?string $customSettings = null;
146149

147150
// virtual properties
148151
protected ?string $createdByDisplayName = null;
@@ -171,6 +174,8 @@ public function __construct() {
171174
$this->addType('usergroupSelectGroups', 'boolean');
172175
$this->addType('usergroupSelectTeams', 'boolean');
173176
$this->addType('showUserStatus', 'boolean');
177+
178+
$this->addType('customSettings', 'string');
174179
}
175180

176181
public static function isValidMetaTypeId(int $metaTypeId): bool {
@@ -209,6 +214,7 @@ public static function fromDto(ColumnDto $data): self {
209214
$column->setUsergroupSelectGroups($data->getUsergroupSelectGroups());
210215
$column->setUsergroupSelectTeams($data->getUsergroupSelectTeams());
211216
$column->setShowUserStatus($data->getShowUserStatus());
217+
$column->setCustomSettings($data->getCustomSettings());
212218
return $column;
213219
}
214220

@@ -287,6 +293,11 @@ public function jsonSerialize(): array {
287293
'usergroupSelectGroups' => $this->usergroupSelectGroups,
288294
'usergroupSelectTeams' => $this->usergroupSelectTeams,
289295
'showUserStatus' => $this->showUserStatus,
296+
'customSettings' => $this->getCustomSettingsArray() ?: new \stdClass(),
290297
];
291298
}
299+
300+
public function getCustomSettingsArray(): array {
301+
return json_decode($this->customSettings, true) ?: [];
302+
}
292303
}

lib/Dto/Column.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function __construct(
3333
private ?bool $usergroupSelectGroups = null,
3434
private ?bool $usergroupSelectTeams = null,
3535
private ?bool $showUserStatus = null,
36+
private ?string $customSettings = null,
3637
) {
3738
}
3839

@@ -62,6 +63,7 @@ public static function createFromArray(array $data): self {
6263
usergroupSelectGroups: $data['usergroupSelectGroups'] ?? null,
6364
usergroupSelectTeams: $data['usergroupSelectTeams'] ?? null,
6465
showUserStatus: $data['showUserStatus'] ?? null,
66+
customSettings: $data['customSettings'] ?? null,
6567
);
6668
}
6769

@@ -160,4 +162,8 @@ public function getUsergroupSelectTeams(): ?bool {
160162
public function getShowUserStatus(): ?bool {
161163
return $this->showUserStatus;
162164
}
165+
166+
public function getCustomSettings(): ?string {
167+
return $this->customSettings;
168+
}
163169
}

0 commit comments

Comments
 (0)