@webitel/ui-sdk 24.10.30 → 24.10.32
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/ui-sdk.js +2637 -2637
- package/dist/ui-sdk.umd.cjs +16 -16
- package/package.json +1 -1
- package/src/api/crm/contactChatMessagesHistory.js +22 -4
- package/src/locale/en/en.js +4 -0
- package/src/locale/ru/ru.js +3 -0
- package/src/locale/ua/ua.js +3 -0
- package/src/modules/Filters/classes/BaseFilterSchema.js +1 -3
- package/src/modules/Filters/components/filter-select.vue +118 -0
- package/src/modules/Filters/store/FiltersStoreModule.js +24 -35
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
getDefaultInstance,
|
|
5
5
|
getDefaultOpenAPIConfig,
|
|
6
6
|
} from '../defaults/index.js';
|
|
7
|
-
import applyTransform, { notify, snakeToCamel, merge } from '../transformers/index.js';
|
|
7
|
+
import applyTransform, { notify, snakeToCamel, merge, sanitize } from '../transformers/index.js';
|
|
8
8
|
|
|
9
9
|
const instance = getDefaultInstance();
|
|
10
10
|
const configuration = getDefaultOpenAPIConfig();
|
|
@@ -33,7 +33,8 @@ const getChat = async ({ contactId, chatId }) => {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
// all messages from all contacts chats
|
|
36
|
-
const getAllMessages = async (
|
|
36
|
+
const getAllMessages = async (params) => {
|
|
37
|
+
|
|
37
38
|
const mergeMessagesData = ({ messages, peers, chats }) => {
|
|
38
39
|
return messages.map(({ from, chat, ...message }) => {
|
|
39
40
|
return {
|
|
@@ -44,8 +45,20 @@ const getAllMessages = async ({ id }) => {
|
|
|
44
45
|
});
|
|
45
46
|
};
|
|
46
47
|
|
|
48
|
+
const {
|
|
49
|
+
contactId,
|
|
50
|
+
page,
|
|
51
|
+
size,
|
|
52
|
+
} = params;
|
|
53
|
+
|
|
47
54
|
try {
|
|
48
|
-
const response = await contactChatService.getContactChatHistory2(
|
|
55
|
+
const response = await contactChatService.getContactChatHistory2(
|
|
56
|
+
contactId,
|
|
57
|
+
undefined,
|
|
58
|
+
undefined,
|
|
59
|
+
size,
|
|
60
|
+
`${page || 1}`,
|
|
61
|
+
);
|
|
49
62
|
const { messages, peers, chats, next } = applyTransform(response.data, [
|
|
50
63
|
snakeToCamel(),
|
|
51
64
|
merge(getDefaultGetListResponse()),
|
|
@@ -55,7 +68,12 @@ const getAllMessages = async ({ id }) => {
|
|
|
55
68
|
next,
|
|
56
69
|
};
|
|
57
70
|
} catch (err) {
|
|
58
|
-
throw applyTransform(err, [
|
|
71
|
+
throw applyTransform(err, [
|
|
72
|
+
notify(({ callback }) => callback({
|
|
73
|
+
type: 'error',
|
|
74
|
+
text: t('errorNotifications.chatHistoryApi'),
|
|
75
|
+
})),
|
|
76
|
+
]);
|
|
59
77
|
}
|
|
60
78
|
};
|
|
61
79
|
|
package/src/locale/en/en.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
ChannelType,
|
|
6
6
|
EngineRoutingSchemaType,
|
|
7
7
|
} from 'webitel-sdk';
|
|
8
|
+
import { notify } from '../../api/transformers/index.js';
|
|
8
9
|
import ChatGatewayProvider from '../../enums/ChatGatewayProvider/ChatGatewayProvider.enum.js';
|
|
9
10
|
import QueueType from '../../enums/QueueType/QueueType.enum.js';
|
|
10
11
|
import AdminSections from '../../enums/WebitelApplications/AdminSections.enum.js';
|
|
@@ -385,4 +386,7 @@ export default {
|
|
|
385
386
|
exportToJson: 'Export to JSON',
|
|
386
387
|
},
|
|
387
388
|
},
|
|
389
|
+
errorNotifications: {
|
|
390
|
+
chatHistoryApi: 'There was an error loading the chat history',
|
|
391
|
+
},
|
|
388
392
|
};
|
package/src/locale/ru/ru.js
CHANGED
package/src/locale/ua/ua.js
CHANGED
|
@@ -88,8 +88,8 @@ export default class BaseFilterSchema {
|
|
|
88
88
|
{
|
|
89
89
|
name,
|
|
90
90
|
value,
|
|
91
|
-
defaultValue,
|
|
92
91
|
multiple,
|
|
92
|
+
defaultValue: defaultValue || value,
|
|
93
93
|
},
|
|
94
94
|
rest,
|
|
95
95
|
);
|
|
@@ -97,8 +97,6 @@ export default class BaseFilterSchema {
|
|
|
97
97
|
this.setupGetters(get);
|
|
98
98
|
this.setupSetters(set);
|
|
99
99
|
this.setupRestores(restore);
|
|
100
|
-
|
|
101
|
-
return this;
|
|
102
100
|
}
|
|
103
101
|
|
|
104
102
|
setupGetters(getters) {
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<wt-select
|
|
3
|
+
:close-on-select="!filterSchema.multiple"
|
|
4
|
+
:multiple="filterSchema.multiple"
|
|
5
|
+
:options="options"
|
|
6
|
+
:track-by="trackBy"
|
|
7
|
+
:value="value"
|
|
8
|
+
:search-method="search"
|
|
9
|
+
v-bind="attrs"
|
|
10
|
+
@input="setValue"
|
|
11
|
+
/>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup>
|
|
15
|
+
|
|
16
|
+
import { computed, reactive, ref, useAttrs, watch } from 'vue';
|
|
17
|
+
import { useI18n } from 'vue-i18n';
|
|
18
|
+
import { useStore } from 'vuex';
|
|
19
|
+
import isEmpty from '../../../scripts/isEmpty.js';
|
|
20
|
+
import getNamespacedState from '../../../store/helpers/getNamespacedState.js';
|
|
21
|
+
|
|
22
|
+
const props = defineProps({
|
|
23
|
+
namespace: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
filterQuery: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const attrs = useAttrs();
|
|
34
|
+
const store = useStore();
|
|
35
|
+
const { t } = useI18n();
|
|
36
|
+
|
|
37
|
+
const filterSchema = computed(() => getNamespacedState(store.state, props.namespace)[props.filterQuery]);
|
|
38
|
+
|
|
39
|
+
const trackBy = computed(() => {
|
|
40
|
+
if (filterSchema.value.storedProp !== undefined) {
|
|
41
|
+
return filterSchema.value.storedProp;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (filterSchema.value.search) {
|
|
45
|
+
return 'id';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (filterSchema.value.options) {
|
|
49
|
+
return 'value';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return 'id';
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const rawValue = computed(() => store.getters[`${props.namespace}/FILTER_${props.filterQuery}`]);
|
|
56
|
+
|
|
57
|
+
const cachedSearchOpts = reactive({});
|
|
58
|
+
|
|
59
|
+
const search = filterSchema.value.search && (async (selectParams) => {
|
|
60
|
+
const params = {
|
|
61
|
+
...selectParams,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
if (trackBy.value === 'id') {
|
|
65
|
+
params.ids = Array.isArray(rawValue.value) ? rawValue.value : [rawValue.value];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const { items, ...rest } = await filterSchema.value.search(params);
|
|
69
|
+
|
|
70
|
+
items.forEach((item) => {
|
|
71
|
+
cachedSearchOpts[item.id] = item;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
items,
|
|
76
|
+
...rest,
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const options = computed(() => {
|
|
81
|
+
const options = filterSchema.value.options;
|
|
82
|
+
|
|
83
|
+
return options;
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const value = computed(() => {
|
|
87
|
+
if (options.value) {
|
|
88
|
+
if (filterSchema.value.multiple) {
|
|
89
|
+
return options.value.filter((option) => rawValue.value.includes(option[trackBy.value]));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return options.value.find((option) => option[trackBy.value] === rawValue.value);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (filterSchema.value.search) {
|
|
96
|
+
if (filterSchema.value.multiple) {
|
|
97
|
+
return rawValue.value.map((value) => cachedSearchOpts[value]);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return cachedSearchOpts[rawValue.value];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return rawValue.value;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const setValue = (value) => {
|
|
107
|
+
const payload = {
|
|
108
|
+
value: isEmpty(value) ? value : value[trackBy.value],
|
|
109
|
+
name: props.filterQuery,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return store.dispatch(`${props.namespace}/SET_FILTER`, payload);
|
|
113
|
+
};
|
|
114
|
+
</script>
|
|
115
|
+
|
|
116
|
+
<style scoped>
|
|
117
|
+
|
|
118
|
+
</style>
|
|
@@ -8,14 +8,12 @@ import FilterEvent from '../enums/FilterEvent.enum.js';
|
|
|
8
8
|
export default class FiltersStoreModule extends BaseStoreModule {
|
|
9
9
|
state = {
|
|
10
10
|
_emitter: mitt(),
|
|
11
|
-
_requireRouter: false,
|
|
12
11
|
};
|
|
13
12
|
|
|
14
13
|
getters = {
|
|
15
14
|
ROUTER: (state, g, rootState) => {
|
|
16
|
-
if (!state._requireRouter) return null;
|
|
17
15
|
if (rootState.router === undefined) {
|
|
18
|
-
|
|
16
|
+
console.warn(
|
|
19
17
|
'"rootState.router" is needed for filters to work properly.' +
|
|
20
18
|
' Please, provide to root state, or setup it in filters module as getter "ROUTER"',
|
|
21
19
|
);
|
|
@@ -36,10 +34,6 @@ export default class FiltersStoreModule extends BaseStoreModule {
|
|
|
36
34
|
|
|
37
35
|
if (!filter) throw new Error(`Unknown filter: ${filterName}`);
|
|
38
36
|
|
|
39
|
-
if (state._requireRouter && !getters.ROUTER) {
|
|
40
|
-
throw new Error(`Router is required for filter: ${filterName}`);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
37
|
return filter.get({
|
|
44
38
|
router: getters.ROUTER,
|
|
45
39
|
});
|
|
@@ -137,13 +131,15 @@ export default class FiltersStoreModule extends BaseStoreModule {
|
|
|
137
131
|
|
|
138
132
|
// clean up query params
|
|
139
133
|
const router = context.getters.ROUTER;
|
|
140
|
-
const query = Object.entries(router.currentRoute.query)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
134
|
+
const query = Object.entries(router.currentRoute.query).reduce(
|
|
135
|
+
(filteredQuery, [qKey, qValue]) => {
|
|
136
|
+
if (context.state[qKey]) {
|
|
137
|
+
return filteredQuery;
|
|
138
|
+
}
|
|
139
|
+
return { ...filteredQuery, [qKey]: qValue };
|
|
140
|
+
},
|
|
141
|
+
{},
|
|
142
|
+
);
|
|
147
143
|
|
|
148
144
|
await router.push({
|
|
149
145
|
...router.currentRoute,
|
|
@@ -167,26 +163,19 @@ export default class FiltersStoreModule extends BaseStoreModule {
|
|
|
167
163
|
},
|
|
168
164
|
|
|
169
165
|
EMIT: async (context, { event, payload }) => {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const eventListeners = context.state._emitter.all.get(event);
|
|
166
|
+
const wildcardListeners = context.state._emitter.all.get('*');
|
|
167
|
+
const eventListeners = context.state._emitter.all.get(event);
|
|
173
168
|
|
|
174
|
-
|
|
169
|
+
const listeners = [...(wildcardListeners || []), ...(eventListeners || [])];
|
|
175
170
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
171
|
+
if (!listeners) {
|
|
172
|
+
console.info(`No listeners for ${event} event`);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
180
175
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
resolve();
|
|
186
|
-
} catch (err) {
|
|
187
|
-
reject(err);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
176
|
+
for (const listener of listeners) {
|
|
177
|
+
await listener({ event, payload });
|
|
178
|
+
}
|
|
190
179
|
},
|
|
191
180
|
};
|
|
192
181
|
|
|
@@ -198,13 +187,13 @@ export default class FiltersStoreModule extends BaseStoreModule {
|
|
|
198
187
|
|
|
199
188
|
addFilter(filter) {
|
|
200
189
|
const setup = (filter) => {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
this.state[filter.name] = stateFilter;
|
|
190
|
+
this.state[filter.name] = new BaseFilterSchema(filter);
|
|
191
|
+
|
|
204
192
|
this.getters[`FILTER_${filter.name}`] = (state, getters) => {
|
|
205
193
|
// if is used as watcher for getter to recompute,
|
|
206
194
|
// because GET_FILTER is function ==> it's not reactive
|
|
207
|
-
if (state[filter.name].value) {
|
|
195
|
+
if (state[filter.name].value) {
|
|
196
|
+
}
|
|
208
197
|
return getters.GET_FILTER(filter.name);
|
|
209
198
|
};
|
|
210
199
|
};
|