@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.
- package/dist/PermissionList.svelte +2 -8
- package/dist/UserConfiguration.svelte +1 -0
- package/dist/util.d.ts +10 -0
- package/dist/util.js +24 -0
- package/package.json +1 -1
|
@@ -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>
|
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
|
+
}
|