Various fixes on core views (#14093)
- Fix fragments - Add id to create inputs - Refresh core views - Fix kanban loading - Fix core views creation from current view --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@@ -4,7 +4,15 @@ import { type ViewField } from '@/views/types/ViewField';
|
||||
import { type CoreViewField } from '~/generated/graphql';
|
||||
|
||||
export const convertCoreViewFieldToViewField = (
|
||||
coreViewField: Omit<CoreViewField, 'workspaceId'>,
|
||||
coreViewField: Pick<
|
||||
CoreViewField,
|
||||
| 'id'
|
||||
| 'fieldMetadataId'
|
||||
| 'position'
|
||||
| 'isVisible'
|
||||
| 'size'
|
||||
| 'aggregateOperation'
|
||||
>,
|
||||
): ViewField => {
|
||||
const viewField: ViewField = {
|
||||
__typename: 'ViewField',
|
||||
|
||||
+8
-1
@@ -3,7 +3,14 @@ import { ViewFilterGroupLogicalOperator } from '@/views/types/ViewFilterGroupLog
|
||||
import { type CoreViewFilterGroup } from '~/generated/graphql';
|
||||
|
||||
export const convertCoreViewFilterGroupToViewFilterGroup = (
|
||||
coreViewFilterGroup: Omit<CoreViewFilterGroup, 'workspaceId'>,
|
||||
coreViewFilterGroup: Pick<
|
||||
CoreViewFilterGroup,
|
||||
| 'id'
|
||||
| 'viewId'
|
||||
| 'parentViewFilterGroupId'
|
||||
| 'logicalOperator'
|
||||
| 'positionInViewFilterGroup'
|
||||
>,
|
||||
): ViewFilterGroup => {
|
||||
return {
|
||||
__typename: 'ViewFilterGroup',
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
import { type CompositeFieldSubFieldName } from '@/settings/data-model/types/CompositeFieldSubFieldName';
|
||||
import { type ViewFilter } from '@/views/types/ViewFilter';
|
||||
import { type CoreViewFilter } from '~/generated/graphql';
|
||||
import { convertViewFilterOperandFromCore } from '../utils/convertViewFilterOperandFromCore';
|
||||
|
||||
export const convertCoreViewFilterToViewFilter = (
|
||||
coreViewFilter: Omit<CoreViewFilter, 'workspaceId'>,
|
||||
coreViewFilter: Pick<
|
||||
CoreViewFilter,
|
||||
| 'id'
|
||||
| 'fieldMetadataId'
|
||||
| 'operand'
|
||||
| 'value'
|
||||
| 'viewFilterGroupId'
|
||||
| 'positionInViewFilterGroup'
|
||||
| 'subFieldName'
|
||||
>,
|
||||
): ViewFilter => {
|
||||
return {
|
||||
__typename: 'ViewFilter',
|
||||
@@ -18,11 +28,8 @@ export const convertCoreViewFilterToViewFilter = (
|
||||
typeof coreViewFilter.value === 'string'
|
||||
? coreViewFilter.value
|
||||
: JSON.stringify(coreViewFilter.value ?? ''),
|
||||
createdAt: coreViewFilter.createdAt,
|
||||
updatedAt: coreViewFilter.updatedAt,
|
||||
viewId: coreViewFilter.viewId,
|
||||
viewFilterGroupId: coreViewFilter.viewFilterGroupId ?? undefined,
|
||||
positionInViewFilterGroup: coreViewFilter.positionInViewFilterGroup ?? null,
|
||||
subFieldName: (coreViewFilter.subFieldName as any) ?? null,
|
||||
viewFilterGroupId: coreViewFilter.viewFilterGroupId,
|
||||
positionInViewFilterGroup: coreViewFilter.positionInViewFilterGroup,
|
||||
subFieldName: coreViewFilter.subFieldName as CompositeFieldSubFieldName,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -2,7 +2,10 @@ import { type ViewGroup } from '@/views/types/ViewGroup';
|
||||
import { type CoreViewGroup } from '~/generated/graphql';
|
||||
|
||||
export const convertCoreViewGroupToViewGroup = (
|
||||
coreViewGroup: Omit<CoreViewGroup, 'workspaceId'>,
|
||||
coreViewGroup: Pick<
|
||||
CoreViewGroup,
|
||||
'id' | 'fieldMetadataId' | 'isVisible' | 'fieldValue' | 'position'
|
||||
>,
|
||||
): ViewGroup => {
|
||||
return {
|
||||
__typename: 'ViewGroup',
|
||||
|
||||
@@ -2,7 +2,7 @@ import { type ViewSort } from '@/views/types/ViewSort';
|
||||
import { type CoreViewSort, ViewSortDirection } from '~/generated/graphql';
|
||||
|
||||
export const convertCoreViewSortToViewSort = (
|
||||
coreViewSort: Omit<CoreViewSort, 'workspaceId'>,
|
||||
coreViewSort: Pick<CoreViewSort, 'id' | 'fieldMetadataId' | 'direction'>,
|
||||
): ViewSort => {
|
||||
return {
|
||||
__typename: 'ViewSort',
|
||||
|
||||
@@ -6,7 +6,7 @@ import { isDefined } from 'twenty-shared/utils';
|
||||
import { type UpdateViewInput } from '~/generated-metadata/graphql';
|
||||
|
||||
export const convertUpdateViewInputToCore = (
|
||||
view: Partial<GraphQLView>,
|
||||
view: Partial<GraphQLView & { __typename?: string }>,
|
||||
): UpdateViewInput => {
|
||||
const {
|
||||
key,
|
||||
@@ -17,6 +17,9 @@ export const convertUpdateViewInputToCore = (
|
||||
viewFilterGroups: _viewFilterGroups,
|
||||
viewGroups: _viewGroups,
|
||||
viewSorts: _viewSorts,
|
||||
kanbanFieldMetadataId: _kanbanFieldMetadataId,
|
||||
id: _id,
|
||||
__typename: _typename,
|
||||
...rest
|
||||
} = view;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { type ViewFilter } from '@/views/types/ViewFilter';
|
||||
import { compareStrictlyExceptForNullAndUndefined } from '~/utils/compareStrictlyExceptForNullAndUndefined';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { compareStrictlyExceptForNullAndUndefined } from '~/utils/compareStrictlyExceptForNullAndUndefined';
|
||||
|
||||
export const getViewFiltersToCreate = (
|
||||
currentViewFilters: ViewFilter[],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { type ViewFilter } from '@/views/types/ViewFilter';
|
||||
import { areViewFiltersEqual } from '@/views/utils/areViewFiltersEqual';
|
||||
import { compareStrictlyExceptForNullAndUndefined } from '~/utils/compareStrictlyExceptForNullAndUndefined';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { compareStrictlyExceptForNullAndUndefined } from '~/utils/compareStrictlyExceptForNullAndUndefined';
|
||||
|
||||
export const getViewFiltersToUpdate = (
|
||||
currentViewFilters: ViewFilter[],
|
||||
|
||||
Reference in New Issue
Block a user