adds a custom renderer to the users page

This commit is contained in:
Keviin Åberg Kultalahti 2021-05-18 12:17:57 +02:00
parent 71929dadd1
commit 07dfc43d11
3 changed files with 32 additions and 4 deletions

View File

@ -17,6 +17,7 @@
import { fetchData } from "helpers" import { fetchData } from "helpers"
import { users } from "stores/portal" import { users } from "stores/portal"
import TagsRenderer from "./_components/TagsTableRenderer.svelte"
import UpdateRolesModal from "./_components/UpdateRolesModal.svelte" import UpdateRolesModal from "./_components/UpdateRolesModal.svelte"
export let userId export let userId
@ -25,14 +26,14 @@
const roleSchema = { const roleSchema = {
name: { displayName: "App" }, name: { displayName: "App" },
role: { type: "options" }, role: {},
} }
// Merge the Apps list and the roles response to get something that makes sense for the table // Merge the Apps list and the roles response to get something that makes sense for the table
$: appList = Object.keys($apps?.data).map(id => ({ $: appList = Object.keys($apps?.data).map(id => ({
...$apps?.data?.[id], ...$apps?.data?.[id],
_id: id, _id: id,
role: $roleFetch?.data?.roles?.[id], role: [$roleFetch?.data?.roles?.[id]],
})) }))
let selectedApp let selectedApp
@ -97,6 +98,7 @@
allowEditColumns={false} allowEditColumns={false}
allowEditRows={false} allowEditRows={false}
allowSelectRows={false} allowSelectRows={false}
customRenderers={[{ column: "role", component: TagsRenderer }]}
/> />
</div> </div>
<Divider size="S" /> <Divider size="S" />

View File

@ -0,0 +1,20 @@
<script>
import { Tag, Tags } from "@budibase/bbui"
export let value
const displayLimit = 5
$: tags = value?.slice(0, displayLimit) ?? []
$: leftover = (value?.length ?? 0) - tags.length
</script>
<Tags>
{#each tags as tag}
<Tag>
{tag}
</Tag>
{/each}
{#if leftover}
<Tag>+{leftover} more</Tag>
{/if}
</Tags>

View File

@ -12,6 +12,7 @@
Layout, Layout,
Modal, Modal,
} from "@budibase/bbui" } from "@budibase/bbui"
import TagsRenderer from "./_components/TagsTableRenderer.svelte"
import AddUserModal from "./_components/AddUserModal.svelte" import AddUserModal from "./_components/AddUserModal.svelte"
import BasicOnboardingModal from "./_components/BasicOnboardingModal.svelte" import BasicOnboardingModal from "./_components/BasicOnboardingModal.svelte"
import { users } from "stores/portal" import { users } from "stores/portal"
@ -20,14 +21,18 @@
const schema = { const schema = {
email: {}, email: {},
status: {}, status: { displayName: "Development Access", type: "boolean" },
// role: { type: "options" },
group: {},
// access: {}, // access: {},
// group: {} // group: {}
} }
let search let search
let email let email
$: filteredUsers = $users.filter(user => user.email.includes(search || "")) $: filteredUsers = $users
.filter(user => user.email.includes(search || ""))
.map(user => ({ ...user, group: ["All"] }))
let createUserModal let createUserModal
let basicOnboardingModal let basicOnboardingModal
@ -68,6 +73,7 @@
allowEditColumns={false} allowEditColumns={false}
allowEditRows={false} allowEditRows={false}
allowSelectRows={false} allowSelectRows={false}
customRenderers={[{ column: "group", component: TagsRenderer }]}
/> />
</div> </div>
</Layout> </Layout>