@webitel/ui-sdk 24.10.3 → 24.10.5
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.css +1 -1
- package/dist/ui-sdk.js +111 -114
- package/dist/ui-sdk.umd.cjs +8 -8
- package/package.json +6 -4
- package/src/api/axios/generateInstance.js +1 -4
- package/src/api/clients/agents/agents.js +31 -78
- package/src/api/clients/buckets/buckets.js +17 -57
- package/src/api/clients/calendars/calendars.js +18 -71
- package/src/api/clients/chatGateways/chatGateways.js +23 -61
- package/src/api/clients/chatGateways/defaults/webChatGateway.js +6 -8
- package/src/api/clients/chatGateways/enums/WebchatAlternativeChannel.enum.js +3 -3
- package/src/api/clients/communications/communications.js +20 -62
- package/src/api/clients/configurations/configurations.js +18 -3
- package/src/api/clients/flows/flow.js +17 -60
- package/src/api/clients/gateways/gateways.js +20 -59
- package/src/api/clients/index.js +1 -1
- package/src/api/clients/lists/blacklists.js +18 -60
- package/src/api/clients/media/media.js +13 -43
- package/src/api/clients/queues/defaults/processing.js +10 -6
- package/src/api/clients/queues/queues.js +21 -69
- package/src/api/clients/roles/roles.js +15 -33
- package/src/api/clients/users/__tests__/users.spec.js +43 -26
- package/src/api/clients/users/users.js +21 -56
- package/src/api/crm/contactChatMessagesHistory.js +8 -23
- package/src/api/crm/contacts.js +235 -0
- package/src/api/crm/enums/ContactsSearchMode.js +9 -0
- package/src/api/crm/index.js +2 -3
- package/src/api/defaults/getDefaultGetParams/getDefaultGetParams.js +1 -4
- package/src/api/defaults/getDefaultInstance/getDefaultInstance.js +10 -11
- package/src/api/defaults/getDefaultOpenAPIConfig/getDefaultOpenAPIConfig.js +6 -5
- package/src/api/defaults/index.js +2 -4
- package/src/api/history/index.js +1 -3
- package/src/api/history/transcript/callTranscript.js +10 -30
- package/src/api/interceptors/request/updateToken.interceptor.js +1 -2
- package/src/api/transformers/merge/merge.transformer.js +4 -1
- package/src/api/transformers/mergeEach/mergeEach.transformer.js +4 -4
- package/src/api/transformers/notify/notify.transformer.js +9 -6
- package/src/api/transformers/starToSearch/starToSearch.transformer.js +8 -6
- package/src/components/index.js +3 -6
- package/src/components/on-demand/wt-cc-agent-status-timers/__tests__/wt-cc-agent-status-timers.spec.js +2 -4
- package/src/components/transitions/wt-expand-transition.vue +2 -3
- package/src/components/wt-app-header/__tests__/WtAppNavigator.spec.js +1 -2
- package/src/components/wt-app-header/__tests__/WtHeaderActions.spec.js +1 -2
- package/src/components/wt-app-header/wt-app-navigator.vue +15 -9
- package/src/components/wt-avatar/wt-avatar.vue +8 -3
- package/src/components/wt-button/wt-button.vue +0 -1
- package/src/components/wt-button-select/__tests__/WtButtonSelect.spec.js +4 -5
- package/src/components/wt-button-select/wt-button-select.vue +0 -1
- package/src/components/wt-context-menu/wt-context-menu.vue +32 -35
- package/src/components/wt-dummy/wt-dummy.vue +2 -5
- package/src/components/wt-expansion-panel/wt-expansion-panel.vue +10 -7
- package/src/components/wt-filters-panel-wrapper/__tests__/WtFiltersPanelWrapper.spec.js +4 -8
- package/src/components/wt-icon/wt-icon.vue +0 -1
- package/src/components/wt-indicator/__tests__/WtIndicator.spec.js +3 -2
- package/src/components/wt-indicator/wt-indicator.vue +10 -1
- package/src/components/wt-input/wt-input.vue +7 -10
- package/src/components/wt-item-link/wt-item-link.vue +7 -4
- package/src/components/wt-navigation-bar/__tests__/WtNavigationBar.spec.js +7 -15
- package/src/components/wt-navigation-bar/wt-navigation-bar.vue +7 -7
- package/src/components/wt-notification/wt-notification.vue +1 -2
- package/src/components/wt-notifications-bar/__tests__/WtNotificationsBar.spec.js +6 -3
- package/src/components/wt-notifications-bar/wt-notifications-bar.vue +4 -1
- package/src/components/wt-page-wrapper/__tests__/WtPageWrapper.spec.js +1 -2
- package/src/components/wt-pagination/wt-pagination.vue +1 -3
- package/src/components/wt-player/scripts/__tests__/createPlyrURL.spec.js +4 -8
- package/src/components/wt-player/wt-player.vue +13 -4
- package/src/components/wt-popup/wt-popup.vue +2 -1
- package/src/components/wt-search-bar/wt-search-bar.vue +1 -1
- package/src/components/wt-select/mixins/multiselectMixin.js +2 -5
- package/src/components/wt-select/wt-select.vue +12 -11
- package/src/components/wt-slider/wt-slider.vue +4 -2
- package/src/components/wt-status-select/wt-status-select.vue +10 -6
- package/src/components/wt-stepper/wt-stepper.vue +6 -4
- package/src/components/wt-switcher/wt-switcher.vue +1 -3
- package/src/components/wt-table/__tests__/WtTable.spec.js +2 -5
- package/src/components/wt-table/wt-table.vue +18 -16
- package/src/components/wt-table-column-select/wt-table-column-select.vue +9 -8
- package/src/components/wt-tabs/wt-tabs.vue +1 -3
- package/src/components/wt-tags-input/mixin/taggableMixin.js +7 -7
- package/src/components/wt-textarea/__tests__/WtTextarea.spec.js +2 -4
- package/src/components/wt-textarea/wt-textarea.vue +3 -2
- package/src/components/wt-timepicker/wt-timepicker.vue +1 -3
- package/src/components/wt-tooltip/_internals/useTooltipTriggerSubscriptions.js +1 -3
- package/src/components/wt-tooltip/_internals/wt-tooltip-floating.vue +8 -12
- package/src/components/wt-tooltip/wt-tooltip.vue +13 -13
- package/src/composables/useCachedInterval/__tests__/useCachedInterval.spec.js +6 -4
- package/src/composables/useCachedInterval/useCachedInterval.js +3 -8
- package/src/composables/useRepresentableAgentPauseCause/__tests__/useRepresentableAgentPauseCause.spec.js +11 -33
- package/src/composables/useRepresentableAgentPauseCause/useRepresentableAgentPauseCause.js +11 -9
- package/src/enums/WebitelApplications/AdminSections.enum.js +28 -28
- package/src/enums/WebitelApplications/CrmSections.enum.js +1 -1
- package/src/locale/en/en.js +12 -15
- package/src/locale/es/es.js +4 -8
- package/src/locale/kz/kz.js +5 -7
- package/src/locale/ru/ru.js +7 -11
- package/src/locale/ua/ua.js +13 -17
- package/src/mixins/dataFilterMixins/__tests__/enumFilterMixin.spec.js +1 -2
- package/src/mixins/dataFilterMixins/__tests__/sortFilterMixin.spec.js +4 -2
- package/src/mixins/dataFilterMixins/__tests__/urlControllerMixin.spec.js +4 -1
- package/src/mixins/dataFilterMixins/_urlControllerMixin/_urlControllerMixin.js +1 -1
- package/src/mixins/dataFilterMixins/apiFilterMixin.js +1 -2
- package/src/mixins/dataFilterMixins/baseFilterMixin/baseFilterMixin.js +1 -2
- package/src/mixins/dataFilterMixins/enumFilterMixin.js +5 -6
- package/src/mixins/dataFilterMixins/paginationFilterMixin.js +1 -2
- package/src/mixins/dataFilterMixins/sortFilterMixin.js +1 -4
- package/src/mixins/validationMixin/__tests__/validationMixin.spec.js +1 -2
- package/src/mixins/validationMixin/useValidation.js +25 -19
- package/src/mixins/validationMixin/validationMixin.js +22 -10
- package/src/modules/AgentStatusSelect/api/pause-cause.js +3 -11
- package/src/modules/AgentStatusSelect/components/__tests__/wt-cc-agent-status-select.spec.js +16 -18
- package/src/modules/AgentStatusSelect/components/__tests__/wt-cc-pause-cause-popup.spec.js +1 -2
- package/src/modules/AgentStatusSelect/components/_internals/wt-cc-pause-cause-popup.vue +12 -12
- package/src/modules/AgentStatusSelect/components/_internals/wt-cc-status-select-error-popup.vue +0 -1
- package/src/modules/AgentStatusSelect/components/wt-cc-agent-status-select.vue +20 -7
- package/src/modules/Appearance/components/__tests__/wt-dark-mode-switcher.spec.js +2 -4
- package/src/modules/Appearance/components/wt-dark-mode-switcher.vue +0 -1
- package/src/modules/AuditForm/components/__tests__/audit-form-question-read-wrapper.spec.js +1 -2
- package/src/modules/AuditForm/components/__tests__/audit-form-question-write-wrapper.spec.js +15 -25
- package/src/modules/AuditForm/components/__tests__/audit-form.spec.js +11 -20
- package/src/modules/AuditForm/components/audit-form-question-read-wrapper.vue +1 -4
- package/src/modules/AuditForm/components/audit-form-question-write-wrapper.vue +4 -7
- package/src/modules/AuditForm/components/audit-form-question.vue +18 -17
- package/src/modules/AuditForm/components/audit-form.vue +12 -14
- package/src/modules/AuditForm/components/questions/options/__tests__/audit-form-question-options-write-row.spec.js +1 -2
- package/src/modules/AuditForm/components/questions/options/__tests__/audit-form-question-options.spec.js +1 -3
- package/src/modules/AuditForm/components/questions/options/audit-form-question-options-write-row.vue +11 -15
- package/src/modules/AuditForm/components/questions/options/audit-form-question-options.vue +1 -4
- package/src/modules/AuditForm/components/questions/score/audit-form-question-score.vue +16 -20
- package/src/modules/AuditForm/schemas/AuditFormQuestionOptionsSchema.js +1 -3
- package/src/modules/CSVExport/CSVExport.js +3 -7
- package/src/modules/CSVExport/XLSExport.js +6 -7
- package/src/modules/CSVExport/__tests__/CSVExport.spec.js +1 -2
- package/src/modules/CSVExport/mixins/exportCSVMixin.js +2 -5
- package/src/modules/CSVExport/mixins/exportXLSMixin.js +2 -4
- package/src/modules/CardStoreModule/store/CardStoreModule.js +2 -6
- package/src/modules/DeleteConfirmationPopup/__tests__/delete-confirmation-popup.spec.js +13 -10
- package/src/modules/DeleteConfirmationPopup/components/delete-confirmation-popup.vue +5 -14
- package/src/modules/FilesExport/FilesExport.js +4 -3
- package/src/modules/FilesExport/__tests__/FilesExport.spec.js +12 -12
- package/src/modules/FilesExport/mixins/exportFilesMixin.js +6 -7
- package/src/modules/FilesExport/scripts/generateMediaURL.js +1 -2
- package/src/modules/Filters/classes/BaseFilterSchema.js +21 -25
- package/src/modules/Filters/components/filter-pagination.vue +7 -3
- package/src/modules/Filters/components/filter-search.vue +21 -12
- package/src/modules/Filters/components/filter-table-fields.vue +1 -3
- package/src/modules/Filters/scripts/getters/index.js +1 -5
- package/src/modules/Filters/scripts/getters/queryGetter.js +2 -3
- package/src/modules/Filters/scripts/restores/index.js +1 -4
- package/src/modules/Filters/scripts/setters/index.js +1 -5
- package/src/modules/Filters/scripts/setters/querySetter.js +24 -22
- package/src/modules/Filters/scripts/utils/changeRouteQuery.js +16 -15
- package/src/modules/Filters/store/FiltersStoreModule.js +51 -45
- package/src/modules/Filters/store/__tests__/FiltersStoreModule.spec.js +51 -45
- package/src/modules/Notifications/store/NotificationsStoreModule.js +41 -38
- package/src/modules/Notifications/store/__tests__/NotificationsStoreModule.actions.spec.js +6 -6
- package/src/modules/QueryFilters/api/defaults.js +2 -3
- package/src/modules/QueryFilters/classes/ApiFilterSchema.js +1 -4
- package/src/modules/QueryFilters/classes/EnumFilterSchema.js +1 -4
- package/src/modules/QueryFilters/components/__tests__/filter-datetime.spec.js +1 -2
- package/src/modules/QueryFilters/components/__tests__/filter-from-to.spec.js +2 -4
- package/src/modules/QueryFilters/components/__tests__/filter-search.spec.js +2 -4
- package/src/modules/QueryFilters/components/filter-table-fields.vue +1 -5
- package/src/modules/QueryFilters/mixins/__tests__/apiFilterMixin.spec.js +4 -3
- package/src/modules/QueryFilters/mixins/__tests__/enumFilterMixin.spec.js +2 -4
- package/src/modules/QueryFilters/mixins/__tests__/sortFilterMixin.spec.js +4 -2
- package/src/modules/QueryFilters/mixins/__tests__/urlControllerMixin.spec.js +4 -1
- package/src/modules/QueryFilters/mixins/_urlControllerMixin/_urlControllerMixin.js +1 -1
- package/src/modules/QueryFilters/mixins/apiFilterMixin.js +1 -1
- package/src/modules/QueryFilters/mixins/baseFilterMixin/baseFilterMixin.js +4 -2
- package/src/modules/QueryFilters/mixins/enumFilterMixin.js +9 -11
- package/src/modules/QueryFilters/mixins/paginationFilterMixin.js +2 -4
- package/src/modules/QueryFilters/mixins/sortFilterMixin.js +2 -5
- package/src/modules/QueryFilters/store/QueryFiltersStoreModule.js +13 -17
- package/src/modules/QueryFilters/store/__tests__/QueryFiltersStoreModule.spec.js +15 -16
- package/src/modules/TableStoreModule/store/TableStoreModule.js +14 -33
- package/src/modules/TableStoreModule/store/__tests__/TableStoreModule.spec.js +69 -83
- package/src/modules/Userinfo/api/userinfo.js +6 -19
- package/src/modules/Userinfo/classes/ApplicationsAccess.js +5 -12
- package/src/modules/Userinfo/store/UserinfoStoreModule.js +38 -41
- package/src/plugins/breakpoint/breakpoint.plugin.js +11 -16
- package/src/scripts/__tests__/caseConverters.spec.js +1 -4
- package/src/scripts/__tests__/debounce.spec.js +3 -1
- package/src/scripts/__tests__/prettifyFileSize.spec.js +2 -2
- package/src/scripts/__tests__/preventHiddenPageCallsDecorator.spec.js +7 -4
- package/src/scripts/__tests__/updateObject.spec.js +3 -5
- package/src/scripts/caseConverters.js +22 -38
- package/src/scripts/debounce.js +1 -5
- package/src/scripts/editProxy.js +8 -7
- package/src/scripts/prettifyFileSize.js +1 -1
- package/src/scripts/preventHiddenPageCallsDecorator.js +3 -6
- package/src/store/BaseStoreModules/ApiStoreModule.js +7 -33
- package/src/store/BaseStoreModules/BaseStoreModule.js +14 -23
- package/src/store/BaseStoreModules/__tests__/BaseStoreModule.spec.js +7 -28
- package/src/store/helpers/getNamespacedState.js +2 -4
- package/src/store/new/modules/apiStoreModule/apiStoreModule.js +7 -27
- package/src/store/new/modules/cardStoreModule/cardStoreModule.js +0 -1
- package/src/store/new/modules/tableStoreModule/__tests__/tableStoreModule.spec.js +64 -77
- package/src/store/new/modules/tableStoreModule/tableStoreModule.js +12 -29
- package/src/tests/mocks/axiosMock.js +25 -19
- package/src/validators/decimalValidator.js +5 -4
- package/src/validators/websocketValidator/__tests__/websocketValidator.spec.js +1 -2
- package/src/validators/websocketValidator/websocketValidator.js +1 -1
|
@@ -35,9 +35,7 @@ export default {
|
|
|
35
35
|
if (optsHaveLocale) {
|
|
36
36
|
return this.options.map((opt) => ({
|
|
37
37
|
...opt,
|
|
38
|
-
name: Array.isArray(opt.locale)
|
|
39
|
-
? this.$tc(...opt.locale)
|
|
40
|
-
: this.$t(opt.locale),
|
|
38
|
+
name: Array.isArray(opt.locale) ? this.$tc(...opt.locale) : this.$t(opt.locale),
|
|
41
39
|
}));
|
|
42
40
|
}
|
|
43
41
|
return this.options;
|
|
@@ -50,9 +48,9 @@ export default {
|
|
|
50
48
|
/*
|
|
51
49
|
restore not just value, but value with all client-side properties like locale
|
|
52
50
|
*/
|
|
53
|
-
newValue = this.localizedOptions
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
newValue = this.localizedOptions.filter((option) =>
|
|
52
|
+
value.some((value) => value === option[this.storedProp]),
|
|
53
|
+
);
|
|
56
54
|
|
|
57
55
|
/*
|
|
58
56
|
but if allowCustomValues is true, we should also restore custom values,
|
|
@@ -61,17 +59,17 @@ export default {
|
|
|
61
59
|
if (this.allowCustomValues) {
|
|
62
60
|
newValue = newValue.concat(
|
|
63
61
|
value
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
.filter(
|
|
63
|
+
(val) => !this.localizedOptions.some((option) => val === option[this.storedProp]),
|
|
64
|
+
)
|
|
65
|
+
.map((val) => ({ [this.storedProp]: val, name: val })),
|
|
67
66
|
);
|
|
68
67
|
}
|
|
69
68
|
} else {
|
|
70
69
|
/*
|
|
71
70
|
see comments above
|
|
72
71
|
*/
|
|
73
|
-
newValue = this.localizedOptions
|
|
74
|
-
.find((option) => value === option[this.storedProp]);
|
|
72
|
+
newValue = this.localizedOptions.find((option) => value === option[this.storedProp]);
|
|
75
73
|
if (this.allowCustomValues) {
|
|
76
74
|
newValue = newValue || { [this.storedProp]: value, name: value };
|
|
77
75
|
}
|
|
@@ -24,15 +24,13 @@ export default {
|
|
|
24
24
|
|
|
25
25
|
restorePage() {
|
|
26
26
|
const defaultPage = 1;
|
|
27
|
-
const value = +this.getValueFromQuery({ filterQuery: 'page' }) ||
|
|
28
|
-
defaultPage;
|
|
27
|
+
const value = +this.getValueFromQuery({ filterQuery: 'page' }) || defaultPage;
|
|
29
28
|
this.setPage(value);
|
|
30
29
|
},
|
|
31
30
|
|
|
32
31
|
restoreSize() {
|
|
33
32
|
const defaultSize = 10;
|
|
34
|
-
const value = +this.getValueFromQuery({ filterQuery: 'size' }) ||
|
|
35
|
-
defaultSize;
|
|
33
|
+
const value = +this.getValueFromQuery({ filterQuery: 'size' }) || defaultSize;
|
|
36
34
|
this.setSize(value);
|
|
37
35
|
},
|
|
38
36
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
queryToSortAdapter,
|
|
3
2
|
SortSymbols,
|
|
3
|
+
queryToSortAdapter,
|
|
4
4
|
sortToQueryAdapter,
|
|
5
5
|
} from '../../../scripts/sortQueryAdapters.js';
|
|
6
6
|
import baseFilterMixin from './baseFilterMixin/baseFilterMixin.js';
|
|
@@ -18,10 +18,7 @@ const getNextSortOrder = (sort) => {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const encodeSortQuery = ({
|
|
22
|
-
column,
|
|
23
|
-
order,
|
|
24
|
-
}) => (`${sortToQueryAdapter(order)}${column.field}`);
|
|
21
|
+
const encodeSortQuery = ({ column, order }) => `${sortToQueryAdapter(order)}${column.field}`;
|
|
25
22
|
|
|
26
23
|
const decodeSortQuery = ({ value }) => {
|
|
27
24
|
const sort = queryToSortAdapter(value.slice(0, 1));
|
|
@@ -3,14 +3,16 @@ import BaseStoreModule from '../../../store/BaseStoreModules/BaseStoreModule.js'
|
|
|
3
3
|
|
|
4
4
|
export default class QueryFiltersStoreModule extends BaseStoreModule {
|
|
5
5
|
getters = {
|
|
6
|
-
GET_FILTERS: (state, getters) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
GET_FILTERS: (state, getters) =>
|
|
7
|
+
Object.keys(state).reduce((filters, filterKey) => {
|
|
8
|
+
const filterValue = getters.GET_FILTER(filterKey);
|
|
9
|
+
return isEmpty(filterValue)
|
|
10
|
+
? filters
|
|
11
|
+
: {
|
|
12
|
+
...filters,
|
|
13
|
+
[filterKey]: filterValue,
|
|
14
|
+
};
|
|
15
|
+
}, {}),
|
|
14
16
|
GET_FILTER: (state) => (filter) => {
|
|
15
17
|
const { value, storedProp, multiple } = state[filter];
|
|
16
18
|
if (multiple) return value.map((item) => item[storedProp]); // if arr, map
|
|
@@ -25,8 +27,7 @@ export default class QueryFiltersStoreModule extends BaseStoreModule {
|
|
|
25
27
|
let newValue = value;
|
|
26
28
|
if (newValue) {
|
|
27
29
|
if (multiple && !Array.isArray(newValue)) newValue = [newValue];
|
|
28
|
-
} else if (newValue === null || newValue ===
|
|
29
|
-
undefined) newValue = defaultValue;
|
|
30
|
+
} else if (newValue === null || newValue === undefined) newValue = defaultValue;
|
|
30
31
|
context.commit('SET_FILTER', { filter, value: newValue });
|
|
31
32
|
},
|
|
32
33
|
RESET_FILTERS: (context) => {
|
|
@@ -46,16 +47,11 @@ export default class QueryFiltersStoreModule extends BaseStoreModule {
|
|
|
46
47
|
};
|
|
47
48
|
|
|
48
49
|
/* FIXME REMOVE COMPLETELY AND USE GET_MODULE() INSERTION*/
|
|
49
|
-
constructor({
|
|
50
|
-
state = {},
|
|
51
|
-
getters = {},
|
|
52
|
-
actions = {},
|
|
53
|
-
mutations = {},
|
|
54
|
-
} = {}) {
|
|
50
|
+
constructor({ state = {}, getters = {}, actions = {}, mutations = {} } = {}) {
|
|
55
51
|
super();
|
|
56
52
|
this.state = { ...this.state, ...state };
|
|
57
53
|
this.getters = { ...this.getters, ...getters };
|
|
58
54
|
this.actions = { ...this.actions, ...actions };
|
|
59
55
|
this.mutations = { ...this.mutations, ...mutations };
|
|
60
|
-
}
|
|
56
|
+
}
|
|
61
57
|
}
|
|
@@ -24,18 +24,18 @@ describe('QueryFiltersStoreModule getters', () => {
|
|
|
24
24
|
module = new QueryFiltersStoreModule().getModule();
|
|
25
25
|
});
|
|
26
26
|
it('GET_FILTER: single value filter', () => {
|
|
27
|
-
expect(module.getters.GET_FILTER(state)(valueFilter))
|
|
28
|
-
.toEqual('jest');
|
|
27
|
+
expect(module.getters.GET_FILTER(state)(valueFilter)).toEqual('jest');
|
|
29
28
|
});
|
|
30
29
|
it('GET_FILTER: array value filter', () => {
|
|
31
|
-
expect(module.getters.GET_FILTER(state)(arrayFilter))
|
|
32
|
-
.toEqual([1]);
|
|
30
|
+
expect(module.getters.GET_FILTER(state)(arrayFilter)).toEqual([1]);
|
|
33
31
|
});
|
|
34
32
|
it('GET_FILTERS filters aggregator', () => {
|
|
35
33
|
const { GET_FILTER } = module.getters;
|
|
36
34
|
module.getters.GET_FILTER = vi.fn((filter) => GET_FILTER(state)(filter));
|
|
37
|
-
expect(module.getters.GET_FILTERS(state, module.getters))
|
|
38
|
-
|
|
35
|
+
expect(module.getters.GET_FILTERS(state, module.getters)).toEqual({
|
|
36
|
+
agent: [1],
|
|
37
|
+
search: 'jest',
|
|
38
|
+
});
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
41
|
|
|
@@ -58,8 +58,7 @@ describe('QueryFiltersStoreModule actions', () => {
|
|
|
58
58
|
it('SET_FILTER: array value filter with single object value', () => {
|
|
59
59
|
const filter = { filter: arrayFilter, value: { id: 3 } };
|
|
60
60
|
module.actions.SET_FILTER(context, filter);
|
|
61
|
-
expect(context.commit)
|
|
62
|
-
.toHaveBeenCalledWith('SET_FILTER', {
|
|
61
|
+
expect(context.commit).toHaveBeenCalledWith('SET_FILTER', {
|
|
63
62
|
filter: filter.filter,
|
|
64
63
|
value: [filter.value],
|
|
65
64
|
});
|
|
@@ -67,14 +66,12 @@ describe('QueryFiltersStoreModule actions', () => {
|
|
|
67
66
|
it('SET_FILTER: sets array value filter with null value to defaultValue', () => {
|
|
68
67
|
const filter = { filter: arrayFilter, value: null };
|
|
69
68
|
module.actions.SET_FILTER(context, filter);
|
|
70
|
-
expect(context.commit)
|
|
71
|
-
.toHaveBeenCalledWith('SET_FILTER', { filter: filter.filter, value: [] });
|
|
69
|
+
expect(context.commit).toHaveBeenCalledWith('SET_FILTER', { filter: filter.filter, value: [] });
|
|
72
70
|
});
|
|
73
71
|
it('SET_FILTER: sets "false" value filter', () => {
|
|
74
72
|
const filter = { filter: valueFilter, value: false };
|
|
75
73
|
module.actions.SET_FILTER(context, filter);
|
|
76
|
-
expect(context.commit)
|
|
77
|
-
.toHaveBeenCalledWith('SET_FILTER', {
|
|
74
|
+
expect(context.commit).toHaveBeenCalledWith('SET_FILTER', {
|
|
78
75
|
filter: filter.filter,
|
|
79
76
|
value: false,
|
|
80
77
|
});
|
|
@@ -88,10 +85,12 @@ describe('QueryFiltersStoreModule actions', () => {
|
|
|
88
85
|
describe('QueryFiltersStoreModule mutations', () => {
|
|
89
86
|
const module = new QueryFiltersStoreModule().getModule();
|
|
90
87
|
it('correctly mutates state at RESET_FILTERS call', () => {
|
|
91
|
-
expect(
|
|
92
|
-
|
|
88
|
+
expect(
|
|
89
|
+
Object.values(state).every((filter) => filter.value === filter.defaultValue),
|
|
90
|
+
).toBeFalsy();
|
|
93
91
|
module.mutations.RESET_FILTERS(state);
|
|
94
|
-
expect(
|
|
95
|
-
|
|
92
|
+
expect(
|
|
93
|
+
Object.values(state).every((filter) => filter.value === filter.defaultValue),
|
|
94
|
+
).toBeTruthy();
|
|
96
95
|
});
|
|
97
96
|
});
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
sortToQueryAdapter,
|
|
4
|
-
} from '../../../scripts/sortQueryAdapters.js';
|
|
5
|
-
import BaseStoreModule
|
|
6
|
-
from '../../../store/BaseStoreModules/BaseStoreModule.js';
|
|
1
|
+
import { queryToSortAdapter, sortToQueryAdapter } from '../../../scripts/sortQueryAdapters.js';
|
|
2
|
+
import BaseStoreModule from '../../../store/BaseStoreModules/BaseStoreModule.js';
|
|
7
3
|
import FilterEvent from '../../Filters/enums/FilterEvent.enum.js';
|
|
8
4
|
|
|
9
5
|
export default class TableStoreModule extends BaseStoreModule {
|
|
@@ -48,10 +44,7 @@ export default class TableStoreModule extends BaseStoreModule {
|
|
|
48
44
|
|
|
49
45
|
actions = {
|
|
50
46
|
// FIXME: maybe move to filters module?
|
|
51
|
-
SET_FILTER: (
|
|
52
|
-
context,
|
|
53
|
-
payload,
|
|
54
|
-
) => context.dispatch('filters/SET_FILTER', payload),
|
|
47
|
+
SET_FILTER: (context, payload) => context.dispatch('filters/SET_FILTER', payload),
|
|
55
48
|
|
|
56
49
|
// FIXME: maybe move to filters module?
|
|
57
50
|
ON_FILTER_EVENT: async (context, { event, payload }) => {
|
|
@@ -66,10 +59,7 @@ export default class TableStoreModule extends BaseStoreModule {
|
|
|
66
59
|
},
|
|
67
60
|
|
|
68
61
|
// FIXME: maybe move to filters module?
|
|
69
|
-
HANDLE_FILTERS_RESTORE: async (context, {
|
|
70
|
-
fields,
|
|
71
|
-
sort,
|
|
72
|
-
}) => {
|
|
62
|
+
HANDLE_FILTERS_RESTORE: async (context, { fields, sort }) => {
|
|
73
63
|
if (sort) await context.dispatch('HANDLE_SORT_CHANGE', { value: sort });
|
|
74
64
|
if (fields?.length) await context.dispatch('HANDLE_FIELDS_CHANGE', { value: fields });
|
|
75
65
|
return context.dispatch('LOAD_DATA_LIST');
|
|
@@ -109,10 +99,7 @@ export default class TableStoreModule extends BaseStoreModule {
|
|
|
109
99
|
const nextSort = queryToSortAdapter(value?.slice(0, 1) || '');
|
|
110
100
|
const field = nextSort ? value.slice(1) : value;
|
|
111
101
|
|
|
112
|
-
const headers = context.state.headers.map(({
|
|
113
|
-
sort: currentSort,
|
|
114
|
-
...header
|
|
115
|
-
}) => {
|
|
102
|
+
const headers = context.state.headers.map(({ sort: currentSort, ...header }) => {
|
|
116
103
|
let sort;
|
|
117
104
|
|
|
118
105
|
if (field) {
|
|
@@ -133,10 +120,10 @@ export default class TableStoreModule extends BaseStoreModule {
|
|
|
133
120
|
|
|
134
121
|
const params = context.getters.GET_LIST_PARAMS(query);
|
|
135
122
|
try {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
123
|
+
const { items = [], next = false } = await context.dispatch('api/GET_LIST', {
|
|
124
|
+
context,
|
|
125
|
+
params,
|
|
126
|
+
});
|
|
140
127
|
|
|
141
128
|
context.commit('SET', { path: 'dataList', value: items });
|
|
142
129
|
context.commit('SET', { path: 'isNextPage', value: next });
|
|
@@ -159,9 +146,7 @@ export default class TableStoreModule extends BaseStoreModule {
|
|
|
159
146
|
});
|
|
160
147
|
},
|
|
161
148
|
|
|
162
|
-
PATCH_ITEM_PROPERTY: async (context, {
|
|
163
|
-
item: _item, index, prop, value,
|
|
164
|
-
}) => {
|
|
149
|
+
PATCH_ITEM_PROPERTY: async (context, { item: _item, index, prop, value }) => {
|
|
165
150
|
const item = _item || context.state.dataList[index];
|
|
166
151
|
|
|
167
152
|
const { id, etag } = item;
|
|
@@ -200,8 +185,7 @@ export default class TableStoreModule extends BaseStoreModule {
|
|
|
200
185
|
await context.dispatch('LOAD_DATA_LIST');
|
|
201
186
|
|
|
202
187
|
/* if no items on current page after DELETE, move to prev page [WTEL-3793] */
|
|
203
|
-
if (!context.state.dataList.length && context.getters.FILTERS.page >
|
|
204
|
-
1) {
|
|
188
|
+
if (!context.state.dataList.length && context.getters.FILTERS.page > 1) {
|
|
205
189
|
await context.dispatch('SET_FILTER', {
|
|
206
190
|
name: 'page',
|
|
207
191
|
value: context.getters.FILTERS.page - 1,
|
|
@@ -218,18 +202,15 @@ export default class TableStoreModule extends BaseStoreModule {
|
|
|
218
202
|
}
|
|
219
203
|
},
|
|
220
204
|
|
|
221
|
-
DELETE_BULK: async (
|
|
222
|
-
context,
|
|
223
|
-
deleted,
|
|
224
|
-
) => Promise.allSettled(deleted.map((item) => context.dispatch('DELETE_SINGLE', item))),
|
|
205
|
+
DELETE_BULK: async (context, deleted) =>
|
|
206
|
+
Promise.allSettled(deleted.map((item) => context.dispatch('DELETE_SINGLE', item))),
|
|
225
207
|
|
|
226
208
|
SET_SELECTED: (context, selected) => {
|
|
227
209
|
context.commit('SET', { path: 'selected', value: selected });
|
|
228
210
|
},
|
|
229
211
|
};
|
|
230
212
|
|
|
231
|
-
mutations = {
|
|
232
|
-
};
|
|
213
|
+
mutations = {};
|
|
233
214
|
|
|
234
215
|
constructor({ headers = [] }) {
|
|
235
216
|
super();
|
|
@@ -15,8 +15,7 @@ describe('TableStoreModule', () => {
|
|
|
15
15
|
|
|
16
16
|
const state = { headers };
|
|
17
17
|
|
|
18
|
-
expect(new TableStoreModule({}).getters.FIELDS(state))
|
|
19
|
-
.toEqual(['id', 'age']);
|
|
18
|
+
expect(new TableStoreModule({}).getters.FIELDS(state)).toEqual(['id', 'age']);
|
|
20
19
|
});
|
|
21
20
|
});
|
|
22
21
|
|
|
@@ -28,24 +27,22 @@ describe('TableStoreModule integration with FiltersStoreModule', () => {
|
|
|
28
27
|
|
|
29
28
|
it('filters restore event triggers LOAD_DATA_LIST', async () => {
|
|
30
29
|
const filters = new FiltersStoreModule()
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const table = new TableStoreModule({})
|
|
42
|
-
.getModule({
|
|
30
|
+
.addFilter({
|
|
31
|
+
name: 'vi',
|
|
32
|
+
value: 23,
|
|
33
|
+
defaultValue: 23,
|
|
34
|
+
get: ['value'],
|
|
35
|
+
set: ['value'],
|
|
36
|
+
restore: () => 'vivi',
|
|
37
|
+
})
|
|
38
|
+
.getModule();
|
|
39
|
+
|
|
40
|
+
const table = new TableStoreModule({}).getModule({
|
|
43
41
|
modules: { filters },
|
|
44
42
|
});
|
|
45
43
|
|
|
46
44
|
const mock = vi.fn();
|
|
47
|
-
vi.spyOn(table.actions, 'LOAD_DATA_LIST')
|
|
48
|
-
.mockImplementationOnce(mock);
|
|
45
|
+
vi.spyOn(table.actions, 'LOAD_DATA_LIST').mockImplementationOnce(mock);
|
|
49
46
|
|
|
50
47
|
const store = createStore({
|
|
51
48
|
state: { router },
|
|
@@ -66,24 +63,22 @@ describe('TableStoreModule integration with FiltersStoreModule', () => {
|
|
|
66
63
|
|
|
67
64
|
it('FILTER_SET event triggers LOAD_DATA_LIST', async () => {
|
|
68
65
|
const filters = new FiltersStoreModule()
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const table = new TableStoreModule({})
|
|
80
|
-
.getModule({
|
|
66
|
+
.addFilter({
|
|
67
|
+
name: 'vi',
|
|
68
|
+
value: 23,
|
|
69
|
+
defaultValue: 23,
|
|
70
|
+
get: ['value'],
|
|
71
|
+
set: ['value'],
|
|
72
|
+
restore: () => {},
|
|
73
|
+
})
|
|
74
|
+
.getModule();
|
|
75
|
+
|
|
76
|
+
const table = new TableStoreModule({}).getModule({
|
|
81
77
|
modules: { filters },
|
|
82
78
|
});
|
|
83
79
|
|
|
84
80
|
const mock = vi.fn();
|
|
85
|
-
vi.spyOn(table.actions, 'LOAD_DATA_LIST')
|
|
86
|
-
.mockImplementationOnce(mock);
|
|
81
|
+
vi.spyOn(table.actions, 'LOAD_DATA_LIST').mockImplementationOnce(mock);
|
|
87
82
|
|
|
88
83
|
const store = createStore({
|
|
89
84
|
state: { router },
|
|
@@ -109,33 +104,31 @@ describe('TableStoreModule integration with FiltersStoreModule', () => {
|
|
|
109
104
|
|
|
110
105
|
it('FILTER_SET with not-page filter name resets page filter', async () => {
|
|
111
106
|
const filters = new FiltersStoreModule()
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const table = new TableStoreModule({})
|
|
133
|
-
.getModule({
|
|
107
|
+
.addFilter([
|
|
108
|
+
{
|
|
109
|
+
name: 'vi',
|
|
110
|
+
value: 23,
|
|
111
|
+
defaultValue: 23,
|
|
112
|
+
get: ['value'],
|
|
113
|
+
set: ['value'],
|
|
114
|
+
restore: () => {},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'page',
|
|
118
|
+
value: 12,
|
|
119
|
+
defaultValue: 12,
|
|
120
|
+
get: ['value'],
|
|
121
|
+
set: ['value'],
|
|
122
|
+
restore: () => {},
|
|
123
|
+
},
|
|
124
|
+
])
|
|
125
|
+
.getModule();
|
|
126
|
+
|
|
127
|
+
const table = new TableStoreModule({}).getModule({
|
|
134
128
|
modules: { filters },
|
|
135
129
|
});
|
|
136
130
|
|
|
137
|
-
vi.spyOn(table.actions, 'LOAD_DATA_LIST')
|
|
138
|
-
.mockImplementationOnce(vi.fn());
|
|
131
|
+
vi.spyOn(table.actions, 'LOAD_DATA_LIST').mockImplementationOnce(vi.fn());
|
|
139
132
|
|
|
140
133
|
const store = createStore({
|
|
141
134
|
state: { router },
|
|
@@ -161,26 +154,22 @@ describe('TableStoreModule integration with FiltersStoreModule', () => {
|
|
|
161
154
|
|
|
162
155
|
it('SORT changes both headers and sort filter', async () => {
|
|
163
156
|
const filters = new FiltersStoreModule()
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
157
|
+
.addFilter({
|
|
158
|
+
name: 'sort',
|
|
159
|
+
value: '',
|
|
160
|
+
get: ['value'],
|
|
161
|
+
set: ['value'],
|
|
162
|
+
restore: () => {},
|
|
163
|
+
})
|
|
164
|
+
.getModule();
|
|
172
165
|
|
|
173
|
-
const headers = [
|
|
174
|
-
{ value: 'id', field: 'sort_me', sort: SortSymbols.NONE },
|
|
175
|
-
];
|
|
166
|
+
const headers = [{ value: 'id', field: 'sort_me', sort: SortSymbols.NONE }];
|
|
176
167
|
|
|
177
|
-
const table = new TableStoreModule({ headers })
|
|
178
|
-
.getModule({
|
|
168
|
+
const table = new TableStoreModule({ headers }).getModule({
|
|
179
169
|
modules: { filters },
|
|
180
170
|
});
|
|
181
171
|
|
|
182
|
-
vi.spyOn(table.actions, 'LOAD_DATA_LIST')
|
|
183
|
-
.mockImplementationOnce(vi.fn());
|
|
172
|
+
vi.spyOn(table.actions, 'LOAD_DATA_LIST').mockImplementationOnce(vi.fn());
|
|
184
173
|
|
|
185
174
|
const store = createStore({
|
|
186
175
|
state: { router },
|
|
@@ -206,27 +195,25 @@ describe('TableStoreModule integration with FiltersStoreModule', () => {
|
|
|
206
195
|
|
|
207
196
|
it('fields filter change changes headers', async () => {
|
|
208
197
|
const filters = new FiltersStoreModule()
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
198
|
+
.addFilter({
|
|
199
|
+
name: 'fields',
|
|
200
|
+
value: [],
|
|
201
|
+
get: ['value'],
|
|
202
|
+
set: ['value'],
|
|
203
|
+
restore: () => {},
|
|
204
|
+
})
|
|
205
|
+
.getModule();
|
|
217
206
|
|
|
218
207
|
const headers = [
|
|
219
208
|
{ value: 'surname', field: 'included', show: false },
|
|
220
209
|
{ value: 'name', field: 'excluded', show: true },
|
|
221
210
|
];
|
|
222
211
|
|
|
223
|
-
const table = new TableStoreModule({ headers })
|
|
224
|
-
.getModule({
|
|
212
|
+
const table = new TableStoreModule({ headers }).getModule({
|
|
225
213
|
modules: { filters },
|
|
226
214
|
});
|
|
227
215
|
|
|
228
|
-
vi.spyOn(table.actions, 'LOAD_DATA_LIST')
|
|
229
|
-
.mockImplementationOnce(vi.fn());
|
|
216
|
+
vi.spyOn(table.actions, 'LOAD_DATA_LIST').mockImplementationOnce(vi.fn());
|
|
230
217
|
|
|
231
218
|
const store = createStore({
|
|
232
219
|
state: { router },
|
|
@@ -243,8 +230,7 @@ describe('TableStoreModule integration with FiltersStoreModule', () => {
|
|
|
243
230
|
value: ['surname'],
|
|
244
231
|
});
|
|
245
232
|
|
|
246
|
-
expect(store.getters['table/filters/GET_FILTER']('fields'))
|
|
247
|
-
.toEqual(['surname']);
|
|
233
|
+
expect(store.getters['table/filters/GET_FILTER']('fields')).toEqual(['surname']);
|
|
248
234
|
|
|
249
235
|
expect(store.getters['table/FIELDS']).toEqual(['id', 'included']);
|
|
250
236
|
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import applyTransform, {
|
|
2
|
-
notify,
|
|
3
|
-
snakeToCamel,
|
|
4
|
-
} from '../../../api/transformers/index.js';
|
|
1
|
+
import applyTransform, { notify, snakeToCamel } from '../../../api/transformers/index.js';
|
|
5
2
|
|
|
6
3
|
const userinfo = (instance) => ({
|
|
7
4
|
async getSession() {
|
|
8
5
|
const url = '/userinfo';
|
|
9
6
|
try {
|
|
10
7
|
const response = await instance.get(url);
|
|
11
|
-
return applyTransform(response.data, [
|
|
12
|
-
snakeToCamel(),
|
|
13
|
-
]);
|
|
8
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
14
9
|
} catch (err) {
|
|
15
|
-
throw applyTransform(err, [
|
|
16
|
-
notify,
|
|
17
|
-
]);
|
|
10
|
+
throw applyTransform(err, [notify]);
|
|
18
11
|
}
|
|
19
12
|
},
|
|
20
13
|
|
|
@@ -22,13 +15,9 @@ const userinfo = (instance) => ({
|
|
|
22
15
|
const url = 'role/metadata/access';
|
|
23
16
|
try {
|
|
24
17
|
const response = await instance.get(url);
|
|
25
|
-
return applyTransform(response.data, [
|
|
26
|
-
snakeToCamel(),
|
|
27
|
-
]);
|
|
18
|
+
return applyTransform(response.data, [snakeToCamel()]);
|
|
28
19
|
} catch (err) {
|
|
29
|
-
throw applyTransform(err, [
|
|
30
|
-
notify,
|
|
31
|
-
]);
|
|
20
|
+
throw applyTransform(err, [notify]);
|
|
32
21
|
}
|
|
33
22
|
},
|
|
34
23
|
|
|
@@ -38,9 +27,7 @@ const userinfo = (instance) => ({
|
|
|
38
27
|
try {
|
|
39
28
|
return await instance.post(url, {});
|
|
40
29
|
} catch (err) {
|
|
41
|
-
throw applyTransform(err, [
|
|
42
|
-
notify,
|
|
43
|
-
]);
|
|
30
|
+
throw applyTransform(err, [notify]);
|
|
44
31
|
}
|
|
45
32
|
},
|
|
46
33
|
});
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import deepCopy from 'deep-copy';
|
|
2
2
|
import deepmerge from 'deepmerge';
|
|
3
|
-
import AdminSections
|
|
4
|
-
|
|
5
|
-
import AuditorSections
|
|
6
|
-
from '../../../enums/WebitelApplications/AuditorSections.enum.js';
|
|
3
|
+
import AdminSections from '../../../enums/WebitelApplications/AdminSections.enum.js';
|
|
4
|
+
import AuditorSections from '../../../enums/WebitelApplications/AuditorSections.enum.js';
|
|
7
5
|
import CrmSections from '../../../enums/WebitelApplications/CrmSections.enum.js';
|
|
8
|
-
import SupervisorSections
|
|
9
|
-
|
|
10
|
-
import WebitelApplications
|
|
11
|
-
from '../../../enums/WebitelApplications/WebitelApplications.enum.js';
|
|
6
|
+
import SupervisorSections from '../../../enums/WebitelApplications/SupervisorSections.enum.js';
|
|
7
|
+
import WebitelApplications from '../../../enums/WebitelApplications/WebitelApplications.enum.js';
|
|
12
8
|
|
|
13
9
|
const applicationsAccess = (value = true) => ({
|
|
14
10
|
[WebitelApplications.AGENT]: {
|
|
@@ -196,16 +192,13 @@ export default class ApplicationsAccess {
|
|
|
196
192
|
constructor({ access, value } = { value: true }) {
|
|
197
193
|
/* if access, deeply merge with falsy values schema
|
|
198
194
|
if no access, "not configured => full permissions" */
|
|
199
|
-
this.access = access
|
|
200
|
-
? ApplicationsAccess.restore(access)
|
|
201
|
-
: applicationsAccess(value);
|
|
195
|
+
this.access = access ? ApplicationsAccess.restore(access) : applicationsAccess(value);
|
|
202
196
|
}
|
|
203
197
|
|
|
204
198
|
// minify schema for API sending
|
|
205
199
|
static minify(access) {
|
|
206
200
|
const rmEmptyKeys = (obj) => {
|
|
207
201
|
Object.keys(obj).forEach((key) => {
|
|
208
|
-
|
|
209
202
|
if (!obj[key] || key === '_locale') delete obj[key];
|
|
210
203
|
if (typeof obj[key] === 'object') {
|
|
211
204
|
rmEmptyKeys(obj[key]);
|