@webitel/ui-sdk 0.1.11 → 0.1.112
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/README.md +29 -29
- package/dist/img/plyr.svg +70 -0
- package/dist/img/svg-sprites/attach.svg +4 -0
- package/dist/img/svg-sprites/index.js +1 -0
- package/dist/img/svg-sprites/wt-icon.svg +880 -0
- package/dist/ui-sdk.common.js +8287 -4335
- package/dist/ui-sdk.common.js.map +1 -1
- package/dist/ui-sdk.css +1 -1
- package/dist/ui-sdk.umd.js +8287 -4335
- package/dist/ui-sdk.umd.js.map +1 -1
- package/dist/ui-sdk.umd.min.js +3 -1
- package/dist/ui-sdk.umd.min.js.map +1 -1
- package/package.json +62 -41
- package/src/components/atoms/wt-badge/__tests__/WtBadge.spec.js +19 -0
- package/src/components/atoms/wt-badge/wt-badge.vue +23 -0
- package/src/components/atoms/wt-button/__tests__/WtButton.spec.js +29 -0
- package/src/components/atoms/wt-button/wt-button.vue +212 -0
- package/src/components/atoms/wt-divider/__tests__/WtDivider.spec.js +9 -0
- package/src/components/atoms/wt-divider/wt-divider.vue +25 -0
- package/src/components/atoms/wt-icon/__tests__/WtIcon.spec.js +24 -0
- package/src/components/atoms/wt-icon/wt-icon.vue +138 -0
- package/src/components/atoms/wt-indicator/__tests__/WtIndicator.spec.js +29 -0
- package/src/components/atoms/wt-indicator/wt-indicator.vue +81 -0
- package/src/components/atoms/wt-input-info/__tests__/WtInputInfo.spec.js +9 -0
- package/src/components/atoms/wt-input-info/wt-input-info.vue +35 -0
- package/src/components/atoms/wt-loader/__tests__/WtLoader.spec.js +9 -0
- package/src/components/atoms/wt-loader/_internals/wt-loader--md.vue +83 -0
- package/src/components/atoms/wt-loader/_internals/wt-loader--sm.vue +189 -0
- package/src/components/atoms/wt-loader/wt-loader.vue +34 -0
- package/src/components/atoms/wt-rounded-action/__tests__/WtRoundedAction.spec.js +20 -0
- package/src/components/atoms/wt-rounded-action/wt-rounded-action.vue +227 -0
- package/src/components/atoms/wt-tooltip/__tests__/WtTooltip.spec.js +29 -0
- package/src/components/atoms/wt-tooltip/wt-tooltip.vue +54 -0
- package/src/components/index.js +98 -0
- package/src/components/molecules/wt-checkbox/__tests__/WtCheckbox.spec.js +41 -0
- package/src/components/molecules/wt-checkbox/wt-checkbox.vue +175 -0
- package/src/components/molecules/wt-datepicker/__tests__/WtDatepicker.spec.js +28 -0
- package/src/components/molecules/wt-datepicker/wt-datepicker.vue +209 -0
- package/src/components/molecules/wt-datetimepicker/__tests__/WtDatetimepicker.spec.js +67 -0
- package/src/components/molecules/wt-datetimepicker/wt-datetimepicker.vue +314 -0
- package/src/components/molecules/wt-icon-btn/__tests__/WtIconBtn.spec.js +31 -0
- package/src/components/molecules/wt-icon-btn/wt-icon-btn.vue +113 -0
- package/src/components/molecules/wt-input/__tests__/WtInput.spec.js +25 -0
- package/src/components/molecules/wt-input/wt-input.vue +316 -0
- package/src/components/molecules/wt-label/__tests__/WtLabel.spec.js +9 -0
- package/src/components/molecules/wt-label/wt-label.vue +87 -0
- package/src/components/molecules/wt-notification/__tests__/WtNotification.spec.js +21 -0
- package/src/components/molecules/wt-notification/wt-notification.vue +74 -0
- package/src/components/molecules/wt-popup/__tests__/WtPopup.spec.js +47 -0
- package/src/components/molecules/wt-popup/wt-popup.vue +130 -0
- package/src/components/molecules/wt-progress-bar/__tests__/WtProgressBar.spec.js +17 -0
- package/src/components/molecules/wt-progress-bar/wt-progress-bar.vue +80 -0
- package/src/components/molecules/wt-radio/__tests__/WtRadio.spec.js +42 -0
- package/src/components/molecules/wt-radio/wt-radio.vue +168 -0
- package/src/components/molecules/wt-search-bar/__tests__/WtSearchBar.spec.js +36 -0
- package/src/components/molecules/wt-search-bar/wt-search-bar.vue +203 -0
- package/src/components/molecules/wt-select/__tests__/WtSelect.spec.js +53 -0
- package/src/components/molecules/wt-select/wt-select.vue +492 -0
- package/src/components/molecules/wt-slider/__tests__/WtSlider.spec.js +9 -0
- package/src/components/molecules/wt-slider/wt-slider.vue +175 -0
- package/src/components/molecules/wt-switcher/__tests__/WtSwitcher.spec.js +31 -0
- package/src/components/molecules/wt-switcher/wt-switcher.vue +177 -0
- package/src/components/molecules/wt-tabs/__tests__/WtTabs.spec.js +36 -0
- package/src/components/molecules/wt-tabs/wt-tabs.vue +127 -0
- package/src/components/molecules/wt-tags-input/__tests__/WtTagsInput.spec.js +45 -0
- package/src/components/molecules/wt-tags-input/wt-tags-input.vue +295 -0
- package/src/components/molecules/wt-textarea/__tests__/WtTextarea.spec.js +46 -0
- package/src/components/molecules/wt-textarea/wt-textarea.vue +185 -0
- package/src/components/molecules/wt-time-input/__tests__/WtTimeInput.spec.js +25 -0
- package/src/components/molecules/wt-time-input/wt-time-input.vue +192 -0
- package/src/components/molecules/wt-timepicker/__tests__/WtTimepicker.spec.js +60 -0
- package/src/components/molecules/wt-timepicker/wt-timepicker.vue +176 -0
- package/src/components/organisms/wt-app-header/__tests__/WtAppHeader.spec.js +19 -0
- package/src/components/organisms/wt-app-header/__tests__/WtAppNavigator.spec.js +23 -0
- package/src/components/organisms/wt-app-header/__tests__/WtHeaderActions.spec.js +21 -0
- package/src/components/organisms/wt-app-header/wt-app-header.vue +23 -0
- package/src/components/organisms/wt-app-header/wt-app-navigator.vue +245 -0
- package/src/components/organisms/wt-app-header/wt-header-actions.vue +177 -0
- package/src/components/organisms/wt-error-page/__tests__/wt-error-page.spec.js +17 -0
- package/src/components/organisms/wt-error-page/wt-error-page.vue +104 -0
- package/src/components/organisms/wt-filters-panel-wrapper/__tests__/wt-filters-panel-wrapper.spec.js +24 -0
- package/src/components/organisms/wt-filters-panel-wrapper/wt-filters-panel-wrapper.vue +146 -0
- package/src/components/organisms/wt-headline/__tests__/WtHeadline.spec.js +47 -0
- package/src/components/organisms/wt-headline/wt-headline.vue +46 -0
- package/src/components/organisms/wt-navigation-bar/__tests__/WtNavigationBar.spec.js +64 -0
- package/src/components/organisms/wt-navigation-bar/wt-navigation-bar.vue +249 -0
- package/src/components/organisms/wt-notifications-bar/__tests__/WtNotificationsBar.spec.js +50 -0
- package/src/components/organisms/wt-notifications-bar/wt-notifications-bar.vue +71 -0
- package/src/components/organisms/wt-page-wrapper/__tests__/WtPageWrapper.spec.js +33 -0
- package/src/components/organisms/wt-page-wrapper/wt-page-wrapper.vue +60 -0
- package/src/components/organisms/wt-pagination/__tests__/WtPagination.spec.js +38 -0
- package/src/components/organisms/wt-pagination/wt-pagination.vue +134 -0
- package/src/components/organisms/wt-player/__tests__/WtPlayer.spec.js +9 -0
- package/src/components/organisms/wt-player/wt-player.vue +116 -0
- package/src/components/organisms/wt-status-select/__tests__/WtStatusSelect.spec.js +25 -0
- package/src/components/organisms/wt-status-select/_internals/StatusOptions.lookup.js +24 -0
- package/src/components/organisms/wt-status-select/wt-status-select.vue +110 -0
- package/src/components/organisms/wt-table/__tests__/WtTable.spec.js +133 -0
- package/src/components/organisms/wt-table/__tests__/WtTableDeleteAction.spec.js +9 -0
- package/src/components/organisms/wt-table/__tests__/WtTableEditAction.spec.js +9 -0
- package/src/components/organisms/wt-table/_internals/getSortOrder.js +12 -0
- package/src/components/organisms/wt-table/table-cells/wt-table-delete-action.vue +18 -0
- package/src/components/organisms/wt-table/table-cells/wt-table-edit-action.vue +19 -0
- package/src/components/organisms/wt-table/wt-table.vue +241 -0
- package/src/components/organisms/wt-table-actions/__tests__/WtTableActions.spec.js +9 -0
- package/src/components/organisms/wt-table-actions/wt-table-actions.vue +90 -0
- package/src/components/organisms/wt-table-column-select/__tests__/WtTableColumnSelect.spec.js +31 -0
- package/src/components/organisms/wt-table-column-select/wt-table-column-select.vue +113 -0
- package/src/components/transitions/__tests__/ExpandTransition.spec.js +9 -0
- package/src/components/transitions/expand-transition.vue +70 -0
- package/src/css/colors/_colors.scss +151 -67
- package/src/css/components/_components.scss +38 -25
- package/src/css/components/atoms/wt-badge/_variables.scss +6 -5
- package/src/css/components/atoms/wt-badge/wt-badge.scss +36 -8
- package/src/css/components/atoms/wt-button/_variables.scss +46 -46
- package/src/css/components/atoms/wt-divider/_variables.scss +4 -4
- package/src/css/components/atoms/wt-icon/_variables.scss +7 -28
- package/src/css/components/atoms/wt-indicator/_variables.scss +18 -0
- package/src/css/components/atoms/wt-input-info/_variables.scss +6 -5
- package/src/css/components/atoms/wt-label/_variables.scss +4 -4
- package/src/css/components/atoms/wt-loader/_variables.scss +7 -7
- package/src/css/components/atoms/wt-rounded-action/_variables.scss +30 -0
- package/src/css/components/atoms/wt-tooltip/_variables.scss +9 -9
- package/src/css/components/molecules/wt-checkbox/_variables.scss +3 -3
- package/src/css/components/molecules/wt-datepicker/_variables.scss +19 -19
- package/src/css/components/molecules/wt-datepicker/datepicker-calendar.scss +100 -100
- package/src/css/components/molecules/wt-datetimepicker/_variables.scss +11 -11
- package/src/css/components/molecules/wt-icon-btn/_variables.scss +2 -2
- package/src/css/components/molecules/wt-input/_variables.scss +5 -5
- package/src/css/components/molecules/wt-notification/_variables.scss +9 -9
- package/src/css/components/molecules/wt-popup/_variables.scss +11 -10
- package/src/css/components/molecules/wt-progress-bar/_variables.scss +11 -0
- package/src/css/components/molecules/wt-radio/_variables.scss +6 -6
- package/src/css/components/molecules/wt-search-bar/_variables.scss +3 -3
- package/src/css/components/molecules/wt-select/_variables.scss +24 -22
- package/src/css/components/molecules/wt-slider/_variables.scss +15 -0
- package/src/css/components/molecules/wt-switcher/_variables.scss +17 -14
- package/src/css/components/molecules/wt-tabs/_variables.scss +13 -13
- package/src/css/components/molecules/wt-tags-input/_variables.scss +25 -0
- package/src/css/components/molecules/wt-textarea/_variables.scss +4 -4
- package/src/css/components/molecules/wt-timepicker/_variables.scss +4 -3
- package/src/css/components/organisms/wt-app-header/_variables.scss +20 -0
- package/src/css/components/organisms/wt-headline/_variables.scss +7 -0
- package/src/css/components/organisms/wt-navigation-bar/_variables.scss +14 -0
- package/src/css/components/organisms/wt-notifications-bar/_variables.scss +7 -0
- package/src/css/components/organisms/wt-page-wrapper/_variables.scss +5 -0
- package/src/css/components/organisms/wt-pagination/_variables.scss +6 -6
- package/src/css/components/organisms/wt-status-select/_variables.scss +6 -0
- package/src/css/components/organisms/wt-table/_variables.scss +16 -0
- package/src/css/components/organisms/wt-table-actions/_variables.scss +4 -0
- package/src/css/display-helpers/_display-helpers.scss +21 -0
- package/src/css/fonts/_fonts.scss +9 -0
- package/src/css/main.scss +68 -65
- package/src/css/shadows/_shadows.scss +7 -0
- package/src/css/sizes/_sizes.scss +2 -0
- package/src/css/sizes/_spacing.scss +17 -0
- package/src/css/sizes/_viewport-breakpoints.scss +20 -0
- package/src/css/styleguide/{styleguide.scss → _styleguide.scss} +4 -3
- package/src/css/styleguide/scroll.scss +43 -40
- package/src/css/transitions/_transitions.scss +1 -0
- package/src/css/transitions/fade/_fade.scss +8 -0
- package/src/css/typography/_typography.scss +72 -72
- package/src/enums/AgentStatus/AgentStatus.enum.js +6 -0
- package/src/enums/WebitelApplications/AdminSections.enum.js +41 -0
- package/src/enums/WebitelApplications/SupervisorSections.enum.js +7 -0
- package/src/enums/WebitelApplications/WebitelApplications.enum.js +10 -0
- package/src/locale/en/en.js +135 -0
- package/src/locale/i18n.js +2 -0
- package/src/locale/ru/ru.js +135 -2
- package/src/locale/ua/ua.js +160 -0
- package/src/mixins/dataFilterMixins/__tests__/apiFilterMixin.spec.js +57 -0
- package/src/mixins/dataFilterMixins/__tests__/enumFilterMixin.spec.js +66 -0
- package/src/mixins/dataFilterMixins/__tests__/paginationFilterMixin.spec.js +93 -0
- package/src/mixins/dataFilterMixins/__tests__/sortFilterMixin.spec.js +60 -0
- package/src/mixins/dataFilterMixins/__tests__/urlControllerMixin.spec.js +48 -0
- package/src/mixins/dataFilterMixins/_urlControllerMixin/_urlControllerMixin.js +37 -0
- package/src/mixins/dataFilterMixins/apiFilterMixin.js +23 -0
- package/src/mixins/dataFilterMixins/baseFilterMixin/baseFilterMixin.js +29 -0
- package/src/mixins/dataFilterMixins/enumFilterMixin.js +30 -0
- package/src/mixins/dataFilterMixins/paginationFilterMixin.js +79 -0
- package/src/mixins/dataFilterMixins/sortFilterMixin.js +75 -0
- package/src/mixins/validationMixin/__tests__/validationMixin.spec.js +47 -0
- package/src/mixins/validationMixin/validationMixin.js +40 -0
- package/src/modules/CSVExport/CSVExport.js +88 -0
- package/src/modules/CSVExport/__tests__/CSVExport.spec.js +63 -0
- package/src/modules/CSVExport/mixins/exportCSVMixin.js +46 -0
- package/src/modules/FilesExport/FilesExport.js +110 -0
- package/src/modules/FilesExport/__tests__/FilesExport.spec.js +66 -0
- package/src/modules/FilesExport/mixins/exportFilesMixin.js +46 -0
- package/src/modules/FilesExport/scripts/generateMediaURL.js +7 -0
- package/src/modules/QueryFilters/api/__tests__/defaults.spec.js +18 -0
- package/src/modules/QueryFilters/api/defaults.js +16 -0
- package/src/modules/QueryFilters/classes/ApiFilterSchema.js +32 -0
- package/src/modules/QueryFilters/classes/BaseFilterSchema.js +6 -0
- package/src/modules/QueryFilters/classes/EnumFilterSchema.js +23 -0
- package/src/modules/QueryFilters/classes/__tests__/ApiFilterSchema.spec.js +25 -0
- package/src/modules/QueryFilters/components/__tests__/abstract-api-filter.spec.js +54 -0
- package/src/modules/QueryFilters/components/__tests__/abstract-enum-filter.spec.js +40 -0
- package/src/modules/QueryFilters/components/__tests__/filter-search.spec.js +49 -0
- package/src/modules/QueryFilters/components/abstract-api-filter.vue +42 -0
- package/src/modules/QueryFilters/components/abstract-enum-filter.vue +32 -0
- package/src/modules/QueryFilters/components/filter-search.vue +33 -0
- package/src/modules/QueryFilters/mixins/__tests__/apiFilterMixin.spec.js +48 -0
- package/src/modules/QueryFilters/mixins/__tests__/enumFilterMixin.spec.js +54 -0
- package/src/modules/QueryFilters/mixins/__tests__/paginationFilterMixin.spec.js +74 -0
- package/src/modules/QueryFilters/mixins/__tests__/sortFilterMixin.spec.js +58 -0
- package/src/modules/QueryFilters/mixins/__tests__/urlControllerMixin.spec.js +48 -0
- package/src/modules/QueryFilters/mixins/_urlControllerMixin/_urlControllerMixin.js +39 -0
- package/src/modules/QueryFilters/mixins/apiFilterMixin.js +36 -0
- package/src/modules/QueryFilters/mixins/baseFilterMixin/baseFilterMixin.js +34 -0
- package/src/modules/QueryFilters/mixins/enumFilterMixin.js +36 -0
- package/src/modules/QueryFilters/mixins/paginationFilterMixin.js +66 -0
- package/src/modules/QueryFilters/mixins/sortFilterMixin.js +56 -0
- package/src/modules/QueryFilters/store/QueryFiltersStoreModule.js +50 -0
- package/src/modules/QueryFilters/store/__tests__/QueryFiltersStoreModule.spec.js +83 -0
- package/src/modules/QueryFilters/store/queryFilters.js +6 -0
- package/src/modules/Userinfo/api/BaseAPIService.js +7 -0
- package/src/modules/Userinfo/api/auth.js +29 -0
- package/src/modules/Userinfo/api/userinfo.js +32 -0
- package/src/modules/Userinfo/classes/ApplicationsAccess.js +170 -0
- package/src/modules/Userinfo/components/__tests__/auth.spec.js +57 -0
- package/src/modules/Userinfo/components/the-auth.vue +75 -0
- package/src/modules/Userinfo/store/UserinfoStoreModule.js +112 -0
- package/src/scripts/__tests__/caseConverters.spec.js +65 -0
- package/src/scripts/__tests__/convertDuration.spec.js +21 -0
- package/src/scripts/__tests__/debounce.spec.js +15 -0
- package/src/scripts/__tests__/editProxy.spec.js +9 -0
- package/src/scripts/__tests__/isEmpty.spec.js +16 -0
- package/src/scripts/__tests__/prettifyFileSize.spec.js +18 -0
- package/src/scripts/__tests__/prettifyTime.spec.js +18 -0
- package/src/scripts/__tests__/preventHiddenPageCallsDecorator.spec.js +16 -0
- package/src/scripts/__tests__/sortQueryAdapters.spec.js +12 -0
- package/src/scripts/caseConverters.js +78 -0
- package/src/scripts/convertDuration.js +15 -0
- package/src/scripts/editProxy.js +9 -0
- package/src/scripts/eventBus.js +4 -0
- package/src/scripts/isEmpty.js +9 -0
- package/src/scripts/prettifyFileSize.js +11 -0
- package/src/scripts/prettifyTime.js +9 -0
- package/src/scripts/preventHiddenPageCallsDecorator.js +6 -0
- package/src/scripts/sortQueryAdapters.js +21 -0
- package/src/store/BaseStoreModules/BaseStoreModule.js +49 -0
- package/src/store/BaseStoreModules/__tests__/BaseStoreModule.spec.js +104 -0
- package/src/store/helpers/__tests__/getNamespacedState.spec.js +11 -0
- package/src/store/helpers/getNamespacedState.js +5 -0
- package/dist/img/arrow-down--active--md.7b60f2fb6090366652124f77c543a516.svg +0 -3
- package/dist/img/arrow-down--disabled--md.f58424cd673258365e78863edd1e92cc.svg +0 -3
- package/dist/img/arrow-down--md.1843b60e1c244e066a650e8d19ea83c9.svg +0 -3
- package/dist/img/calendar--active--md.7fd3d949ec7234a4940ea452d95b4165.svg +0 -6
- package/dist/img/calendar--disabled--md.8e7a1e18f93ae8af270060400e6f881c.svg +0 -3
- package/dist/img/calendar--md.9c265581c3a405ff0f0e46e8092f36b8.svg +0 -6
- package/src/css/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/src/css/fonts/Montserrat/Montserrat-SemiBold.ttf +0 -0
- package/src/css/fonts.scss +0 -9
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { shallowMount, createLocalVue } from '@vue/test-utils';
|
|
2
|
+
import VueRouter from 'vue-router';
|
|
3
|
+
import _urlControllerMixin from '../_urlControllerMixin/_urlControllerMixin';
|
|
4
|
+
|
|
5
|
+
const localVue = createLocalVue();
|
|
6
|
+
localVue.use(VueRouter);
|
|
7
|
+
const router = new VueRouter();
|
|
8
|
+
|
|
9
|
+
const $t = () => {};
|
|
10
|
+
const filterQuery = 'team';
|
|
11
|
+
|
|
12
|
+
describe('URL Controller mixin Set and Get operations', () => {
|
|
13
|
+
let wrapper;
|
|
14
|
+
const Component = {
|
|
15
|
+
render() {},
|
|
16
|
+
mixins: [_urlControllerMixin],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
router.replace('/');
|
|
21
|
+
wrapper = shallowMount(Component, {
|
|
22
|
+
localVue,
|
|
23
|
+
router,
|
|
24
|
+
mocks: { $t },
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('Array of objects', async () => {
|
|
29
|
+
const value = [{ name: 'team 1', id: '1' }, { name: 'team 2', id: '2' }];
|
|
30
|
+
wrapper.vm.setValueToQuery({ filterQuery, value });
|
|
31
|
+
const queryValue = wrapper.vm.getValueFromQuery({ filterQuery });
|
|
32
|
+
expect(queryValue).toEqual(['1', '2']);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('Array of values', async () => {
|
|
36
|
+
const value = ['hello', '1'];
|
|
37
|
+
wrapper.vm.setValueToQuery({ filterQuery, value });
|
|
38
|
+
const queryValue = wrapper.vm.getValueFromQuery({ filterQuery });
|
|
39
|
+
expect(queryValue).toEqual(value);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('String value', async () => {
|
|
43
|
+
const value = 'hello there';
|
|
44
|
+
wrapper.vm.setValueToQuery({ filterQuery, value });
|
|
45
|
+
const queryValue = wrapper.vm.getValueFromQuery({ filterQuery });
|
|
46
|
+
expect(queryValue).toEqual(value);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import deepEqual from 'deep-equal';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
methods: {
|
|
5
|
+
changeRouteQuery({ filterQuery, value }) {
|
|
6
|
+
const query = { ...this.$route.query };
|
|
7
|
+
query[filterQuery] = value;
|
|
8
|
+
return this.$router.replace({
|
|
9
|
+
name: this.$router.currentRoute.name,
|
|
10
|
+
query,
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
setValueToQuery({ filterQuery, value, storedProp = 'id' }) {
|
|
15
|
+
let newValue = '';
|
|
16
|
+
if (Array.isArray(value)) {
|
|
17
|
+
if (value.length && typeof value[0] !== 'object') {
|
|
18
|
+
newValue = value;
|
|
19
|
+
} else {
|
|
20
|
+
newValue = value.map((item) => item[storedProp]);
|
|
21
|
+
}
|
|
22
|
+
} else if (typeof value === 'object' && value !== null) {
|
|
23
|
+
newValue = value[storedProp];
|
|
24
|
+
} else {
|
|
25
|
+
newValue = value;
|
|
26
|
+
}
|
|
27
|
+
if (!deepEqual(this.$route.query[filterQuery], newValue)) {
|
|
28
|
+
this.changeRouteQuery({
|
|
29
|
+
value: newValue,
|
|
30
|
+
filterQuery,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
getValueFromQuery({ filterQuery }) {
|
|
36
|
+
return this.$route.query[filterQuery];
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import baseFilterMixin from './baseFilterMixin/baseFilterMixin';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
mixins: [baseFilterMixin],
|
|
5
|
+
computed: {
|
|
6
|
+
locale() {
|
|
7
|
+
return this.filterSchema?.locale;
|
|
8
|
+
},
|
|
9
|
+
storedProp() {
|
|
10
|
+
return this.filterSchema?.storedProp;
|
|
11
|
+
},
|
|
12
|
+
multiple() {
|
|
13
|
+
return this.filterSchema?.multiple;
|
|
14
|
+
},
|
|
15
|
+
closeOnSelect() {
|
|
16
|
+
return this.filterSchema?.storedProp;
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
methods: {
|
|
20
|
+
async restoreValue(id) {
|
|
21
|
+
if (id && id.length) {
|
|
22
|
+
let newValue;
|
|
23
|
+
if (this.multiple) {
|
|
24
|
+
const idsArr = Array.isArray(id) ? id : [id];
|
|
25
|
+
this.setValue({ filter: this.filterQuery, value: idsArr.map((id) => ({ id })) });
|
|
26
|
+
newValue = await this.fetchSelected(idsArr);
|
|
27
|
+
} else {
|
|
28
|
+
this.setValue({ filter: this.filterQuery, value: { id } });
|
|
29
|
+
newValue = await this.fetchSelected(id);
|
|
30
|
+
}
|
|
31
|
+
this.setValue({ filter: this.filterQuery, value: newValue });
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
fetchSelected() {},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import _urlControllerMixin from '../_urlControllerMixin/_urlControllerMixin';
|
|
2
|
+
import getNamespacedState from '../../../../store/helpers/getNamespacedState';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
mixins: [_urlControllerMixin],
|
|
6
|
+
props: {
|
|
7
|
+
namespace: {
|
|
8
|
+
type: String,
|
|
9
|
+
description: 'Store module namespace for state and actions mapping.',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
created() {
|
|
13
|
+
this.restore({ filterQuery: this.filterQuery });
|
|
14
|
+
},
|
|
15
|
+
computed: {
|
|
16
|
+
filterSchema() {
|
|
17
|
+
if (!this.$store) throw new Error('Vuex is required for default filterSchema baseFilterMixin property');
|
|
18
|
+
return getNamespacedState(this.$store.state, this.namespace)[this.filterQuery];
|
|
19
|
+
},
|
|
20
|
+
value() {
|
|
21
|
+
return this.filterSchema.value;
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
methods: {
|
|
25
|
+
restore({ filterQuery }) {
|
|
26
|
+
const value = this.getValueFromQuery({ filterQuery });
|
|
27
|
+
if (value) this.restoreValue(value);
|
|
28
|
+
},
|
|
29
|
+
setValue(payload) {
|
|
30
|
+
if (!this.$store) throw new Error('Vuex is required for default setValue() baseFilterMixin method');
|
|
31
|
+
return this.$store.dispatch(`${this.namespace}/SET_FILTER`, payload);
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import baseFilterMixin from './baseFilterMixin/baseFilterMixin';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
mixins: [baseFilterMixin],
|
|
5
|
+
computed: {
|
|
6
|
+
options() {
|
|
7
|
+
return this.filterSchema.options;
|
|
8
|
+
},
|
|
9
|
+
locale() {
|
|
10
|
+
return this.filterSchema?.locale;
|
|
11
|
+
},
|
|
12
|
+
storedProp() {
|
|
13
|
+
return this.filterSchema?.storedProp;
|
|
14
|
+
},
|
|
15
|
+
multiple() {
|
|
16
|
+
return this.filterSchema?.multiple;
|
|
17
|
+
},
|
|
18
|
+
closeOnSelect() {
|
|
19
|
+
return this.filterSchema?.storedProp;
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
methods: {
|
|
23
|
+
restoreValue(value) {
|
|
24
|
+
let newValue;
|
|
25
|
+
if (Array.isArray(value)) {
|
|
26
|
+
newValue = this.options
|
|
27
|
+
.filter((option) => value
|
|
28
|
+
.some((value) => value === option[this.storedProp]));
|
|
29
|
+
} else {
|
|
30
|
+
newValue = this.options
|
|
31
|
+
.find((option) => value === option[this.storedProp]);
|
|
32
|
+
}
|
|
33
|
+
this.setValue({ filter: this.filterQuery, value: newValue });
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import baseFilterMixin from './baseFilterMixin/baseFilterMixin';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
mixins: [baseFilterMixin],
|
|
5
|
+
|
|
6
|
+
props: {
|
|
7
|
+
isNext: {
|
|
8
|
+
type: Boolean,
|
|
9
|
+
default: true,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
computed: {
|
|
14
|
+
isPrev() {
|
|
15
|
+
return this.page > 1;
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
methods: {
|
|
20
|
+
restore() {
|
|
21
|
+
this.restorePage();
|
|
22
|
+
this.restoreSize();
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
restorePage() {
|
|
26
|
+
const defaultPage = 1;
|
|
27
|
+
const value = +this.getValueFromQuery({ filterQuery: 'page' }) || defaultPage;
|
|
28
|
+
this.setPage(value);
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
restoreSize() {
|
|
32
|
+
const defaultSize = 10;
|
|
33
|
+
const value = +this.getValueFromQuery({ filterQuery: 'size' }) || defaultSize;
|
|
34
|
+
this.setSize(value);
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
next() {
|
|
38
|
+
this.$emit('input');
|
|
39
|
+
const value = this.page + 1;
|
|
40
|
+
this.setPage(value);
|
|
41
|
+
this.setValueToQuery({
|
|
42
|
+
filterQuery: 'page',
|
|
43
|
+
value,
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
prev() {
|
|
48
|
+
this.$emit('input');
|
|
49
|
+
const value = this.page - 1;
|
|
50
|
+
this.setPage(value);
|
|
51
|
+
this.setValueToQuery({
|
|
52
|
+
filterQuery: 'page',
|
|
53
|
+
value,
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
sizeChange(value) {
|
|
58
|
+
this.$emit('input');
|
|
59
|
+
this.setSize(value);
|
|
60
|
+
this.setValueToQuery({
|
|
61
|
+
filterQuery: 'size',
|
|
62
|
+
value,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import baseFilterMixin from './baseFilterMixin/baseFilterMixin';
|
|
2
|
+
import { SortSymbols, queryToSortAdapter, sortToQueryAdapter } from '../../../scripts/sortQueryAdapters';
|
|
3
|
+
|
|
4
|
+
const getNextSortOrder = (sort) => {
|
|
5
|
+
switch (sort) {
|
|
6
|
+
case SortSymbols.NONE: return SortSymbols.ASC;
|
|
7
|
+
case SortSymbols.ASC: return SortSymbols.DESC;
|
|
8
|
+
case SortSymbols.DESC: return SortSymbols.NONE;
|
|
9
|
+
default: return SortSymbols.ASC;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const encodeSortQuery = ({ column, order }) => (`${sortToQueryAdapter(order)}${column.field}`);
|
|
14
|
+
|
|
15
|
+
const decodeSortQuery = ({ value }) => {
|
|
16
|
+
const sort = queryToSortAdapter(value.slice(0, 1));
|
|
17
|
+
const sortedColumn = sort ? value.slice(1) : value;
|
|
18
|
+
return {
|
|
19
|
+
[sortedColumn]: sort,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
mixins: [baseFilterMixin],
|
|
25
|
+
data: () => ({
|
|
26
|
+
filterQuery: 'sort',
|
|
27
|
+
}),
|
|
28
|
+
methods: {
|
|
29
|
+
sort(column) {
|
|
30
|
+
const order = getNextSortOrder(column.sort);
|
|
31
|
+
this.setValue({ column, order });
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
setValue({ column, order }) {
|
|
35
|
+
const headers = this.headers.map((header) => ({
|
|
36
|
+
...header,
|
|
37
|
+
sort: header === column ? order : null,
|
|
38
|
+
}));
|
|
39
|
+
const value = encodeSortQuery({ column, order });
|
|
40
|
+
this.setHeaders(headers);
|
|
41
|
+
this.setValueToQuery({
|
|
42
|
+
value,
|
|
43
|
+
filterQuery: this.filterQuery,
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
restoreValue(value) {
|
|
48
|
+
const sortedColumns = decodeSortQuery({ value });
|
|
49
|
+
const headers = this.headers.map((header) => ({
|
|
50
|
+
...header,
|
|
51
|
+
sort: sortedColumns[header.field] || null,
|
|
52
|
+
}));
|
|
53
|
+
this.setHeaders(headers);
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import BaseStoreModule from '../../../store/BaseStoreModules/BaseStoreModule';
|
|
2
|
+
import isEmpty from '../../../scripts/isEmpty';
|
|
3
|
+
|
|
4
|
+
export default class QueryFiltersStoreModule extends BaseStoreModule {
|
|
5
|
+
getters = {
|
|
6
|
+
GET_FILTERS: (state, getters) => Object.keys(state)
|
|
7
|
+
.reduce((filters, filterKey) => {
|
|
8
|
+
const filterValue = getters.GET_FILTER(filterKey);
|
|
9
|
+
return isEmpty(filterValue) ? filters : { ...filters, [filterKey]: filterValue };
|
|
10
|
+
}, {}),
|
|
11
|
+
GET_FILTER: (state) => (filter) => {
|
|
12
|
+
const { value, storedProp, multiple } = state[filter];
|
|
13
|
+
if (multiple) return value.map((item) => item[storedProp]); // if arr, map
|
|
14
|
+
if (storedProp) return value[storedProp]; // if object and has specific prop, return this prop
|
|
15
|
+
return value; // else return val
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
actions = {
|
|
20
|
+
SET_FILTER: (context, { filter, value }) => {
|
|
21
|
+
const { multiple, defaultValue } = context.state[filter];
|
|
22
|
+
let newValue = value;
|
|
23
|
+
if (newValue) {
|
|
24
|
+
if (multiple && !Array.isArray(newValue)) newValue = [newValue];
|
|
25
|
+
} else {
|
|
26
|
+
newValue = defaultValue;
|
|
27
|
+
}
|
|
28
|
+
context.commit('SET_FILTER', { filter, value: newValue });
|
|
29
|
+
},
|
|
30
|
+
RESET_FILTERS: (context) => {
|
|
31
|
+
context.commit('RESET_FILTERS');
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
mutations = {
|
|
36
|
+
SET_FILTER: (state, { filter, value }) => {
|
|
37
|
+
state[filter].value = value;
|
|
38
|
+
},
|
|
39
|
+
RESET_FILTERS: (state) => {
|
|
40
|
+
Object.keys(state).forEach((filter) => {
|
|
41
|
+
state[filter].value = state[filter].defaultValue;
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
constructor({ state = {} } = {}) {
|
|
47
|
+
super();
|
|
48
|
+
this.state = state;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// import { shallowMount, createLocalVue } from '@vue/test-utils';
|
|
2
|
+
// import Vuex from 'vuex';
|
|
3
|
+
// import queryFilters from '../queryFilters';
|
|
4
|
+
import QueryFiltersStoreModule from '../QueryFiltersStoreModule';
|
|
5
|
+
|
|
6
|
+
const valueFilter = 'search';
|
|
7
|
+
const arrayFilter = 'agent';
|
|
8
|
+
const state = {
|
|
9
|
+
[valueFilter]: {
|
|
10
|
+
value: 'jest',
|
|
11
|
+
defaultValue: '',
|
|
12
|
+
},
|
|
13
|
+
[arrayFilter]: {
|
|
14
|
+
value: [{ id: 1 }],
|
|
15
|
+
defaultValue: [],
|
|
16
|
+
storedProp: 'id',
|
|
17
|
+
multiple: true,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
describe('QueryFiltersStoreModule getters', () => {
|
|
22
|
+
let module;
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
module = new QueryFiltersStoreModule().getModule();
|
|
25
|
+
});
|
|
26
|
+
it('GET_FILTER: single value filter', () => {
|
|
27
|
+
expect(module.getters.GET_FILTER(state)(valueFilter))
|
|
28
|
+
.toEqual('jest');
|
|
29
|
+
});
|
|
30
|
+
it('GET_FILTER: array value filter', () => {
|
|
31
|
+
expect(module.getters.GET_FILTER(state)(arrayFilter))
|
|
32
|
+
.toEqual([1]);
|
|
33
|
+
});
|
|
34
|
+
it('GET_FILTERS filters aggregator', () => {
|
|
35
|
+
const { GET_FILTER } = module.getters;
|
|
36
|
+
module.getters.GET_FILTER = jest.fn((filter) => GET_FILTER(state)(filter));
|
|
37
|
+
expect(module.getters.GET_FILTERS(state, module.getters))
|
|
38
|
+
.toEqual({ agent: [1], search: 'jest' });
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('QueryFiltersStoreModule actions', () => {
|
|
43
|
+
const context = {
|
|
44
|
+
state: { ...state },
|
|
45
|
+
commit: jest.fn(),
|
|
46
|
+
};
|
|
47
|
+
const module = new QueryFiltersStoreModule().getModule();
|
|
48
|
+
it('SET_FILTER: single value filter', () => {
|
|
49
|
+
const filter = { filter: valueFilter, value: '3' };
|
|
50
|
+
module.actions.SET_FILTER(context, filter);
|
|
51
|
+
expect(context.commit).toHaveBeenCalledWith('SET_FILTER', filter);
|
|
52
|
+
});
|
|
53
|
+
it('SET_FILTER: array value filter', () => {
|
|
54
|
+
const filter = { filter: 'agent', value: [{ id: 3 }] };
|
|
55
|
+
module.actions.SET_FILTER(context, filter);
|
|
56
|
+
expect(context.commit).toHaveBeenCalledWith('SET_FILTER', filter);
|
|
57
|
+
});
|
|
58
|
+
it('SET_FILTER: array value filter with single object value', () => {
|
|
59
|
+
const filter = { filter: arrayFilter, value: { id: 3 } };
|
|
60
|
+
module.actions.SET_FILTER(context, filter);
|
|
61
|
+
expect(context.commit)
|
|
62
|
+
.toHaveBeenCalledWith('SET_FILTER', { filter: filter.filter, value: [filter.value] });
|
|
63
|
+
});
|
|
64
|
+
it('SET_FILTER: sets array value filter with null value to defaultValue', () => {
|
|
65
|
+
const filter = { filter: arrayFilter, value: null };
|
|
66
|
+
module.actions.SET_FILTER(context, filter);
|
|
67
|
+
expect(context.commit)
|
|
68
|
+
.toHaveBeenCalledWith('SET_FILTER', { filter: filter.filter, value: [] });
|
|
69
|
+
});
|
|
70
|
+
it('calls RESET_FILTERS mutation on RESET_FILTERS action call', () => {
|
|
71
|
+
module.actions.RESET_FILTERS(context);
|
|
72
|
+
expect(context.commit).toHaveBeenCalledWith('RESET_FILTERS');
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('QueryFiltersStoreModule mutations', () => {
|
|
77
|
+
const module = new QueryFiltersStoreModule().getModule();
|
|
78
|
+
it('correctly mutates state at RESET_FILTERS call', () => {
|
|
79
|
+
expect(Object.values(state).every((filter) => filter.value === filter.defaultValue)).toBeFalsy();
|
|
80
|
+
module.mutations.RESET_FILTERS(state);
|
|
81
|
+
expect(Object.values(state).every((filter) => filter.value === filter.defaultValue)).toBeTruthy();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import BaseAPIService from './BaseAPIService';
|
|
2
|
+
|
|
3
|
+
class AuthAPI extends BaseAPIService {
|
|
4
|
+
async setToken(token) {
|
|
5
|
+
localStorage.setItem('access-token', token);
|
|
6
|
+
this._instance.defaults.headers['X-Webitel-Access'] = localStorage.getItem('access-token');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
removeToken() {
|
|
10
|
+
localStorage.removeItem('access-token');
|
|
11
|
+
localStorage.removeItem('domain');
|
|
12
|
+
this._instance.defaults.headers['X-Webitel-Access'] = '';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async logout() {
|
|
16
|
+
const url = '/logout';
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
await this._instance.post(url, {});
|
|
20
|
+
this.removeToken();
|
|
21
|
+
} catch (err) {
|
|
22
|
+
throw err;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const auth = new AuthAPI();
|
|
28
|
+
|
|
29
|
+
export default auth;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import BaseAPIService from './BaseAPIService';
|
|
2
|
+
|
|
3
|
+
class UserinfoAPI extends BaseAPIService {
|
|
4
|
+
// gets user by token from localstorage
|
|
5
|
+
// stores response username in vuex
|
|
6
|
+
async getSession() {
|
|
7
|
+
// const tokenCheck = localStorage.getItem('access-token');
|
|
8
|
+
// if (typeof tokenCheck === 'string') { // if there is no token, localStorage returns object
|
|
9
|
+
const url = '/userinfo';
|
|
10
|
+
try {
|
|
11
|
+
const response = await this._instance.get(url);
|
|
12
|
+
return response;
|
|
13
|
+
} catch (err) {
|
|
14
|
+
throw err;
|
|
15
|
+
}
|
|
16
|
+
// }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async getApplicationsAccess() {
|
|
20
|
+
const url = 'role/metadata/access';
|
|
21
|
+
try {
|
|
22
|
+
const response = await this._instance.get(url);
|
|
23
|
+
return response;
|
|
24
|
+
} catch (err) {
|
|
25
|
+
throw err;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const userinfo = new UserinfoAPI();
|
|
31
|
+
|
|
32
|
+
export default userinfo;
|