Skip to content

Commit 0c34758

Browse files
committed
feat: add support for teams in usergroup column
Signed-off-by: Cleopatra Enjeck M <[email protected]>
1 parent fd9e43a commit 0c34758

File tree

14 files changed

+151
-48
lines changed

14 files changed

+151
-48
lines changed

lib/Controller/Api1Controller.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ public function indexViewColumns(int $viewId): DataResponse {
777777
* @param bool|null $usergroupMultipleItems Can select multiple users or/and groups, if column is usergroup
778778
* @param bool|null $usergroupSelectUsers Can select users, if column type is usergroup
779779
* @param bool|null $usergroupSelectGroups Can select groups, if column type is usergroup
780+
* @param bool|null $usergroupSelectTeams Can select teams, if column type is usergroup
780781
* @param bool|null $usergroupShowUserStatus Whether to show the user's status, if column type is usergroup
781782
* @param int[]|null $selectedViewIds View IDs where this column should be added to be presented
782783
*
@@ -814,6 +815,7 @@ public function createColumn(
814815
?bool $usergroupMultipleItems = null,
815816
?bool $usergroupSelectUsers = null,
816817
?bool $usergroupSelectGroups = null,
818+
?bool $usergroupSelectTeams = null,
817819
?bool $usergroupShowUserStatus = null,
818820

819821
?array $selectedViewIds = []
@@ -892,6 +894,7 @@ public function createColumn(
892894
* @param bool|null $usergroupMultipleItems Can select multiple users or/and groups, if column is usergroup
893895
* @param bool|null $usergroupSelectUsers Can select users, if column type is usergroup
894896
* @param bool|null $usergroupSelectGroups Can select groups, if column type is usergroup
897+
* @param bool|null $usergroupSelectTeams Can select teams, if column type is usergroup
895898
* @param bool|null $usergroupShowUserStatus Whether to show the user's status, if column type is usergroup
896899
*
897900
* @return DataResponse<Http::STATUS_OK, TablesColumn, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
@@ -925,6 +928,7 @@ public function updateColumn(
925928
?bool $usergroupMultipleItems,
926929
?bool $usergroupSelectUsers,
927930
?bool $usergroupSelectGroups,
931+
?bool $usergroupSelectTeams,
928932
?bool $usergroupShowUserStatus,
929933

930934
): DataResponse {
@@ -1494,6 +1498,7 @@ public function createTableShare(int $tableId, string $receiver, string $receive
14941498
* @param bool|null $usergroupMultipleItems Can select multiple users or/and groups, if column is usergroup
14951499
* @param bool|null $usergroupSelectUsers Can select users, if column type is usergroup
14961500
* @param bool|null $usergroupSelectGroups Can select groups, if column type is usergroup
1501+
* @param bool|null $usergroupSelectTeams Can select teams, if column type is usergroup
14971502
* @param bool|null $usergroupShowUserStatus Whether to show the user's status, if column type is usergroup
14981503
* @param int[]|null $selectedViewIds View IDs where this column should be added to be presented
14991504
*
@@ -1531,6 +1536,7 @@ public function createTableColumn(
15311536
?bool $usergroupMultipleItems = null,
15321537
?bool $usergroupSelectUsers = null,
15331538
?bool $usergroupSelectGroups = null,
1539+
?bool $usergroupSelectTeams = null,
15341540
?bool $usergroupShowUserStatus = null,
15351541
?array $selectedViewIds = []
15361542
): DataResponse {

lib/Controller/ApiColumnsController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ public function createDatetimeColumn(int $baseNodeId, string $title, ?string $da
295295
* @param boolean $usergroupMultipleItems Whether you can select multiple users or/and groups
296296
* @param boolean $usergroupSelectUsers Whether you can select users
297297
* @param boolean $usergroupSelectGroups Whether you can select groups
298+
* @param boolean $usergroupSelectTeams Whether you can select teams
298299
* @param boolean $showUserStatus Whether to show the user's status
299300
* @param string|null $description Description
300301
* @param int[]|null $selectedViewIds View IDs where this columns should be added
@@ -309,7 +310,7 @@ public function createDatetimeColumn(int $baseNodeId, string $title, ?string $da
309310
* @throws NotFoundError
310311
* @throws PermissionError
311312
*/
312-
public function createUsergroupColumn(int $baseNodeId, string $title, ?string $usergroupDefault, bool $usergroupMultipleItems = null, bool $usergroupSelectUsers = null, bool $usergroupSelectGroups = null, bool $showUserStatus = null, string $description = null, ?array $selectedViewIds = [], bool $mandatory = false, string $baseNodeType = 'table'): DataResponse {
313+
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 {
313314
$tableId = $baseNodeType === 'table' ? $baseNodeId : null;
314315
$viewId = $baseNodeType === 'view' ? $baseNodeId : null;
315316
$column = $this->service->create(

lib/Controller/ColumnController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public function create(
103103
?bool $usergroupMultipleItems,
104104
?bool $usergroupSelectUsers,
105105
?bool $usergroupSelectGroups,
106+
?bool $usergroupSelectTeams,
106107
?bool $showUserStatus,
107108

108109
?array $selectedViewIds
@@ -136,6 +137,7 @@ public function create(
136137
$usergroupMultipleItems,
137138
$usergroupSelectUsers,
138139
$usergroupSelectGroups,
140+
$usergroupSelectTeams,
139141
$showUserStatus,
140142

141143
$selectedViewIds) {
@@ -204,6 +206,7 @@ public function update(
204206
?bool $usergroupMultipleItems,
205207
?bool $usergroupSelectUsers,
206208
?bool $usergroupSelectGroups,
209+
?bool $usergroupSelectTeams,
207210
?bool $showUserStatus
208211
): DataResponse {
209212
return $this->handleError(function () use (
@@ -235,6 +238,7 @@ public function update(
235238
$usergroupMultipleItems,
236239
$usergroupSelectUsers,
237240
$usergroupSelectGroups,
241+
$usergroupSelectTeams,
238242
$showUserStatus
239243
) {
240244
return $this->service->update(

lib/Db/Column.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
* @method setUsergroupSelectUsers(?bool $usergroupSelectUsers)
7575
* @method getUsergroupSelectGroups(): bool
7676
* @method setUsergroupSelectGroups(?bool $usergroupSelectGroups)
77+
* @method getUsergroupSelectTeams(): bool
78+
* @method setUsergroupSelectTeams(?bool $usergroupSelectTeams)
7779
* @method getShowUserStatus(): bool
7880
* @method setShowUserStatus(?bool $showUserStatus)
7981
*/
@@ -130,6 +132,7 @@ class Column extends Entity implements JsonSerializable {
130132
protected ?bool $usergroupMultipleItems = null;
131133
protected ?bool $usergroupSelectUsers = null;
132134
protected ?bool $usergroupSelectGroups = null;
135+
protected ?bool $usergroupSelectTeams = null;
133136
protected ?bool $showUserStatus = null;
134137

135138
public function __construct() {
@@ -150,6 +153,7 @@ public function __construct() {
150153
$this->addType('usergroupMultipleItems', 'boolean');
151154
$this->addType('usergroupSelectUsers', 'boolean');
152155
$this->addType('usergroupSelectGroups', 'boolean');
156+
$this->addType('usergroupSelectTeams', 'boolean');
153157
$this->addType('showUserStatus', 'boolean');
154158
}
155159

@@ -252,6 +256,7 @@ public function jsonSerialize(): array {
252256
'usergroupMultipleItems' => $this->usergroupMultipleItems,
253257
'usergroupSelectUsers' => $this->usergroupSelectUsers,
254258
'usergroupSelectGroups' => $this->usergroupSelectGroups,
259+
'usergroupSelectTeams' => $this->usergroupSelectTeams,
255260
'showUserStatus' => $this->showUserStatus,
256261
];
257262
}

lib/Migration/Version000000Date20210921000000.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
181181
'notnull' => false,
182182
'default' => 0,
183183
]);
184+
$table->addColumn('usergroup_select_teams', Types::BOOLEAN, [
185+
'notnull' => false,
186+
'default' => 0,
187+
]);
184188
$table->addColumn('show_user_status', Types::BOOLEAN, [
185189
'notnull' => false,
186190
'default' => 0,

lib/Migration/Version000800Date20240712000000.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ private function haveUserGroupColumnDefinitionFields(ISchemaWrapper $schema) {
7777
'default' => 0,
7878
]);
7979
}
80+
if (!$table->hasColumn('usergroup_select_teams')) {
81+
$table->addColumn('usergroup_select_teams', Types::BOOLEAN, [
82+
'notnull' => false,
83+
'default' => 0,
84+
]);
85+
}
8086
if (!$table->hasColumn('show_user_status')) {
8187
$table->addColumn('show_user_status', Types::BOOLEAN, [
8288
'notnull' => false,
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
/** @noinspection PhpUnused */
4+
5+
declare(strict_types=1);
6+
/**
7+
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
8+
* SPDX-License-Identifier: AGPL-3.0-or-later
9+
*/
10+
namespace OCA\Tables\Migration;
11+
12+
use Closure;
13+
use OCP\DB\Exception;
14+
use OCP\DB\ISchemaWrapper;
15+
use OCP\DB\Types;
16+
use OCP\Migration\IOutput;
17+
use OCP\Migration\SimpleMigrationStep;
18+
19+
class Version000800Date20240828000000 extends SimpleMigrationStep {
20+
/**
21+
* @param IOutput $output
22+
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
23+
* @param array $options
24+
* @return null|ISchemaWrapper
25+
* @throws Exception
26+
*/
27+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
28+
/** @var ISchemaWrapper $schema */
29+
$schema = $schemaClosure();
30+
31+
if ($schema->hasTable('tables_columns')) {
32+
if ($schema->hasTable('tables_row_cells_usergroup')) {
33+
$table = $schema->getTable('tables_columns');
34+
if (!$table->hasColumn('usergroup_select_teams')) {
35+
$table->addColumn('usergroup_select_teams', Types::BOOLEAN, [
36+
'notnull' => false,
37+
'default' => 0,
38+
]);
39+
}
40+
}
41+
return $schema;
42+
}
43+
return null;
44+
}
45+
}

lib/ResponseDefinitions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
* usergroupMultipleItems: bool,
128128
* usergroupSelectUsers: bool,
129129
* usergroupSelectGroups: bool,
130+
* usergroupSelectTeams: bool,
130131
* showUserStatus: bool,
131132
* }
132133
*

src/modules/modals/CreateColumn.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export default {
181181
usergroupMultipleItems: false,
182182
usergroupSelectUsers: true,
183183
usergroupSelectGroups: false,
184+
usergroupSelectTeams: false,
184185
showUserStatus: false,
185186
},
186187
textAppAvailable: !!window.OCA?.Text?.createEditor,
@@ -334,6 +335,7 @@ export default {
334335
data.usergroupMultipleItems = this.column.usergroupMultipleItems
335336
data.usergroupSelectUsers = this.column.usergroupSelectUsers
336337
data.usergroupSelectGroups = this.column.usergroupSelectGroups
338+
data.usergroupSelectTeams = this.column.usergroupSelectTeams
337339
data.showUserStatus = this.column.showUserStatus
338340
} else if (this.column.type === 'number') {
339341
data.numberDefault = this.column.numberDefault
@@ -387,6 +389,7 @@ export default {
387389
usergroupMultipleItems: false,
388390
usergroupSelectUsers: true,
389391
usergroupSelectGroups: false,
392+
usergroupSelectTeams: false,
390393
showUserStatus: false,
391394
}
392395
if (mainForm) {

src/shared/components/ncTable/mixins/columnsTypes/usergroup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default class UsergroupColumn extends AbstractUsergroupColumn {
1414
this.usergroupMultipleItems = data.usergroupMultipleItems
1515
this.usergroupSelectUsers = data.usergroupSelectUsers
1616
this.usergroupSelectGroups = data.usergroupSelectGroups
17+
this.usergroupSelectTeams = data.usergroupSelectTeams
1718
}
1819

1920
getValueString(valueObject) {

0 commit comments

Comments
 (0)