From bdc5de2e2761e48356a23fe6454033a770e474a5 Mon Sep 17 00:00:00 2001 From: volodymyr Date: Thu, 14 Dec 2023 16:59:18 +0200 Subject: [PATCH 1/3] fix: supervisor table sort fixing [WTEL-4084] --- src/mixins/dataFilterMixins/sortFilterMixin.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/mixins/dataFilterMixins/sortFilterMixin.js b/src/mixins/dataFilterMixins/sortFilterMixin.js index f278e1ce..f445dba9 100644 --- a/src/mixins/dataFilterMixins/sortFilterMixin.js +++ b/src/mixins/dataFilterMixins/sortFilterMixin.js @@ -53,11 +53,15 @@ export default { }, setValue({ column, order }) { - this.headers = this.headers.map((col) => ({ - ...col, - sort: col === column ? order : null, - })); + const headers = this.headers.map((col) => { + const sortFieldValue = col?.sort; + return { + ...col, + sort: col === column ? order : sortFieldValue, + } + }); const value = encodeSortQuery({ column, order }); + this.setHeaders(headers); return this.setValueToQuery({ value, filterQuery: this.filterQuery, @@ -66,10 +70,11 @@ export default { restoreValue(value) { const sortedColumns = decodeSortQuery({ value }); - this.headers = this.headers.map((header) => ({ + const headers = this.headers.map((header) => ({ ...header, sort: sortedColumns[header.field] || null, })); + this.setHeaders(headers); }, }, }; From 67d7b736588cd13b0c40c906fa497b9fc547d905 Mon Sep 17 00:00:00 2001 From: dlohvinov Date: Thu, 14 Dec 2023 20:55:29 +0200 Subject: [PATCH 2/3] 23.12.114: reordered wt-app-navigator apps [WTEL-4073] --- package.json | 2 +- .../wt-app-header/wt-app-navigator.vue | 26 +++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 190efcee..8de111f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@webitel/ui-sdk", - "version": "23.12.113", + "version": "23.12.114", "private": false, "scripts": { "dev": "vite", diff --git a/src/components/wt-app-header/wt-app-navigator.vue b/src/components/wt-app-header/wt-app-navigator.vue index 140cedea..3a13336b 100644 --- a/src/components/wt-app-header/wt-app-navigator.vue +++ b/src/components/wt-app-header/wt-app-navigator.vue @@ -38,8 +38,8 @@ >

props.apps.reduce((apps, app) => ({ +const order = [ + WebitelApplications.AGENT, + WebitelApplications.SUPERVISOR, + WebitelApplications.HISTORY, + WebitelApplications.ADMIN, + WebitelApplications.ANALYTICS, + WebitelApplications.AUDIT, + WebitelApplications.CRM, +]; + +const formattedApps = computed(() => props.apps.reduce((apps, app) => ([ ...apps, - [app.name]: { + { ...app, img: props.darkMode ? pics[app.name].dark : pics[app.name].light, currentApp: props.currentApp === app.name, }, -}), {})); +]), []).sort((a, b) => order.indexOf(a.name) - order.indexOf(b.name))); function close() { isOpened.value = false; @@ -189,14 +199,14 @@ function close() { // a tag .wt-app-navigator__card__link { - box-sizing: border-box; display: inline-flex; flex-direction: column; justify-content: space-between; + box-sizing: border-box; width: 100%; height: 100%; - cursor: pointer; padding: var(--wt-app-navigator-item-padding); + cursor: pointer; } // img inside a From 2e24f6c61300dbfd6c0324ecf8417aa16616fb8e Mon Sep 17 00:00:00 2001 From: volodymyr Date: Fri, 15 Dec 2023 11:43:56 +0200 Subject: [PATCH 3/3] fix: tests fixed [WTEL-4084] --- .../__tests__/sortFilterMixin.spec.js | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/mixins/dataFilterMixins/__tests__/sortFilterMixin.spec.js b/src/mixins/dataFilterMixins/__tests__/sortFilterMixin.spec.js index ba2cdc95..d28579d7 100644 --- a/src/mixins/dataFilterMixins/__tests__/sortFilterMixin.spec.js +++ b/src/mixins/dataFilterMixins/__tests__/sortFilterMixin.spec.js @@ -19,39 +19,46 @@ const headers = [{ field: 'online', }]; +const sortedHeaders = [{ + value: 'queue', + show: true, + sort: 'asc', + field: 'queue', +}, { + value: 'agents', + show: true, + sort: null, + field: 'online', +}]; + describe('Sort filter mixin', () => { - let wrapper; + const setHeaders = vi.fn(); const Component = { render() {}, mixins: [sortFilterMixin], data: () => ({ headers }), + methods: { setHeaders }, }; beforeEach(async () => { await router.replace('/'); - wrapper = shallowMount(Component, { - global: { plugins: [router] }, - }); }); + it('Correctly sets value from $route query', async () => { await router.replace({ path: '/', query: { sort: '+queue' } }); - const queue = wrapper.vm.headers.find((header) => header.value === 'queue'); - expect(queue.sort).toEqual('asc'); - }); - - it('After "sort" trigger, header column sort value changes properly', async () => { - let queue; - queue = wrapper.vm.headers.find((header) => header.value === 'queue'); - await wrapper.vm.sort(queue); - queue = wrapper.vm.headers.find((header) => header.value === 'queue'); - expect(queue.sort).toEqual('asc'); + const wrapper = shallowMount(Component, { + global: { plugins: [router] }, + }); + expect(setHeaders).toHaveBeenCalledWith(sortedHeaders); }); - it('After "sort" trigger, url query changes properly', async () => { - await router.replace({ path: '/', query: { sort: '+queue' } }); + it('After "sort" trigger, header column sort value changes properly', () => { + const wrapper = shallowMount(Component, { + global: { plugins: [router] }, + }); const queue = wrapper.vm.headers.find((header) => header.value === 'queue'); - await wrapper.vm.sort(queue); - expect(wrapper.vm.$route.query.sort).toEqual('-queue'); + wrapper.vm.sort(queue); + expect(setHeaders).toHaveBeenCalledWith(sortedHeaders); }); });