@webitel/ui-sdk 24.10.3 → 24.10.4
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/index.js +1 -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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CallActions, ChatActions, JobState } from 'webitel-sdk';
|
|
2
2
|
import i18n from '../../../locale/i18n.js';
|
|
3
3
|
import BaseStoreModule from '../../../store/BaseStoreModules/BaseStoreModule.js';
|
|
4
|
-
import endChatSound from '../assets/audio/end-chat.wav';
|
|
5
4
|
import endCallSound from '../assets/audio/end-call.mp3';
|
|
5
|
+
import endChatSound from '../assets/audio/end-chat.wav';
|
|
6
6
|
import newChatSound from '../assets/audio/new-chat.wav';
|
|
7
7
|
import newMessageSound from '../assets/audio/new-message.wav';
|
|
8
8
|
import ringingSound from '../assets/audio/ringing.mp3';
|
|
@@ -45,8 +45,7 @@ export default class NotificationsStoreModule extends BaseStoreModule {
|
|
|
45
45
|
|
|
46
46
|
getters = {
|
|
47
47
|
IS_MAIN_TAB: (state) => state.thisTabId === state.currentTabId,
|
|
48
|
-
IS_SOUND_ALLOWED: (state, getters) => getters.IS_MAIN_TAB &&
|
|
49
|
-
!state.currentlyPlaying,
|
|
48
|
+
IS_SOUND_ALLOWED: (state, getters) => getters.IS_MAIN_TAB && !state.currentlyPlaying,
|
|
50
49
|
};
|
|
51
50
|
|
|
52
51
|
actions = {
|
|
@@ -102,32 +101,30 @@ export default class NotificationsStoreModule extends BaseStoreModule {
|
|
|
102
101
|
},
|
|
103
102
|
|
|
104
103
|
// public
|
|
105
|
-
INITIALIZE: (context) =>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
DESTROY: (context) =>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
PLAY_SOUND: (context, {
|
|
119
|
-
|
|
120
|
-
sound = getNotificationSound(action),
|
|
121
|
-
}) => {
|
|
122
|
-
if (context.getters.IS_SOUND_ALLOWED
|
|
123
|
-
&& !localStorage.getItem('wtIsPlaying')
|
|
124
|
-
) {
|
|
125
|
-
|
|
104
|
+
INITIALIZE: (context) =>
|
|
105
|
+
Promise.allSettled([
|
|
106
|
+
context.dispatch('_SETUP_THIS_TAB_ID'),
|
|
107
|
+
context.dispatch('_SETUP_UNREAD_COUND_BROADCAST_LISTENING'),
|
|
108
|
+
context.dispatch('_SUBSCRIBE_TAB_CLOSING'),
|
|
109
|
+
]),
|
|
110
|
+
|
|
111
|
+
DESTROY: (context) =>
|
|
112
|
+
Promise.allSettled([
|
|
113
|
+
context.dispatch('STOP_SOUND'),
|
|
114
|
+
context.dispatch('_REMOVE_CURRENT_TAB_ID'),
|
|
115
|
+
]),
|
|
116
|
+
|
|
117
|
+
PLAY_SOUND: (context, { action, sound = getNotificationSound(action) }) => {
|
|
118
|
+
if (context.getters.IS_SOUND_ALLOWED && !localStorage.getItem('wtIsPlaying')) {
|
|
126
119
|
const audio = sound instanceof Audio ? sound : new Audio(sound);
|
|
127
120
|
|
|
128
|
-
audio.addEventListener(
|
|
129
|
-
|
|
130
|
-
|
|
121
|
+
audio.addEventListener(
|
|
122
|
+
'ended',
|
|
123
|
+
() => {
|
|
124
|
+
context.dispatch('STOP_SOUND');
|
|
125
|
+
},
|
|
126
|
+
{ once: true },
|
|
127
|
+
);
|
|
131
128
|
|
|
132
129
|
if (action === CallActions.Ringing) audio.loop = true;
|
|
133
130
|
|
|
@@ -139,23 +136,29 @@ export default class NotificationsStoreModule extends BaseStoreModule {
|
|
|
139
136
|
|
|
140
137
|
STOP_SOUND: (context) => {
|
|
141
138
|
const { currentlyPlaying } = context.state;
|
|
142
|
-
if (currentlyPlaying && currentlyPlaying instanceof
|
|
143
|
-
Audio) currentlyPlaying.pause();
|
|
139
|
+
if (currentlyPlaying && currentlyPlaying instanceof Audio) currentlyPlaying.pause();
|
|
144
140
|
localStorage.removeItem('wtIsPlaying');
|
|
145
141
|
context.commit('RESET_CURRENTLY_PLAYING');
|
|
146
142
|
},
|
|
147
143
|
|
|
148
|
-
SEND_NOTIFICATION: (
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
144
|
+
SEND_NOTIFICATION: (
|
|
145
|
+
context,
|
|
146
|
+
{
|
|
147
|
+
locale,
|
|
148
|
+
text = i18n.t(locale),
|
|
149
|
+
icon = notificationIcon,
|
|
150
|
+
interval = NOTIFICATION_VISIBLE_INTERVAL,
|
|
151
|
+
},
|
|
152
|
+
) => {
|
|
154
153
|
const notification = new Notification(text, { icon });
|
|
155
154
|
|
|
156
|
-
notification.addEventListener(
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
notification.addEventListener(
|
|
156
|
+
'click',
|
|
157
|
+
() => {
|
|
158
|
+
window.focus();
|
|
159
|
+
},
|
|
160
|
+
{ once: true },
|
|
161
|
+
);
|
|
159
162
|
|
|
160
163
|
setTimeout(() => {
|
|
161
164
|
notification.close();
|
|
@@ -38,8 +38,7 @@ describe('features/notifications store: actions', () => {
|
|
|
38
38
|
|
|
39
39
|
it('INITIALIZE action dispatches _SETUP_UNREAD_COUND_BROADCAST_LISTENING action', () => {
|
|
40
40
|
notificationsModule.actions.INITIALIZE(context);
|
|
41
|
-
expect(context.dispatch.mock.calls[1][0])
|
|
42
|
-
.toContain('_SETUP_UNREAD_COUND_BROADCAST_LISTENING');
|
|
41
|
+
expect(context.dispatch.mock.calls[1][0]).toContain('_SETUP_UNREAD_COUND_BROADCAST_LISTENING');
|
|
43
42
|
});
|
|
44
43
|
|
|
45
44
|
it('INITIALIZE action dispatches _SETUP_THIS_TAB_ID action', () => {
|
|
@@ -59,8 +58,10 @@ describe('features/notifications store: actions', () => {
|
|
|
59
58
|
|
|
60
59
|
it('INCREMENT_UNREAD_COUNT action dispatches _SET_UNREAD_COUNT and increases unreadCount', () => {
|
|
61
60
|
notificationsModule.actions.INCREMENT_UNREAD_COUNT(context);
|
|
62
|
-
expect(context.dispatch)
|
|
63
|
-
|
|
61
|
+
expect(context.dispatch).toHaveBeenCalledWith(
|
|
62
|
+
'_SET_UNREAD_COUNT',
|
|
63
|
+
context.state.unreadCount + 1,
|
|
64
|
+
);
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
it('_SETUP_UNREAD_COUND_BROADCAST_LISTENING action commits SET_BROADCAST_CHANNEL mutation', () => {
|
|
@@ -99,8 +100,7 @@ describe('features/notifications store: actions', () => {
|
|
|
99
100
|
it('_SET_UNREAD_COUNT action commits _SET_UNREAD_COUNT mutation with count', () => {
|
|
100
101
|
const unreadCount = 5;
|
|
101
102
|
notificationsModule.actions._SET_UNREAD_COUNT(context, unreadCount);
|
|
102
|
-
expect(context.commit)
|
|
103
|
-
.toHaveBeenCalledWith('SET_UNREAD_COUNT', unreadCount);
|
|
103
|
+
expect(context.commit).toHaveBeenCalledWith('SET_UNREAD_COUNT', unreadCount);
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
it('_RESET_UNREAD_COUNT action does not dispatch if unread count is 0', () => {
|
|
@@ -2,10 +2,7 @@ import BaseFilterSchema from './BaseFilterSchema.js';
|
|
|
2
2
|
|
|
3
3
|
export default class ApiFilterSchema extends BaseFilterSchema {
|
|
4
4
|
constructor(params = {}) {
|
|
5
|
-
const {
|
|
6
|
-
value = [],
|
|
7
|
-
defaultValue = [],
|
|
8
|
-
} = params;
|
|
5
|
+
const { value = [], defaultValue = [] } = params;
|
|
9
6
|
super({ value, defaultValue });
|
|
10
7
|
const {
|
|
11
8
|
locale = { label: 'filter' },
|
|
@@ -2,10 +2,7 @@ import BaseFilterSchema from './BaseFilterSchema.js';
|
|
|
2
2
|
|
|
3
3
|
export default class EnumFilterSchema extends BaseFilterSchema {
|
|
4
4
|
constructor(params = {}) {
|
|
5
|
-
const {
|
|
6
|
-
value = [],
|
|
7
|
-
defaultValue = [],
|
|
8
|
-
} = params;
|
|
5
|
+
const { value = [], defaultValue = [] } = params;
|
|
9
6
|
super({ value, defaultValue });
|
|
10
7
|
const {
|
|
11
8
|
locale = { label: 'filter' },
|
|
@@ -42,8 +42,7 @@ describe('DatetimeFilter Filter', () => {
|
|
|
42
42
|
const value = Date.now();
|
|
43
43
|
await router.replace({ query: { [filterQuery]: value } });
|
|
44
44
|
const setValueMock = vi.fn();
|
|
45
|
-
vi.spyOn(baseFilterMixin.methods, 'setValue')
|
|
46
|
-
.mockImplementationOnce(setValueMock);
|
|
45
|
+
vi.spyOn(baseFilterMixin.methods, 'setValue').mockImplementationOnce(setValueMock);
|
|
47
46
|
shallowMount(DatetimeFilter, mountOptions);
|
|
48
47
|
expect(setValueMock).toHaveBeenCalledWith({ filter: filterQuery, value });
|
|
49
48
|
});
|
|
@@ -40,8 +40,7 @@ describe('FilterFromTo Filter', () => {
|
|
|
40
40
|
const value = 10;
|
|
41
41
|
await router.replace({ query: { [`${filterQuery}From`]: value } });
|
|
42
42
|
const setValueMock = vi.fn();
|
|
43
|
-
vi.spyOn(baseFilterMixin.methods, 'setValue')
|
|
44
|
-
.mockImplementation(setValueMock);
|
|
43
|
+
vi.spyOn(baseFilterMixin.methods, 'setValue').mockImplementation(setValueMock);
|
|
45
44
|
shallowMount(FilterFromTo, mountOptions);
|
|
46
45
|
expect(setValueMock).toHaveBeenNthCalledWith(1, {
|
|
47
46
|
filter: filterQuery,
|
|
@@ -52,8 +51,7 @@ describe('FilterFromTo Filter', () => {
|
|
|
52
51
|
const value = 10;
|
|
53
52
|
await router.replace({ query: { [`${filterQuery}To`]: value } });
|
|
54
53
|
const setValueMock = vi.fn();
|
|
55
|
-
vi.spyOn(baseFilterMixin.methods, 'setValue')
|
|
56
|
-
.mockImplementation(setValueMock);
|
|
54
|
+
vi.spyOn(baseFilterMixin.methods, 'setValue').mockImplementation(setValueMock);
|
|
57
55
|
shallowMount(FilterFromTo, mountOptions);
|
|
58
56
|
expect(setValueMock).toHaveBeenNthCalledWith(2, {
|
|
59
57
|
filter: filterQuery,
|
|
@@ -40,10 +40,8 @@ describe('Search Filter', () => {
|
|
|
40
40
|
const search = 'jest';
|
|
41
41
|
await router.replace({ query: { [filterQuery]: search } });
|
|
42
42
|
const setValueMock = vi.fn();
|
|
43
|
-
vi.spyOn(baseFilterMixin.methods, 'setValue')
|
|
44
|
-
.mockImplementationOnce(setValueMock);
|
|
43
|
+
vi.spyOn(baseFilterMixin.methods, 'setValue').mockImplementationOnce(setValueMock);
|
|
45
44
|
shallowMount(SearchFilter, mountOptions);
|
|
46
|
-
expect(setValueMock)
|
|
47
|
-
.toHaveBeenCalledWith({ filter: filterQuery, value: search });
|
|
45
|
+
expect(setValueMock).toHaveBeenCalledWith({ filter: filterQuery, value: search });
|
|
48
46
|
});
|
|
49
47
|
});
|
|
@@ -84,11 +84,7 @@ export default {
|
|
|
84
84
|
|
|
85
85
|
// copy-pasted params from "setValueArrayToQuery method
|
|
86
86
|
// for easier future refactors, if method should be abstract
|
|
87
|
-
setToLocalStorage({
|
|
88
|
-
filterQuery,
|
|
89
|
-
value,
|
|
90
|
-
storedProp = 'id',
|
|
91
|
-
}) {
|
|
87
|
+
setToLocalStorage({ filterQuery, value, storedProp = 'id' }) {
|
|
92
88
|
const filter = value.map((item) => item[storedProp]);
|
|
93
89
|
localStorage.setItem(`${this.entity}-${filterQuery}`, filter);
|
|
94
90
|
},
|
|
@@ -20,7 +20,9 @@ describe('API filter mixin', () => {
|
|
|
20
20
|
filterQuery: 'team',
|
|
21
21
|
}),
|
|
22
22
|
computed: {
|
|
23
|
-
filterSchema() {
|
|
23
|
+
filterSchema() {
|
|
24
|
+
return filterSchema;
|
|
25
|
+
},
|
|
24
26
|
},
|
|
25
27
|
methods: { setValue },
|
|
26
28
|
};
|
|
@@ -35,8 +37,7 @@ describe('API filter mixin', () => {
|
|
|
35
37
|
const wrapper = shallowMount(Component, {
|
|
36
38
|
global: { plugins: [router] },
|
|
37
39
|
});
|
|
38
|
-
expect(setValue)
|
|
39
|
-
.toHaveBeenCalledWith({
|
|
40
|
+
expect(setValue).toHaveBeenCalledWith({
|
|
40
41
|
filter: 'team',
|
|
41
42
|
value: [{ id: team[0] }, { id: team[1] }],
|
|
42
43
|
});
|
|
@@ -21,8 +21,7 @@ const router = createRouter({
|
|
|
21
21
|
describe('Enum filter mixin', () => {
|
|
22
22
|
const setValue = vi.fn();
|
|
23
23
|
const Component = {
|
|
24
|
-
render() {
|
|
25
|
-
},
|
|
24
|
+
render() {},
|
|
26
25
|
mixins: [enumFilterMixin],
|
|
27
26
|
data: () => ({
|
|
28
27
|
filterQuery: 'direction',
|
|
@@ -43,8 +42,7 @@ describe('Enum filter mixin', () => {
|
|
|
43
42
|
global: { plugins: [router] },
|
|
44
43
|
});
|
|
45
44
|
await wrapper.vm.$nextTick();
|
|
46
|
-
expect(setValue)
|
|
47
|
-
.toHaveBeenCalledWith({ filter: 'direction', value: options[0] });
|
|
45
|
+
expect(setValue).toHaveBeenCalledWith({ filter: 'direction', value: options[0] });
|
|
48
46
|
});
|
|
49
47
|
|
|
50
48
|
it('Sets empty array value if $route query is empty', async () => {
|
|
@@ -13,7 +13,8 @@ const headers = [
|
|
|
13
13
|
show: true,
|
|
14
14
|
sort: null,
|
|
15
15
|
field: 'queue',
|
|
16
|
-
},
|
|
16
|
+
},
|
|
17
|
+
{
|
|
17
18
|
value: 'agents',
|
|
18
19
|
show: true,
|
|
19
20
|
sort: null,
|
|
@@ -27,7 +28,8 @@ const sortedHeaders = [
|
|
|
27
28
|
show: true,
|
|
28
29
|
sort: 'asc',
|
|
29
30
|
field: 'queue',
|
|
30
|
-
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
31
33
|
value: 'agents',
|
|
32
34
|
show: true,
|
|
33
35
|
sort: null,
|
|
@@ -24,7 +24,10 @@ describe('URL Controller mixin Set and Get operations', () => {
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
it('Array of objects', async () => {
|
|
27
|
-
const value = [
|
|
27
|
+
const value = [
|
|
28
|
+
{ name: 'team 1', id: '1' },
|
|
29
|
+
{ name: 'team 2', id: '2' },
|
|
30
|
+
];
|
|
28
31
|
await wrapper.vm.setValueToQuery({ filterQuery, value });
|
|
29
32
|
const queryValue = wrapper.vm.getValueFromQuery({ filterQuery });
|
|
30
33
|
expect(queryValue).toEqual(['1', '2']);
|
|
@@ -14,7 +14,8 @@ export default {
|
|
|
14
14
|
},
|
|
15
15
|
computed: {
|
|
16
16
|
filterSchema() {
|
|
17
|
-
if (!this.$store)
|
|
17
|
+
if (!this.$store)
|
|
18
|
+
throw new Error('Vuex is required for default filterSchema baseFilterMixin property');
|
|
18
19
|
return getNamespacedState(this.$store.state, this.namespace)[this.filterQuery];
|
|
19
20
|
},
|
|
20
21
|
value() {
|
|
@@ -27,7 +28,8 @@ export default {
|
|
|
27
28
|
if (value) this.restoreValue(value);
|
|
28
29
|
},
|
|
29
30
|
setValue(payload) {
|
|
30
|
-
if (!this.$store)
|
|
31
|
+
if (!this.$store)
|
|
32
|
+
throw new Error('Vuex is required for default setValue() baseFilterMixin method');
|
|
31
33
|
return this.$store.dispatch(`${this.namespace}/SET_FILTER`, payload);
|
|
32
34
|
},
|
|
33
35
|
},
|
|
@@ -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
|
});
|