mirror of
https://github.com/nextcloud/tables.git
synced 2025-07-22 18:28:09 +00:00
fix: Properly display teams in usergroup
Signed-off-by: Cleopatra Enjeck M. <patrathewhiz@gmail.com>
This commit is contained in:

committed by
Enjeck

parent
b12c22d4fe
commit
fca79c7352
14
lib/Constants/UsergroupType.php
Normal file
14
lib/Constants/UsergroupType.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\Tables\Constants;
|
||||
|
||||
class UsergroupType {
|
||||
public const USER = 0;
|
||||
public const GROUP = 1;
|
||||
public const CIRCLE = 2;
|
||||
}
|
@ -7,8 +7,11 @@
|
||||
|
||||
namespace OCA\Tables\Db;
|
||||
|
||||
use OCA\Tables\Constants\UsergroupType;
|
||||
use OCA\Tables\Helper\CircleHelper;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IUserSession;
|
||||
|
||||
/** @template-extends RowCellMapperSuper<RowCellUsergroup, array, array> */
|
||||
class RowCellUsergroupMapper extends RowCellMapperSuper {
|
||||
@ -17,6 +20,8 @@ class RowCellUsergroupMapper extends RowCellMapperSuper {
|
||||
public function __construct(
|
||||
IDBConnection $db,
|
||||
private IUserManager $userManager,
|
||||
private CircleHelper $circleHelper,
|
||||
protected IUserSession $userSession,
|
||||
) {
|
||||
parent::__construct($db, $this->table, RowCellUsergroup::class);
|
||||
}
|
||||
@ -34,7 +39,12 @@ class RowCellUsergroupMapper extends RowCellMapperSuper {
|
||||
}
|
||||
|
||||
public function formatEntity(Column $column, RowCellSuper $cell) {
|
||||
$displayName = $cell->getValueType() === 0 ? ($this->userManager->getDisplayName($cell->getValue()) ?? $cell->getValue()) : $cell->getValue();
|
||||
$displayName = $cell->getValue();
|
||||
if ($cell->getValueType() === UsergroupType::USER) {
|
||||
$displayName = $this->userManager->getDisplayName($cell->getValue()) ?? $cell->getValue();
|
||||
} elseif ($cell->getValueType() === UsergroupType::CIRCLE) {
|
||||
$displayName = $this->circleHelper->getCircleDisplayName($cell->getValue(), $this->userSession->getUser()->getUID() ?? '') ?? $cell->getValue();
|
||||
}
|
||||
return [
|
||||
'id' => $cell->getValue(),
|
||||
'type' => $cell->getValueType(),
|
||||
|
@ -6,7 +6,7 @@
|
||||
<!-- eslint-disable-next-line vue/no-v-html -->
|
||||
<div v-if="value" class="table-cell-usergroup">
|
||||
<div v-for="item in value" :key="item.id" class="inline usergroup-entry">
|
||||
<NcUserBubble :user="item.id" :avatar-image="item.type === 1 ? 'icon-group' : ''" :is-no-user="item.type !== 0" :display-name="item.displayName ?? item.id" :show-user-status="isUser(item) && column.showUserStatus" :size="column.showUserStatus ? 34 : 20" :primary="isCurrentUser(item)" />
|
||||
<NcUserBubble :user="item.id" :avatar-image="getAvatarImage(item)" :is-no-user="!isUser(item)" :display-name="item.displayName ?? item.id" :show-user-status="isUser(item) && column.showUserStatus" :size="column.showUserStatus ? 34 : 20" :primary="isCurrentUser(item)" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -14,6 +14,7 @@
|
||||
<script>
|
||||
import { getCurrentUser } from '@nextcloud/auth'
|
||||
import { NcUserBubble } from '@nextcloud/vue'
|
||||
import { USERGROUP_TYPE } from '../../../constants.js'
|
||||
|
||||
const currentUser = getCurrentUser()
|
||||
|
||||
@ -41,7 +42,18 @@ export default {
|
||||
return (item) => this.isUser(item) && item.id === currentUser?.uid
|
||||
},
|
||||
isUser() {
|
||||
return (item) => item.type === 0
|
||||
return (item) => item.type === USERGROUP_TYPE.USER
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getAvatarImage(item) {
|
||||
if (item.type === USERGROUP_TYPE.GROUP) {
|
||||
return 'icon-group'
|
||||
}
|
||||
if (item.type === USERGROUP_TYPE.CIRCLE) {
|
||||
return 'icon-circles'
|
||||
}
|
||||
return ''
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -33,3 +33,9 @@ export const NAV_ENTRY_MODE = {
|
||||
}
|
||||
|
||||
export const ALLOWED_PROTOCOLS = ['http:', 'https:']
|
||||
|
||||
export const USERGROUP_TYPE = {
|
||||
USER: 0,
|
||||
GROUP: 1,
|
||||
CIRCLE: 2,
|
||||
}
|
||||
|
Reference in New Issue
Block a user