From d9fef992b3f7cda71482600d45d7e36a67749ddc Mon Sep 17 00:00:00 2001 From: Cleopatra Enjeck M Date: Thu, 29 Aug 2024 05:33:07 +0100 Subject: [PATCH 1/5] feat: add support for teams in usergroup column Signed-off-by: Cleopatra Enjeck M --- lib/Controller/Api1Controller.php | 6 ++ lib/Controller/ApiColumnsController.php | 1 + lib/Controller/ColumnController.php | 4 + lib/Db/Column.php | 5 ++ .../Version000000Date20210921000000.php | 4 + .../Version000800Date20240712000000.php | 6 ++ .../Version000800Date20240828000000.php | 45 +++++++++++ lib/ResponseDefinitions.php | 1 + src/modules/modals/CreateColumn.vue | 3 + .../ncTable/mixins/columnsTypes/usergroup.js | 1 + .../ncTable/partials/TableCellUsergroup.vue | 2 +- .../forms/UsergroupForm.vue | 80 ++++++++++--------- .../rowTypePartials/UsergroupForm.vue | 5 +- src/shared/mixins/searchUserGroup.js | 34 ++++++-- 14 files changed, 150 insertions(+), 47 deletions(-) create mode 100644 lib/Migration/Version000800Date20240828000000.php diff --git a/lib/Controller/Api1Controller.php b/lib/Controller/Api1Controller.php index 8d86aef18..f69aed74b 100644 --- a/lib/Controller/Api1Controller.php +++ b/lib/Controller/Api1Controller.php @@ -766,6 +766,7 @@ public function indexViewColumns(int $viewId): DataResponse { * @param bool|null $usergroupMultipleItems Can select multiple users or/and groups, if column is usergroup * @param bool|null $usergroupSelectUsers Can select users, if column type is usergroup * @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 int[]|null $selectedViewIds View IDs where this column should be added to be presented * @@ -806,6 +807,7 @@ public function createColumn( ?bool $usergroupMultipleItems = null, ?bool $usergroupSelectUsers = null, ?bool $usergroupSelectGroups = null, + ?bool $usergroupSelectTeams = null, ?bool $usergroupShowUserStatus = null, ?array $selectedViewIds = [] @@ -880,6 +882,7 @@ public function createColumn( * @param bool|null $usergroupMultipleItems Can select multiple users or/and groups, if column is usergroup * @param bool|null $usergroupSelectUsers Can select users, if column type is usergroup * @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 * * @return DataResponse|DataResponse @@ -916,6 +919,7 @@ public function updateColumn( ?bool $usergroupMultipleItems, ?bool $usergroupSelectUsers, ?bool $usergroupSelectGroups, + ?bool $usergroupSelectTeams, ?bool $usergroupShowUserStatus, ): DataResponse { @@ -1472,6 +1476,7 @@ public function createTableShare(int $tableId, string $receiver, string $receive * @param bool|null $usergroupMultipleItems Can select multiple users or/and groups, if column is usergroup * @param bool|null $usergroupSelectUsers Can select users, if column type is usergroup * @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 int[]|null $selectedViewIds View IDs where this column should be added to be presented * @@ -1513,6 +1518,7 @@ public function createTableColumn( ?bool $usergroupMultipleItems = null, ?bool $usergroupSelectUsers = null, ?bool $usergroupSelectGroups = null, + ?bool $usergroupSelectTeams = null, ?bool $usergroupShowUserStatus = null, ?array $selectedViewIds = [] ): DataResponse { diff --git a/lib/Controller/ApiColumnsController.php b/lib/Controller/ApiColumnsController.php index 9560dbd26..3044fba6f 100644 --- a/lib/Controller/ApiColumnsController.php +++ b/lib/Controller/ApiColumnsController.php @@ -295,6 +295,7 @@ public function createDatetimeColumn(int $baseNodeId, string $title, ?string $da * @param boolean $usergroupMultipleItems Whether you can select multiple users or/and groups * @param boolean $usergroupSelectUsers Whether you can select users * @param boolean $usergroupSelectGroups Whether you can select groups + * @param boolean $usergroupSelectTeams Whether you can select teams * @param boolean $showUserStatus Whether to show the user's status * @param string|null $description Description * @param int[]|null $selectedViewIds View IDs where this columns should be added diff --git a/lib/Controller/ColumnController.php b/lib/Controller/ColumnController.php index df1a9509d..e9d548e9c 100644 --- a/lib/Controller/ColumnController.php +++ b/lib/Controller/ColumnController.php @@ -96,6 +96,7 @@ public function create( ?bool $usergroupMultipleItems, ?bool $usergroupSelectUsers, ?bool $usergroupSelectGroups, + ?bool $usergroupSelectTeams, ?bool $showUserStatus, ?array $selectedViewIds @@ -129,6 +130,7 @@ public function create( $usergroupMultipleItems, $usergroupSelectUsers, $usergroupSelectGroups, + $usergroupSelectTeams, $showUserStatus, $selectedViewIds) { @@ -195,6 +197,7 @@ public function update( ?bool $usergroupMultipleItems, ?bool $usergroupSelectUsers, ?bool $usergroupSelectGroups, + ?bool $usergroupSelectTeams, ?bool $showUserStatus ): DataResponse { return $this->handleError(function () use ( @@ -226,6 +229,7 @@ public function update( $usergroupMultipleItems, $usergroupSelectUsers, $usergroupSelectGroups, + $usergroupSelectTeams, $showUserStatus ) { return $this->service->update( diff --git a/lib/Db/Column.php b/lib/Db/Column.php index 04d1f65a6..84f27933b 100644 --- a/lib/Db/Column.php +++ b/lib/Db/Column.php @@ -74,6 +74,8 @@ * @method setUsergroupSelectUsers(?bool $usergroupSelectUsers) * @method getUsergroupSelectGroups(): bool * @method setUsergroupSelectGroups(?bool $usergroupSelectGroups) + * @method getUsergroupSelectTeams(): bool + * @method setUsergroupSelectTeams(?bool $usergroupSelectTeams) * @method getShowUserStatus(): bool * @method setShowUserStatus(?bool $showUserStatus) */ @@ -130,6 +132,7 @@ class Column extends Entity implements JsonSerializable { protected ?bool $usergroupMultipleItems = null; protected ?bool $usergroupSelectUsers = null; protected ?bool $usergroupSelectGroups = null; + protected ?bool $usergroupSelectTeams = null; protected ?bool $showUserStatus = null; public function __construct() { @@ -150,6 +153,7 @@ public function __construct() { $this->addType('usergroupMultipleItems', 'boolean'); $this->addType('usergroupSelectUsers', 'boolean'); $this->addType('usergroupSelectGroups', 'boolean'); + $this->addType('usergroupSelectTeams', 'boolean'); $this->addType('showUserStatus', 'boolean'); } @@ -252,6 +256,7 @@ public function jsonSerialize(): array { 'usergroupMultipleItems' => $this->usergroupMultipleItems, 'usergroupSelectUsers' => $this->usergroupSelectUsers, 'usergroupSelectGroups' => $this->usergroupSelectGroups, + 'usergroupSelectTeams' => $this->usergroupSelectTeams, 'showUserStatus' => $this->showUserStatus, ]; } diff --git a/lib/Migration/Version000000Date20210921000000.php b/lib/Migration/Version000000Date20210921000000.php index a8f03734c..71935daaf 100644 --- a/lib/Migration/Version000000Date20210921000000.php +++ b/lib/Migration/Version000000Date20210921000000.php @@ -181,6 +181,10 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt 'notnull' => false, 'default' => 0, ]); + $table->addColumn('usergroup_select_teams', Types::BOOLEAN, [ + 'notnull' => false, + 'default' => 0, + ]); $table->addColumn('show_user_status', Types::BOOLEAN, [ 'notnull' => false, 'default' => 0, diff --git a/lib/Migration/Version000800Date20240712000000.php b/lib/Migration/Version000800Date20240712000000.php index 726d7929e..677903849 100644 --- a/lib/Migration/Version000800Date20240712000000.php +++ b/lib/Migration/Version000800Date20240712000000.php @@ -77,6 +77,12 @@ private function haveUserGroupColumnDefinitionFields(ISchemaWrapper $schema) { 'default' => 0, ]); } + if (!$table->hasColumn('usergroup_select_teams')) { + $table->addColumn('usergroup_select_teams', Types::BOOLEAN, [ + 'notnull' => false, + 'default' => 0, + ]); + } if (!$table->hasColumn('show_user_status')) { $table->addColumn('show_user_status', Types::BOOLEAN, [ 'notnull' => false, diff --git a/lib/Migration/Version000800Date20240828000000.php b/lib/Migration/Version000800Date20240828000000.php new file mode 100644 index 000000000..a85e44d83 --- /dev/null +++ b/lib/Migration/Version000800Date20240828000000.php @@ -0,0 +1,45 @@ +hasTable('tables_columns')) { + if ($schema->hasTable('tables_row_cells_usergroup')) { + $table = $schema->getTable('tables_columns'); + if (!$table->hasColumn('usergroup_select_teams')) { + $table->addColumn('usergroup_select_teams', Types::BOOLEAN, [ + 'notnull' => false, + 'default' => 0, + ]); + } + } + return $schema; + } + return null; + } +} diff --git a/lib/ResponseDefinitions.php b/lib/ResponseDefinitions.php index 5e3826d02..f605e0cde 100644 --- a/lib/ResponseDefinitions.php +++ b/lib/ResponseDefinitions.php @@ -127,6 +127,7 @@ * usergroupMultipleItems: bool, * usergroupSelectUsers: bool, * usergroupSelectGroups: bool, + * usergroupSelectTeams: bool, * showUserStatus: bool, * } * diff --git a/src/modules/modals/CreateColumn.vue b/src/modules/modals/CreateColumn.vue index 2c5a46c13..e3b0c6d0e 100644 --- a/src/modules/modals/CreateColumn.vue +++ b/src/modules/modals/CreateColumn.vue @@ -181,6 +181,7 @@ export default { usergroupMultipleItems: false, usergroupSelectUsers: true, usergroupSelectGroups: false, + usergroupSelectTeams: false, showUserStatus: false, }, textAppAvailable: !!window.OCA?.Text?.createEditor, @@ -334,6 +335,7 @@ export default { data.usergroupMultipleItems = this.column.usergroupMultipleItems data.usergroupSelectUsers = this.column.usergroupSelectUsers data.usergroupSelectGroups = this.column.usergroupSelectGroups + data.usergroupSelectTeams = this.column.usergroupSelectTeams data.showUserStatus = this.column.showUserStatus } else if (this.column.type === 'number') { data.numberDefault = this.column.numberDefault @@ -387,6 +389,7 @@ export default { usergroupMultipleItems: false, usergroupSelectUsers: true, usergroupSelectGroups: false, + usergroupSelectTeams: false, showUserStatus: false, } if (mainForm) { diff --git a/src/shared/components/ncTable/mixins/columnsTypes/usergroup.js b/src/shared/components/ncTable/mixins/columnsTypes/usergroup.js index aa075756a..3cd565dc8 100644 --- a/src/shared/components/ncTable/mixins/columnsTypes/usergroup.js +++ b/src/shared/components/ncTable/mixins/columnsTypes/usergroup.js @@ -14,6 +14,7 @@ export default class UsergroupColumn extends AbstractUsergroupColumn { this.usergroupMultipleItems = data.usergroupMultipleItems this.usergroupSelectUsers = data.usergroupSelectUsers this.usergroupSelectGroups = data.usergroupSelectGroups + this.usergroupSelectTeams = data.usergroupSelectTeams } getValueString(valueObject) { diff --git a/src/shared/components/ncTable/partials/TableCellUsergroup.vue b/src/shared/components/ncTable/partials/TableCellUsergroup.vue index e225b7fd6..c107556fd 100644 --- a/src/shared/components/ncTable/partials/TableCellUsergroup.vue +++ b/src/shared/components/ncTable/partials/TableCellUsergroup.vue @@ -6,7 +6,7 @@
- +
diff --git a/src/shared/components/ncTable/partials/columnTypePartials/forms/UsergroupForm.vue b/src/shared/components/ncTable/partials/columnTypePartials/forms/UsergroupForm.vue index 0de615f27..003f44057 100644 --- a/src/shared/components/ncTable/partials/columnTypePartials/forms/UsergroupForm.vue +++ b/src/shared/components/ncTable/partials/columnTypePartials/forms/UsergroupForm.vue @@ -6,17 +6,15 @@
- - {{ t('tables', 'Users') }} - - - {{ t('tables', 'Groups') }} - - - {{ t('tables', 'Users and groups') }} + + {{ t('tables', selectOptions[key]) }}
@@ -27,7 +25,7 @@