@isoftdata/svelte-user-configuration 1.0.11 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -138,19 +138,13 @@ $: computedPermissions = getComputedPermissions(permissions, permissionValueMap,
138
138
  property="groupValue"
139
139
  class="px-4"
140
140
  >
141
- <span
142
- style="width: 5em;"
143
- class="badge badge-pill badge-{permissionValueList[permission.groupValue ?? 'NONE'].color}">{permissionValueList[permission.groupValue ?? 'NONE'].label}</span
144
- >
141
+ <span class="badge badge-pill badge-{permissionValueList[permission.groupValue ?? 'NONE'].color}">{permissionValueList[permission.groupValue ?? 'NONE'].label}</span>
145
142
  </Td>
146
143
  <Td
147
144
  property="computedValue"
148
145
  class="px-4"
149
146
  >
150
- <span
151
- style="width: 5em;"
152
- class="badge badge-pill badge-{permissionValueList[permission.computedValue ?? 'NONE'].color}">{permissionValueList[permission.computedValue ?? 'NONE'].label}</span
153
- >
147
+ <span class="badge badge-pill badge-{permissionValueList[permission.computedValue ?? 'NONE'].color}">{permissionValueList[permission.computedValue ?? 'NONE'].label}</span>
154
148
  </Td>
155
149
  {/if}
156
150
  <Td property="category">{permission.category}</Td>
@@ -81,6 +81,7 @@ export let permissionValueChange = void 0;
81
81
  <div class="form-row">
82
82
  <div class="col-12">
83
83
  <PermissionList
84
+ {siteLabel}
84
85
  {permissions}
85
86
  {permissionValueMap}
86
87
  {groupPermissionValueMap}
package/dist/util.d.ts CHANGED
@@ -26,6 +26,8 @@ export interface UserAccount {
26
26
  export type { IconName } from '@fortawesome/fontawesome-common-types';
27
27
  export type HTMLDivAttributes = HTMLAttributes<HTMLDivElement>;
28
28
  export type SiteLabel = string;
29
+ export type PermissionValue = 'NONE' | 'SITE' | 'GLOBAL';
30
+ export declare const valueRank: Record<PermissionValue, number>;
29
31
  export type GenerateNewActivationPINFn = ComponentProps<UserAccountInfo>['generateNewActivationPIN'];
30
32
  export type SuccessFn = ComponentProps<UserAccountInfo>['success'];
31
33
  export type ErrorFn = ComponentProps<UserAccountInfo>['error'];
@@ -48,3 +50,11 @@ export type PermissionValueMap = ComponentProps<PermissionList>['permissionValue
48
50
  export type GroupPermissionValueMap = ComponentProps<PermissionList>['groupPermissionValueMap'];
49
51
  export type PermissionValueChangeFn = ComponentProps<PermissionList>['permissionValueChange'];
50
52
  export type PermissionListCardHeaderTitle = ComponentProps<PermissionList>['cardHeaderTitle'];
53
+ /** Returns a Map where the key is the `permissioniId` and the value is the highest permission level for the given group membership
54
+ *
55
+ * You'll probably want to call this in your code when the group membership changes, and pass the result to the `groupPermissionValueMap` prop of the `PermissionList` component.
56
+ */
57
+ export declare function getGroupHighestPermissionValueMap(groupMembershipSet: Set<number>, groupPermissionMap: Map<number, {
58
+ permissionId: number;
59
+ value: PermissionValue;
60
+ }[]>): Map<number, PermissionValue>;
package/dist/util.js CHANGED
@@ -3,3 +3,27 @@ import PasswordSetModal from './PasswordSetModal.svelte';
3
3
  import UserAccountInfo from './UserAccountInfo.svelte';
4
4
  import UserSiteAccess from './UserSiteAccess.svelte';
5
5
  import UserGroupMembership from './UserGroupMembership.svelte';
6
+ export const valueRank = {
7
+ NONE: 0,
8
+ SITE: 1,
9
+ GLOBAL: 2,
10
+ };
11
+ /** Returns a Map where the key is the `permissioniId` and the value is the highest permission level for the given group membership
12
+ *
13
+ * You'll probably want to call this in your code when the group membership changes, and pass the result to the `groupPermissionValueMap` prop of the `PermissionList` component.
14
+ */
15
+ export function getGroupHighestPermissionValueMap(groupMembershipSet, groupPermissionMap) {
16
+ const valueMap = new Map();
17
+ for (const groupId of groupMembershipSet) {
18
+ const groupPermissions = groupPermissionMap.get(groupId);
19
+ if (groupPermissions) {
20
+ for (const { permissionId, value } of groupPermissions) {
21
+ const currentValue = valueMap.get(permissionId);
22
+ if (!currentValue || valueRank[value] > valueRank[currentValue]) {
23
+ valueMap.set(permissionId, value);
24
+ }
25
+ }
26
+ }
27
+ }
28
+ return valueMap;
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isoftdata/svelte-user-configuration",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",