Skip to content

Commit e08458c

Browse files
committed
feat(client): improve user groups tab
1 parent 983ccee commit e08458c

File tree

2 files changed

+32
-55
lines changed

2 files changed

+32
-55
lines changed

apps/client/src/components/Checklist.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
:key="itemId"
1616
clickable
1717
v-ripple
18-
class="text-grey-1"
1918
:style="{
2019
'background-color': selectedItemIds.has(itemId) ? '#505050' : '',
2120
}"

apps/client/src/layouts/PagesLayout/MainToolbar/PagesSettingsDialog/GroupsTab.vue

Lines changed: 32 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -25,50 +25,38 @@
2525

2626
<div style="flex: 1; height: 0; display: flex">
2727
<div style="flex: 1">
28-
<q-list
28+
<Checklist
29+
:item-ids="memberGroupsIds"
30+
:selected-item-ids="baseSelectedGroupIds"
31+
@select="(pageId) => baseSelectedGroupIds.add(pageId)"
32+
@unselect="(pageId) => baseSelectedGroupIds.delete(pageId)"
2933
style="
3034
border-radius: 10px;
3135
padding: 0;
3236
overflow-y: auto;
3337
max-height: 100%;
38+
background-color: #383838;
3439
"
3540
>
36-
<template
37-
v-for="groupId in memberGroupsIds"
38-
:key="groupId"
39-
>
40-
<q-item
41-
v-if="
42-
realtimeCtx.hget('group', groupId, 'permanent-deletion-date') ==
43-
null
44-
"
45-
class="text-grey-1"
46-
style="background-color: #424242"
47-
clickable
48-
v-ripple
49-
active-class="bg-grey-7"
50-
:active="baseSelectedGroupIds.has(groupId)"
51-
@click="select(groupId, $event as MouseEvent)"
52-
>
53-
<q-item-section>
54-
<q-item-label>
55-
{{ groupNames()(groupId).get().text }}
56-
</q-item-label>
57-
<q-item-label caption>
58-
{{
59-
rolesMap()[
60-
realtimeCtx.hget(
61-
'group-member',
62-
`${groupId}:${authStore().userId}`,
63-
'role',
64-
)!
65-
]?.name
66-
}}
67-
</q-item-label>
68-
</q-item-section>
69-
</q-item>
41+
<template #item="{ itemId: groupId }">
42+
<q-item-section>
43+
<q-item-label>
44+
{{ groupNames()(groupId).get().text }}
45+
</q-item-label>
46+
<q-item-label caption>
47+
{{
48+
rolesMap()[
49+
realtimeCtx.hget(
50+
'group-member',
51+
`${groupId}:${authStore().userId}`,
52+
'role',
53+
)!
54+
]?.name
55+
}}
56+
</q-item-label>
57+
</q-item-section>
7058
</template>
71-
</q-list>
59+
</Checklist>
7260
</div>
7361

7462
<Gap style="width: 16px" />
@@ -110,12 +98,14 @@ const groupIds = inject<Ref<string[]>>('groupIds')!;
11098
const realtimeCtx = inject<RealtimeContext>('realtimeCtx')!;
11199
112100
const memberGroupsIds = computed(() =>
113-
groupIds.value.filter((groupId) =>
114-
realtimeCtx.hget(
115-
'group-member',
116-
`${groupId}:${authStore().userId}`,
117-
'exists',
118-
),
101+
groupIds.value.filter(
102+
(groupId) =>
103+
realtimeCtx.hget('group', groupId, 'permanent-deletion-date') == null &&
104+
realtimeCtx.hget(
105+
'group-member',
106+
`${groupId}:${authStore().userId}`,
107+
'exists',
108+
),
119109
),
120110
);
121111
@@ -146,18 +136,6 @@ function deselectAll() {
146136
}
147137
}
148138
149-
function select(groupId: string, event: MouseEvent) {
150-
if (!isCtrlDown(event)) {
151-
baseSelectedGroupIds.value.clear();
152-
}
153-
154-
if (baseSelectedGroupIds.value.has(groupId)) {
155-
baseSelectedGroupIds.value.delete(groupId);
156-
} else {
157-
baseSelectedGroupIds.value.add(groupId);
158-
}
159-
}
160-
161139
async function leaveSelectedGroups() {
162140
try {
163141
await asyncDialog({

0 commit comments

Comments
 (0)