@webitel/ui-sdk 24.10.2 → 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.
Files changed (201) hide show
  1. package/dist/ui-sdk.css +1 -1
  2. package/dist/ui-sdk.js +111 -114
  3. package/dist/ui-sdk.umd.cjs +8 -8
  4. package/package.json +6 -4
  5. package/src/api/axios/generateInstance.js +1 -4
  6. package/src/api/clients/agents/agents.js +31 -78
  7. package/src/api/clients/buckets/buckets.js +17 -57
  8. package/src/api/clients/calendars/calendars.js +18 -71
  9. package/src/api/clients/chatGateways/chatGateways.js +23 -61
  10. package/src/api/clients/chatGateways/defaults/webChatGateway.js +6 -8
  11. package/src/api/clients/chatGateways/enums/WebchatAlternativeChannel.enum.js +3 -3
  12. package/src/api/clients/communications/communications.js +20 -62
  13. package/src/api/clients/configurations/configurations.js +18 -3
  14. package/src/api/clients/flows/flow.js +17 -60
  15. package/src/api/clients/gateways/gateways.js +20 -59
  16. package/src/api/clients/index.js +1 -1
  17. package/src/api/clients/lists/blacklists.js +18 -60
  18. package/src/api/clients/media/media.js +13 -43
  19. package/src/api/clients/queues/defaults/processing.js +10 -6
  20. package/src/api/clients/queues/queues.js +21 -69
  21. package/src/api/clients/roles/roles.js +15 -33
  22. package/src/api/clients/users/__tests__/users.spec.js +43 -26
  23. package/src/api/clients/users/users.js +21 -56
  24. package/src/api/crm/contactChatMessagesHistory.js +8 -23
  25. package/src/api/crm/index.js +1 -3
  26. package/src/api/defaults/getDefaultGetParams/getDefaultGetParams.js +1 -4
  27. package/src/api/defaults/getDefaultInstance/getDefaultInstance.js +10 -11
  28. package/src/api/defaults/getDefaultOpenAPIConfig/getDefaultOpenAPIConfig.js +6 -5
  29. package/src/api/defaults/index.js +2 -4
  30. package/src/api/history/index.js +1 -3
  31. package/src/api/history/transcript/callTranscript.js +10 -30
  32. package/src/api/interceptors/request/updateToken.interceptor.js +1 -2
  33. package/src/api/transformers/merge/merge.transformer.js +4 -1
  34. package/src/api/transformers/mergeEach/mergeEach.transformer.js +4 -4
  35. package/src/api/transformers/notify/notify.transformer.js +9 -6
  36. package/src/api/transformers/starToSearch/starToSearch.transformer.js +8 -6
  37. package/src/components/index.js +3 -6
  38. package/src/components/on-demand/wt-cc-agent-status-timers/__tests__/wt-cc-agent-status-timers.spec.js +2 -4
  39. package/src/components/transitions/wt-expand-transition.vue +2 -3
  40. package/src/components/wt-app-header/__tests__/WtAppNavigator.spec.js +1 -2
  41. package/src/components/wt-app-header/__tests__/WtHeaderActions.spec.js +1 -2
  42. package/src/components/wt-app-header/wt-app-navigator.vue +15 -9
  43. package/src/components/wt-avatar/wt-avatar.vue +8 -3
  44. package/src/components/wt-button/wt-button.vue +0 -1
  45. package/src/components/wt-button-select/__tests__/WtButtonSelect.spec.js +4 -5
  46. package/src/components/wt-button-select/wt-button-select.vue +0 -1
  47. package/src/components/wt-context-menu/wt-context-menu.vue +32 -35
  48. package/src/components/wt-dummy/wt-dummy.vue +2 -5
  49. package/src/components/wt-expansion-panel/wt-expansion-panel.vue +10 -7
  50. package/src/components/wt-filters-panel-wrapper/__tests__/WtFiltersPanelWrapper.spec.js +4 -8
  51. package/src/components/wt-icon/wt-icon.vue +0 -1
  52. package/src/components/wt-indicator/__tests__/WtIndicator.spec.js +3 -2
  53. package/src/components/wt-indicator/wt-indicator.vue +10 -1
  54. package/src/components/wt-input/wt-input.vue +7 -10
  55. package/src/components/wt-item-link/wt-item-link.vue +7 -4
  56. package/src/components/wt-navigation-bar/__tests__/WtNavigationBar.spec.js +7 -15
  57. package/src/components/wt-navigation-bar/wt-navigation-bar.vue +7 -7
  58. package/src/components/wt-notification/wt-notification.vue +1 -2
  59. package/src/components/wt-notifications-bar/__tests__/WtNotificationsBar.spec.js +6 -3
  60. package/src/components/wt-notifications-bar/wt-notifications-bar.vue +4 -1
  61. package/src/components/wt-page-wrapper/__tests__/WtPageWrapper.spec.js +1 -2
  62. package/src/components/wt-pagination/wt-pagination.vue +1 -3
  63. package/src/components/wt-player/scripts/__tests__/createPlyrURL.spec.js +4 -8
  64. package/src/components/wt-player/wt-player.vue +13 -4
  65. package/src/components/wt-popup/wt-popup.vue +2 -1
  66. package/src/components/wt-search-bar/wt-search-bar.vue +1 -1
  67. package/src/components/wt-select/mixins/multiselectMixin.js +2 -5
  68. package/src/components/wt-select/wt-select.vue +12 -11
  69. package/src/components/wt-slider/wt-slider.vue +4 -2
  70. package/src/components/wt-status-select/wt-status-select.vue +10 -6
  71. package/src/components/wt-stepper/wt-stepper.vue +6 -4
  72. package/src/components/wt-switcher/wt-switcher.vue +1 -3
  73. package/src/components/wt-table/__tests__/WtTable.spec.js +2 -5
  74. package/src/components/wt-table/wt-table.vue +18 -16
  75. package/src/components/wt-table-column-select/wt-table-column-select.vue +9 -8
  76. package/src/components/wt-tabs/wt-tabs.vue +1 -3
  77. package/src/components/wt-tags-input/mixin/taggableMixin.js +7 -7
  78. package/src/components/wt-textarea/__tests__/WtTextarea.spec.js +2 -4
  79. package/src/components/wt-textarea/wt-textarea.vue +3 -2
  80. package/src/components/wt-timepicker/wt-timepicker.vue +1 -3
  81. package/src/components/wt-tooltip/_internals/useTooltipTriggerSubscriptions.js +1 -3
  82. package/src/components/wt-tooltip/_internals/wt-tooltip-floating.vue +8 -12
  83. package/src/components/wt-tooltip/wt-tooltip.vue +13 -13
  84. package/src/composables/useCachedInterval/__tests__/useCachedInterval.spec.js +6 -4
  85. package/src/composables/useCachedInterval/useCachedInterval.js +3 -8
  86. package/src/composables/useRepresentableAgentPauseCause/__tests__/useRepresentableAgentPauseCause.spec.js +11 -33
  87. package/src/composables/useRepresentableAgentPauseCause/useRepresentableAgentPauseCause.js +11 -9
  88. package/src/enums/WebitelApplications/AdminSections.enum.js +28 -28
  89. package/src/enums/WebitelApplications/CrmSections.enum.js +1 -1
  90. package/src/locale/en/en.js +12 -15
  91. package/src/locale/es/es.js +4 -8
  92. package/src/locale/kz/kz.js +5 -7
  93. package/src/locale/ru/ru.js +7 -11
  94. package/src/locale/ua/ua.js +13 -17
  95. package/src/mixins/dataFilterMixins/__tests__/enumFilterMixin.spec.js +1 -2
  96. package/src/mixins/dataFilterMixins/__tests__/sortFilterMixin.spec.js +4 -2
  97. package/src/mixins/dataFilterMixins/__tests__/urlControllerMixin.spec.js +4 -1
  98. package/src/mixins/dataFilterMixins/_urlControllerMixin/_urlControllerMixin.js +1 -1
  99. package/src/mixins/dataFilterMixins/apiFilterMixin.js +1 -2
  100. package/src/mixins/dataFilterMixins/baseFilterMixin/baseFilterMixin.js +1 -2
  101. package/src/mixins/dataFilterMixins/enumFilterMixin.js +5 -6
  102. package/src/mixins/dataFilterMixins/paginationFilterMixin.js +1 -2
  103. package/src/mixins/dataFilterMixins/sortFilterMixin.js +1 -4
  104. package/src/mixins/validationMixin/__tests__/validationMixin.spec.js +1 -2
  105. package/src/mixins/validationMixin/useValidation.js +25 -19
  106. package/src/mixins/validationMixin/validationMixin.js +22 -10
  107. package/src/modules/AgentStatusSelect/api/pause-cause.js +3 -11
  108. package/src/modules/AgentStatusSelect/components/__tests__/wt-cc-agent-status-select.spec.js +16 -18
  109. package/src/modules/AgentStatusSelect/components/__tests__/wt-cc-pause-cause-popup.spec.js +1 -2
  110. package/src/modules/AgentStatusSelect/components/_internals/wt-cc-pause-cause-popup.vue +12 -12
  111. package/src/modules/AgentStatusSelect/components/_internals/wt-cc-status-select-error-popup.vue +0 -1
  112. package/src/modules/AgentStatusSelect/components/wt-cc-agent-status-select.vue +20 -7
  113. package/src/modules/Appearance/components/__tests__/wt-dark-mode-switcher.spec.js +2 -4
  114. package/src/modules/Appearance/components/wt-dark-mode-switcher.vue +0 -1
  115. package/src/modules/AuditForm/components/__tests__/audit-form-question-read-wrapper.spec.js +1 -2
  116. package/src/modules/AuditForm/components/__tests__/audit-form-question-write-wrapper.spec.js +15 -25
  117. package/src/modules/AuditForm/components/__tests__/audit-form.spec.js +11 -20
  118. package/src/modules/AuditForm/components/audit-form-question-read-wrapper.vue +1 -4
  119. package/src/modules/AuditForm/components/audit-form-question-write-wrapper.vue +4 -7
  120. package/src/modules/AuditForm/components/audit-form-question.vue +18 -17
  121. package/src/modules/AuditForm/components/audit-form.vue +12 -14
  122. package/src/modules/AuditForm/components/questions/options/__tests__/audit-form-question-options-write-row.spec.js +1 -2
  123. package/src/modules/AuditForm/components/questions/options/__tests__/audit-form-question-options.spec.js +1 -3
  124. package/src/modules/AuditForm/components/questions/options/audit-form-question-options-write-row.vue +11 -15
  125. package/src/modules/AuditForm/components/questions/options/audit-form-question-options.vue +1 -4
  126. package/src/modules/AuditForm/components/questions/score/audit-form-question-score.vue +16 -20
  127. package/src/modules/AuditForm/schemas/AuditFormQuestionOptionsSchema.js +1 -3
  128. package/src/modules/CSVExport/CSVExport.js +3 -7
  129. package/src/modules/CSVExport/XLSExport.js +6 -7
  130. package/src/modules/CSVExport/__tests__/CSVExport.spec.js +1 -2
  131. package/src/modules/CSVExport/mixins/exportCSVMixin.js +2 -5
  132. package/src/modules/CSVExport/mixins/exportXLSMixin.js +2 -4
  133. package/src/modules/CardStoreModule/store/CardStoreModule.js +2 -6
  134. package/src/modules/DeleteConfirmationPopup/__tests__/delete-confirmation-popup.spec.js +13 -10
  135. package/src/modules/DeleteConfirmationPopup/components/delete-confirmation-popup.vue +5 -14
  136. package/src/modules/FilesExport/FilesExport.js +4 -3
  137. package/src/modules/FilesExport/__tests__/FilesExport.spec.js +12 -12
  138. package/src/modules/FilesExport/mixins/exportFilesMixin.js +6 -7
  139. package/src/modules/FilesExport/scripts/generateMediaURL.js +1 -2
  140. package/src/modules/Filters/classes/BaseFilterSchema.js +21 -23
  141. package/src/modules/Filters/components/filter-pagination.vue +7 -3
  142. package/src/modules/Filters/components/filter-search.vue +21 -12
  143. package/src/modules/Filters/components/filter-table-fields.vue +1 -3
  144. package/src/modules/Filters/scripts/getters/index.js +1 -5
  145. package/src/modules/Filters/scripts/getters/queryGetter.js +8 -3
  146. package/src/modules/Filters/scripts/getters/valueGetter.js +1 -2
  147. package/src/modules/Filters/scripts/restores/index.js +1 -4
  148. package/src/modules/Filters/scripts/setters/index.js +1 -5
  149. package/src/modules/Filters/scripts/setters/querySetter.js +24 -22
  150. package/src/modules/Filters/scripts/utils/changeRouteQuery.js +16 -15
  151. package/src/modules/Filters/store/FiltersStoreModule.js +51 -45
  152. package/src/modules/Filters/store/__tests__/FiltersStoreModule.spec.js +51 -45
  153. package/src/modules/Notifications/store/NotificationsStoreModule.js +41 -38
  154. package/src/modules/Notifications/store/__tests__/NotificationsStoreModule.actions.spec.js +6 -6
  155. package/src/modules/QueryFilters/api/defaults.js +2 -3
  156. package/src/modules/QueryFilters/classes/ApiFilterSchema.js +1 -4
  157. package/src/modules/QueryFilters/classes/EnumFilterSchema.js +1 -4
  158. package/src/modules/QueryFilters/components/__tests__/filter-datetime.spec.js +1 -2
  159. package/src/modules/QueryFilters/components/__tests__/filter-from-to.spec.js +2 -4
  160. package/src/modules/QueryFilters/components/__tests__/filter-search.spec.js +2 -4
  161. package/src/modules/QueryFilters/components/filter-table-fields.vue +1 -5
  162. package/src/modules/QueryFilters/mixins/__tests__/apiFilterMixin.spec.js +4 -3
  163. package/src/modules/QueryFilters/mixins/__tests__/enumFilterMixin.spec.js +2 -4
  164. package/src/modules/QueryFilters/mixins/__tests__/sortFilterMixin.spec.js +4 -2
  165. package/src/modules/QueryFilters/mixins/__tests__/urlControllerMixin.spec.js +4 -1
  166. package/src/modules/QueryFilters/mixins/_urlControllerMixin/_urlControllerMixin.js +1 -1
  167. package/src/modules/QueryFilters/mixins/apiFilterMixin.js +1 -1
  168. package/src/modules/QueryFilters/mixins/baseFilterMixin/baseFilterMixin.js +4 -2
  169. package/src/modules/QueryFilters/mixins/enumFilterMixin.js +9 -11
  170. package/src/modules/QueryFilters/mixins/paginationFilterMixin.js +2 -4
  171. package/src/modules/QueryFilters/mixins/sortFilterMixin.js +2 -5
  172. package/src/modules/QueryFilters/store/QueryFiltersStoreModule.js +13 -17
  173. package/src/modules/QueryFilters/store/__tests__/QueryFiltersStoreModule.spec.js +15 -16
  174. package/src/modules/TableStoreModule/store/TableStoreModule.js +14 -33
  175. package/src/modules/TableStoreModule/store/__tests__/TableStoreModule.spec.js +69 -83
  176. package/src/modules/Userinfo/api/userinfo.js +6 -19
  177. package/src/modules/Userinfo/classes/ApplicationsAccess.js +5 -12
  178. package/src/modules/Userinfo/store/UserinfoStoreModule.js +38 -41
  179. package/src/plugins/breakpoint/breakpoint.plugin.js +11 -16
  180. package/src/scripts/__tests__/caseConverters.spec.js +1 -4
  181. package/src/scripts/__tests__/debounce.spec.js +3 -1
  182. package/src/scripts/__tests__/prettifyFileSize.spec.js +2 -2
  183. package/src/scripts/__tests__/preventHiddenPageCallsDecorator.spec.js +7 -4
  184. package/src/scripts/__tests__/updateObject.spec.js +3 -5
  185. package/src/scripts/caseConverters.js +22 -38
  186. package/src/scripts/debounce.js +1 -5
  187. package/src/scripts/editProxy.js +8 -7
  188. package/src/scripts/prettifyFileSize.js +1 -1
  189. package/src/scripts/preventHiddenPageCallsDecorator.js +3 -6
  190. package/src/store/BaseStoreModules/ApiStoreModule.js +7 -33
  191. package/src/store/BaseStoreModules/BaseStoreModule.js +14 -23
  192. package/src/store/BaseStoreModules/__tests__/BaseStoreModule.spec.js +7 -28
  193. package/src/store/helpers/getNamespacedState.js +2 -4
  194. package/src/store/new/modules/apiStoreModule/apiStoreModule.js +7 -27
  195. package/src/store/new/modules/cardStoreModule/cardStoreModule.js +0 -1
  196. package/src/store/new/modules/tableStoreModule/__tests__/tableStoreModule.spec.js +64 -77
  197. package/src/store/new/modules/tableStoreModule/tableStoreModule.js +12 -29
  198. package/src/tests/mocks/axiosMock.js +25 -19
  199. package/src/validators/decimalValidator.js +5 -4
  200. package/src/validators/websocketValidator/__tests__/websocketValidator.spec.js +1 -2
  201. package/src/validators/websocketValidator/websocketValidator.js +1 -1
@@ -1,9 +1,5 @@
1
- import {
2
- queryToSortAdapter,
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
- let {
137
- items = [],
138
- next = false,
139
- } = await context.dispatch('api/GET_LIST', { context, params });
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
- .addFilter({
32
- name: 'vi',
33
- value: 23,
34
- defaultValue: 23,
35
- get: ['value'],
36
- set: ['value'],
37
- restore: () => 'vivi',
38
- })
39
- .getModule();
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
- .addFilter({
70
- name: 'vi',
71
- value: 23,
72
- defaultValue: 23,
73
- get: ['value'],
74
- set: ['value'],
75
- restore: () => {},
76
- })
77
- .getModule();
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
- .addFilter([
113
- {
114
- name: 'vi',
115
- value: 23,
116
- defaultValue: 23,
117
- get: ['value'],
118
- set: ['value'],
119
- restore: () => {},
120
- },
121
- {
122
- name: 'page',
123
- value: 12,
124
- defaultValue: 12,
125
- get: ['value'],
126
- set: ['value'],
127
- restore: () => {},
128
- },
129
- ])
130
- .getModule();
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
- .addFilter({
165
- name: 'sort',
166
- value: '',
167
- get: ['value'],
168
- set: ['value'],
169
- restore: () => {},
170
- })
171
- .getModule();
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
- .addFilter({
210
- name: 'fields',
211
- value: [],
212
- get: ['value'],
213
- set: ['value'],
214
- restore: () => {},
215
- })
216
- .getModule();
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
- from '../../../enums/WebitelApplications/AdminSections.enum.js';
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
- from '../../../enums/WebitelApplications/SupervisorSections.enum.js';
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]);
@@ -29,33 +29,33 @@ export default class UserinfoStoreModule extends BaseStoreModule {
29
29
  getters = {
30
30
  THIS_APP: (state) => state.thisApp,
31
31
  // if no access[app] => accessed by default
32
- CHECK_APP_ACCESS: (state) => (app) => !state.access[app] ||
33
- state.access[app]?._enabled,
34
- CHECK_OBJECT_ACCESS: (state, getters) => ({ name, route }) => {
35
- if (!state.access[getters.THIS_APP] ||
36
- !state.access[getters.THIS_APP]._enabled) return false;
37
- if (route) return getters.CHECK_OBJECT_ACCESS_BY_ROUTE(route);
38
- return getters.CHECK_OBJECT_ACCESS_BY_NAME(name);
39
- },
40
- CHECK_OBJECT_ACCESS_BY_NAME: (state, getters) => (name) => (
41
- state.access[getters.THIS_APP][name]?._enabled
42
- ),
32
+ CHECK_APP_ACCESS: (state) => (app) => !state.access[app] || state.access[app]?._enabled,
33
+ CHECK_OBJECT_ACCESS:
34
+ (state, getters) =>
35
+ ({ name, route }) => {
36
+ if (!state.access[getters.THIS_APP] || !state.access[getters.THIS_APP]._enabled)
37
+ return false;
38
+ if (route) return getters.CHECK_OBJECT_ACCESS_BY_ROUTE(route);
39
+ return getters.CHECK_OBJECT_ACCESS_BY_NAME(name);
40
+ },
41
+ CHECK_OBJECT_ACCESS_BY_NAME: (state, getters) => (name) =>
42
+ state.access[getters.THIS_APP][name]?._enabled,
43
43
  CHECK_OBJECT_ACCESS_BY_ROUTE: (state, getters) => (route) => {
44
- const accessKey = Object.keys(state.access[getters.THIS_APP])
45
- .find((object) => route.name.includes(object));
44
+ const accessKey = Object.keys(state.access[getters.THIS_APP]).find((object) =>
45
+ route.name.includes(object),
46
+ );
46
47
  return state.access[getters.THIS_APP][accessKey]?._enabled;
47
48
  },
48
- GET_OBJECT_SCOPE: (state, getters) => ({ name, route }) => {
49
- if (route) return getters.GET_OBJECT_SCOPE_BY_ROUTE(route);
50
- return getters.GET_OBJECT_SCOPE_BY_NAME(name);
51
- },
52
- GET_OBJECT_SCOPE_BY_NAME: (state) => (name) => (
53
- Object.values(state.scope).find((object) => name === object.name)
54
- ),
55
- GET_OBJECT_SCOPE_BY_ROUTE: (state) => (route) => (
56
- Object.values(state.scope)
57
- .find((object) => route.name.includes(object.route))
58
- ),
49
+ GET_OBJECT_SCOPE:
50
+ (state, getters) =>
51
+ ({ name, route }) => {
52
+ if (route) return getters.GET_OBJECT_SCOPE_BY_ROUTE(route);
53
+ return getters.GET_OBJECT_SCOPE_BY_NAME(name);
54
+ },
55
+ GET_OBJECT_SCOPE_BY_NAME: (state) => (name) =>
56
+ Object.values(state.scope).find((object) => name === object.name),
57
+ GET_OBJECT_SCOPE_BY_ROUTE: (state) => (route) =>
58
+ Object.values(state.scope).find((object) => route.name.includes(object.route)),
59
59
  HAS_READ_ACCESS: (state, getters) => (checkedObject) => {
60
60
  if (!getters.CHECK_OBJECT_ACCESS(checkedObject)) return false;
61
61
  if (state.permissions[Permissions.READ]) return true;
@@ -86,13 +86,13 @@ export default class UserinfoStoreModule extends BaseStoreModule {
86
86
  CONVERT_USER_PERMISSIONS: (context, initialPermissions) => {
87
87
  let permissions = {};
88
88
  if (!initialPermissions) return permissions;
89
- permissions = initialPermissions.reduce((
90
- permissions,
91
- currentPermission,
92
- ) => ({
93
- ...permissions,
94
- [currentPermission.id]: currentPermission,
95
- }), {});
89
+ permissions = initialPermissions.reduce(
90
+ (permissions, currentPermission) => ({
91
+ ...permissions,
92
+ [currentPermission.id]: currentPermission,
93
+ }),
94
+ {},
95
+ );
96
96
  return permissions;
97
97
  },
98
98
 
@@ -105,14 +105,17 @@ export default class UserinfoStoreModule extends BaseStoreModule {
105
105
 
106
106
  const session = await userinfo.getSession();
107
107
 
108
- if ((session.expiresAt - Date.now() < HOUR_LENGTH)) {
108
+ if (session.expiresAt - Date.now() < HOUR_LENGTH) {
109
109
  await context.dispatch('LOGOUT');
110
110
  throw new Error(`Session expires soon ${session.expiresAt}`);
111
111
  }
112
112
 
113
113
  await context.dispatch('SET_SESSION', session);
114
114
  const access = await userinfo.getApplicationsAccess();
115
- await context.dispatch('SET_APPLICATIONS_ACCESS', new ApplicationsAccess({ access }).getAccess());
115
+ await context.dispatch(
116
+ 'SET_APPLICATIONS_ACCESS',
117
+ new ApplicationsAccess({ access }).getAccess(),
118
+ );
116
119
  await context.dispatch('AFTER_OPEN_SESSION_HOOK');
117
120
  },
118
121
  SET_SESSION: async (context, _session) => {
@@ -137,19 +140,13 @@ export default class UserinfoStoreModule extends BaseStoreModule {
137
140
  }
138
141
  },
139
142
 
140
- LOGOUT: async (
141
- context,
142
- { authUrl = import.meta.env.VITE_AUTH_URL } = {},
143
- ) => {
143
+ LOGOUT: async (context, { authUrl = import.meta.env.VITE_AUTH_URL } = {}) => {
144
144
  if (!authUrl) throw new Error('No authUrl for LOGOUT provided');
145
145
  await userinfo.logout();
146
146
  window.location.href = authUrl;
147
147
  },
148
148
 
149
- SET_APPLICATIONS_ACCESS: (
150
- context,
151
- access,
152
- ) => context.commit('SET_APPLICATIONS_ACCESS', access),
149
+ SET_APPLICATIONS_ACCESS: (context, access) => context.commit('SET_APPLICATIONS_ACCESS', access),
153
150
 
154
151
  SET_LOADING: (context, isLoading) => {
155
152
  context.commit('SET_LOADING', isLoading);
@@ -37,15 +37,10 @@ const breakpoint = reactive({
37
37
  width: 0,
38
38
  });
39
39
 
40
- const getClientWidth = () => Math.max(
41
- document.documentElement.clientWidth,
42
- window.innerWidth || 0,
43
- );
40
+ const getClientWidth = () => Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
44
41
 
45
- const getClientHeight = () => Math.max(
46
- document.documentElement.clientHeight,
47
- window.innerHeight || 0,
48
- );
42
+ const getClientHeight = () =>
43
+ Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
49
44
 
50
45
  const thresholds = {
51
46
  xs: 600,
@@ -62,9 +57,9 @@ const onResize = () => {
62
57
 
63
58
  const xs = width < thresholds.xs;
64
59
  const sm = width < thresholds.sm && !xs;
65
- const md = width < (thresholds.md - scrollBarWidth) && !(sm || xs);
66
- const lg = width < (thresholds.lg - scrollBarWidth) && !(md || sm || xs);
67
- const xl = width >= (thresholds.lg - scrollBarWidth);
60
+ const md = width < thresholds.md - scrollBarWidth && !(sm || xs);
61
+ const lg = width < thresholds.lg - scrollBarWidth && !(md || sm || xs);
62
+ const xl = width >= thresholds.lg - scrollBarWidth;
68
63
 
69
64
  breakpoint.height = height;
70
65
  breakpoint.width = width;
@@ -88,16 +83,16 @@ const onResize = () => {
88
83
  breakpoint.xlOnly = xl;
89
84
 
90
85
  switch (true) {
91
- case (xs):
86
+ case xs:
92
87
  breakpoint.name = 'xs';
93
88
  break;
94
- case (sm):
89
+ case sm:
95
90
  breakpoint.name = 'sm';
96
91
  break;
97
- case (md):
92
+ case md:
98
93
  breakpoint.name = 'md';
99
94
  break;
100
- case (lg):
95
+ case lg:
101
96
  breakpoint.name = 'lg';
102
97
  break;
103
98
  default:
@@ -106,7 +101,7 @@ const onResize = () => {
106
101
  }
107
102
 
108
103
  if (typeof mobileBreakpoint === 'number') {
109
- breakpoint.mobile = width < parseInt(mobileBreakpoint, 10);
104
+ breakpoint.mobile = width < Number.parseInt(mobileBreakpoint, 10);
110
105
 
111
106
  return;
112
107
  }
@@ -60,10 +60,7 @@ describe('Case converters', () => {
60
60
 
61
61
  it('Camel-Snake Arrays', () => {
62
62
  const camelArr = ['camelToSnake', { camelToSnake: { camelToSnake: null } }];
63
- const snakeArr = [
64
- 'camel_to_snake',
65
- { camel_to_snake: { camel_to_snake: null } },
66
- ];
63
+ const snakeArr = ['camel_to_snake', { camel_to_snake: { camel_to_snake: null } }];
67
64
  expect(objCamelToSnake(camelArr)).toEqual(snakeArr);
68
65
  expect(objSnakeToCamel(snakeArr)).toEqual(camelArr);
69
66
  });
@@ -3,7 +3,9 @@ import debounce from '../debounce.js';
3
3
  describe('debounce', () => {
4
4
  it('debounces call', async () => {
5
5
  let isFnCalled = false;
6
- let fn = () => { isFnCalled = true; };
6
+ let fn = () => {
7
+ isFnCalled = true;
8
+ };
7
9
  fn = debounce(fn, 50);
8
10
  fn();
9
11
  expect(isFnCalled).toBeFalsy();
@@ -1,12 +1,12 @@
1
1
  import prettifyFileSize from '../prettifyFileSize.js';
2
2
 
3
3
  describe('prettifyFileSize', () => {
4
- it('prettifies bytes to kb\'s', () => {
4
+ it("prettifies bytes to kb's", () => {
5
5
  const size = 1025;
6
6
  expect(prettifyFileSize(size)).toBe('1 Kb');
7
7
  });
8
8
 
9
- it('prettifies bytes to mb\'s', () => {
9
+ it("prettifies bytes to mb's", () => {
10
10
  const size = 1205 ** 2;
11
11
  expect(prettifyFileSize(size)).toBe('1.38 Mb');
12
12
  });
@@ -1,14 +1,17 @@
1
- import preventHiddenPageCallsDecorator
2
- from '../preventHiddenPageCallsDecorator.js';
1
+ import preventHiddenPageCallsDecorator from '../preventHiddenPageCallsDecorator.js';
3
2
 
4
3
  describe('preventHiddenPageCallsDecorator', () => {
5
4
  it('prevents call on hidden page', () => {
6
5
  let isFnCalled = false;
7
- let fn = () => { isFnCalled = true; };
6
+ let fn = () => {
7
+ isFnCalled = true;
8
+ };
8
9
  fn = preventHiddenPageCallsDecorator(fn, 50);
9
10
  Object.defineProperty(document, 'hidden', {
10
11
  configurable: true,
11
- get() { return true; },
12
+ get() {
13
+ return true;
14
+ },
12
15
  });
13
16
  expect(isFnCalled).toBeFalsy();
14
17
  fn();