@webitel/ui-sdk 0.9.64 → 1.0.1
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/CHANGELOG.md +41 -0
- package/dist/fonts/Montserrat-Black.27e3649b.ttf +0 -0
- package/dist/fonts/Montserrat-BlackItalic.d9b6ba59.ttf +0 -0
- package/dist/fonts/Montserrat-Bold.ade91f47.ttf +0 -0
- package/dist/fonts/Montserrat-BoldItalic.1b384149.ttf +0 -0
- package/dist/fonts/Montserrat-ExtraBold.19ba7aa5.ttf +0 -0
- package/dist/fonts/Montserrat-ExtraBoldItalic.52a50ca0.ttf +0 -0
- package/dist/fonts/Montserrat-ExtraLight.570a244c.ttf +0 -0
- package/dist/fonts/Montserrat-ExtraLightItalic.1170df55.ttf +0 -0
- package/dist/fonts/Montserrat-Italic.a7063e0c.ttf +0 -0
- package/dist/fonts/Montserrat-Light.409c7f79.ttf +0 -0
- package/dist/fonts/Montserrat-LightItalic.01c4560c.ttf +0 -0
- package/dist/fonts/Montserrat-Medium.c8b6e083.ttf +0 -0
- package/dist/fonts/Montserrat-MediumItalic.40a74702.ttf +0 -0
- package/dist/fonts/Montserrat-SemiBoldItalic.83c1ec1f.ttf +0 -0
- package/dist/fonts/Montserrat-Thin.43dd5b7a.ttf +0 -0
- package/dist/fonts/Montserrat-ThinItalic.3c2b290f.ttf +0 -0
- package/dist/ui-sdk.common.js +939 -920
- package/dist/ui-sdk.common.js.map +1 -1
- package/dist/ui-sdk.css +1 -1
- package/dist/ui-sdk.umd.js +939 -920
- package/dist/ui-sdk.umd.js.map +1 -1
- package/dist/ui-sdk.umd.min.js +2 -2
- package/dist/ui-sdk.umd.min.js.map +1 -1
- package/package.json +5 -6
- package/src/components/atoms/wt-button/wt-button.vue +187 -150
- package/src/components/atoms/wt-chip/__tests__/WtChip.spec.js +19 -0
- package/src/components/atoms/wt-chip/wt-chip.vue +23 -0
- package/src/components/atoms/wt-context-menu/wt-context-menu.vue +1 -1
- package/src/components/atoms/wt-icon/wt-icon.vue +4 -0
- package/src/components/atoms/wt-indicator/wt-indicator.vue +39 -6
- package/src/components/atoms/wt-input-info/wt-input-info.vue +1 -1
- package/src/components/atoms/wt-loader/_internals/wt-loader--sm.vue +34 -153
- package/src/components/atoms/wt-loader/wt-loader.vue +2 -4
- package/src/components/atoms/wt-rounded-action/__tests__/WtRoundedAction.spec.js +0 -11
- package/src/components/atoms/wt-rounded-action/wt-rounded-action.vue +27 -179
- package/src/components/atoms/wt-tooltip/wt-tooltip.vue +2 -2
- package/src/components/index.js +2 -2
- package/src/components/molecules/wt-button-select/wt-button-select.vue +2 -1
- package/src/components/molecules/wt-datepicker/wt-datepicker.vue +61 -59
- package/src/components/molecules/wt-datetimepicker/wt-datetimepicker.vue +2 -2
- package/src/components/molecules/wt-input/wt-input.vue +4 -22
- package/src/components/molecules/wt-label/wt-label.vue +2 -2
- package/src/components/molecules/wt-notification/wt-notification.vue +3 -2
- package/src/components/molecules/wt-popup/__tests__/WtPopup.spec.js +1 -1
- package/src/components/molecules/wt-popup/wt-popup.vue +26 -28
- package/src/components/molecules/wt-progress-bar/wt-progress-bar.vue +3 -4
- package/src/components/molecules/wt-radio/wt-radio.vue +0 -2
- package/src/components/molecules/wt-search-bar/wt-search-bar.vue +4 -20
- package/src/components/molecules/wt-select/wt-select.vue +26 -25
- package/src/components/molecules/wt-tabs/wt-tabs.vue +6 -18
- package/src/components/molecules/wt-tags-input/wt-tags-input.vue +31 -20
- package/src/components/molecules/wt-textarea/wt-textarea.vue +6 -14
- package/src/components/molecules/wt-time-input/wt-time-input.vue +1 -1
- package/src/components/organisms/wt-app-header/wt-app-header.vue +1 -0
- package/src/components/organisms/wt-app-header/wt-app-navigator.vue +32 -33
- package/src/components/organisms/wt-app-header/wt-header-actions.vue +145 -144
- package/src/components/organisms/wt-filters-panel-wrapper/wt-filters-panel-wrapper.vue +3 -3
- package/src/components/organisms/wt-headline/wt-headline.vue +1 -2
- package/src/components/organisms/wt-navigation-bar/wt-navigation-bar.vue +8 -11
- package/src/components/organisms/wt-page-wrapper/wt-page-wrapper.vue +6 -14
- package/src/components/organisms/wt-pagination/wt-pagination.vue +5 -5
- package/src/components/organisms/wt-player/wt-player.vue +1 -1
- package/src/components/organisms/wt-status-select/wt-status-select.vue +24 -4
- package/src/components/organisms/wt-table/wt-table.vue +15 -12
- package/src/components/organisms/wt-table-actions/wt-table-actions.vue +2 -4
- package/src/components/organisms/wt-table-column-select/wt-table-column-select.vue +1 -1
- package/src/css/components/_components.scss +1 -1
- package/src/css/components/atoms/wt-button/_variables.scss +22 -24
- package/src/css/components/atoms/wt-chip/_variables.scss +7 -0
- package/src/css/components/atoms/{wt-badge/wt-badge.scss → wt-chip/wt-chip.scss} +12 -7
- package/src/css/components/atoms/wt-context-menu/_variables.scss +1 -1
- package/src/css/components/atoms/wt-indicator/_variables.scss +6 -2
- package/src/css/components/atoms/wt-rounded-action/_variables.scss +3 -26
- package/src/css/components/atoms/wt-tooltip/_variables.scss +7 -5
- package/src/css/components/molecules/wt-button-select/_variables.scss +5 -8
- package/src/css/components/molecules/wt-checkbox/_variables.scss +1 -1
- package/src/css/components/molecules/wt-datepicker/_variables.scss +15 -14
- package/src/css/components/molecules/wt-datepicker/datepicker-calendar.scss +20 -31
- package/src/css/components/molecules/wt-datetimepicker/_variables.scss +5 -5
- package/src/css/components/molecules/wt-input/_variables.scss +3 -3
- package/src/css/components/molecules/wt-notification/_variables.scss +4 -4
- package/src/css/components/molecules/wt-popup/_variables.scss +16 -8
- package/src/css/components/molecules/wt-progress-bar/_variables.scss +3 -3
- package/src/css/components/molecules/wt-radio/_variables.scss +1 -1
- package/src/css/components/molecules/wt-search-bar/_variables.scss +5 -1
- package/src/css/components/molecules/wt-select/_variables.scss +49 -13
- package/src/css/components/molecules/wt-switcher/_variables.scss +1 -1
- package/src/css/components/molecules/wt-tabs/_variables.scss +2 -2
- package/src/css/components/molecules/wt-tags-input/_variables.scss +4 -5
- package/src/css/components/molecules/wt-textarea/_variables.scss +9 -1
- package/src/css/components/molecules/wt-timepicker/_variables.scss +1 -1
- package/src/css/components/organisms/wt-app-header/_variables.scss +13 -9
- package/src/css/components/organisms/wt-headline/_variables.scss +3 -4
- package/src/css/components/organisms/wt-navigation-bar/_variables.scss +10 -10
- package/src/css/components/organisms/wt-notifications-bar/_variables.scss +2 -2
- package/src/css/components/organisms/wt-page-wrapper/_variables.scss +3 -3
- package/src/css/components/organisms/wt-pagination/_variables.scss +1 -3
- package/src/css/components/organisms/wt-player/_variables.scss +2 -2
- package/src/css/components/organisms/wt-status-select/_variables.scss +3 -3
- package/src/css/components/organisms/wt-table/_variables.scss +9 -9
- package/src/css/components/organisms/wt-table-actions/_variables.scss +2 -1
- package/src/css/main.scss +7 -5
- package/src/css/styleguide/_styleguide.scss +8 -3
- package/src/css/styleguide/border-radius/_border-radius.scss +4 -0
- package/src/css/{colors → styleguide/colors}/_colors.scss +5 -7
- package/src/css/{display-helpers → styleguide/display-helpers}/_display-helpers.scss +2 -0
- package/src/css/styleguide/elevations/_elevations.scss +13 -0
- package/src/css/styleguide/fonts/_fonts.scss +126 -0
- package/src/css/styleguide/placeholder/_placeholder.scss +49 -0
- package/src/css/styleguide/spacings/_spacings.scss +15 -0
- package/src/css/styleguide/transitions/_transitions.scss +1 -0
- package/src/css/{transitions → styleguide/transitions}/fade/_fade.scss +0 -0
- package/src/css/styleguide/typography/_typography.scss +102 -0
- package/src/css/{sizes → styleguide/viewport-breakpoints}/_viewport-breakpoints.scss +0 -0
- package/src/locale/en/en.js +28 -3
- package/src/locale/ru/ru.js +26 -1
- package/src/locale/ua/ua.js +26 -1
- package/src/modules/QueryFilters/api/__tests__/defaults.spec.js +18 -0
- package/src/modules/QueryFilters/api/defaults.js +16 -0
- package/src/modules/QueryFilters/components/__tests__/abstract-enum-filter.spec.js +0 -3
- package/src/modules/QueryFilters/components/__tests__/filter-search.spec.js +28 -23
- package/src/modules/QueryFilters/components/filter-search.vue +1 -1
- package/src/modules/QueryFilters/mixins/__tests__/apiFilterMixin.spec.js +14 -15
- package/src/modules/QueryFilters/mixins/__tests__/enumFilterMixin.spec.js +35 -50
- package/src/modules/QueryFilters/mixins/__tests__/paginationFilterMixin.spec.js +86 -0
- package/src/modules/QueryFilters/mixins/__tests__/sortFilterMixin.spec.js +11 -16
- 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/baseFilterMixin/baseFilterMixin.js +2 -8
- package/src/modules/QueryFilters/mixins/enumFilterMixin.js +9 -11
- package/src/modules/QueryFilters/mixins/paginationFilterMixin.js +76 -0
- package/src/modules/QueryFilters/store/QueryFiltersStoreModule.js +0 -6
- package/src/modules/QueryFilters/store/queryFilters.js +6 -0
- package/src/components/atoms/wt-badge/__tests__/WtBadge.spec.js +0 -19
- package/src/components/atoms/wt-badge/wt-badge.vue +0 -23
- package/src/css/components/atoms/wt-badge/_variables.scss +0 -7
- package/src/css/fonts/_fonts.scss +0 -9
- package/src/css/shadows/_shadows.scss +0 -7
- package/src/css/sizes/_sizes.scss +0 -2
- package/src/css/sizes/_spacing.scss +0 -33
- package/src/css/transitions/_transitions.scss +0 -1
- package/src/css/typography/_typography.scss +0 -72
- package/src/modules/QueryFilters/components/__tests__/filter-pagination.spec.js +0 -71
- package/src/modules/QueryFilters/components/filter-pagination.vue +0 -110
- package/src/modules/QueryFilters/store/QueryControllerStoreModule.js +0 -64
- package/src/modules/QueryFilters/store/__tests__/QueryControllerStoreModule.spec.js +0 -42
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
resetPage() {
|
|
58
|
+
this.$emit('input');
|
|
59
|
+
const value = 1;
|
|
60
|
+
this.setPage(value);
|
|
61
|
+
this.setValueToQuery({
|
|
62
|
+
filterQuery: 'page',
|
|
63
|
+
value,
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
sizeChange(value) {
|
|
68
|
+
this.$emit('input');
|
|
69
|
+
this.setSize(value);
|
|
70
|
+
this.setValueToQuery({
|
|
71
|
+
filterQuery: 'size',
|
|
72
|
+
value,
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
@@ -43,12 +43,6 @@ export default class QueryFiltersStoreModule extends BaseStoreModule {
|
|
|
43
43
|
},
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
generateQueryControllerActions(controllerNamespace) {
|
|
47
|
-
this.actions.SET_VALUE_TO_QUERY = (context, payload) => context.dispatch(`${controllerNamespace}/SET_VALUE_TO_QUERY`, payload, { root: true });
|
|
48
|
-
this.actions.GET_VALUE_FROM_QUERY = (context, payload) => context.dispatch(`${controllerNamespace}/GET_VALUE_FROM_QUERY`, payload, { root: true });
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
46
|
constructor({ state = {} } = {}) {
|
|
53
47
|
super();
|
|
54
48
|
this.state = state;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils';
|
|
2
|
-
import WtBadge from '../wt-badge.vue';
|
|
3
|
-
|
|
4
|
-
describe('WtBadge', () => {
|
|
5
|
-
it('renders a component', () => {
|
|
6
|
-
const wrapper = shallowMount(WtBadge);
|
|
7
|
-
expect(wrapper.classes('wt-badge')).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('renders a badge content via default slot', () => {
|
|
11
|
-
const content = 'badge content';
|
|
12
|
-
const wrapper = shallowMount(WtBadge, {
|
|
13
|
-
slots: {
|
|
14
|
-
default: content,
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
expect(wrapper.find('.wt-badge').text()).toBe(content);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<span class="wt-badge" :class="`wt-badge--${color}-color`">
|
|
3
|
-
<slot></slot>
|
|
4
|
-
</span>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script>
|
|
8
|
-
export default {
|
|
9
|
-
name: 'wt-badge',
|
|
10
|
-
props: {
|
|
11
|
-
color: {
|
|
12
|
-
type: String,
|
|
13
|
-
default: 'main',
|
|
14
|
-
options: ['main', 'outline', 'accent', 'secondary', 'success', 'danger', 'transfer'],
|
|
15
|
-
notes: '"main" and "outline" are badge-specific colors',
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
<style lang="scss" scoped>
|
|
22
|
-
@import '../../../css/components/atoms/wt-badge/wt-badge';
|
|
23
|
-
</style>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
@font-face {
|
|
2
|
-
font-family: 'Montserrat Semi';
|
|
3
|
-
src: url('../../assets/fonts/Montserrat/Montserrat-SemiBold.ttf') format('truetype');
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
@font-face {
|
|
7
|
-
font-family: 'Montserrat Regular';
|
|
8
|
-
src: url('../../assets/fonts/Montserrat/Montserrat-Regular.ttf') format('truetype');
|
|
9
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--shadow-style-down-50: 0px 0px 1px rgba(0, 0, 0, 0.15), inset 1px 1px 1px rgba(0, 0, 0, 0.05);
|
|
3
|
-
--shadow-style-down-100: 0px 0px 1px rgba(0, 0, 0, 0.15), inset 1px 1px 1px rgba(0, 0, 0, 0.05), inset 0px 0px 8px rgba(0, 0, 0, 0.1);
|
|
4
|
-
--shadow-style-up-50: 1px 1px 2px rgba(0, 0, 0, 0.08), inset 1px 1px 1px #FFFFFF, inset -1px -1px 1px rgba(0, 0, 0, 0.05);
|
|
5
|
-
--shadow-style-up-100: 1px 1px 2px rgba(0, 0, 0, 0.05), -1px -1px 5px #FFFFFF, inset 1px 1px 1px #FFFFFF, inset -1px -1px 3px rgba(0, 0, 0, 0.1);
|
|
6
|
-
--shadow-style-font: 0px 0px 10px rgba(0, 0, 0, 0.1);
|
|
7
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
//@import './viewport-breakpoints';
|
|
2
|
-
|
|
3
|
-
:root {
|
|
4
|
-
// Start point
|
|
5
|
-
--_spacing-multiplicity: 4px;
|
|
6
|
-
|
|
7
|
-
// Spacings
|
|
8
|
-
--spacing--xs: calc(var(--_spacing-multiplicity) * 1);
|
|
9
|
-
--spacing--sm: calc(var(--_spacing-multiplicity) * 2);
|
|
10
|
-
--spacing--md: calc(var(--_spacing-multiplicity) * 3);
|
|
11
|
-
--spacing--lg: calc(var(--_spacing-multiplicity) * 4);
|
|
12
|
-
--spacing--xl: calc(var(--_spacing-multiplicity) * 5);
|
|
13
|
-
--spacing--2xl: calc(var(--_spacing-multiplicity) * 6);
|
|
14
|
-
--spacing--3xl: calc(var(--_spacing-multiplicity) * 7);
|
|
15
|
-
|
|
16
|
-
// Border radius
|
|
17
|
-
--border-radius: var(--spacing--xs);
|
|
18
|
-
|
|
19
|
-
// DEPRECATED
|
|
20
|
-
--component-padding: var(--spacing--lg);
|
|
21
|
-
--component-spacing: var(--spacing--lg);
|
|
22
|
-
--icon-spacing: var(--spacing--sm);
|
|
23
|
-
|
|
24
|
-
//@media (#{$media} and #{$media-width-sm}) {
|
|
25
|
-
// --component-padding: 10px;
|
|
26
|
-
// --component-spacing: 10px;
|
|
27
|
-
//}
|
|
28
|
-
//
|
|
29
|
-
//@media (#{$media} and #{$media-width-xs}) {
|
|
30
|
-
// --component-padding: 10px;
|
|
31
|
-
// --component-spacing: 1px;
|
|
32
|
-
//}
|
|
33
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import "./fade/fade";
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
%typo-heading-lg {
|
|
3
|
-
font: {
|
|
4
|
-
family: 'Montserrat Semi', monospace;
|
|
5
|
-
size: 24px;
|
|
6
|
-
}
|
|
7
|
-
line-height: 30px;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
%typo-heading-md {
|
|
11
|
-
font: {
|
|
12
|
-
family: 'Montserrat Semi', monospace;
|
|
13
|
-
size: 20px;
|
|
14
|
-
}
|
|
15
|
-
line-height: 30px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
%typo-heading-sm {
|
|
19
|
-
font: {
|
|
20
|
-
family: 'Montserrat Semi', monospace;
|
|
21
|
-
size: 18px;
|
|
22
|
-
}
|
|
23
|
-
line-height: 24px;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
%typo-strong-lg {
|
|
27
|
-
font: {
|
|
28
|
-
family: 'Montserrat Semi', monospace;
|
|
29
|
-
size: 14px;
|
|
30
|
-
}
|
|
31
|
-
line-height: 18px;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
%typo-strong-md {
|
|
35
|
-
font: {
|
|
36
|
-
family: 'Montserrat Semi', monospace;
|
|
37
|
-
size: 12px;
|
|
38
|
-
}
|
|
39
|
-
line-height: 14px;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
%typo-strong-sm {
|
|
43
|
-
font: {
|
|
44
|
-
family: 'Montserrat Semi', monospace;
|
|
45
|
-
size: 10px;
|
|
46
|
-
}
|
|
47
|
-
line-height: 12px;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
%typo-body-lg {
|
|
51
|
-
font: {
|
|
52
|
-
family: 'Montserrat Regular', monospace;
|
|
53
|
-
size: 14px;
|
|
54
|
-
}
|
|
55
|
-
line-height: 18px;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
%typo-body-md {
|
|
59
|
-
font: {
|
|
60
|
-
family: 'Montserrat Regular', monospace;
|
|
61
|
-
size: 12px;
|
|
62
|
-
}
|
|
63
|
-
line-height: 14px;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
%typo-body-sm {
|
|
67
|
-
font: {
|
|
68
|
-
family: 'Montserrat Regular', monospace;
|
|
69
|
-
size: 10px;
|
|
70
|
-
}
|
|
71
|
-
line-height: 12px;
|
|
72
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils';
|
|
2
|
-
import BaseFilterSchema from '../../classes/BaseFilterSchema';
|
|
3
|
-
import baseFilterMixin from '../../mixins/baseFilterMixin/baseFilterMixin';
|
|
4
|
-
import FilterPagination from '../filter-pagination.vue';
|
|
5
|
-
|
|
6
|
-
const pageDefaultValue = 1;
|
|
7
|
-
const page = 2;
|
|
8
|
-
const size = 20;
|
|
9
|
-
|
|
10
|
-
const pageFilterSchema = new BaseFilterSchema({ value: page, defaultValue: pageDefaultValue });
|
|
11
|
-
const sizeFilterSchema = new BaseFilterSchema({ value: size });
|
|
12
|
-
|
|
13
|
-
describe('Pagination filter mixin', () => {
|
|
14
|
-
const setValue = jest.fn();
|
|
15
|
-
const setValueToQuery = jest.fn();
|
|
16
|
-
const getValueFromQuery = jest.fn(({ filterQuery }) => (filterQuery === 'page' ? page : size));
|
|
17
|
-
|
|
18
|
-
let wrapper;
|
|
19
|
-
|
|
20
|
-
jest.spyOn(baseFilterMixin.methods, 'setValue').mockImplementation(setValue);
|
|
21
|
-
jest.spyOn(baseFilterMixin.methods, 'setValueToQuery').mockImplementation(setValueToQuery);
|
|
22
|
-
jest.spyOn(baseFilterMixin.methods, 'getValueFromQuery').mockImplementation(getValueFromQuery);
|
|
23
|
-
|
|
24
|
-
const computed = {
|
|
25
|
-
pageFilterSchema() { return pageFilterSchema; },
|
|
26
|
-
sizeFilterSchema() { return sizeFilterSchema; },
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
beforeEach(() => {
|
|
30
|
-
setValue.mockClear();
|
|
31
|
-
setValueToQuery.mockClear();
|
|
32
|
-
getValueFromQuery.mockClear();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('Correctly sets value from $route query', async () => {
|
|
36
|
-
wrapper = shallowMount(FilterPagination, {
|
|
37
|
-
computed,
|
|
38
|
-
});
|
|
39
|
-
expect(setValue).toHaveBeenNthCalledWith(1, { filter: 'page', value: page });
|
|
40
|
-
expect(setValue).toHaveBeenNthCalledWith(2, { filter: 'size', value: size });
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('At "prev" page, changes query and emits event', async () => {
|
|
44
|
-
wrapper = shallowMount(FilterPagination, { computed });
|
|
45
|
-
wrapper.vm.prev();
|
|
46
|
-
expect(wrapper.emitted().input).toBeTruthy();
|
|
47
|
-
expect(setValue).toHaveBeenLastCalledWith({ filter: 'page', value: page - 1 });
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('At "next" page, changes query and emits event', async () => {
|
|
51
|
-
wrapper = shallowMount(FilterPagination, { computed });
|
|
52
|
-
wrapper.vm.next();
|
|
53
|
-
expect(wrapper.emitted().input).toBeTruthy();
|
|
54
|
-
expect(setValue).toHaveBeenLastCalledWith({ filter: 'page', value: page + 1 });
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('At "resetPage" method, changes query and emits event', async () => {
|
|
58
|
-
wrapper = shallowMount(FilterPagination, { computed });
|
|
59
|
-
wrapper.vm.resetPage();
|
|
60
|
-
expect(wrapper.emitted().input).toBeTruthy();
|
|
61
|
-
expect(setValue).toHaveBeenLastCalledWith({ filter: 'page', value: pageDefaultValue });
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('At "sizeChange", changes query and emits event', async () => {
|
|
65
|
-
const newSize = 40;
|
|
66
|
-
wrapper = shallowMount(FilterPagination, { computed });
|
|
67
|
-
wrapper.vm.sizeChange(newSize);
|
|
68
|
-
expect(wrapper.emitted().input).toBeTruthy();
|
|
69
|
-
expect(setValue).toHaveBeenLastCalledWith({ filter: 'size', value: newSize });
|
|
70
|
-
});
|
|
71
|
-
});
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<wt-pagination
|
|
3
|
-
:next="isNext"
|
|
4
|
-
:prev="isPrev"
|
|
5
|
-
:size="sizeFilterSchema.value"
|
|
6
|
-
debounce
|
|
7
|
-
@change="sizeChange"
|
|
8
|
-
@next="next"
|
|
9
|
-
@prev="prev"
|
|
10
|
-
></wt-pagination>
|
|
11
|
-
</template>
|
|
12
|
-
|
|
13
|
-
<script>
|
|
14
|
-
import getNamespacedState from '../../../store/helpers/getNamespacedState';
|
|
15
|
-
import baseFilterMixin from '../mixins/baseFilterMixin/baseFilterMixin';
|
|
16
|
-
|
|
17
|
-
export default {
|
|
18
|
-
name: 'filter-pagination',
|
|
19
|
-
mixins: [baseFilterMixin],
|
|
20
|
-
props: {
|
|
21
|
-
isNext: {
|
|
22
|
-
type: Boolean,
|
|
23
|
-
default: true,
|
|
24
|
-
},
|
|
25
|
-
pageFilterQuery: {
|
|
26
|
-
type: String,
|
|
27
|
-
default: 'page',
|
|
28
|
-
},
|
|
29
|
-
sizeFilterQuery: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: 'size',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
computed: {
|
|
36
|
-
pageFilterSchema() {
|
|
37
|
-
if (!this.$store) throw new Error('Vuex is required for page filter binding');
|
|
38
|
-
return getNamespacedState(this.$store.state, this.namespace)[this.pageFilterQuery];
|
|
39
|
-
},
|
|
40
|
-
sizeFilterSchema() {
|
|
41
|
-
if (!this.$store) throw new Error('Vuex is required for size filter binding');
|
|
42
|
-
return getNamespacedState(this.$store.state, this.namespace)[this.sizeFilterQuery];
|
|
43
|
-
},
|
|
44
|
-
isPrev() {
|
|
45
|
-
return this.pageFilterSchema.value > 1;
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
methods: {
|
|
50
|
-
restore() {
|
|
51
|
-
this.restorePage();
|
|
52
|
-
this.restoreSize();
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
restorePage() {
|
|
56
|
-
const value = +this.getValueFromQuery({ filterQuery: this.pageFilterQuery });
|
|
57
|
-
if (value) this.setValue({ filter: this.pageFilterQuery, value });
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
restoreSize() {
|
|
61
|
-
const value = +this.getValueFromQuery({ filterQuery: this.sizeFilterQuery });
|
|
62
|
-
if (value) this.setValue({ filter: this.sizeFilterQuery, value });
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
next() {
|
|
66
|
-
this.$emit('input');
|
|
67
|
-
const value = this.pageFilterSchema.value + 1;
|
|
68
|
-
this.setValue({ filter: this.pageFilterQuery, value });
|
|
69
|
-
this.setValueToQuery({
|
|
70
|
-
filterQuery: this.pageFilterQuery,
|
|
71
|
-
value,
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
prev() {
|
|
76
|
-
this.$emit('input');
|
|
77
|
-
const value = this.pageFilterSchema.value - 1;
|
|
78
|
-
this.setValue({ filter: this.pageFilterQuery, value });
|
|
79
|
-
this.setValueToQuery({
|
|
80
|
-
filterQuery: this.pageFilterQuery,
|
|
81
|
-
value,
|
|
82
|
-
});
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
resetPage() {
|
|
86
|
-
this.$emit('input');
|
|
87
|
-
const value = this.pageFilterSchema.defaultValue;
|
|
88
|
-
this.setValue({ filter: this.pageFilterQuery, value });
|
|
89
|
-
this.setValueToQuery({
|
|
90
|
-
filterQuery: this.pageFilterQuery,
|
|
91
|
-
value,
|
|
92
|
-
});
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
sizeChange(value) {
|
|
96
|
-
this.$emit('input');
|
|
97
|
-
this.setValue({ filter: this.sizeFilterQuery, value });
|
|
98
|
-
this.setValueToQuery({
|
|
99
|
-
filterQuery: this.sizeFilterQuery,
|
|
100
|
-
value,
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
</script>
|
|
107
|
-
|
|
108
|
-
<style scoped>
|
|
109
|
-
|
|
110
|
-
</style>
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import deepEqual from 'deep-equal';
|
|
2
|
-
import BaseStoreModule from '../../../store/BaseStoreModules/BaseStoreModule';
|
|
3
|
-
|
|
4
|
-
export default class QueryControllerStoreModule extends BaseStoreModule {
|
|
5
|
-
getters = {
|
|
6
|
-
GET_VALUE_FROM_QUERY: (state) => ({ filterQuery }) => state.router.currentRoute.query[filterQuery],
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
actions = {
|
|
10
|
-
// OVERRIDE ME
|
|
11
|
-
// eslint-disable-next-line no-unused-vars
|
|
12
|
-
BEFORE_CHANGE_ROUTE_QUERY_HOOK: (context, { query, filterQuery, value }) => query,
|
|
13
|
-
// OVERRIDE ME
|
|
14
|
-
AFTER_CHANGE_ROUTE_QUERY_HOOK: (context, { query }) => query,
|
|
15
|
-
_CHANGE_ROUTE_QUERY: async (context, { filterQuery, value }) => {
|
|
16
|
-
try {
|
|
17
|
-
const { router } = context.state;
|
|
18
|
-
let query = { ...router.currentRoute.query };
|
|
19
|
-
query[filterQuery] = value;
|
|
20
|
-
query = await context.dispatch('BEFORE_CHANGE_ROUTE_QUERY_HOOK', { query, filterQuery, value });
|
|
21
|
-
await router.replace({
|
|
22
|
-
name: router.currentRoute.name,
|
|
23
|
-
query,
|
|
24
|
-
});
|
|
25
|
-
await context.dispatch('AFTER_CHANGE_ROUTE_QUERY_HOOK', { query });
|
|
26
|
-
} catch (err) {
|
|
27
|
-
throw err;
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
SET_VALUE_TO_QUERY: async (
|
|
31
|
-
context,
|
|
32
|
-
{ filterQuery, value, storedProp = 'id' },
|
|
33
|
-
) => {
|
|
34
|
-
try {
|
|
35
|
-
let newValue = '';
|
|
36
|
-
if (Array.isArray(value)) {
|
|
37
|
-
if (value.length && typeof value[0] !== 'object') {
|
|
38
|
-
newValue = value;
|
|
39
|
-
} else {
|
|
40
|
-
newValue = value.map((item) => item[storedProp]);
|
|
41
|
-
}
|
|
42
|
-
} else if (typeof value === 'object' && value !== null) {
|
|
43
|
-
newValue = value[storedProp];
|
|
44
|
-
} else {
|
|
45
|
-
newValue = value;
|
|
46
|
-
}
|
|
47
|
-
if (!deepEqual(context.state.router.currentRoute.query[filterQuery], newValue)) {
|
|
48
|
-
await context.dispatch('_CHANGE_ROUTE_QUERY', {
|
|
49
|
-
value: newValue,
|
|
50
|
-
filterQuery,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
} catch (err) {
|
|
54
|
-
throw err;
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
constructor({ router } = {}) {
|
|
60
|
-
super();
|
|
61
|
-
if (!router) throw new Error('Pass router object to QueryController Store Module');
|
|
62
|
-
this.state.router = router;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { createLocalVue } from '@vue/test-utils';
|
|
2
|
-
import VueRouter from 'vue-router';
|
|
3
|
-
import Vuex from 'vuex';
|
|
4
|
-
import QueryContrllerStoreModule from '../QueryControllerStoreModule';
|
|
5
|
-
|
|
6
|
-
const localVue = createLocalVue();
|
|
7
|
-
localVue.use(Vuex);
|
|
8
|
-
localVue.use(VueRouter);
|
|
9
|
-
const router = new VueRouter();
|
|
10
|
-
|
|
11
|
-
const filterQuery = 'team';
|
|
12
|
-
|
|
13
|
-
describe('Query Controller Store Module Actions', () => {
|
|
14
|
-
const store = new Vuex.Store({
|
|
15
|
-
...new QueryContrllerStoreModule({ router }).getModule(),
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
router.replace('/');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('Array of objects', async () => {
|
|
23
|
-
const value = [{ name: 'team 1', id: '1' }, { name: 'team 2', id: '2' }];
|
|
24
|
-
await store.dispatch('SET_VALUE_TO_QUERY', { filterQuery, value });
|
|
25
|
-
const queryValue = await store.getters.GET_VALUE_FROM_QUERY({ filterQuery });
|
|
26
|
-
expect(queryValue).toEqual(['1', '2']);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('Array of values', async () => {
|
|
30
|
-
const value = ['hello', '1'];
|
|
31
|
-
await store.dispatch('SET_VALUE_TO_QUERY', { filterQuery, value });
|
|
32
|
-
const queryValue = await store.getters.GET_VALUE_FROM_QUERY({ filterQuery });
|
|
33
|
-
expect(queryValue).toEqual(value);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('String value', async () => {
|
|
37
|
-
const value = 'hello there';
|
|
38
|
-
await store.dispatch('SET_VALUE_TO_QUERY', { filterQuery, value });
|
|
39
|
-
const queryValue = await store.getters.GET_VALUE_FROM_QUERY({ filterQuery });
|
|
40
|
-
expect(queryValue).toEqual(value);
|
|
41
|
-
});
|
|
42
|
-
});
|