diff --git a/front/src/generated/graphql.tsx b/front/src/generated/graphql.tsx index 9a34f7b190..b73cb3d6bb 100644 --- a/front/src/generated/graphql.tsx +++ b/front/src/generated/graphql.tsx @@ -2404,6 +2404,8 @@ export type DeleteActivityMutationVariables = Exact<{ export type DeleteActivityMutation = { __typename?: 'Mutation', deleteManyActivities: { __typename?: 'AffectedRows', count: number } }; +export type ActivityUpdatePartsFragment = { __typename?: 'Activity', id: string, body?: string | null, title?: string | null, type: ActivityType, completedAt?: string | null, dueAt?: string | null, assignee?: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string } | null }; + export type UpdateActivityMutationVariables = Exact<{ where: ActivityWhereUniqueInput; data: ActivityUpdateInput; @@ -2831,7 +2833,22 @@ export type DeleteCurrentWorkspaceMutationVariables = Exact<{ [key: string]: nev export type DeleteCurrentWorkspaceMutation = { __typename?: 'Mutation', deleteCurrentWorkspace: { __typename?: 'Workspace', id: string } }; - +export const ActivityUpdatePartsFragmentDoc = gql` + fragment ActivityUpdateParts on Activity { + id + body + title + type + completedAt + dueAt + assignee { + id + firstName + lastName + displayName + } +} + `; export const CreateCommentDocument = gql` mutation CreateComment($commentId: String!, $commentText: String!, $authorId: String!, $activityId: String!, $createdAt: DateTime!) { createOneComment( @@ -3286,21 +3303,10 @@ export type DeleteActivityMutationOptions = Apollo.BaseMutationOptions; /** diff --git a/front/src/modules/companies/components/CompanyBoardCard.tsx b/front/src/modules/companies/components/CompanyBoardCard.tsx index 223fa92c36..e92ecd150d 100644 --- a/front/src/modules/companies/components/CompanyBoardCard.tsx +++ b/front/src/modules/companies/components/CompanyBoardCard.tsx @@ -7,6 +7,7 @@ import { fieldsDefinitionsState } from '@/ui/board/states/fieldsDefinitionsState import { selectedBoardCardIdsState } from '@/ui/board/states/selectedBoardCardIdsState'; import { EntityChipVariant } from '@/ui/chip/components/EntityChip'; import { GenericEditableField } from '@/ui/editable-field/components/GenericEditableField'; +import { EditableFieldEntityIdContext } from '@/ui/editable-field/states/EditableFieldEntityIdContext'; import { Checkbox, CheckboxVariant, @@ -172,7 +173,9 @@ export function CompanyBoardCard() { {fieldsDefinitions.map((viewField) => { return ( - + + + ); })} diff --git a/front/src/modules/ui/editable-field/components/GenericEditableDateField.tsx b/front/src/modules/ui/editable-field/components/GenericEditableDateField.tsx index 6093b85cfb..5d9c561558 100644 --- a/front/src/modules/ui/editable-field/components/GenericEditableDateField.tsx +++ b/front/src/modules/ui/editable-field/components/GenericEditableDateField.tsx @@ -1,7 +1,6 @@ import { useContext } from 'react'; import { useRecoilValue } from 'recoil'; -import { BoardCardIdContext } from '@/ui/board/states/BoardCardIdContext'; import { ViewFieldDateMetadata, ViewFieldDefinition, @@ -10,6 +9,7 @@ import { DateInputDisplay } from '@/ui/input/date/components/DateInputDisplay'; import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope'; import { parseDate } from '~/utils/date-utils'; +import { EditableFieldEntityIdContext } from '../states/EditableFieldEntityIdContext'; import { FieldContext } from '../states/FieldContext'; import { genericEntityFieldFamilySelector } from '../states/genericEntityFieldFamilySelector'; @@ -21,11 +21,11 @@ type OwnProps = { }; export function GenericEditableDateField({ viewField }: OwnProps) { - const currentEntityId = useContext(BoardCardIdContext); + const currentEditableFieldEntityId = useContext(EditableFieldEntityIdContext); const fieldValue = useRecoilValue( genericEntityFieldFamilySelector({ - entityId: currentEntityId ?? '', + entityId: currentEditableFieldEntityId ?? '', fieldName: viewField.metadata.fieldName, }), ); diff --git a/front/src/modules/ui/editable-field/components/GenericEditableDateFieldEditMode.tsx b/front/src/modules/ui/editable-field/components/GenericEditableDateFieldEditMode.tsx index 5e98881f9d..73e1e8ef37 100644 --- a/front/src/modules/ui/editable-field/components/GenericEditableDateFieldEditMode.tsx +++ b/front/src/modules/ui/editable-field/components/GenericEditableDateFieldEditMode.tsx @@ -1,13 +1,13 @@ import { useContext } from 'react'; import { useRecoilState } from 'recoil'; -import { BoardCardIdContext } from '@/ui/board/states/BoardCardIdContext'; import { ViewFieldDateMetadata, ViewFieldDefinition, } from '@/ui/editable-field/types/ViewField'; import { useUpdateGenericEntityField } from '../hooks/useUpdateGenericEntityField'; +import { EditableFieldEntityIdContext } from '../states/EditableFieldEntityIdContext'; import { genericEntityFieldFamilySelector } from '../states/genericEntityFieldFamilySelector'; import { EditableFieldEditModeDate } from '../variants/components/EditableFieldEditModeDate'; @@ -16,12 +16,12 @@ type OwnProps = { }; export function GenericEditableDateFieldEditMode({ viewField }: OwnProps) { - const currentEntityId = useContext(BoardCardIdContext); + const currentEditableFieldEntityId = useContext(EditableFieldEntityIdContext); // TODO: we could use a hook that would return the field value with the right type const [fieldValue, setFieldValue] = useRecoilState( genericEntityFieldFamilySelector({ - entityId: currentEntityId ?? '', + entityId: currentEditableFieldEntityId ?? '', fieldName: viewField.metadata.fieldName, }), ); @@ -33,8 +33,8 @@ export function GenericEditableDateFieldEditMode({ viewField }: OwnProps) { setFieldValue(newDateISO); - if (currentEntityId && updateField && newDateISO) { - updateField(currentEntityId, viewField, newDateISO); + if (currentEditableFieldEntityId && updateField && newDateISO) { + updateField(currentEditableFieldEntityId, viewField, newDateISO); } } diff --git a/front/src/modules/ui/editable-field/components/GenericEditableNumberField.tsx b/front/src/modules/ui/editable-field/components/GenericEditableNumberField.tsx index c776713799..252352e4b1 100644 --- a/front/src/modules/ui/editable-field/components/GenericEditableNumberField.tsx +++ b/front/src/modules/ui/editable-field/components/GenericEditableNumberField.tsx @@ -1,13 +1,13 @@ import { useContext } from 'react'; import { useRecoilValue } from 'recoil'; -import { BoardCardIdContext } from '@/ui/board/states/BoardCardIdContext'; import { ViewFieldDefinition, ViewFieldNumberMetadata, } from '@/ui/editable-field/types/ViewField'; import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope'; +import { EditableFieldEntityIdContext } from '../states/EditableFieldEntityIdContext'; import { FieldContext } from '../states/FieldContext'; import { genericEntityFieldFamilySelector } from '../states/genericEntityFieldFamilySelector'; @@ -19,11 +19,11 @@ type OwnProps = { }; export function GenericEditableNumberField({ viewField }: OwnProps) { - const currentEntityId = useContext(BoardCardIdContext); + const currentEditableFieldEntityId = useContext(EditableFieldEntityIdContext); const fieldValue = useRecoilValue( genericEntityFieldFamilySelector({ - entityId: currentEntityId ?? '', + entityId: currentEditableFieldEntityId ?? '', fieldName: viewField.metadata.fieldName, }), ); diff --git a/front/src/modules/ui/editable-field/components/GenericEditableNumberFieldEditMode.tsx b/front/src/modules/ui/editable-field/components/GenericEditableNumberFieldEditMode.tsx index 4dea3dfa07..35afc59c50 100644 --- a/front/src/modules/ui/editable-field/components/GenericEditableNumberFieldEditMode.tsx +++ b/front/src/modules/ui/editable-field/components/GenericEditableNumberFieldEditMode.tsx @@ -1,7 +1,6 @@ import { useContext, useRef, useState } from 'react'; import { useRecoilState } from 'recoil'; -import { BoardCardIdContext } from '@/ui/board/states/BoardCardIdContext'; import { ViewFieldDefinition, ViewFieldNumberMetadata, @@ -14,6 +13,7 @@ import { import { useRegisterCloseFieldHandlers } from '../hooks/useRegisterCloseFieldHandlers'; import { useUpdateGenericEntityField } from '../hooks/useUpdateGenericEntityField'; +import { EditableFieldEntityIdContext } from '../states/EditableFieldEntityIdContext'; import { genericEntityFieldFamilySelector } from '../states/genericEntityFieldFamilySelector'; type OwnProps = { @@ -21,12 +21,12 @@ type OwnProps = { }; export function GenericEditableNumberFieldEditMode({ viewField }: OwnProps) { - const currentEntityId = useContext(BoardCardIdContext); + const currentEditableFieldEntityId = useContext(EditableFieldEntityIdContext); // TODO: we could use a hook that would return the field value with the right type const [fieldValue, setFieldValue] = useRecoilState( genericEntityFieldFamilySelector({ - entityId: currentEntityId ?? '', + entityId: currentEditableFieldEntityId ?? '', fieldName: viewField.metadata.fieldName, }), ); @@ -44,9 +44,9 @@ export function GenericEditableNumberFieldEditMode({ viewField }: OwnProps) { setFieldValue(castAsIntegerOrNull(internalValue)); - if (currentEntityId && updateField) { + if (currentEditableFieldEntityId && updateField) { updateField( - currentEntityId, + currentEditableFieldEntityId, viewField, castAsIntegerOrNull(internalValue), ); diff --git a/front/src/modules/ui/editable-field/components/GenericEditableRelationField.tsx b/front/src/modules/ui/editable-field/components/GenericEditableRelationField.tsx index 1c79f68fdd..a52f9ecf30 100644 --- a/front/src/modules/ui/editable-field/components/GenericEditableRelationField.tsx +++ b/front/src/modules/ui/editable-field/components/GenericEditableRelationField.tsx @@ -2,7 +2,6 @@ import { useContext } from 'react'; import { useRecoilValue } from 'recoil'; import { PersonChip } from '@/people/components/PersonChip'; -import { BoardCardIdContext } from '@/ui/board/states/BoardCardIdContext'; import { ViewFieldDefinition, ViewFieldRelationMetadata, @@ -11,6 +10,7 @@ import { Entity } from '@/ui/input/relation-picker/types/EntityTypeForSelect'; import { RelationPickerHotkeyScope } from '@/ui/input/relation-picker/types/RelationPickerHotkeyScope'; import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope'; +import { EditableFieldEntityIdContext } from '../states/EditableFieldEntityIdContext'; import { FieldContext } from '../states/FieldContext'; import { genericEntityFieldFamilySelector } from '../states/genericEntityFieldFamilySelector'; @@ -47,11 +47,11 @@ function RelationChip({ } export function GenericEditableRelationField({ viewField }: OwnProps) { - const currentEntityId = useContext(BoardCardIdContext); + const currentEditableFieldEntityId = useContext(EditableFieldEntityIdContext); const fieldValue = useRecoilValue( genericEntityFieldFamilySelector({ - entityId: currentEntityId ?? '', + entityId: currentEditableFieldEntityId ?? '', fieldName: viewField.metadata.fieldName, }), ); diff --git a/front/src/modules/ui/editable-field/components/GenericEditableRelationFieldEditMode.tsx b/front/src/modules/ui/editable-field/components/GenericEditableRelationFieldEditMode.tsx index f37fe0dd05..ce00ba74b3 100644 --- a/front/src/modules/ui/editable-field/components/GenericEditableRelationFieldEditMode.tsx +++ b/front/src/modules/ui/editable-field/components/GenericEditableRelationFieldEditMode.tsx @@ -3,7 +3,6 @@ import styled from '@emotion/styled'; import { useRecoilState } from 'recoil'; import { PeoplePicker } from '@/people/components/PeoplePicker'; -import { BoardCardIdContext } from '@/ui/board/states/BoardCardIdContext'; import { ViewFieldDefinition, ViewFieldRelationMetadata, @@ -14,6 +13,7 @@ import { Entity } from '@/ui/input/relation-picker/types/EntityTypeForSelect'; import { useEditableField } from '../hooks/useEditableField'; import { useUpdateGenericEntityField } from '../hooks/useUpdateGenericEntityField'; +import { EditableFieldEntityIdContext } from '../states/EditableFieldEntityIdContext'; import { genericEntityFieldFamilySelector } from '../states/genericEntityFieldFamilySelector'; const RelationPickerContainer = styled.div` @@ -56,12 +56,12 @@ function RelationPicker({ } export function GenericEditableRelationFieldEditMode({ viewField }: OwnProps) { - const currentEntityId = useContext(BoardCardIdContext); + const currentEditableFieldEntityId = useContext(EditableFieldEntityIdContext); // TODO: we could use a hook that would return the field value with the right type const [fieldValue, setFieldValue] = useRecoilState( genericEntityFieldFamilySelector({ - entityId: currentEntityId ?? '', + entityId: currentEditableFieldEntityId ?? '', fieldName: viewField.metadata.fieldName, }), ); @@ -78,8 +78,8 @@ export function GenericEditableRelationFieldEditMode({ viewField }: OwnProps) { avatarUrl: newRelation?.avatarUrl ?? null, }); - if (currentEntityId && updateField) { - updateField(currentEntityId, viewField, newRelation); + if (currentEditableFieldEntityId && updateField) { + updateField(currentEditableFieldEntityId, viewField, newRelation); } closeEditableField(); diff --git a/front/src/modules/ui/editable-field/components/ProbabilityEditableFieldEditMode.tsx b/front/src/modules/ui/editable-field/components/ProbabilityEditableFieldEditMode.tsx index 01bb592e57..e41c010889 100644 --- a/front/src/modules/ui/editable-field/components/ProbabilityEditableFieldEditMode.tsx +++ b/front/src/modules/ui/editable-field/components/ProbabilityEditableFieldEditMode.tsx @@ -2,10 +2,10 @@ import { useContext, useState } from 'react'; import styled from '@emotion/styled'; import { useRecoilState } from 'recoil'; -import { BoardCardIdContext } from '@/ui/board/states/BoardCardIdContext'; import { useEditableField } from '@/ui/editable-field/hooks/useEditableField'; import { useUpdateGenericEntityField } from '../hooks/useUpdateGenericEntityField'; +import { EditableFieldEntityIdContext } from '../states/EditableFieldEntityIdContext'; import { genericEntityFieldFamilySelector } from '../states/genericEntityFieldFamilySelector'; import { ViewFieldDefinition, @@ -76,10 +76,11 @@ export function ProbabilityEditableFieldEditMode({ viewField }: OwnProps) { const [nextProbabilityIndex, setNextProbabilityIndex] = useState< number | null >(null); - const currentEntityId = useContext(BoardCardIdContext); + const currentEditableFieldEntityId = useContext(EditableFieldEntityIdContext); + const [fieldValue, setFieldValue] = useRecoilState( genericEntityFieldFamilySelector({ - entityId: currentEntityId ?? '', + entityId: currentEditableFieldEntityId ?? '', fieldName: viewField.metadata.fieldName, }), ); @@ -91,8 +92,8 @@ export function ProbabilityEditableFieldEditMode({ viewField }: OwnProps) { function handleChange(newValue: number) { setFieldValue(newValue); - if (currentEntityId && updateField) { - updateField(currentEntityId, viewField, newValue); + if (currentEditableFieldEntityId && updateField) { + updateField(currentEditableFieldEntityId, viewField, newValue); } closeEditableField(); } diff --git a/front/src/modules/ui/editable-field/hooks/useCurrentEntityId.ts b/front/src/modules/ui/editable-field/hooks/useCurrentEntityId.ts deleted file mode 100644 index 32793d3a93..0000000000 --- a/front/src/modules/ui/editable-field/hooks/useCurrentEntityId.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { useContext } from 'react'; - -import { EntityIdContext } from '../states/EntityIdContext'; - -export function useCurrentEntityId() { - return useContext(EntityIdContext); -} diff --git a/front/src/modules/ui/editable-field/states/EditableFieldContext.ts b/front/src/modules/ui/editable-field/states/EditableFieldContext.ts deleted file mode 100644 index a8b1df3158..0000000000 --- a/front/src/modules/ui/editable-field/states/EditableFieldContext.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { createContext } from 'react'; - -export const EditableFieldContext = createContext(null); diff --git a/front/src/modules/ui/editable-field/states/EditableFieldEntityIdContext.ts b/front/src/modules/ui/editable-field/states/EditableFieldEntityIdContext.ts new file mode 100644 index 0000000000..bf6875085d --- /dev/null +++ b/front/src/modules/ui/editable-field/states/EditableFieldEntityIdContext.ts @@ -0,0 +1,3 @@ +import { createContext } from 'react'; + +export const EditableFieldEntityIdContext = createContext(null); diff --git a/front/src/modules/ui/editable-field/states/EntityIdContext.ts b/front/src/modules/ui/editable-field/states/EntityIdContext.ts deleted file mode 100644 index 75bd8e6d0b..0000000000 --- a/front/src/modules/ui/editable-field/states/EntityIdContext.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { createContext } from 'react'; - -export const EntityIdContext = createContext(null);