From 545f3d62b7717a1ccec7c5d7c3bf4d50521f0e8b Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Thu, 14 Jul 2022 08:39:39 +0100 Subject: [PATCH] overview card updates --- packages/backend-core/src/db/utils.ts | 22 ----- .../overview/_components/AccessTab.svelte | 86 +++++++++---------- .../_components/AssignmentModal.svelte | 50 +++++++++-- .../overview/_components/OverviewTab.svelte | 50 ++++++++++- .../src/api/controllers/global/groups.ts | 9 +- 5 files changed, 134 insertions(+), 83 deletions(-) diff --git a/packages/backend-core/src/db/utils.ts b/packages/backend-core/src/db/utils.ts index 780917686f..8a50efbca9 100644 --- a/packages/backend-core/src/db/utils.ts +++ b/packages/backend-core/src/db/utils.ts @@ -148,28 +148,6 @@ export function getTemplateParams( } } -/** - * Generates a new user group ID - * @returns {string} The new user group ID which info can be stored under. - */ -exports.generateUserGroupID = () => { - return `${DocumentTypes.GROUP}${SEPARATOR}${newid()}` -} - -/** - * Gets parameters for retrieving groups. - */ -exports.getUserGroupsParams = (groupId: any, otherProps = {}) => { - if (!groupId) { - groupId = "" - } - return { - ...otherProps, - startkey: `${DocumentTypes.GROUP}${SEPARATOR}${groupId}`, - endkey: `${DocumentTypes.GROUP}${SEPARATOR}${groupId}${UNICODE_MAX}`, - } -} - /** * Generates a new role ID. * @returns {string} The new role ID which the role doc can be stored under. diff --git a/packages/builder/src/pages/builder/portal/overview/_components/AccessTab.svelte b/packages/builder/src/pages/builder/portal/overview/_components/AccessTab.svelte index 23fe33893d..7d274796f6 100644 --- a/packages/builder/src/pages/builder/portal/overview/_components/AccessTab.svelte +++ b/packages/builder/src/pages/builder/portal/overview/_components/AccessTab.svelte @@ -23,10 +23,13 @@ let assignmentModal let appGroups = [] let appUsers = [] + let prevSearch = undefined, + search = undefined let pageInfo = createPaginationStore() $: page = $pageInfo.page - $: fetchUsers(page) + $: console.log(page) + $: fetchUsers(page, search) $: isProPlan = $auth.user?.license.plan.type === Constants.PlanType.FREE @@ -43,19 +46,6 @@ }) }) - $: filteredUsers = - $users.data?.filter(x => { - return !Object.keys(x.roles).find(y => { - return extractAppId(y) === extractAppId(app.appId) - }) - }) || [] - - $: filteredGroups = $groups.filter(element => { - return !element.apps.find(y => { - return y.appId === app.appId - }) - }) - function extractAppId(id) { const split = id?.split("_") || [] return split.length ? split[split.length - 1] : null @@ -99,10 +89,16 @@ groups.actions.save(group) } - async function fetchUsers(page) { + async function fetchUsers(page, search) { if ($pageInfo.loading) { return } + // need to remove the page if they've started searching + if (search && !prevSearch) { + pageInfo.reset() + page = undefined + } + prevSearch = search try { pageInfo.loading() await users.search({ page, appId: app.appId }) @@ -136,7 +132,7 @@ > - {#if isProPlan} + {#if isProPlan && appGroups.length} {#each appGroups as group} {/if} - - {#each appUsers as user} - - updateUserRole(e.detail, user)} - autoWidth - quiet - value={user.roles[ - Object.keys(user.roles).find( - x => extractAppId(x) === extractAppId(app.appId) - ) - ]} - /> - - {/each} - - + {#if appUsers.length} + + {#each appUsers as user} + + updateUserRole(e.detail, user)} + autoWidth + quiet + value={user.roles[ + Object.keys(user.roles).find( + x => extractAppId(x) === extractAppId(app.appId) + ) + ]} + /> + + {/each} + + + {/if} {:else}
@@ -200,11 +198,7 @@
- +