From 2b3d372ba3453c0f7e3cc9bbc48de951cf003f35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C5=A1per=20Grom?= Date: Fri, 18 Aug 2023 15:18:13 +0200 Subject: [PATCH] Member dashboard view more, Pagination query, lint fix, duplicate requests (#1357) --- frontend/package.json | 2 +- .../hubspot-readonly-attr-popover.vue | 5 ++-- .../components/hubspot-settings-drawer.vue | 5 ++-- .../modules/auth/pages/terms-and-privacy.vue | 2 +- .../automation/components/automation-form.vue | 5 ++-- .../automation/pages/automation-list-page.vue | 2 +- .../bulk/bulk-edit-attribute-popover.vue | 27 +++++++++-------- .../components/list/member-list-table.vue | 29 ++++++++++++++++-- .../components/list/member-list-toolbar.vue | 7 +++-- .../modules/member/pages/member-list-page.vue | 29 +++++++++++++++--- .../pages/member-merge-suggestions-page.vue | 6 ++-- .../src/modules/member/store/pinia/actions.ts | 2 +- .../src/modules/member/store/pinia/state.ts | 4 --- .../list/organization-list-table.vue | 30 ++++++++++++++++--- .../pages/organization-list-page.vue | 25 ++++++++++++++-- .../organization/store/pinia/actions.ts | 2 +- .../modules/organization/store/pinia/state.ts | 4 --- .../modules/tag/components/tag-popover.vue | 16 ++++++---- .../modules/filters/components/Filter.vue | 13 ++++---- .../filters/services/filter-api.service.ts | 6 ---- .../filters/services/filter-query.service.ts | 10 ------- .../modules/filters/types/FilterConfig.ts | 9 +----- .../modules/filters/types/FilterQuery.ts | 2 -- .../saved-views/components/SavedViews.vue | 14 ++------- .../saved-views/types/SavedViewsConfig.ts | 4 +-- frontend/src/shared/platform/platform.vue | 3 +- 26 files changed, 156 insertions(+), 107 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index cb553ad10c..71d90ed2da 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -3,7 +3,7 @@ "version": "0.5.0", "private": true, "scripts": { - "lint": "eslint \"{src,tests}/**/*.{js,ts}\" --max-warnings=0", + "lint": "eslint \"{src,tests}/**/*.{js,ts,vue}\" --max-warnings=0", "lint:fix": "npm run lint -- --fix", "build:localhost": "vite build --mode localhost", "build:production": "vite build --mode prod", diff --git a/frontend/src/integrations/hubspot/components/hubspot-readonly-attr-popover.vue b/frontend/src/integrations/hubspot/components/hubspot-readonly-attr-popover.vue index f2fc58ea02..2ef1f79a63 100644 --- a/frontend/src/integrations/hubspot/components/hubspot-readonly-attr-popover.vue +++ b/frontend/src/integrations/hubspot/components/hubspot-readonly-attr-popover.vue @@ -10,7 +10,8 @@

- The following attributes, auto-generated by crowd.dev, are only mapped into HubSpot, and won't be overwritten if their value is updated on your HubSpot account. + The following attributes, auto-generated by crowd.dev, are only mapped into HubSpot, + and won't be overwritten if their value is updated on your HubSpot account.

@@ -44,7 +45,7 @@ diff --git a/frontend/src/shared/modules/filters/components/Filter.vue b/frontend/src/shared/modules/filters/components/Filter.vue index 16efda9b60..e441fb4556 100644 --- a/frontend/src/shared/modules/filters/components/Filter.vue +++ b/frontend/src/shared/modules/filters/components/Filter.vue @@ -93,7 +93,7 @@ const switchOperator = () => { const alignFilterList = (value: Filter) => { const { - settings, search, relation, order, pagination, ...filterValues + settings, search, relation, order, ...filterValues } = value; filterList.value = Object.keys(filterValues); }; @@ -107,7 +107,12 @@ const removeFilter = (key) => { const { setQuery, parseQuery } = filterQueryService(); const { buildApiFilter } = filterApiService(); +const savedFilter = ref({}); const fetch = (value: Filter) => { + if (JSON.stringify(value) === JSON.stringify(savedFilter.value)) { + return; + } + savedFilter.value = { ...value }; const data = buildApiFilter(value, { ...props.config, ...props.customConfig }, props.searchConfig, props.savedViewsConfig); emit('fetch', data); }; @@ -126,11 +131,6 @@ const alignQueryUrl = () => { ...props.customConfig, }, props.savedViewsConfig); - // Remove pagination if it's not in filters store state - if (!props.modelValue.pagination) { - delete parsed.pagination; - } - if (!parsed || Object.keys(parsed).length === 0) { const query = setQuery(props.modelValue); router.push({ query, hash: props.hash ? `#${props.hash}` : undefined }); @@ -138,6 +138,7 @@ const alignQueryUrl = () => { fetch(props.modelValue); return; } + filters.value = parsed as Filter; if (!!parsed && Object.keys(parsed).length > 0) { alignFilterList(parsed as Filter); diff --git a/frontend/src/shared/modules/filters/services/filter-api.service.ts b/frontend/src/shared/modules/filters/services/filter-api.service.ts index 82d84c2209..3919b6207b 100644 --- a/frontend/src/shared/modules/filters/services/filter-api.service.ts +++ b/frontend/src/shared/modules/filters/services/filter-api.service.ts @@ -14,7 +14,6 @@ export const filterApiService = () => { search, relation, order, - pagination, settings, ...filterValues } = values; @@ -89,13 +88,8 @@ export const filterApiService = () => { const orderBy = `${order.prop}_${order.order === 'descending' ? 'DESC' : 'ASC'}`; - const limit = pagination?.perPage || 20; - const offset = ((pagination?.page || 1) - 1) * limit; - return { filter, - limit, - offset, orderBy, body, }; diff --git a/frontend/src/shared/modules/filters/services/filter-query.service.ts b/frontend/src/shared/modules/filters/services/filter-query.service.ts index 8aece3dac3..d293437af9 100644 --- a/frontend/src/shared/modules/filters/services/filter-query.service.ts +++ b/frontend/src/shared/modules/filters/services/filter-query.service.ts @@ -26,10 +26,6 @@ export const filterQueryService = () => { Object.keys(object[key]).forEach((setting) => { object[key][setting] = savedViewsConfig.settings[setting].queryUrlParser(object[key][setting]); }); - } else if (key === 'pagination') { - Object.keys(object[key]).forEach((paginationProperty) => { - object[key][paginationProperty] = +object[key][paginationProperty]; - }); } else if (key in config) { const { type } = config[key]; const queryUrlParser = type === FilterConfigType.CUSTOM ? (config[key] as CustomFilterConfig).queryUrlParser : queryUrlParserByType[type]; @@ -55,12 +51,6 @@ export const filterQueryService = () => { if (filter) { const mappedFilter = { ...filter, - ...(filter.pagination && { - pagination: { - page: filter.pagination?.page || 1, - perPage: filter.pagination?.perPage || 20, - }, - }), }; Object.entries(mappedFilter).forEach(([key, filterValue]) => { if (typeof filterValue === 'object') { diff --git a/frontend/src/shared/modules/filters/types/FilterConfig.ts b/frontend/src/shared/modules/filters/types/FilterConfig.ts index 2f36171f1d..aab26460de 100644 --- a/frontend/src/shared/modules/filters/types/FilterConfig.ts +++ b/frontend/src/shared/modules/filters/types/FilterConfig.ts @@ -45,11 +45,4 @@ export interface FilterStatic { settings?: Record } -export type FilterObject = FilterStatic & Record - -export interface Filter extends FilterObject { - pagination: { - page: number, - perPage: number - }, -} +export type Filter = FilterStatic & Record diff --git a/frontend/src/shared/modules/filters/types/FilterQuery.ts b/frontend/src/shared/modules/filters/types/FilterQuery.ts index 9f61ea7008..fed80c01e0 100644 --- a/frontend/src/shared/modules/filters/types/FilterQuery.ts +++ b/frontend/src/shared/modules/filters/types/FilterQuery.ts @@ -2,6 +2,4 @@ export interface FilterQuery { filter: any, body: any, orderBy: string, - limit: number, - offset: number, } diff --git a/frontend/src/shared/modules/saved-views/components/SavedViews.vue b/frontend/src/shared/modules/saved-views/components/SavedViews.vue index a50bf577ab..de6699f806 100644 --- a/frontend/src/shared/modules/saved-views/components/SavedViews.vue +++ b/frontend/src/shared/modules/saved-views/components/SavedViews.vue @@ -27,7 +27,7 @@ import { computed, defineProps, ref, watch, } from 'vue'; -import { Filter, FilterObject } from '@/shared/modules/filters/types/FilterConfig'; +import { Filter } from '@/shared/modules/filters/types/FilterConfig'; import { SavedView, SavedViewsConfig } from '@/shared/modules/saved-views/types/SavedViewsConfig'; import { isEqual } from 'lodash'; @@ -62,15 +62,13 @@ const getView = (id: string): SavedView => { const currentView = computed(() => getView(selectedTab.value)); -const compareFilterToCurrentValues = (filter: FilterObject): boolean => { +const compareFilterToCurrentValues = (filter: Filter): boolean => { const compareFilter = { ...filter, }; const currentFilter = { ...props.modelValue, }; - delete currentFilter.pagination; - delete compareFilter.pagination; return isEqual(compareFilter, currentFilter); }; @@ -85,10 +83,6 @@ const onTabChange = (id: string) => { if (filter) { filters.value = { ...filter, - pagination: { - page: 1, - perPage: filters.value.pagination.perPage, - }, }; } }; @@ -97,10 +91,6 @@ const onTabChange = (id: string) => { const reset = () => { filters.value = { ...currentView.value.filter, - pagination: { - page: 1, - perPage: filters.value.pagination.perPage, - }, }; }; diff --git a/frontend/src/shared/modules/saved-views/types/SavedViewsConfig.ts b/frontend/src/shared/modules/saved-views/types/SavedViewsConfig.ts index 07e6f8f0ba..36913335f5 100644 --- a/frontend/src/shared/modules/saved-views/types/SavedViewsConfig.ts +++ b/frontend/src/shared/modules/saved-views/types/SavedViewsConfig.ts @@ -1,9 +1,9 @@ -import { FilterObject } from '@/shared/modules/filters/types/FilterConfig'; +import { Filter } from '@/shared/modules/filters/types/FilterConfig'; export interface SavedView { id: string; label: string; - filter: FilterObject & Record + filter: Filter & Record } export interface SavedViewsSetting { diff --git a/frontend/src/shared/platform/platform.vue b/frontend/src/shared/platform/platform.vue index cb2a6933e9..1bfcc71671 100644 --- a/frontend/src/shared/platform/platform.vue +++ b/frontend/src/shared/platform/platform.vue @@ -109,7 +109,8 @@ const href = computed(() => { return props.href; } - return (props.usernameHandles.length === 1 ? (CrowdIntegrations.getConfig(props.platform)?.url(props.usernameHandles[0]) ?? props.backupUrl) : null); + return (props.usernameHandles.length === 1 + ? (CrowdIntegrations.getConfig(props.platform)?.url(props.usernameHandles[0]) ?? props.backupUrl) : null); }); const trackClick = () => {