@webitel/ui-sdk 24.12.95 → 24.12.97
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/CHANGELOG.md +37 -0
- package/dist/ui-sdk.css +1 -1
- package/dist/ui-sdk.js +3179 -3219
- package/dist/ui-sdk.umd.cjs +16 -16
- package/package.json +14 -8
- package/src/api/defaults/getDefaultInstance/getDefaultInstance.js +5 -2
- package/src/api/defaults/index.js +1 -1
- package/src/components/wt-dual-panel/wt-dual-panel.vue +1 -2
- package/src/components/wt-icon-action/iconMappings.js +1 -1
- package/src/composables/useAccessControl/v2/createUserAccessControl.ts +66 -0
- package/src/composables/useAccessControl/v2/types/CreateUserAccessControl.d.ts +21 -0
- package/src/enums/CrudAction/CrudAction.js +6 -0
- package/src/enums/CrudAction/CrudAction.ts +8 -0
- package/src/enums/WtObject/WtObject.js +51 -1
- package/src/enums/WtObject/WtObject.ts +51 -1
- package/src/enums/index.js +6 -19
- package/src/enums/index.ts +33 -0
- package/src/locale/en/en.js +1 -1
- package/src/locale/ru/ru.js +1 -1
- package/src/locale/ua/ua.js +1 -1
- package/src/modules/Filters/v2/headers/createTableHeadersStore.ts +127 -78
- package/src/modules/Filters/v2/persist/usePersistedStorage.ts +0 -5
- package/src/modules/Filters/v2/table/createTableStore.store.ts +3 -2
- package/src/modules/Userinfo/api/userinfo.js +21 -34
- package/src/modules/Userinfo/store/UserinfoStoreModule.js +1 -1
- package/src/modules/Userinfo/v2/api/UserinfoAPI.ts +62 -0
- package/src/modules/Userinfo/v2/enums/GlobalActions/GlobalActions.ts +36 -0
- package/src/modules/Userinfo/v2/enums/ScopeClass/ScopeClass.ts +47 -0
- package/src/modules/Userinfo/v2/enums/index.ts +7 -0
- package/src/modules/Userinfo/v2/index.ts +0 -0
- package/src/modules/Userinfo/v2/mappings/mappings.ts +161 -0
- package/src/modules/Userinfo/v2/scripts/utils.ts +123 -0
- package/src/modules/Userinfo/v2/stores/__tests__/accessStore.spec.ts +136 -0
- package/src/modules/Userinfo/v2/stores/accessStore.ts +131 -0
- package/src/modules/Userinfo/v2/stores/userinfoStore.ts +56 -0
- package/src/modules/Userinfo/v2/types/UserAccess.d.ts +118 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webitel/ui-sdk",
|
|
3
|
-
"version": "24.12.
|
|
3
|
+
"version": "24.12.97",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
"docs:dev": "vitepress dev docs --port 8080",
|
|
17
17
|
"docs:build": "vitepress build docs",
|
|
18
18
|
"docs:preview": "vitepress preview docs",
|
|
19
|
-
"tsc": "
|
|
20
|
-
"update-node": "nvm install --lts && nvm alias default node"
|
|
19
|
+
"tsc": "tsc -p tsconfig.json",
|
|
20
|
+
"update-node": "nvm install --lts && nvm alias default node",
|
|
21
|
+
"i": "npm install"
|
|
21
22
|
},
|
|
22
23
|
"main": "./dist/@webitel/ui-sdk.mjs",
|
|
23
24
|
"type": "module",
|
|
@@ -34,6 +35,10 @@
|
|
|
34
35
|
"import": "./src/enums/index.js",
|
|
35
36
|
"require": "./src/enums/index.js"
|
|
36
37
|
},
|
|
38
|
+
"./components": {
|
|
39
|
+
"import": "./src/components/index.js",
|
|
40
|
+
"require": "./src/components/index.js"
|
|
41
|
+
},
|
|
37
42
|
"./scripts": {
|
|
38
43
|
"import": "./src/scripts/index.js",
|
|
39
44
|
"require": "./src/scripts/index.js"
|
|
@@ -140,13 +145,13 @@
|
|
|
140
145
|
"devDependencies": {
|
|
141
146
|
"@eslint/js": "^9.17.0",
|
|
142
147
|
"@tsconfig/node22": "^22.0.0",
|
|
143
|
-
"@types/node": "^22.
|
|
148
|
+
"@types/node": "^22.12.0",
|
|
144
149
|
"@vitejs/plugin-vue": "^5.2.0",
|
|
145
150
|
"@vitest/coverage-v8": "^2.1.5",
|
|
146
151
|
"@vue/compat": "^3.5.13",
|
|
147
152
|
"@vue/compiler-sfc": "^3.5.13",
|
|
148
153
|
"@vue/test-utils": "^2.4.6",
|
|
149
|
-
"@vue/tsconfig": "^0.
|
|
154
|
+
"@vue/tsconfig": "^0.7.0",
|
|
150
155
|
"eslint": "^9.17.0",
|
|
151
156
|
"eslint-config-prettier": "^9.1.0",
|
|
152
157
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
@@ -162,8 +167,8 @@
|
|
|
162
167
|
"prettier": "^3.4.2",
|
|
163
168
|
"prismjs": "^1.29.0",
|
|
164
169
|
"sass": "^1.81.0",
|
|
165
|
-
"typescript": "5.
|
|
166
|
-
"typescript-eslint": "^8.
|
|
170
|
+
"typescript": "5.7.3",
|
|
171
|
+
"typescript-eslint": "^8.22.0",
|
|
167
172
|
"typescript-plugin-css-modules": "^5.1.0",
|
|
168
173
|
"vite": "^5.4.11",
|
|
169
174
|
"vite-plugin-checker": "^0.8.0",
|
|
@@ -175,7 +180,8 @@
|
|
|
175
180
|
"vitest": "^2.1.5",
|
|
176
181
|
"vue": "^3.5.13",
|
|
177
182
|
"vue-tsc": "^2.1.10",
|
|
178
|
-
"vuex": "^4.1.0"
|
|
183
|
+
"vuex": "^4.1.0",
|
|
184
|
+
"pinia": "^2.3.0"
|
|
179
185
|
},
|
|
180
186
|
"optionalDependencies": {
|
|
181
187
|
"@rollup/rollup-linux-x64-gnu": "4.9.5"
|
|
@@ -2,13 +2,16 @@ import generateInstance from '../../axios/generateInstance.js';
|
|
|
2
2
|
import updateTokenInterceptor from '../../interceptors/request/updateToken.interceptor.js';
|
|
3
3
|
import handleUnauthorizedInterceptor from '../../interceptors/response/handleUnauthorized.interceptor.js';
|
|
4
4
|
|
|
5
|
-
const getDefaultInstance = () =>
|
|
6
|
-
generateInstance({
|
|
5
|
+
const getDefaultInstance = () => {
|
|
6
|
+
return generateInstance({
|
|
7
7
|
interceptors: {
|
|
8
8
|
request: [updateTokenInterceptor],
|
|
9
9
|
response: [handleUnauthorizedInterceptor],
|
|
10
10
|
},
|
|
11
11
|
baseURL: import.meta.env.VITE_API_URL,
|
|
12
12
|
});
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { getDefaultInstance };
|
|
13
16
|
|
|
14
17
|
export default getDefaultInstance;
|
|
@@ -4,8 +4,8 @@ import getDefaultInstance from './getDefaultInstance/getDefaultInstance.js';
|
|
|
4
4
|
import getDefaultOpenAPIConfig from './getDefaultOpenAPIConfig/getDefaultOpenAPIConfig.js';
|
|
5
5
|
|
|
6
6
|
export {
|
|
7
|
-
getDefaultGetParams,
|
|
8
7
|
getDefaultGetListResponse,
|
|
8
|
+
getDefaultGetParams,
|
|
9
9
|
getDefaultInstance,
|
|
10
10
|
getDefaultOpenAPIConfig,
|
|
11
11
|
};
|
|
@@ -33,8 +33,7 @@
|
|
|
33
33
|
<script setup>
|
|
34
34
|
import { computed, defineEmits, ref } from 'vue';
|
|
35
35
|
|
|
36
|
-
import IconAction from '../../enums
|
|
37
|
-
import { ComponentSize } from '../../enums/index.js';
|
|
36
|
+
import { ComponentSize, IconAction } from '../../enums';
|
|
38
37
|
|
|
39
38
|
const props = defineProps({
|
|
40
39
|
actionsPanel: {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
import { useRoute } from 'vue-router';
|
|
3
|
+
|
|
4
|
+
import { _wtUiLog } from '../../../scripts/logger';
|
|
5
|
+
import type {
|
|
6
|
+
CreateUserAccessControlComposableParams,
|
|
7
|
+
UseAccessControlReturn,
|
|
8
|
+
} from './types/CreateUserAccessControl';
|
|
9
|
+
|
|
10
|
+
export const createUserAccessControlComposable = (
|
|
11
|
+
useUserinfoStore: CreateUserAccessControlComposableParams,
|
|
12
|
+
) => {
|
|
13
|
+
const useUserAccessControl = (
|
|
14
|
+
resource?: string,
|
|
15
|
+
// options: UseUserAccessControlComposableOptions = {},
|
|
16
|
+
): UseAccessControlReturn => {
|
|
17
|
+
const route = useRoute();
|
|
18
|
+
const object = resource || route?.meta?.WtObject;
|
|
19
|
+
|
|
20
|
+
const userinfoStore = useUserinfoStore();
|
|
21
|
+
|
|
22
|
+
if (!object) {
|
|
23
|
+
_wtUiLog.error({
|
|
24
|
+
module: 'access control',
|
|
25
|
+
entity: 'useUserAccessControl composable',
|
|
26
|
+
})(
|
|
27
|
+
'No WtObject found in route meta or passed as first param, cannot check access control',
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const hasReadAccess = computed(() => {
|
|
32
|
+
return userinfoStore.hasReadAccess(object);
|
|
33
|
+
});
|
|
34
|
+
const hasCreateAccess = computed(() => {
|
|
35
|
+
return userinfoStore.hasCreateAccess(object);
|
|
36
|
+
});
|
|
37
|
+
const hasUpdateAccess = computed(() => {
|
|
38
|
+
return userinfoStore.hasUpdateAccess(object);
|
|
39
|
+
});
|
|
40
|
+
const hasDeleteAccess = computed(() => {
|
|
41
|
+
return userinfoStore.hasDeleteAccess(object);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const hasSaveActionAccess = computed(() => {
|
|
45
|
+
if (route.params.id === 'new') return hasCreateAccess.value;
|
|
46
|
+
return hasUpdateAccess.value;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const disableUserInput = computed(() => {
|
|
50
|
+
if (route.params.id === 'new') return !hasCreateAccess.value;
|
|
51
|
+
return !hasUpdateAccess.value;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
hasReadAccess,
|
|
56
|
+
hasCreateAccess,
|
|
57
|
+
hasUpdateAccess,
|
|
58
|
+
hasDeleteAccess,
|
|
59
|
+
|
|
60
|
+
hasSaveActionAccess,
|
|
61
|
+
disableUserInput,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return useUserAccessControl;
|
|
66
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
import type { WtObject } from '../../../../enums';
|
|
4
|
+
import type { createUserAccessStore } from '../../../../modules/Userinfo/v2/stores/accessStore';
|
|
5
|
+
|
|
6
|
+
export type CreateUserAccessControlComposableParams =
|
|
7
|
+
ReturnType<createUserAccessStore>;
|
|
8
|
+
|
|
9
|
+
export type UseUserAccessControlComposableOptions = {
|
|
10
|
+
resource?: WtObject;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export interface UseAccessControlReturn {
|
|
14
|
+
hasReadAccess: Ref<boolean>;
|
|
15
|
+
hasCreateAccess: Ref<boolean>;
|
|
16
|
+
hasUpdateAccess: Ref<boolean>;
|
|
17
|
+
hasDeleteAccess: Ref<boolean>;
|
|
18
|
+
|
|
19
|
+
hasSaveActionAccess: Ref<boolean>;
|
|
20
|
+
disableUserInput: Ref<boolean>;
|
|
21
|
+
}
|
|
@@ -5,5 +5,55 @@ export const WtObject = {
|
|
|
5
5
|
Agent: 'agent',
|
|
6
6
|
Queue: 'queue',
|
|
7
7
|
Contact: 'contact',
|
|
8
|
-
|
|
8
|
+
Region: 'region',
|
|
9
|
+
User: 'user',
|
|
10
|
+
Resource: 'resource',
|
|
11
|
+
Device: 'device',
|
|
12
|
+
License: 'license',
|
|
13
|
+
Flow: 'flow',
|
|
14
|
+
Dialplan: 'dialplan',
|
|
15
|
+
Gateway: 'gateway',
|
|
16
|
+
Chatplan: 'chatplan',
|
|
17
|
+
ChatGateway: 'chatGateway',
|
|
18
|
+
Blacklist: 'blacklist',
|
|
19
|
+
Calendar: 'calendar',
|
|
20
|
+
Communication: 'communication',
|
|
21
|
+
PauseCause: 'pauseCause',
|
|
22
|
+
Media: 'media',
|
|
23
|
+
ShiftTemplate: 'shiftTemplate',
|
|
24
|
+
PauseTemplate: 'pauseTemplate',
|
|
25
|
+
WorkingCondition: 'workingCondition',
|
|
26
|
+
Skill: 'skill',
|
|
27
|
+
Bucket: 'bucket',
|
|
28
|
+
Member: 'member',
|
|
29
|
+
ResourceGroup: 'resourceGroup',
|
|
30
|
+
Team: 'team',
|
|
31
|
+
Storage: 'storage',
|
|
32
|
+
CognitiveProfile: 'cognitiveProfile',
|
|
33
|
+
EmailProfile: 'emailProfile',
|
|
34
|
+
SingleSignOn: 'singleSignOn',
|
|
35
|
+
ImportCsv: 'importCsv',
|
|
36
|
+
Trigger: 'trigger',
|
|
37
|
+
Role: 'role',
|
|
38
|
+
Object: 'object',
|
|
39
|
+
ChangeLog: 'changelog',
|
|
40
|
+
Configuration: 'configuration',
|
|
41
|
+
GlobalVariable: 'globalVariable',
|
|
42
|
+
ActiveCall: 'activeCall',
|
|
43
|
+
Scorecard: 'scorecard',
|
|
44
|
+
Logger: 'logger',
|
|
45
|
+
Call: 'call',
|
|
46
|
+
RecordFile: 'recordFile',
|
|
47
|
+
ContactGroup: 'contactGroup',
|
|
48
|
+
ChatBot: 'chatBot',
|
|
49
|
+
Cases: 'cases',
|
|
50
|
+
CaseComment: 'caseComment',
|
|
51
|
+
Slas: 'slas',
|
|
52
|
+
ServiceCatalog: 'serviceCatalog',
|
|
53
|
+
CaseSource: 'caseSource',
|
|
54
|
+
CloseReasonGroup: 'closeReasonGroup',
|
|
55
|
+
Priorities: 'priorities',
|
|
56
|
+
Status: 'status',
|
|
57
|
+
Source: 'source',
|
|
58
|
+
CustomLookup: 'customLookup',
|
|
9
59
|
};
|
|
@@ -5,7 +5,57 @@ export const WtObject = {
|
|
|
5
5
|
Agent: 'agent',
|
|
6
6
|
Queue: 'queue',
|
|
7
7
|
Contact: 'contact',
|
|
8
|
-
|
|
8
|
+
Region: 'region',
|
|
9
|
+
User: 'user',
|
|
10
|
+
Resource: 'resource',
|
|
11
|
+
Device: 'device',
|
|
12
|
+
License: 'license',
|
|
13
|
+
Flow: 'flow',
|
|
14
|
+
Dialplan: 'dialplan',
|
|
15
|
+
Gateway: 'gateway',
|
|
16
|
+
Chatplan: 'chatplan',
|
|
17
|
+
ChatGateway: 'chatGateway',
|
|
18
|
+
Blacklist: 'blacklist',
|
|
19
|
+
Calendar: 'calendar',
|
|
20
|
+
Communication: 'communication',
|
|
21
|
+
PauseCause: 'pauseCause',
|
|
22
|
+
Media: 'media',
|
|
23
|
+
ShiftTemplate: 'shiftTemplate',
|
|
24
|
+
PauseTemplate: 'pauseTemplate',
|
|
25
|
+
WorkingCondition: 'workingCondition',
|
|
26
|
+
Skill: 'skill',
|
|
27
|
+
Bucket: 'bucket',
|
|
28
|
+
Member: 'member',
|
|
29
|
+
ResourceGroup: 'resourceGroup',
|
|
30
|
+
Team: 'team',
|
|
31
|
+
Storage: 'storage',
|
|
32
|
+
CognitiveProfile: 'cognitiveProfile',
|
|
33
|
+
EmailProfile: 'emailProfile',
|
|
34
|
+
SingleSignOn: 'singleSignOn',
|
|
35
|
+
ImportCsv: 'importCsv',
|
|
36
|
+
Trigger: 'trigger',
|
|
37
|
+
Role: 'role',
|
|
38
|
+
Object: 'object',
|
|
39
|
+
ChangeLog: 'changelog',
|
|
40
|
+
Configuration: 'configuration',
|
|
41
|
+
GlobalVariable: 'globalVariable',
|
|
42
|
+
ActiveCall: 'activeCall',
|
|
43
|
+
Scorecard: 'scorecard',
|
|
44
|
+
Logger: 'logger',
|
|
45
|
+
Call: 'call',
|
|
46
|
+
RecordFile: 'recordFile',
|
|
47
|
+
ContactGroup: 'contactGroup',
|
|
48
|
+
ChatBot: 'chatBot',
|
|
49
|
+
Cases: 'cases',
|
|
50
|
+
CaseComment: 'caseComment',
|
|
51
|
+
Slas: 'slas',
|
|
52
|
+
ServiceCatalog: 'serviceCatalog',
|
|
53
|
+
CaseSource: 'caseSource',
|
|
54
|
+
CloseReasonGroup: 'closeReasonGroup',
|
|
55
|
+
Priorities: 'priorities',
|
|
56
|
+
Status: 'status',
|
|
57
|
+
Source: 'source',
|
|
58
|
+
CustomLookup: 'customLookup',
|
|
9
59
|
} as const;
|
|
10
60
|
|
|
11
61
|
export type WtObject = (typeof WtObject)[keyof typeof WtObject];
|
package/src/enums/index.js
CHANGED
|
@@ -2,28 +2,15 @@ import AbstractUserStatus from './AbstractUserStatus/AbstractUserStatus.enum.js'
|
|
|
2
2
|
import AgentStatus from './AgentStatus/AgentStatus.enum.js';
|
|
3
3
|
import ChatGatewayProvider from './ChatGatewayProvider/ChatGatewayProvider.enum.js';
|
|
4
4
|
import { ComponentSize } from './ComponentSize/ComponentSize';
|
|
5
|
+
import { CrudAction } from './CrudAction/CrudAction';
|
|
5
6
|
import IconAction from './IconAction/IconAction.enum.js';
|
|
6
7
|
import QueueType from './QueueType/QueueType.enum.js';
|
|
7
8
|
import TypesExportedSettings from './TypesExportedSettings/TypesExportedSettings.enum.js';
|
|
8
9
|
import { AdminSections } from './WebitelApplications/AdminSections';
|
|
9
|
-
import AuditorSections from './WebitelApplications/AuditorSections
|
|
10
|
-
import CrmSections from './WebitelApplications/CrmSections
|
|
11
|
-
import SupervisorSections from './WebitelApplications/SupervisorSections
|
|
10
|
+
import { AuditorSections } from './WebitelApplications/AuditorSections';
|
|
11
|
+
import { CrmSections } from './WebitelApplications/CrmSections';
|
|
12
|
+
import { SupervisorSections } from './WebitelApplications/SupervisorSections';
|
|
12
13
|
import WebitelApplications from './WebitelApplications/WebitelApplications.enum.js';
|
|
14
|
+
import { WtApplication } from './WebitelApplications/WtApplication';
|
|
13
15
|
import { WtObject } from './WtObject/WtObject';
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
AbstractUserStatus,
|
|
17
|
-
AdminSections,
|
|
18
|
-
AgentStatus,
|
|
19
|
-
AuditorSections,
|
|
20
|
-
ChatGatewayProvider,
|
|
21
|
-
ComponentSize,
|
|
22
|
-
CrmSections,
|
|
23
|
-
IconAction,
|
|
24
|
-
QueueType,
|
|
25
|
-
SupervisorSections,
|
|
26
|
-
TypesExportedSettings,
|
|
27
|
-
WebitelApplications,
|
|
28
|
-
WtObject,
|
|
29
|
-
};
|
|
16
|
+
export { AbstractUserStatus, AdminSections, AgentStatus, AuditorSections, ChatGatewayProvider, ComponentSize, CrmSections, CrudAction, IconAction, QueueType, SupervisorSections, TypesExportedSettings, WebitelApplications, WtApplication, WtObject, };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import AbstractUserStatus from './AbstractUserStatus/AbstractUserStatus.enum.js';
|
|
2
|
+
import AgentStatus from './AgentStatus/AgentStatus.enum.js';
|
|
3
|
+
import ChatGatewayProvider from './ChatGatewayProvider/ChatGatewayProvider.enum.js';
|
|
4
|
+
import { ComponentSize } from './ComponentSize/ComponentSize';
|
|
5
|
+
import { CrudAction } from './CrudAction/CrudAction';
|
|
6
|
+
import IconAction from './IconAction/IconAction.enum.js';
|
|
7
|
+
import QueueType from './QueueType/QueueType.enum.js';
|
|
8
|
+
import TypesExportedSettings from './TypesExportedSettings/TypesExportedSettings.enum.js';
|
|
9
|
+
import { AdminSections } from './WebitelApplications/AdminSections';
|
|
10
|
+
import { AuditorSections } from './WebitelApplications/AuditorSections';
|
|
11
|
+
import { CrmSections } from './WebitelApplications/CrmSections';
|
|
12
|
+
import { SupervisorSections } from './WebitelApplications/SupervisorSections';
|
|
13
|
+
import WebitelApplications from './WebitelApplications/WebitelApplications.enum.js';
|
|
14
|
+
import { WtApplication } from './WebitelApplications/WtApplication';
|
|
15
|
+
import { WtObject } from './WtObject/WtObject';
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
AbstractUserStatus,
|
|
19
|
+
AdminSections,
|
|
20
|
+
AgentStatus,
|
|
21
|
+
AuditorSections,
|
|
22
|
+
ChatGatewayProvider,
|
|
23
|
+
ComponentSize,
|
|
24
|
+
CrmSections,
|
|
25
|
+
CrudAction,
|
|
26
|
+
IconAction,
|
|
27
|
+
QueueType,
|
|
28
|
+
SupervisorSections,
|
|
29
|
+
TypesExportedSettings,
|
|
30
|
+
WebitelApplications,
|
|
31
|
+
WtApplication,
|
|
32
|
+
WtObject,
|
|
33
|
+
};
|
package/src/locale/en/en.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
EngineRoutingSchemaType,
|
|
7
7
|
} from 'webitel-sdk';
|
|
8
8
|
|
|
9
|
+
import { IconAction } from '../../enums';
|
|
9
10
|
import ChatGatewayProvider from '../../enums/ChatGatewayProvider/ChatGatewayProvider.enum.js';
|
|
10
|
-
import { IconAction } from '../../enums/index.js';
|
|
11
11
|
import QueueType from '../../enums/QueueType/QueueType.enum.js';
|
|
12
12
|
import AdminSections from '../../enums/WebitelApplications/AdminSections.enum.js';
|
|
13
13
|
import AuditorSections from '../../enums/WebitelApplications/AuditorSections.enum.js';
|
package/src/locale/ru/ru.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
EngineRoutingSchemaType,
|
|
7
7
|
} from 'webitel-sdk';
|
|
8
8
|
|
|
9
|
+
import { IconAction } from '../../enums';
|
|
9
10
|
import ChatGatewayProvider from '../../enums/ChatGatewayProvider/ChatGatewayProvider.enum.js';
|
|
10
|
-
import { IconAction } from '../../enums/index.js';
|
|
11
11
|
import QueueType from '../../enums/QueueType/QueueType.enum.js';
|
|
12
12
|
import AdminSections from '../../enums/WebitelApplications/AdminSections.enum.js';
|
|
13
13
|
import AuditorSections from '../../enums/WebitelApplications/AuditorSections.enum.js';
|
package/src/locale/ua/ua.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
EngineRoutingSchemaType,
|
|
7
7
|
} from 'webitel-sdk';
|
|
8
8
|
|
|
9
|
+
import { IconAction } from '../../enums';
|
|
9
10
|
import ChatGatewayProvider from '../../enums/ChatGatewayProvider/ChatGatewayProvider.enum.js';
|
|
10
|
-
import { IconAction } from '../../enums/index.js';
|
|
11
11
|
import QueueType from '../../enums/QueueType/QueueType.enum.js';
|
|
12
12
|
import AdminSections from '../../enums/WebitelApplications/AdminSections.enum.js';
|
|
13
13
|
import AuditorSections from '../../enums/WebitelApplications/AuditorSections.enum.js';
|
|
@@ -1,89 +1,138 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import {
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { computed, ref } from "vue";
|
|
3
|
+
|
|
4
|
+
import {WtTableHeader} from "../../../../components/wt-table/types/WtTable";
|
|
5
|
+
import { sortToQueryAdapter } from "../../../../scripts";
|
|
6
|
+
import { SortSymbols } from "../../../../scripts/sortQueryAdapters";
|
|
7
|
+
import { usePersistedStorage } from "../persist/usePersistedStorage.ts";
|
|
5
8
|
|
|
6
9
|
export const createTableHeadersStore = (
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
namespace: string,
|
|
11
|
+
{ headers: rawHeaders },
|
|
9
12
|
) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
13
|
+
const id = `${namespace}/headers`;
|
|
14
|
+
|
|
15
|
+
return defineStore(id, () => {
|
|
16
|
+
const headers = ref(rawHeaders);
|
|
17
|
+
|
|
18
|
+
const shownHeaders = computed(() => {
|
|
19
|
+
return headers.value.filter((header) => header.show);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const fields = computed(() => {
|
|
23
|
+
return shownHeaders.value.map((header) => header.field);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const sort = computed(() => {
|
|
27
|
+
const encodeSortQuery = ({ column, order }) =>
|
|
28
|
+
`${sortToQueryAdapter(order)}${column.field}`;
|
|
29
|
+
|
|
30
|
+
const sortedCol = headers.value.find((header) => header.sort);
|
|
31
|
+
|
|
32
|
+
return sortedCol
|
|
33
|
+
? encodeSortQuery({ column: sortedCol, order: sortedCol.sort })
|
|
34
|
+
: null;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const $reset = () => {
|
|
38
|
+
headers.value = rawHeaders;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const updateShownHeaders = (value) => {
|
|
42
|
+
headers.value = value;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const updateFields = (fields: string[]) => {
|
|
46
|
+
const newHeaders = headers.value.map((header: WtTableHeader) => {
|
|
47
|
+
return {
|
|
48
|
+
...header,
|
|
49
|
+
show: fields.includes(header.field),
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
updateShownHeaders(newHeaders);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const updateSort = (column) => {
|
|
56
|
+
const getNextSortOrder = (sort) => {
|
|
57
|
+
switch (sort) {
|
|
58
|
+
case SortSymbols.NONE:
|
|
59
|
+
return SortSymbols.ASC;
|
|
60
|
+
case SortSymbols.ASC:
|
|
61
|
+
return SortSymbols.DESC;
|
|
62
|
+
case SortSymbols.DESC:
|
|
63
|
+
return SortSymbols.NONE;
|
|
64
|
+
default:
|
|
65
|
+
return SortSymbols.ASC;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const changeHeadersSort = ({ headers, sortedHeader, order }) => {
|
|
70
|
+
return headers.map((header) => {
|
|
71
|
+
if (header.sort === undefined) return header;
|
|
72
|
+
|
|
73
|
+
// reset all headers by default
|
|
74
|
+
let newSort = null;
|
|
75
|
+
|
|
76
|
+
if (header.field === sortedHeader.field) {
|
|
77
|
+
newSort = order;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
...header,
|
|
82
|
+
sort: newSort,
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const order = getNextSortOrder(column.sort);
|
|
88
|
+
|
|
89
|
+
const newHeaders = changeHeadersSort({
|
|
90
|
+
headers: headers.value,
|
|
91
|
+
sortedHeader: column,
|
|
92
|
+
order,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
headers.value = newHeaders;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const setupPersistence = async () => {
|
|
99
|
+
const { restore: restoreFields } = usePersistedStorage({
|
|
100
|
+
name: "fields",
|
|
101
|
+
value: fields,
|
|
102
|
+
onStore: (save, { name }) => {
|
|
103
|
+
const value = fields.value.join(',');
|
|
104
|
+
return save({ name, value })
|
|
105
|
+
},
|
|
106
|
+
onRestore: async (restore, name) => {
|
|
107
|
+
const value = await restore(name) as string;
|
|
108
|
+
if (value) {
|
|
109
|
+
return updateFields(value.split(','));
|
|
110
|
+
}
|
|
59
111
|
}
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
...header,
|
|
63
|
-
sort: newSort,
|
|
64
|
-
};
|
|
65
112
|
});
|
|
66
|
-
};
|
|
67
113
|
|
|
68
|
-
|
|
114
|
+
const { restore: restoreSort } = usePersistedStorage({
|
|
115
|
+
name: "sort",
|
|
116
|
+
value: sort,
|
|
117
|
+
});
|
|
69
118
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
119
|
+
return Promise.allSettled([
|
|
120
|
+
restoreFields(),
|
|
121
|
+
restoreSort(),
|
|
122
|
+
]);
|
|
123
|
+
};
|
|
75
124
|
|
|
76
|
-
|
|
77
|
-
|
|
125
|
+
return {
|
|
126
|
+
headers,
|
|
127
|
+
shownHeaders,
|
|
128
|
+
fields,
|
|
129
|
+
sort,
|
|
78
130
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
shownHeaders,
|
|
82
|
-
fields,
|
|
83
|
-
sort,
|
|
131
|
+
updateShownHeaders,
|
|
132
|
+
updateSort,
|
|
84
133
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
134
|
+
setupPersistence,
|
|
135
|
+
$reset,
|
|
136
|
+
};
|
|
137
|
+
});
|
|
89
138
|
};
|
|
@@ -72,11 +72,6 @@ export const usePersistedStorage = ({
|
|
|
72
72
|
so that onStore is called only once on each value change
|
|
73
73
|
*/
|
|
74
74
|
const save = async ({ name, value: storedValue }) => {
|
|
75
|
-
// await Promise.allSettled(
|
|
76
|
-
// setItemFns.map((setItem) => {
|
|
77
|
-
// return setItem({ name, value: storedValue });
|
|
78
|
-
// }),
|
|
79
|
-
// );
|
|
80
75
|
setItemFns.forEach((setter) => {
|
|
81
76
|
setter(name, storedValue);
|
|
82
77
|
});
|