Calm motion: animations on this site only fade, with no movement
Permission matrix
Roles by permissions as check boxes, in groups
Sets what each role in a team can do. A box at the top of each role turns all of its permissions on or off. For channels of notices, use the notification preferences.
Basic
| Permission | Owner | Producer | Editor | Guest |
|---|---|---|---|---|
| Episodes | ||||
| upload audio | ||||
| edit show notes | ||||
| publish episodes | ||||
| Show | ||||
| see statistics | ||||
| invite people | ||||
| Account | ||||
| change billing | ||||
vue
<template>
<BlessPermissionMatrix v-model="grants" :roles :permissions style="max-width: 640px" />
</template>
<script setup lang="ts">
import { ref } from "vue";
import { BlessPermissionMatrix } from "blessing-ui";
const roles = [
{ key: "owner", label: "Owner", locked: true },
{ key: "producer", label: "Producer" },
{ key: "editor", label: "Editor" },
{ key: "guest", label: "Guest" },
];
const permissions = [
{ key: "upload", label: "upload audio", group: "Episodes" },
{ key: "edit", label: "edit show notes", group: "Episodes" },
{ key: "publish", label: "publish episodes", group: "Episodes" },
{ key: "stats", label: "see statistics", group: "Show" },
{ key: "invite", label: "invite people", group: "Show" },
{ key: "billing", label: "change billing", group: "Account" },
];
const grants = ref<Record<string, string[]>>({
producer: ["upload", "edit", "publish", "stats", "invite"],
editor: ["upload", "edit"],
guest: ["stats"],
});
</script>rolesis a list of columns. Each role has akey, alabel, and an optionallocked. A locked role, such as the owner, has every permission, cannot change, and has a gray column.permissionsis a list of rows. Each permission has akey, alabel, and an optionalgroup. A new group name starts a heading row.v-modelholds the permissions of each role, such as{ editor: ["upload", "edit"] }.- The box at the top of a role shows on, off, or a dash for some.
- The grid is a table of native check boxes. Each box has a name in words, such as "Editor can publish episodes". Write each permission label so that it reads well after "can".
- Change the words with
labelsor a label pack:title,permission,locked, and the functionsallandcell.
Usage
ts
import { BlessPermissionMatrix } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
roles* | BlessRole[] | — | |
permissions* | BlessPermission[] | — | |
label | string | — | names the table |
labels | Partial<{ title: string; permission: string; all: (role: string) => string; cell: (role: string, permission: string) => string; locked: string; }> | — | |
modelValue | CheckMatrix | {} | the permissions of each role, by role key |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: CheckMatrix] |