Add back pickers on all pages, fix command menu (#2662)
* Add back pickers on all pages, fix command menu * Fix lint
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
_env_?: Record<string, string>;
|
_env_?: Record<string, string>;
|
||||||
|
__APOLLO_CLIENT__?: any;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -102,8 +102,6 @@ export const ActivityComments = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('asd', { activity, comments });
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{comments.length > 0 && (
|
{comments.length > 0 && (
|
||||||
|
|||||||
@ -5,6 +5,9 @@ import { useApolloFactory } from '@/apollo/hooks/useApolloFactory';
|
|||||||
export const ApolloProvider = ({ children }: React.PropsWithChildren) => {
|
export const ApolloProvider = ({ children }: React.PropsWithChildren) => {
|
||||||
const apolloClient = useApolloFactory();
|
const apolloClient = useApolloFactory();
|
||||||
|
|
||||||
|
// This will attach the right apollo client to Apollo Dev Tools
|
||||||
|
window.__APOLLO_CLIENT__ = apolloClient;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ApolloProviderBase client={apolloClient}>{children}</ApolloProviderBase>
|
<ApolloProviderBase client={apolloClient}>{children}</ApolloProviderBase>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -83,6 +83,18 @@ export class ApolloFactory<TCacheShape> implements ApolloManager<TCacheShape> {
|
|||||||
onErrorCb?.(graphQLErrors);
|
onErrorCb?.(graphQLErrors);
|
||||||
|
|
||||||
for (const graphQLError of graphQLErrors) {
|
for (const graphQLError of graphQLErrors) {
|
||||||
|
if (graphQLError.message === 'Unauthorized') {
|
||||||
|
return fromPromise(
|
||||||
|
renewToken(uri, this.tokenPair)
|
||||||
|
.then((tokens) => {
|
||||||
|
onTokenPairChange?.(tokens);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
onUnauthenticatedError?.();
|
||||||
|
}),
|
||||||
|
).flatMap(() => forward(operation));
|
||||||
|
}
|
||||||
|
|
||||||
switch (graphQLError?.extensions?.code) {
|
switch (graphQLError?.extensions?.code) {
|
||||||
case 'UNAUTHENTICATED': {
|
case 'UNAUTHENTICATED': {
|
||||||
return fromPromise(
|
return fromPromise(
|
||||||
|
|||||||
@ -2,8 +2,13 @@ import { useState } from 'react';
|
|||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
|
|
||||||
import { useOpenActivityRightDrawer } from '@/activities/hooks/useOpenActivityRightDrawer';
|
import { useOpenActivityRightDrawer } from '@/activities/hooks/useOpenActivityRightDrawer';
|
||||||
|
import { useFindManyObjectRecords } from '@/object-record/hooks/useFindManyObjectRecords';
|
||||||
|
import { Person } from '@/people/types/Person';
|
||||||
|
import { IconNotes } from '@/ui/display/icon';
|
||||||
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||||
import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope';
|
import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope';
|
||||||
|
import { Avatar } from '@/users/components/Avatar';
|
||||||
|
import { getLogoUrlFromDomainName } from '~/utils';
|
||||||
|
|
||||||
import { useCommandMenu } from '../hooks/useCommandMenu';
|
import { useCommandMenu } from '../hooks/useCommandMenu';
|
||||||
import { commandMenuCommandsState } from '../states/commandMenuCommandsState';
|
import { commandMenuCommandsState } from '../states/commandMenuCommandsState';
|
||||||
@ -36,47 +41,38 @@ export const CommandMenu = () => {
|
|||||||
[openCommandMenu, setSearch],
|
[openCommandMenu, setSearch],
|
||||||
);
|
);
|
||||||
|
|
||||||
// const { data: peopleData } = useSearchPeopleQuery({
|
const { objects: people } = useFindManyObjectRecords<Person>({
|
||||||
// skip: !isCommandMenuOpened,
|
skip: !isCommandMenuOpened,
|
||||||
// variables: {
|
objectNamePlural: 'people',
|
||||||
// where: {
|
filter: {
|
||||||
// OR: [
|
or: [
|
||||||
// { firstName: { contains: search, mode: QueryMode.Insensitive } },
|
{ name: { firstName: { like: `%${search}%` } } },
|
||||||
// { lastName: { contains: search, mode: QueryMode.Insensitive } },
|
{ name: { firstName: { like: `%${search}%` } } },
|
||||||
// ],
|
],
|
||||||
// },
|
},
|
||||||
// limit: 3,
|
limit: 3,
|
||||||
// },
|
});
|
||||||
// });
|
|
||||||
|
|
||||||
// const people = peopleData?.searchResults ?? [];
|
const { objects: companies } = useFindManyObjectRecords<Person>({
|
||||||
|
skip: !isCommandMenuOpened,
|
||||||
|
objectNamePlural: 'companies',
|
||||||
|
filter: {
|
||||||
|
name: { like: `%${search}%` },
|
||||||
|
},
|
||||||
|
limit: 3,
|
||||||
|
});
|
||||||
|
|
||||||
// const { data: companyData } = useSearchCompanyQuery({
|
const { objects: activities } = useFindManyObjectRecords<Person>({
|
||||||
// skip: !isCommandMenuOpened,
|
skip: !isCommandMenuOpened,
|
||||||
// variables: {
|
objectNamePlural: 'activities',
|
||||||
// where: {
|
filter: {
|
||||||
// OR: [{ name: { contains: search, mode: QueryMode.Insensitive } }],
|
or: [
|
||||||
// },
|
{ title: { like: `%${search}%` } },
|
||||||
// limit: 3,
|
{ body: { like: `%${search}%` } },
|
||||||
// },
|
],
|
||||||
// });
|
},
|
||||||
|
limit: 3,
|
||||||
// const companies = companyData?.searchResults ?? [];
|
});
|
||||||
|
|
||||||
// const { data: activityData } = useSearchActivityQuery({
|
|
||||||
// skip: !isCommandMenuOpened,
|
|
||||||
// variables: {
|
|
||||||
// where: {
|
|
||||||
// OR: [
|
|
||||||
// { title: { contains: search, mode: QueryMode.Insensitive } },
|
|
||||||
// { body: { contains: search, mode: QueryMode.Insensitive } },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// limit: 3,
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const activities = activityData?.searchResults ?? [];
|
|
||||||
|
|
||||||
const checkInShortcuts = (cmd: Command, search: string) => {
|
const checkInShortcuts = (cmd: Command, search: string) => {
|
||||||
return (cmd.firstHotKey + (cmd.secondHotKey ?? ''))
|
return (cmd.firstHotKey + (cmd.secondHotKey ?? ''))
|
||||||
@ -149,12 +145,12 @@ export const CommandMenu = () => {
|
|||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CommandGroup>
|
</CommandGroup>
|
||||||
{/* <CommandGroup heading="People">
|
<CommandGroup heading="People">
|
||||||
{people.map((person) => (
|
{people.map((person) => (
|
||||||
<CommandMenuItem
|
<CommandMenuItem
|
||||||
key={person.id}
|
key={person.id}
|
||||||
to={`person/${person.id}`}
|
to={`object/person/${person.id}`}
|
||||||
label={person.displayName}
|
label={person.name?.firstName + ' ' + person.name?.lastName}
|
||||||
Icon={() => (
|
Icon={() => (
|
||||||
<Avatar
|
<Avatar
|
||||||
type="rounded"
|
type="rounded"
|
||||||
@ -171,7 +167,7 @@ export const CommandMenu = () => {
|
|||||||
<CommandMenuItem
|
<CommandMenuItem
|
||||||
key={company.id}
|
key={company.id}
|
||||||
label={company.name}
|
label={company.name}
|
||||||
to={`companies/${company.id}`}
|
to={`object/company/${company.id}`}
|
||||||
Icon={() => (
|
Icon={() => (
|
||||||
<Avatar
|
<Avatar
|
||||||
colorId={company.id}
|
colorId={company.id}
|
||||||
@ -191,7 +187,7 @@ export const CommandMenu = () => {
|
|||||||
onClick={() => openActivityRightDrawer(activity.id)}
|
onClick={() => openActivityRightDrawer(activity.id)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CommandGroup> */}
|
</CommandGroup>
|
||||||
</StyledList>
|
</StyledList>
|
||||||
</StyledDialog>
|
</StyledDialog>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useMutation, useQuery } from '@apollo/client';
|
import { useMutation } from '@apollo/client';
|
||||||
import { getOperationName } from '@apollo/client/utilities';
|
import { getOperationName } from '@apollo/client/utilities';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { flip, offset, useFloating } from '@floating-ui/react';
|
import { flip, offset, useFloating } from '@floating-ui/react';
|
||||||
@ -8,11 +8,14 @@ import { v4 } from 'uuid';
|
|||||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||||
import { IconPlus } from '@/ui/display/icon';
|
import { IconPlus } from '@/ui/display/icon';
|
||||||
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
|
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
|
||||||
|
import { RelationPicker } from '@/ui/input/components/internal/relation-picker/components/RelationPicker';
|
||||||
|
import { EntityForSelect } from '@/ui/input/relation-picker/types/EntityForSelect';
|
||||||
import { RelationPickerHotkeyScope } from '@/ui/input/relation-picker/types/RelationPickerHotkeyScope';
|
import { RelationPickerHotkeyScope } from '@/ui/input/relation-picker/types/RelationPickerHotkeyScope';
|
||||||
import { DoubleTextInput } from '@/ui/object/field/meta-types/input/components/internal/DoubleTextInput';
|
import { DoubleTextInput } from '@/ui/object/field/meta-types/input/components/internal/DoubleTextInput';
|
||||||
import { FieldDoubleText } from '@/ui/object/field/types/FieldDoubleText';
|
import { FieldDoubleText } from '@/ui/object/field/types/FieldDoubleText';
|
||||||
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
|
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
|
||||||
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
|
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
|
||||||
|
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||||
|
|
||||||
const StyledContainer = styled.div`
|
const StyledContainer = styled.div`
|
||||||
position: static;
|
position: static;
|
||||||
@ -65,43 +68,29 @@ export const AddPersonToCompany = ({
|
|||||||
goBackToPreviousHotkeyScope,
|
goBackToPreviousHotkeyScope,
|
||||||
} = usePreviousHotkeyScope();
|
} = usePreviousHotkeyScope();
|
||||||
|
|
||||||
// TODO: refactor with useObjectMetadataItem V2 with typed hooks
|
|
||||||
const { findManyQuery, updateOneMutation, createOneMutation } =
|
const { findManyQuery, updateOneMutation, createOneMutation } =
|
||||||
useObjectMetadataItem({
|
useObjectMetadataItem({
|
||||||
objectNameSingular: 'person',
|
objectNameSingular: 'person',
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data: peopleNotInCompany } = useQuery(findManyQuery, {
|
|
||||||
variables: {
|
|
||||||
filter: {
|
|
||||||
companyId: {
|
|
||||||
neq: companyId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const [updatePerson] = useMutation(updateOneMutation);
|
const [updatePerson] = useMutation(updateOneMutation);
|
||||||
const [createPerson] = useMutation(createOneMutation);
|
const [createPerson] = useMutation(createOneMutation);
|
||||||
|
|
||||||
const handlePersonSelected = async ({
|
const handlePersonSelected =
|
||||||
selectedPersonId,
|
(companyId: string) => async (newPerson: EntityForSelect | null) => {
|
||||||
companyId,
|
if (!newPerson) return;
|
||||||
}: {
|
await updatePerson({
|
||||||
selectedPersonId: string;
|
variables: {
|
||||||
companyId: string | null;
|
idToUpdate: newPerson.id,
|
||||||
}) => {
|
input: {
|
||||||
await updatePerson({
|
companyId: companyId,
|
||||||
variables: {
|
},
|
||||||
idToUpdate: selectedPersonId,
|
|
||||||
input: {
|
|
||||||
companyId: companyId,
|
|
||||||
},
|
},
|
||||||
},
|
refetchQueries: [getOperationName(findManyQuery) ?? ''],
|
||||||
refetchQueries: [getOperationName(findManyQuery) ?? ''],
|
});
|
||||||
});
|
|
||||||
handleClosePicker();
|
handleClosePicker();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClosePicker = () => {
|
const handleClosePicker = () => {
|
||||||
if (isDropdownOpen) {
|
if (isDropdownOpen) {
|
||||||
@ -111,21 +100,12 @@ export const AddPersonToCompany = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleOpenPicker = () => {
|
const handleOpenPicker = () => {
|
||||||
// TODO: TEMPORARY - example to implement when the picker is back
|
if (!isDropdownOpen) {
|
||||||
handleCreatePerson({
|
setIsDropdownOpen(true);
|
||||||
firstValue: 'John',
|
setHotkeyScopeAndMemorizePreviousScope(
|
||||||
secondValue: 'Doe',
|
RelationPickerHotkeyScope.RelationPicker,
|
||||||
});
|
);
|
||||||
// handlePersonSelected({
|
}
|
||||||
// companyId,
|
|
||||||
// selectedPersonId: peopleNotInCompany.people.edges[0].node.id,
|
|
||||||
// });
|
|
||||||
// if (!isDropdownOpen) {
|
|
||||||
// setIsDropdownOpen(true);
|
|
||||||
// setHotkeyScopeAndMemorizePreviousScope(
|
|
||||||
// RelationPickerHotkeyScope.RelationPicker,
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCreatePerson = async ({
|
const handleCreatePerson = async ({
|
||||||
@ -178,14 +158,23 @@ export const AddPersonToCompany = ({
|
|||||||
/>
|
/>
|
||||||
</StyledInputContainer>
|
</StyledInputContainer>
|
||||||
) : (
|
) : (
|
||||||
<>todo</>
|
<RelationPicker
|
||||||
// <PeoplePicker
|
recordId={''}
|
||||||
// personId={''}
|
onSubmit={handlePersonSelected(companyId)}
|
||||||
// onSubmit={handlePersonSelected(companyId)}
|
onCancel={handleClosePicker}
|
||||||
// onCancel={handleClosePicker}
|
excludeRecordIds={peopleIds ?? []}
|
||||||
// onCreate={() => setIsCreationDropdownOpen(true)}
|
fieldDefinition={{
|
||||||
// excludePersonIds={peopleIds}
|
label: 'Person',
|
||||||
// />
|
iconName: 'IconUser',
|
||||||
|
fieldMetadataId: '',
|
||||||
|
type: FieldMetadataType.Relation,
|
||||||
|
metadata: {
|
||||||
|
relationObjectMetadataNameSingular: 'person',
|
||||||
|
relationObjectMetadataNamePlural: 'people',
|
||||||
|
fieldName: 'person',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ export const CompanyChip = ({
|
|||||||
}: CompanyChipProps) => (
|
}: CompanyChipProps) => (
|
||||||
<EntityChip
|
<EntityChip
|
||||||
entityId={id}
|
entityId={id}
|
||||||
linkToEntity={`/objects/companies/${id}`}
|
linkToEntity={`/object/company/${id}`}
|
||||||
name={name}
|
name={name}
|
||||||
avatarType="squared"
|
avatarType="squared"
|
||||||
avatarUrl={avatarUrl}
|
avatarUrl={avatarUrl}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ const StyledContainer = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: ${({ theme }) => theme.spacing(2)};
|
gap: ${({ theme }) => theme.spacing(2)};
|
||||||
margin-bottom: ${({ theme }) => theme.spacing(2)};
|
margin-bottom: ${({ theme }) => theme.spacing(6)};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledTitleContainer = styled.div`
|
const StyledTitleContainer = styled.div`
|
||||||
|
|||||||
@ -9,8 +9,8 @@ import { PaginatedObjectTypeResults } from '@/object-record/types/PaginatedObjec
|
|||||||
import { filterAvailableTableColumns } from '@/object-record/utils/filterAvailableTableColumns';
|
import { filterAvailableTableColumns } from '@/object-record/utils/filterAvailableTableColumns';
|
||||||
import { Opportunity } from '@/pipeline/types/Opportunity';
|
import { Opportunity } from '@/pipeline/types/Opportunity';
|
||||||
import { PipelineStep } from '@/pipeline/types/PipelineStep';
|
import { PipelineStep } from '@/pipeline/types/PipelineStep';
|
||||||
import { turnFiltersIntoWhereClauseV2 } from '@/ui/object/object-filter-dropdown/utils/turnFiltersIntoWhereClauseV2';
|
import { turnFiltersIntoWhereClause } from '@/ui/object/object-filter-dropdown/utils/turnFiltersIntoWhereClause';
|
||||||
import { turnSortsIntoOrderByV2 } from '@/ui/object/object-sort-dropdown/utils/turnSortsIntoOrderByV2';
|
import { turnSortsIntoOrderBy } from '@/ui/object/object-sort-dropdown/utils/turnSortsIntoOrderBy';
|
||||||
import { useBoardActionBarEntries } from '@/ui/object/record-board/hooks/useBoardActionBarEntries';
|
import { useBoardActionBarEntries } from '@/ui/object/record-board/hooks/useBoardActionBarEntries';
|
||||||
import { useBoardContext } from '@/ui/object/record-board/hooks/useBoardContext';
|
import { useBoardContext } from '@/ui/object/record-board/hooks/useBoardContext';
|
||||||
import { useBoardContextMenuEntries } from '@/ui/object/record-board/hooks/useBoardContextMenuEntries';
|
import { useBoardContextMenuEntries } from '@/ui/object/record-board/hooks/useBoardContextMenuEntries';
|
||||||
@ -88,12 +88,12 @@ export const HooksCompanyBoardEffect = () => {
|
|||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
const filter = turnFiltersIntoWhereClauseV2(
|
const filter = turnFiltersIntoWhereClause(
|
||||||
mapViewFiltersToFilters(currentViewFilters),
|
mapViewFiltersToFilters(currentViewFilters),
|
||||||
objectMetadataItem?.fields ?? [],
|
objectMetadataItem?.fields ?? [],
|
||||||
);
|
);
|
||||||
|
|
||||||
const orderBy = turnSortsIntoOrderByV2(
|
const orderBy = turnSortsIntoOrderBy(
|
||||||
mapViewSortsToSorts(currentViewSorts),
|
mapViewSortsToSorts(currentViewSorts),
|
||||||
objectMetadataItem?.fields ?? [],
|
objectMetadataItem?.fields ?? [],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,6 +1,12 @@
|
|||||||
import { useCallback, useContext, useState } from 'react';
|
import { useCallback, useContext, useState } from 'react';
|
||||||
|
import { useQuery } from '@apollo/client';
|
||||||
|
|
||||||
|
import { useCreateOpportunity } from '@/companies/hooks/useCreateOpportunity';
|
||||||
|
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||||
|
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
||||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||||
|
import { useRelationPicker } from '@/ui/input/components/internal/relation-picker/hooks/useRelationPicker';
|
||||||
|
import { SingleEntitySelect } from '@/ui/input/relation-picker/components/SingleEntitySelect';
|
||||||
import { relationPickerSearchFilterScopedState } from '@/ui/input/relation-picker/states/relationPickerSearchFilterScopedState';
|
import { relationPickerSearchFilterScopedState } from '@/ui/input/relation-picker/states/relationPickerSearchFilterScopedState';
|
||||||
import { RelationPickerHotkeyScope } from '@/ui/input/relation-picker/types/RelationPickerHotkeyScope';
|
import { RelationPickerHotkeyScope } from '@/ui/input/relation-picker/types/RelationPickerHotkeyScope';
|
||||||
import { NewButton } from '@/ui/object/record-board/components/NewButton';
|
import { NewButton } from '@/ui/object/record-board/components/NewButton';
|
||||||
@ -8,13 +14,14 @@ import { BoardColumnContext } from '@/ui/object/record-board/contexts/BoardColum
|
|||||||
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
|
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
|
||||||
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
||||||
|
|
||||||
export const NewCompanyProgressButton = () => {
|
export const NewOpportunityButton = () => {
|
||||||
const [isCreatingCard, setIsCreatingCard] = useState(false);
|
const [isCreatingCard, setIsCreatingCard] = useState(false);
|
||||||
const column = useContext(BoardColumnContext);
|
const column = useContext(BoardColumnContext);
|
||||||
|
|
||||||
const pipelineStepId = column?.columnDefinition.id || '';
|
const pipelineStepId = column?.columnDefinition.id || '';
|
||||||
|
|
||||||
const { enqueueSnackBar } = useSnackBar();
|
const { enqueueSnackBar } = useSnackBar();
|
||||||
|
const { createOpportunity } = useCreateOpportunity();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
goBackToPreviousHotkeyScope,
|
goBackToPreviousHotkeyScope,
|
||||||
@ -33,7 +40,7 @@ export const NewCompanyProgressButton = () => {
|
|||||||
throw new Error('Pipeline stage id is not defined');
|
throw new Error('Pipeline stage id is not defined');
|
||||||
}
|
}
|
||||||
|
|
||||||
//createCompanyProgress(company.id, pipelineStepId);
|
createOpportunity(company.id, pipelineStepId);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleNewClick = useCallback(() => {
|
const handleNewClick = useCallback(() => {
|
||||||
@ -52,23 +59,38 @@ export const NewCompanyProgressButton = () => {
|
|||||||
relationPickerSearchFilterScopedState,
|
relationPickerSearchFilterScopedState,
|
||||||
);
|
);
|
||||||
|
|
||||||
// const companies = useFilteredSearchCompanyQuery({
|
const { findManyQuery } = useObjectMetadataItem({
|
||||||
// searchFilter: relationPickerSearchFilter,
|
objectNameSingular: 'company',
|
||||||
// });
|
});
|
||||||
|
const useFindManyQuery = (options: any) => useQuery(findManyQuery, options);
|
||||||
|
const { identifiersMapper, searchQuery } = useRelationPicker();
|
||||||
|
|
||||||
|
const filteredSearchEntityResults = useFilteredSearchEntityQuery({
|
||||||
|
queryHook: useFindManyQuery,
|
||||||
|
filters: [
|
||||||
|
{
|
||||||
|
fieldNames: searchQuery?.computeFilterFields?.('company') ?? [],
|
||||||
|
filter: relationPickerSearchFilter,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
orderByField: 'createdAt',
|
||||||
|
selectedIds: [],
|
||||||
|
mappingFunction: (record: any) => identifiersMapper?.(record, 'company'),
|
||||||
|
objectNamePlural: 'companies',
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{isCreatingCard ? (
|
{isCreatingCard ? (
|
||||||
<>TODO</>
|
<SingleEntitySelect
|
||||||
|
disableBackgroundBlur
|
||||||
|
entitiesToSelect={filteredSearchEntityResults.entitiesToSelect}
|
||||||
|
loading={filteredSearchEntityResults.loading}
|
||||||
|
onCancel={handleCancel}
|
||||||
|
onEntitySelected={handleEntitySelect}
|
||||||
|
selectedEntity={filteredSearchEntityResults.selectedEntities[0]}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
// <SingleEntitySelect
|
|
||||||
// disableBackgroundBlur
|
|
||||||
// entitiesToSelect={companies.entitiesToSelect}
|
|
||||||
// loading={companies.loading}
|
|
||||||
// onCancel={handleCancel}
|
|
||||||
// onEntitySelected={handleEntitySelect}
|
|
||||||
// selectedEntity={companies.selectedEntities[0]}
|
|
||||||
// />
|
|
||||||
<NewButton onClick={handleNewClick} />
|
<NewButton onClick={handleNewClick} />
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
@ -1,8 +1,13 @@
|
|||||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { useRecoilState } from 'recoil';
|
import { useQuery } from '@apollo/client';
|
||||||
|
import { useRecoilValue } from 'recoil';
|
||||||
|
|
||||||
import { currentPipelineState } from '@/pipeline/states/currentPipelineState';
|
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||||
|
import { currentPipelineStepsState } from '@/pipeline/states/currentPipelineStepsState';
|
||||||
|
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
||||||
import { IconChevronDown } from '@/ui/display/icon';
|
import { IconChevronDown } from '@/ui/display/icon';
|
||||||
|
import { useRelationPicker } from '@/ui/input/components/internal/relation-picker/hooks/useRelationPicker';
|
||||||
|
import { SingleEntitySelectBase } from '@/ui/input/relation-picker/components/SingleEntitySelectBase';
|
||||||
import { useEntitySelectSearch } from '@/ui/input/relation-picker/hooks/useEntitySelectSearch';
|
import { useEntitySelectSearch } from '@/ui/input/relation-picker/hooks/useEntitySelectSearch';
|
||||||
import { EntityForSelect } from '@/ui/input/relation-picker/types/EntityForSelect';
|
import { EntityForSelect } from '@/ui/input/relation-picker/types/EntityForSelect';
|
||||||
import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu';
|
import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu';
|
||||||
@ -13,7 +18,7 @@ import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownM
|
|||||||
import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
|
import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
|
||||||
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
|
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
|
||||||
|
|
||||||
export type CompanyProgressPickerProps = {
|
export type OpportunityPickerProps = {
|
||||||
companyId: string | null;
|
companyId: string | null;
|
||||||
onSubmit: (
|
onSubmit: (
|
||||||
newCompanyId: EntityForSelect | null,
|
newCompanyId: EntityForSelect | null,
|
||||||
@ -22,19 +27,33 @@ export type CompanyProgressPickerProps = {
|
|||||||
onCancel?: () => void;
|
onCancel?: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CompanyProgressPicker = ({
|
export const OpportunityPicker = ({
|
||||||
companyId,
|
|
||||||
onSubmit,
|
onSubmit,
|
||||||
onCancel,
|
onCancel,
|
||||||
}: CompanyProgressPickerProps) => {
|
}: OpportunityPickerProps) => {
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const { searchFilter, handleSearchFilterChange } = useEntitySelectSearch();
|
const { searchFilter, handleSearchFilterChange } = useEntitySelectSearch();
|
||||||
|
|
||||||
// const companies = useFilteredSearchCompanyQuery({
|
const { findManyQuery } = useObjectMetadataItem({
|
||||||
// searchFilter,
|
objectNameSingular: 'company',
|
||||||
// selectedIds: companyId ? [companyId] : [],
|
});
|
||||||
// });
|
const useFindManyQuery = (options: any) => useQuery(findManyQuery, options);
|
||||||
|
const { identifiersMapper, searchQuery } = useRelationPicker();
|
||||||
|
|
||||||
|
const filteredSearchEntityResults = useFilteredSearchEntityQuery({
|
||||||
|
queryHook: useFindManyQuery,
|
||||||
|
filters: [
|
||||||
|
{
|
||||||
|
fieldNames: searchQuery?.computeFilterFields?.('company') ?? [],
|
||||||
|
filter: searchFilter,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
orderByField: 'createdAt',
|
||||||
|
selectedIds: [],
|
||||||
|
mappingFunction: (record: any) => identifiersMapper?.(record, 'company'),
|
||||||
|
objectNamePlural: 'companies',
|
||||||
|
});
|
||||||
|
|
||||||
const [isProgressSelectionUnfolded, setIsProgressSelectionUnfolded] =
|
const [isProgressSelectionUnfolded, setIsProgressSelectionUnfolded] =
|
||||||
useState(false);
|
useState(false);
|
||||||
@ -43,12 +62,7 @@ export const CompanyProgressPicker = ({
|
|||||||
string | null
|
string | null
|
||||||
>(null);
|
>(null);
|
||||||
|
|
||||||
const [currentPipeline] = useRecoilState(currentPipelineState);
|
const currentPipelineSteps = useRecoilValue(currentPipelineStepsState);
|
||||||
|
|
||||||
const currentPipelineSteps = useMemo(
|
|
||||||
() => currentPipeline?.pipelineSteps ?? [],
|
|
||||||
[currentPipeline],
|
|
||||||
);
|
|
||||||
|
|
||||||
const handlePipelineStepChange = (newPipelineStepId: string) => {
|
const handlePipelineStepChange = (newPipelineStepId: string) => {
|
||||||
setSelectedPipelineStepId(newPipelineStepId);
|
setSelectedPipelineStepId(newPipelineStepId);
|
||||||
@ -110,13 +124,13 @@ export const CompanyProgressPicker = ({
|
|||||||
/>
|
/>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<RecoilScope>
|
<RecoilScope>
|
||||||
{/* <SingleEntitySelectBase
|
<SingleEntitySelectBase
|
||||||
entitiesToSelect={companies.entitiesToSelect}
|
entitiesToSelect={filteredSearchEntityResults.entitiesToSelect}
|
||||||
loading={companies.loading}
|
loading={filteredSearchEntityResults.loading}
|
||||||
onCancel={onCancel}
|
onCancel={onCancel}
|
||||||
onEntitySelected={handleEntitySelected}
|
onEntitySelected={handleEntitySelected}
|
||||||
selectedEntity={companies.selectedEntities[0]}
|
selectedEntity={filteredSearchEntityResults.selectedEntities[0]}
|
||||||
/> */}
|
/>
|
||||||
</RecoilScope>
|
</RecoilScope>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
34
front/src/modules/companies/hooks/useCreateOpportunity.ts
Normal file
34
front/src/modules/companies/hooks/useCreateOpportunity.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { useRecoilCallback } from 'recoil';
|
||||||
|
import { v4 } from 'uuid';
|
||||||
|
|
||||||
|
import { useCreateOneObjectRecord } from '@/object-record/hooks/useCreateOneObjectRecord';
|
||||||
|
import { Opportunity } from '@/pipeline/types/Opportunity';
|
||||||
|
import { boardCardIdsByColumnIdFamilyState } from '@/ui/object/record-board/states/boardCardIdsByColumnIdFamilyState';
|
||||||
|
|
||||||
|
export const useCreateOpportunity = () => {
|
||||||
|
const { createOneObject: createOneOpportunity } =
|
||||||
|
useCreateOneObjectRecord<Opportunity>({
|
||||||
|
objectNameSingular: 'opportunity',
|
||||||
|
});
|
||||||
|
|
||||||
|
const createOpportunity = useRecoilCallback(
|
||||||
|
({ set }) =>
|
||||||
|
async (companyId: string, pipelineStepId: string) => {
|
||||||
|
const newUuid = v4();
|
||||||
|
|
||||||
|
set(boardCardIdsByColumnIdFamilyState(pipelineStepId), (oldValue) => [
|
||||||
|
...oldValue,
|
||||||
|
newUuid,
|
||||||
|
]);
|
||||||
|
|
||||||
|
await createOneOpportunity?.({
|
||||||
|
id: newUuid,
|
||||||
|
pipelineStepId,
|
||||||
|
companyId: companyId,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[createOneOpportunity],
|
||||||
|
);
|
||||||
|
|
||||||
|
return { createOpportunity };
|
||||||
|
};
|
||||||
@ -172,7 +172,7 @@ export const useFavorites = ({
|
|||||||
favorites.filter((favorite: Favorite) => favorite.id !== idToDelete),
|
favorites.filter((favorite: Favorite) => favorite.id !== idToDelete),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
[apolloClient, deleteOneMutation],
|
[apolloClient, deleteOneMutation, performOptimisticEvict],
|
||||||
);
|
);
|
||||||
|
|
||||||
const computeNewPosition = (destIndex: number, sourceIndex: number) => {
|
const computeNewPosition = (destIndex: number, sourceIndex: number) => {
|
||||||
|
|||||||
@ -15,7 +15,9 @@ export const useComputeDefinitionsFromFieldMetadata = (
|
|||||||
const activeFieldMetadataItems = useMemo(
|
const activeFieldMetadataItems = useMemo(
|
||||||
() =>
|
() =>
|
||||||
objectMetadataItem
|
objectMetadataItem
|
||||||
? objectMetadataItem.fields.filter(({ isActive }) => isActive)
|
? objectMetadataItem.fields.filter(
|
||||||
|
({ isActive, isSystem }) => isActive && !isSystem,
|
||||||
|
)
|
||||||
: [],
|
: [],
|
||||||
[objectMetadataItem],
|
[objectMetadataItem],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { useRecoilValue } from 'recoil';
|
|||||||
|
|
||||||
import { objectMetadataItemFamilySelector } from '@/object-metadata/states/objectMetadataItemFamilySelector';
|
import { objectMetadataItemFamilySelector } from '@/object-metadata/states/objectMetadataItemFamilySelector';
|
||||||
import { useGenerateCreateOneObjectMutation } from '@/object-record/utils/generateCreateOneObjectMutation';
|
import { useGenerateCreateOneObjectMutation } from '@/object-record/utils/generateCreateOneObjectMutation';
|
||||||
|
import { useGenerateCacheFragment } from '@/object-record/utils/useGenerateCacheFragment';
|
||||||
import { useGenerateDeleteOneObjectMutation } from '@/object-record/utils/useGenerateDeleteOneObjectMutation';
|
import { useGenerateDeleteOneObjectMutation } from '@/object-record/utils/useGenerateDeleteOneObjectMutation';
|
||||||
import { useGenerateFindManyCustomObjectsQuery } from '@/object-record/utils/useGenerateFindManyCustomObjectsQuery';
|
import { useGenerateFindManyCustomObjectsQuery } from '@/object-record/utils/useGenerateFindManyCustomObjectsQuery';
|
||||||
import { useGenerateFindOneCustomObjectQuery } from '@/object-record/utils/useGenerateFindOneCustomObjectQuery';
|
import { useGenerateFindOneCustomObjectQuery } from '@/object-record/utils/useGenerateFindOneCustomObjectQuery';
|
||||||
@ -36,6 +37,10 @@ export const useObjectMetadataItem = ({
|
|||||||
|
|
||||||
const objectNotFoundInMetadata = !isDefined(objectMetadataItem);
|
const objectNotFoundInMetadata = !isDefined(objectMetadataItem);
|
||||||
|
|
||||||
|
const cacheFragment = useGenerateCacheFragment({
|
||||||
|
objectMetadataItem,
|
||||||
|
});
|
||||||
|
|
||||||
const findManyQuery = useGenerateFindManyCustomObjectsQuery({
|
const findManyQuery = useGenerateFindManyCustomObjectsQuery({
|
||||||
objectMetadataItem,
|
objectMetadataItem,
|
||||||
});
|
});
|
||||||
@ -67,6 +72,7 @@ export const useObjectMetadataItem = ({
|
|||||||
basePathToShowPage,
|
basePathToShowPage,
|
||||||
objectMetadataItem,
|
objectMetadataItem,
|
||||||
objectNotFoundInMetadata,
|
objectNotFoundInMetadata,
|
||||||
|
cacheFragment,
|
||||||
findManyQuery,
|
findManyQuery,
|
||||||
findOneQuery,
|
findOneQuery,
|
||||||
createOneMutation,
|
createOneMutation,
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadata
|
|||||||
import { formatFieldMetadataItemAsColumnDefinition } from '@/object-metadata/utils/formatFieldMetadataItemAsColumnDefinition';
|
import { formatFieldMetadataItemAsColumnDefinition } from '@/object-metadata/utils/formatFieldMetadataItemAsColumnDefinition';
|
||||||
import { filterAvailableFieldMetadataItem } from '@/object-record/utils/filterAvailableFieldMetadataItem';
|
import { filterAvailableFieldMetadataItem } from '@/object-record/utils/filterAvailableFieldMetadataItem';
|
||||||
import { IconBuildingSkyscraper } from '@/ui/display/icon';
|
import { IconBuildingSkyscraper } from '@/ui/display/icon';
|
||||||
|
import { useRelationPicker } from '@/ui/input/components/internal/relation-picker/hooks/useRelationPicker';
|
||||||
import { PageBody } from '@/ui/layout/page/PageBody';
|
import { PageBody } from '@/ui/layout/page/PageBody';
|
||||||
import { PageContainer } from '@/ui/layout/page/PageContainer';
|
import { PageContainer } from '@/ui/layout/page/PageContainer';
|
||||||
import { PageFavoriteButton } from '@/ui/layout/page/PageFavoriteButton';
|
import { PageFavoriteButton } from '@/ui/layout/page/PageFavoriteButton';
|
||||||
@ -40,6 +41,8 @@ export const RecordShowPage = () => {
|
|||||||
objectNameSingular,
|
objectNameSingular,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { identifiersMapper } = useRelationPicker();
|
||||||
|
|
||||||
const { favorites, createFavorite, deleteFavorite } = useFavorites({
|
const { favorites, createFavorite, deleteFavorite } = useFavorites({
|
||||||
objectNamePlural: objectMetadataItem?.namePlural,
|
objectNamePlural: objectMetadataItem?.namePlural,
|
||||||
});
|
});
|
||||||
@ -118,6 +121,11 @@ export const RecordShowPage = () => {
|
|||||||
? object.name.firstName + ' ' + object.name.lastName
|
? object.name.firstName + ' ' + object.name.lastName
|
||||||
: object.name;
|
: object.name;
|
||||||
|
|
||||||
|
const recordIdentifiers = identifiersMapper?.(
|
||||||
|
object,
|
||||||
|
objectMetadataItem?.nameSingular ?? '',
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer>
|
<PageContainer>
|
||||||
<PageTitle title={pageName} />
|
<PageTitle title={pageName} />
|
||||||
@ -144,8 +152,8 @@ export const RecordShowPage = () => {
|
|||||||
<ShowPageLeftContainer>
|
<ShowPageLeftContainer>
|
||||||
<ShowPageSummaryCard
|
<ShowPageSummaryCard
|
||||||
id={object.id}
|
id={object.id}
|
||||||
logoOrAvatar={''}
|
logoOrAvatar={recordIdentifiers?.avatarUrl}
|
||||||
title={object.name ?? 'No name'}
|
title={recordIdentifiers?.name ?? 'No name'}
|
||||||
date={object.createdAt ?? ''}
|
date={object.createdAt ?? ''}
|
||||||
renderTitleEditComponent={() => <></>}
|
renderTitleEditComponent={() => <></>}
|
||||||
avatarType="squared"
|
avatarType="squared"
|
||||||
|
|||||||
@ -34,6 +34,7 @@ export const getRecordOptimisticEffectDefinition = ({
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
draft.edges.unshift({ node: newData, cursor: '' });
|
draft.edges.unshift({ node: newData, cursor: '' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -30,24 +30,29 @@ export const useFindManyObjectRecords = <
|
|||||||
objectNamePlural,
|
objectNamePlural,
|
||||||
filter,
|
filter,
|
||||||
orderBy,
|
orderBy,
|
||||||
|
limit,
|
||||||
onCompleted,
|
onCompleted,
|
||||||
skip,
|
skip,
|
||||||
}: Pick<ObjectMetadataItemIdentifier, 'objectNamePlural'> & {
|
}: Pick<ObjectMetadataItemIdentifier, 'objectNamePlural'> & {
|
||||||
filter?: any;
|
filter?: any;
|
||||||
orderBy?: any;
|
orderBy?: any;
|
||||||
|
limit?: number;
|
||||||
onCompleted?: (data: PaginatedObjectTypeResults<ObjectType>) => void;
|
onCompleted?: (data: PaginatedObjectTypeResults<ObjectType>) => void;
|
||||||
skip?: boolean;
|
skip?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
|
const findManyQueryStateIdentifier =
|
||||||
|
objectNamePlural + JSON.stringify(filter);
|
||||||
|
|
||||||
const [lastCursor, setLastCursor] = useRecoilState(
|
const [lastCursor, setLastCursor] = useRecoilState(
|
||||||
cursorFamilyState(objectNamePlural),
|
cursorFamilyState(findManyQueryStateIdentifier),
|
||||||
);
|
);
|
||||||
|
|
||||||
const [hasNextPage, setHasNextPage] = useRecoilState(
|
const [hasNextPage, setHasNextPage] = useRecoilState(
|
||||||
hasNextPageFamilyState(objectNamePlural),
|
hasNextPageFamilyState(findManyQueryStateIdentifier),
|
||||||
);
|
);
|
||||||
|
|
||||||
const [, setIsFetchingMoreObjects] = useRecoilState(
|
const [, setIsFetchingMoreObjects] = useRecoilState(
|
||||||
isFetchingMoreObjectsFamilyState(objectNamePlural),
|
isFetchingMoreObjectsFamilyState(findManyQueryStateIdentifier),
|
||||||
);
|
);
|
||||||
|
|
||||||
const { objectMetadataItem, objectNotFoundInMetadata, findManyQuery } =
|
const { objectMetadataItem, objectNotFoundInMetadata, findManyQuery } =
|
||||||
@ -68,6 +73,7 @@ export const useFindManyObjectRecords = <
|
|||||||
variables: {
|
variables: {
|
||||||
filter: filter ?? {},
|
filter: filter ?? {},
|
||||||
orderBy: orderBy ?? {},
|
orderBy: orderBy ?? {},
|
||||||
|
limit: limit ?? 30,
|
||||||
},
|
},
|
||||||
onCompleted: (data) => {
|
onCompleted: (data) => {
|
||||||
if (objectMetadataItem) {
|
if (objectMetadataItem) {
|
||||||
|
|||||||
@ -2,8 +2,8 @@ import { useRecoilValue } from 'recoil';
|
|||||||
|
|
||||||
import { useOptimisticEffect } from '@/apollo/optimistic-effect/hooks/useOptimisticEffect';
|
import { useOptimisticEffect } from '@/apollo/optimistic-effect/hooks/useOptimisticEffect';
|
||||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||||
import { turnFiltersIntoWhereClauseV2 } from '@/ui/object/object-filter-dropdown/utils/turnFiltersIntoWhereClauseV2';
|
import { turnFiltersIntoWhereClause } from '@/ui/object/object-filter-dropdown/utils/turnFiltersIntoWhereClause';
|
||||||
import { turnSortsIntoOrderByV2 } from '@/ui/object/object-sort-dropdown/utils/turnSortsIntoOrderByV2';
|
import { turnSortsIntoOrderBy } from '@/ui/object/object-sort-dropdown/utils/turnSortsIntoOrderBy';
|
||||||
import { useRecordTableScopedStates } from '@/ui/object/record-table/hooks/internal/useRecordTableScopedStates';
|
import { useRecordTableScopedStates } from '@/ui/object/record-table/hooks/internal/useRecordTableScopedStates';
|
||||||
import { useRecordTable } from '@/ui/object/record-table/hooks/useRecordTable';
|
import { useRecordTable } from '@/ui/object/record-table/hooks/useRecordTable';
|
||||||
|
|
||||||
@ -31,11 +31,11 @@ export const useObjectRecordTable = () => {
|
|||||||
const tableFilters = useRecoilValue(tableFiltersState);
|
const tableFilters = useRecoilValue(tableFiltersState);
|
||||||
const tableSorts = useRecoilValue(tableSortsState);
|
const tableSorts = useRecoilValue(tableSortsState);
|
||||||
|
|
||||||
const filter = turnFiltersIntoWhereClauseV2(
|
const filter = turnFiltersIntoWhereClause(
|
||||||
tableFilters,
|
tableFilters,
|
||||||
foundObjectMetadataItem?.fields ?? [],
|
foundObjectMetadataItem?.fields ?? [],
|
||||||
);
|
);
|
||||||
const orderBy = turnSortsIntoOrderByV2(
|
const orderBy = turnSortsIntoOrderBy(
|
||||||
tableSorts,
|
tableSorts,
|
||||||
foundObjectMetadataItem?.fields ?? [],
|
foundObjectMetadataItem?.fields ?? [],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useMutation } from '@apollo/client';
|
import { useApolloClient, useMutation } from '@apollo/client';
|
||||||
|
|
||||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||||
import { ObjectMetadataItemIdentifier } from '@/object-metadata/types/ObjectMetadataItemIdentifier';
|
import { ObjectMetadataItemIdentifier } from '@/object-metadata/types/ObjectMetadataItemIdentifier';
|
||||||
@ -11,10 +11,13 @@ export const useUpdateOneObjectRecord = <T>({
|
|||||||
objectMetadataItem: foundObjectMetadataItem,
|
objectMetadataItem: foundObjectMetadataItem,
|
||||||
objectNotFoundInMetadata,
|
objectNotFoundInMetadata,
|
||||||
updateOneMutation,
|
updateOneMutation,
|
||||||
|
cacheFragment,
|
||||||
} = useObjectMetadataItem({
|
} = useObjectMetadataItem({
|
||||||
objectNameSingular,
|
objectNameSingular,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { cache } = useApolloClient();
|
||||||
|
|
||||||
// TODO: type this with a minimal type at least with Record<string, any>
|
// TODO: type this with a minimal type at least with Record<string, any>
|
||||||
const [mutate] = useMutation(updateOneMutation);
|
const [mutate] = useMutation(updateOneMutation);
|
||||||
|
|
||||||
@ -29,6 +32,15 @@ export const useUpdateOneObjectRecord = <T>({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cachedRecordId = cache.identify({
|
||||||
|
__typename: capitalize(foundObjectMetadataItem?.nameSingular ?? ''),
|
||||||
|
id: idToUpdate,
|
||||||
|
});
|
||||||
|
const cachedRecord = cache.readFragment({
|
||||||
|
id: cachedRecordId,
|
||||||
|
fragment: cacheFragment,
|
||||||
|
});
|
||||||
|
|
||||||
const updatedObject = await mutate({
|
const updatedObject = await mutate({
|
||||||
variables: {
|
variables: {
|
||||||
idToUpdate: idToUpdate,
|
idToUpdate: idToUpdate,
|
||||||
@ -38,7 +50,7 @@ export const useUpdateOneObjectRecord = <T>({
|
|||||||
},
|
},
|
||||||
optimisticResponse: {
|
optimisticResponse: {
|
||||||
[`update${capitalize(objectNameSingular)}`]: {
|
[`update${capitalize(objectNameSingular)}`]: {
|
||||||
id: idToUpdate,
|
...(cachedRecord ?? {}),
|
||||||
...input,
|
...input,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -0,0 +1,29 @@
|
|||||||
|
import { gql } from '@apollo/client';
|
||||||
|
|
||||||
|
import { useMapFieldMetadataToGraphQLQuery } from '@/object-metadata/hooks/useMapFieldMetadataToGraphQLQuery';
|
||||||
|
import { EMPTY_MUTATION } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||||
|
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||||
|
import { capitalize } from '~/utils/string/capitalize';
|
||||||
|
|
||||||
|
export const useGenerateCacheFragment = ({
|
||||||
|
objectMetadataItem,
|
||||||
|
}: {
|
||||||
|
objectMetadataItem: ObjectMetadataItem | undefined | null;
|
||||||
|
}) => {
|
||||||
|
const mapFieldMetadataToGraphQLQuery = useMapFieldMetadataToGraphQLQuery();
|
||||||
|
|
||||||
|
if (!objectMetadataItem) {
|
||||||
|
return EMPTY_MUTATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
const capitalizedObjectName = capitalize(objectMetadataItem.nameSingular);
|
||||||
|
|
||||||
|
return gql`
|
||||||
|
fragment ${capitalizedObjectName}Fragment on ${capitalizedObjectName} {
|
||||||
|
id
|
||||||
|
${objectMetadataItem.fields
|
||||||
|
.map((field) => mapFieldMetadataToGraphQLQuery(field))
|
||||||
|
.join('\n')}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
};
|
||||||
@ -1,4 +1,5 @@
|
|||||||
import { CompanyProgressPicker } from '@/companies/components/CompanyProgressPicker';
|
import { OpportunityPicker } from '@/companies/components/OpportunityPicker';
|
||||||
|
import { useCreateOpportunity } from '@/companies/hooks/useCreateOpportunity';
|
||||||
import { PageHotkeyScope } from '@/types/PageHotkeyScope';
|
import { PageHotkeyScope } from '@/types/PageHotkeyScope';
|
||||||
import { IconPlus } from '@/ui/display/icon/index';
|
import { IconPlus } from '@/ui/display/icon/index';
|
||||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||||
@ -17,6 +18,8 @@ export const PipelineAddButton = () => {
|
|||||||
dropdownScopeId: 'add-pipeline-progress',
|
dropdownScopeId: 'add-pipeline-progress',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { createOpportunity } = useCreateOpportunity();
|
||||||
|
|
||||||
const handleCompanySelected = (
|
const handleCompanySelected = (
|
||||||
selectedCompany: EntityForSelect | null,
|
selectedCompany: EntityForSelect | null,
|
||||||
selectedPipelineStepId: string | null,
|
selectedPipelineStepId: string | null,
|
||||||
@ -24,9 +27,7 @@ export const PipelineAddButton = () => {
|
|||||||
if (!selectedCompany?.id) {
|
if (!selectedCompany?.id) {
|
||||||
enqueueSnackBar(
|
enqueueSnackBar(
|
||||||
'There was a problem with the company selection, please retry.',
|
'There was a problem with the company selection, please retry.',
|
||||||
{
|
{ variant: 'error' },
|
||||||
variant: 'error',
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
logError('There was a problem with the company selection, please retry.');
|
logError('There was a problem with the company selection, please retry.');
|
||||||
@ -36,16 +37,14 @@ export const PipelineAddButton = () => {
|
|||||||
if (!selectedPipelineStepId) {
|
if (!selectedPipelineStepId) {
|
||||||
enqueueSnackBar(
|
enqueueSnackBar(
|
||||||
'There was a problem with the pipeline stage selection, please retry.',
|
'There was a problem with the pipeline stage selection, please retry.',
|
||||||
{
|
{ variant: 'error' },
|
||||||
variant: 'error',
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
logError('There was a problem with the pipeline stage selection.');
|
logError('There was a problem with the pipeline step selection.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
closeDropdown();
|
closeDropdown();
|
||||||
//createCompanyProgress(selectedCompany.id, selectedPipelineStepId);
|
createOpportunity(selectedCompany.id, selectedPipelineStepId);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -62,7 +61,7 @@ export const PipelineAddButton = () => {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
dropdownComponents={
|
dropdownComponents={
|
||||||
<CompanyProgressPicker
|
<OpportunityPicker
|
||||||
companyId={null}
|
companyId={null}
|
||||||
onSubmit={handleCompanySelected}
|
onSubmit={handleCompanySelected}
|
||||||
onCancel={closeDropdown}
|
onCancel={closeDropdown}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { useQuery } from '@apollo/client';
|
|||||||
|
|
||||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||||
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
||||||
import { IconUserCircle } from '@/ui/display/icon';
|
import { IconForbid } from '@/ui/display/icon';
|
||||||
import { useRelationPicker } from '@/ui/input/components/internal/relation-picker/hooks/useRelationPicker';
|
import { useRelationPicker } from '@/ui/input/components/internal/relation-picker/hooks/useRelationPicker';
|
||||||
import { SingleEntitySelect } from '@/ui/input/relation-picker/components/SingleEntitySelect';
|
import { SingleEntitySelect } from '@/ui/input/relation-picker/components/SingleEntitySelect';
|
||||||
import { relationPickerSearchFilterScopedState } from '@/ui/input/relation-picker/states/relationPickerSearchFilterScopedState';
|
import { relationPickerSearchFilterScopedState } from '@/ui/input/relation-picker/states/relationPickerSearchFilterScopedState';
|
||||||
@ -17,6 +17,7 @@ export type RelationPickerProps = {
|
|||||||
onSubmit: (newUser: EntityForSelect | null) => void;
|
onSubmit: (newUser: EntityForSelect | null) => void;
|
||||||
onCancel?: () => void;
|
onCancel?: () => void;
|
||||||
width?: number;
|
width?: number;
|
||||||
|
excludeRecordIds?: string[];
|
||||||
initialSearchFilter?: string | null;
|
initialSearchFilter?: string | null;
|
||||||
fieldDefinition: FieldDefinition<FieldRelationMetadata>;
|
fieldDefinition: FieldDefinition<FieldRelationMetadata>;
|
||||||
};
|
};
|
||||||
@ -25,6 +26,7 @@ export const RelationPicker = ({
|
|||||||
recordId,
|
recordId,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
onCancel,
|
onCancel,
|
||||||
|
excludeRecordIds,
|
||||||
width,
|
width,
|
||||||
initialSearchFilter,
|
initialSearchFilter,
|
||||||
fieldDefinition,
|
fieldDefinition,
|
||||||
@ -63,6 +65,7 @@ export const RelationPicker = ({
|
|||||||
fieldDefinition.metadata.relationObjectMetadataNameSingular,
|
fieldDefinition.metadata.relationObjectMetadataNameSingular,
|
||||||
),
|
),
|
||||||
selectedIds: recordId ? [recordId] : [],
|
selectedIds: recordId ? [recordId] : [],
|
||||||
|
excludeEntityIds: excludeRecordIds,
|
||||||
objectNamePlural: fieldDefinition.metadata.relationObjectMetadataNamePlural,
|
objectNamePlural: fieldDefinition.metadata.relationObjectMetadataNamePlural,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -72,8 +75,8 @@ export const RelationPicker = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<SingleEntitySelect
|
<SingleEntitySelect
|
||||||
EmptyIcon={IconUserCircle}
|
EmptyIcon={IconForbid}
|
||||||
emptyLabel="No Owner"
|
emptyLabel={'No ' + fieldDefinition.label}
|
||||||
entitiesToSelect={records.entitiesToSelect}
|
entitiesToSelect={records.entitiesToSelect}
|
||||||
loading={records.loading}
|
loading={records.loading}
|
||||||
onCancel={onCancel}
|
onCancel={onCancel}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ const StyledOuterContainer = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
gap: ${({ theme }) => (useIsMobile() ? theme.spacing(3) : '0')};
|
gap: ${({ theme }) => (useIsMobile() ? theme.spacing(3) : '0')};
|
||||||
height: ${() => (useIsMobile() ? '100%' : 'auto')};
|
height: ${() => (useIsMobile() ? '100%' : '100%')};
|
||||||
overflow-x: ${() => (useIsMobile() ? 'hidden' : 'auto')};
|
overflow-x: ${() => (useIsMobile() ? 'hidden' : 'auto')};
|
||||||
width: 100%;
|
width: 100%;
|
||||||
`;
|
`;
|
||||||
|
|||||||
@ -31,6 +31,12 @@ const StyledInnerContainer = styled.div`
|
|||||||
}};
|
}};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const StyledIntermediateContainer = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-bottom: ${({ theme }) => theme.spacing(3)};
|
||||||
|
`;
|
||||||
|
|
||||||
export type ShowPageLeftContainerProps = {
|
export type ShowPageLeftContainerProps = {
|
||||||
children: ReactElement[];
|
children: ReactElement[];
|
||||||
};
|
};
|
||||||
@ -46,7 +52,9 @@ export const ShowPageLeftContainer = ({
|
|||||||
) : (
|
) : (
|
||||||
<StyledOuterContainer>
|
<StyledOuterContainer>
|
||||||
<ScrollWrapper>
|
<ScrollWrapper>
|
||||||
<StyledInnerContainer>{children}</StyledInnerContainer>
|
<StyledIntermediateContainer>
|
||||||
|
<StyledInnerContainer>{children}</StyledInnerContainer>
|
||||||
|
</StyledIntermediateContainer>
|
||||||
</ScrollWrapper>
|
</ScrollWrapper>
|
||||||
</StyledOuterContainer>
|
</StyledOuterContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -91,16 +91,18 @@ export const ShowPageSummaryCard = ({
|
|||||||
const onFileChange = (e: ChangeEvent<HTMLInputElement>) => {
|
const onFileChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
if (e.target.files) onUploadPicture?.(e.target.files[0]);
|
if (e.target.files) onUploadPicture?.(e.target.files[0]);
|
||||||
};
|
};
|
||||||
const handleAvatarClick = () => {
|
|
||||||
inputFileRef?.current?.click?.();
|
// Todo - add back in when we have the ability to upload a picture
|
||||||
};
|
// const handleAvatarClick = () => {
|
||||||
|
// inputFileRef?.current?.click?.();
|
||||||
|
// };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledShowPageSummaryCard>
|
<StyledShowPageSummaryCard>
|
||||||
<StyledAvatarWrapper>
|
<StyledAvatarWrapper>
|
||||||
<Avatar
|
<Avatar
|
||||||
avatarUrl={logoOrAvatar}
|
avatarUrl={logoOrAvatar}
|
||||||
onClick={onUploadPicture ? handleAvatarClick : undefined}
|
// onClick={onUploadPicture ? handleAvatarClick : undefined}
|
||||||
size="xl"
|
size="xl"
|
||||||
colorId={id}
|
colorId={id}
|
||||||
placeholder={title}
|
placeholder={title}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ type FilterToTurnIntoWhereClause = Omit<Filter, 'definition'> & {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const turnFiltersIntoWhereClauseV2 = (
|
export const turnFiltersIntoWhereClause = (
|
||||||
filters: FilterToTurnIntoWhereClause[],
|
filters: FilterToTurnIntoWhereClause[],
|
||||||
fields: Pick<Field, 'id' | 'name'>[],
|
fields: Pick<Field, 'id' | 'name'>[],
|
||||||
) => {
|
) => {
|
||||||
@ -2,7 +2,7 @@ import { Field } from '~/generated/graphql';
|
|||||||
|
|
||||||
import { Sort } from '../types/Sort';
|
import { Sort } from '../types/Sort';
|
||||||
|
|
||||||
export const turnSortsIntoOrderByV2 = (
|
export const turnSortsIntoOrderBy = (
|
||||||
sorts: Sort[],
|
sorts: Sort[],
|
||||||
fields: Pick<Field, 'id' | 'name'>[],
|
fields: Pick<Field, 'id' | 'name'>[],
|
||||||
) => {
|
) => {
|
||||||
@ -1,12 +1,6 @@
|
|||||||
import { ComponentType } from 'react';
|
import { ComponentType } from 'react';
|
||||||
|
|
||||||
import { Opportunity } from '@/pipeline/types/Opportunity';
|
|
||||||
import { FilterDefinitionByEntity } from '@/ui/object/object-filter-dropdown/types/FilterDefinitionByEntity';
|
|
||||||
import { SortDefinition } from '@/ui/object/object-sort-dropdown/types/SortDefinition';
|
|
||||||
|
|
||||||
export type BoardOptions = {
|
export type BoardOptions = {
|
||||||
newCardComponent: React.ReactNode;
|
newCardComponent: React.ReactNode;
|
||||||
CardComponent: ComponentType;
|
CardComponent: ComponentType;
|
||||||
filterDefinitions: FilterDefinitionByEntity<Opportunity>[];
|
|
||||||
sortDefinitions: SortDefinition[];
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,50 +0,0 @@
|
|||||||
import { useQuery } from '@apollo/client';
|
|
||||||
|
|
||||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
|
||||||
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
|
||||||
import { ObjectFilterDropdownEntitySearchSelect } from '@/ui/object/object-filter-dropdown/components/ObjectFilterDropdownEntitySearchSelect';
|
|
||||||
import { useFilter } from '@/ui/object/object-filter-dropdown/hooks/useFilter';
|
|
||||||
|
|
||||||
export const FilterDropdownUserSearchSelect = () => {
|
|
||||||
const {
|
|
||||||
objectFilterDropdownSearchInput,
|
|
||||||
objectFilterDropdownSelectedEntityId,
|
|
||||||
} = useFilter();
|
|
||||||
|
|
||||||
const { findManyQuery } = useObjectMetadataItem({
|
|
||||||
objectNameSingular: 'workspaceMember',
|
|
||||||
});
|
|
||||||
|
|
||||||
const useFindManyWorkspaceMembers = (options: any) =>
|
|
||||||
useQuery(findManyQuery, options);
|
|
||||||
|
|
||||||
const workspaceMembers = useFilteredSearchEntityQuery({
|
|
||||||
queryHook: useFindManyWorkspaceMembers,
|
|
||||||
filters: [
|
|
||||||
{
|
|
||||||
fieldNames: ['name.firstName', 'name.lastName'],
|
|
||||||
filter: objectFilterDropdownSearchInput,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
orderByField: 'createdAt',
|
|
||||||
mappingFunction: (workspaceMember) => ({
|
|
||||||
entityType: 'WorkspaceMember',
|
|
||||||
id: workspaceMember.id,
|
|
||||||
name:
|
|
||||||
workspaceMember.name.firstName + ' ' + workspaceMember.name.lastName,
|
|
||||||
avatarType: 'rounded',
|
|
||||||
avatarUrl: '',
|
|
||||||
record: workspaceMember,
|
|
||||||
}),
|
|
||||||
selectedIds: objectFilterDropdownSelectedEntityId
|
|
||||||
? [objectFilterDropdownSelectedEntityId]
|
|
||||||
: [],
|
|
||||||
objectNamePlural: 'workspaceMembers',
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ObjectFilterDropdownEntitySearchSelect
|
|
||||||
entitiesForSelect={workspaceMembers}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import { BoardFieldDefinition } from '@/ui/object/record-board/types/BoardFieldDefinition';
|
|
||||||
import { FieldMetadata } from '@/ui/object/field/types/FieldMetadata';
|
import { FieldMetadata } from '@/ui/object/field/types/FieldMetadata';
|
||||||
|
import { BoardFieldDefinition } from '@/ui/object/record-board/types/BoardFieldDefinition';
|
||||||
import { ColumnDefinition } from '@/ui/object/record-table/types/ColumnDefinition';
|
import { ColumnDefinition } from '@/ui/object/record-table/types/ColumnDefinition';
|
||||||
|
|
||||||
export type ViewField = {
|
export type ViewField = {
|
||||||
|
|||||||
@ -1,13 +1,8 @@
|
|||||||
import { CompanyBoardCard } from '@/companies/components/CompanyBoardCard';
|
import { CompanyBoardCard } from '@/companies/components/CompanyBoardCard';
|
||||||
import { NewCompanyProgressButton } from '@/companies/components/NewCompanyProgressButton';
|
import { NewOpportunityButton } from '@/companies/components/NewOpportunityButton';
|
||||||
import { BoardOptions } from '@/ui/object/record-board/types/BoardOptions';
|
import { BoardOptions } from '@/ui/object/record-board/types/BoardOptions';
|
||||||
|
|
||||||
import { opportunityBoardFilterDefinitions } from './constants/opportunityBoardFilterDefinitions';
|
|
||||||
import { opportunityBoardSortDefinitions } from './constants/opportunityBoardSortDefinitions';
|
|
||||||
|
|
||||||
export const opportunitiesBoardOptions: BoardOptions = {
|
export const opportunitiesBoardOptions: BoardOptions = {
|
||||||
newCardComponent: <NewCompanyProgressButton />,
|
newCardComponent: <NewOpportunityButton />,
|
||||||
CardComponent: CompanyBoardCard,
|
CardComponent: CompanyBoardCard,
|
||||||
filterDefinitions: opportunityBoardFilterDefinitions,
|
|
||||||
sortDefinitions: opportunityBoardSortDefinitions,
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -89,7 +89,7 @@ export const seedCompanyFieldMetadata = async (
|
|||||||
description: undefined,
|
description: undefined,
|
||||||
icon: 'IconCalendar',
|
icon: 'IconCalendar',
|
||||||
isNullable: false,
|
isNullable: false,
|
||||||
isSystem: true,
|
isSystem: false,
|
||||||
defaultValue: { type: 'now' },
|
defaultValue: { type: 'now' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -84,7 +84,7 @@ export const seedOpportunityFieldMetadata = async (
|
|||||||
description: undefined,
|
description: undefined,
|
||||||
icon: 'IconCalendar',
|
icon: 'IconCalendar',
|
||||||
isNullable: false,
|
isNullable: false,
|
||||||
isSystem: true,
|
isSystem: false,
|
||||||
defaultValue: { type: 'now' },
|
defaultValue: { type: 'now' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -175,7 +175,7 @@ export const seedOpportunityFieldMetadata = async (
|
|||||||
description: 'Opportunity pipeline step',
|
description: 'Opportunity pipeline step',
|
||||||
icon: 'IconKanban',
|
icon: 'IconKanban',
|
||||||
isNullable: true,
|
isNullable: true,
|
||||||
isSystem: false,
|
isSystem: true,
|
||||||
defaultValue: undefined,
|
defaultValue: undefined,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -239,7 +239,7 @@ export const seedOpportunityFieldMetadata = async (
|
|||||||
description: 'Opportunity person',
|
description: 'Opportunity person',
|
||||||
icon: 'IconUser',
|
icon: 'IconUser',
|
||||||
isNullable: true,
|
isNullable: true,
|
||||||
isSystem: false,
|
isSystem: true,
|
||||||
defaultValue: undefined,
|
defaultValue: undefined,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -89,7 +89,7 @@ export const seedPersonFieldMetadata = async (
|
|||||||
description: undefined,
|
description: undefined,
|
||||||
icon: 'IconCalendar',
|
icon: 'IconCalendar',
|
||||||
isNullable: false,
|
isNullable: false,
|
||||||
isSystem: true,
|
isSystem: false,
|
||||||
defaultValue: { type: 'now' },
|
defaultValue: { type: 'now' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -126,7 +126,7 @@ export const seedPersonFieldMetadata = async (
|
|||||||
},
|
},
|
||||||
description: 'Contact’s name',
|
description: 'Contact’s name',
|
||||||
icon: 'IconUser',
|
icon: 'IconUser',
|
||||||
isNullable: false,
|
isNullable: true,
|
||||||
isSystem: false,
|
isSystem: false,
|
||||||
defaultValue: { firstName: '', lastName: '' },
|
defaultValue: { firstName: '', lastName: '' },
|
||||||
},
|
},
|
||||||
@ -301,11 +301,11 @@ export const seedPersonFieldMetadata = async (
|
|||||||
workspaceId: SeedWorkspaceId,
|
workspaceId: SeedWorkspaceId,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
type: FieldMetadataType.RELATION,
|
type: FieldMetadataType.RELATION,
|
||||||
name: 'pointOfContactForOpporunities',
|
name: 'pointOfContactForOpportunities',
|
||||||
label: 'POC for Opportunities',
|
label: 'POC for Opportunities',
|
||||||
targetColumnMap: {},
|
targetColumnMap: {},
|
||||||
description: 'Point of Contact for Opportuniites',
|
description: 'Point of Contact for Opportuniites',
|
||||||
icon: 'IconArrowTarget',
|
icon: 'IconTargetArrow',
|
||||||
isNullable: true,
|
isNullable: true,
|
||||||
isSystem: false,
|
isSystem: false,
|
||||||
defaultValue: undefined,
|
defaultValue: undefined,
|
||||||
|
|||||||
@ -1,16 +1,25 @@
|
|||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
|
||||||
export class AddCascadeDeleteOnRefreshTokenUser1700661180856 implements MigrationInterface {
|
export class AddCascadeDeleteOnRefreshTokenUser1700661180856
|
||||||
name = 'AddCascadeDeleteOnRefreshTokenUser1700661180856'
|
implements MigrationInterface
|
||||||
|
{
|
||||||
|
name = 'AddCascadeDeleteOnRefreshTokenUser1700661180856';
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(`ALTER TABLE "core"."refreshToken" DROP CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e"`);
|
await queryRunner.query(
|
||||||
await queryRunner.query(`ALTER TABLE "core"."refreshToken" ADD CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e" FOREIGN KEY ("userId") REFERENCES "core"."user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
`ALTER TABLE "core"."refreshToken" DROP CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e"`,
|
||||||
}
|
);
|
||||||
|
await queryRunner.query(
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
`ALTER TABLE "core"."refreshToken" ADD CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e" FOREIGN KEY ("userId") REFERENCES "core"."user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||||
await queryRunner.query(`ALTER TABLE "core"."refreshToken" DROP CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e"`);
|
);
|
||||||
await queryRunner.query(`ALTER TABLE "core"."refreshToken" ADD CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e" FOREIGN KEY ("userId") REFERENCES "core"."user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "core"."refreshToken" DROP CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e"`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "core"."refreshToken" ADD CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e" FOREIGN KEY ("userId") REFERENCES "core"."user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,16 +1,25 @@
|
|||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
|
||||||
export class AddWorkspaceDeleteCascadeSetNullInUser1700663611659 implements MigrationInterface {
|
export class AddWorkspaceDeleteCascadeSetNullInUser1700663611659
|
||||||
name = 'AddWorkspaceDeleteCascadeSetNullInUser1700663611659'
|
implements MigrationInterface
|
||||||
|
{
|
||||||
|
name = 'AddWorkspaceDeleteCascadeSetNullInUser1700663611659';
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(`ALTER TABLE "core"."user" DROP CONSTRAINT "FK_2ec910029395fa7655621c88908"`);
|
await queryRunner.query(
|
||||||
await queryRunner.query(`ALTER TABLE "core"."user" ADD CONSTRAINT "FK_2ec910029395fa7655621c88908" FOREIGN KEY ("defaultWorkspaceId") REFERENCES "core"."workspace"("id") ON DELETE SET NULL ON UPDATE NO ACTION`);
|
`ALTER TABLE "core"."user" DROP CONSTRAINT "FK_2ec910029395fa7655621c88908"`,
|
||||||
}
|
);
|
||||||
|
await queryRunner.query(
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
`ALTER TABLE "core"."user" ADD CONSTRAINT "FK_2ec910029395fa7655621c88908" FOREIGN KEY ("defaultWorkspaceId") REFERENCES "core"."workspace"("id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
||||||
await queryRunner.query(`ALTER TABLE "core"."user" DROP CONSTRAINT "FK_2ec910029395fa7655621c88908"`);
|
);
|
||||||
await queryRunner.query(`ALTER TABLE "core"."user" ADD CONSTRAINT "FK_2ec910029395fa7655621c88908" FOREIGN KEY ("defaultWorkspaceId") REFERENCES "core"."workspace"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "core"."user" DROP CONSTRAINT "FK_2ec910029395fa7655621c88908"`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "core"."user" ADD CONSTRAINT "FK_2ec910029395fa7655621c88908" FOREIGN KEY ("defaultWorkspaceId") REFERENCES "core"."workspace"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
|
||||||
export class AddWorkspaceCacheVersion1700650554672 implements MigrationInterface {
|
export class AddWorkspaceCacheVersion1700650554672
|
||||||
name = 'AddWorkspaceCacheVersion1700650554672'
|
implements MigrationInterface
|
||||||
|
{
|
||||||
|
name = 'AddWorkspaceCacheVersion1700650554672';
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(`CREATE TABLE "metadata"."workspaceCacheVersion" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "workspaceId" character varying NOT NULL, "version" character varying NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_1a80ecf2638b477809403cc26ed" UNIQUE ("workspaceId"), CONSTRAINT "PK_5d502f8dbfb5b9a8bf2439320e9" PRIMARY KEY ("id"))`);
|
await queryRunner.query(
|
||||||
}
|
`CREATE TABLE "metadata"."workspaceCacheVersion" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "workspaceId" character varying NOT NULL, "version" character varying NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_1a80ecf2638b477809403cc26ed" UNIQUE ("workspaceId"), CONSTRAINT "PK_5d502f8dbfb5b9a8bf2439320e9" PRIMARY KEY ("id"))`,
|
||||||
|
);
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
}
|
||||||
await queryRunner.query(`DROP TABLE "metadata"."workspaceCacheVersion"`);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`DROP TABLE "metadata"."workspaceCacheVersion"`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,20 +1,37 @@
|
|||||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
|
||||||
export class AddCascadeDeleteOnRelationObject1700661538754 implements MigrationInterface {
|
export class AddCascadeDeleteOnRelationObject1700661538754
|
||||||
name = 'AddCascadeDeleteOnRelationObject1700661538754'
|
implements MigrationInterface
|
||||||
|
{
|
||||||
|
name = 'AddCascadeDeleteOnRelationObject1700661538754';
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824"`);
|
await queryRunner.query(
|
||||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d"`);
|
`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824"`,
|
||||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d" FOREIGN KEY ("fromObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
);
|
||||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824" FOREIGN KEY ("toObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
await queryRunner.query(
|
||||||
}
|
`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d"`,
|
||||||
|
);
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
await queryRunner.query(
|
||||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824"`);
|
`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d" FOREIGN KEY ("fromObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d"`);
|
);
|
||||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d" FOREIGN KEY ("fromObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
await queryRunner.query(
|
||||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824" FOREIGN KEY ("toObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824" FOREIGN KEY ("toObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824"`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d"`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d" FOREIGN KEY ("fromObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824" FOREIGN KEY ("toObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,6 +63,7 @@ const opportunityMetadata = {
|
|||||||
},
|
},
|
||||||
description: 'Opportunity pipeline step',
|
description: 'Opportunity pipeline step',
|
||||||
icon: 'IconKanban',
|
icon: 'IconKanban',
|
||||||
|
isSystem: true,
|
||||||
isNullable: true,
|
isNullable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -90,6 +91,7 @@ const opportunityMetadata = {
|
|||||||
description: 'Opportunity person',
|
description: 'Opportunity person',
|
||||||
icon: 'IconUser',
|
icon: 'IconUser',
|
||||||
isNullable: true,
|
isNullable: true,
|
||||||
|
isSystem: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
isCustom: false,
|
isCustom: false,
|
||||||
|
|||||||
@ -23,7 +23,7 @@ const personMetadata = {
|
|||||||
},
|
},
|
||||||
description: 'Contact’s name',
|
description: 'Contact’s name',
|
||||||
icon: 'IconUser',
|
icon: 'IconUser',
|
||||||
isNullable: false,
|
isNullable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
isCustom: false,
|
isCustom: false,
|
||||||
@ -116,7 +116,7 @@ const personMetadata = {
|
|||||||
},
|
},
|
||||||
description: 'Contact’s avatar',
|
description: 'Contact’s avatar',
|
||||||
icon: 'IconFileUpload',
|
icon: 'IconFileUpload',
|
||||||
isNullable: false,
|
isNullable: true,
|
||||||
},
|
},
|
||||||
// Relations
|
// Relations
|
||||||
{
|
{
|
||||||
@ -151,8 +151,8 @@ const personMetadata = {
|
|||||||
label: 'POC for Opportunities',
|
label: 'POC for Opportunities',
|
||||||
targetColumnMap: {},
|
targetColumnMap: {},
|
||||||
description: 'Point of Contact for Opportunities',
|
description: 'Point of Contact for Opportunities',
|
||||||
icon: 'IconArrowTarget',
|
icon: 'IconTargetArrow',
|
||||||
isNullable: false,
|
isNullable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
isCustom: false,
|
isCustom: false,
|
||||||
|
|||||||
@ -47,7 +47,7 @@ export const basicFieldsMetadata: Partial<FieldMetadataEntity>[] = [
|
|||||||
value: 'id',
|
value: 'id',
|
||||||
},
|
},
|
||||||
isNullable: true,
|
isNullable: true,
|
||||||
// isSystem: true,
|
isSystem: true,
|
||||||
isCustom: false,
|
isCustom: false,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
defaultValue: { type: 'uuid' },
|
defaultValue: { type: 'uuid' },
|
||||||
@ -75,6 +75,7 @@ export const basicFieldsMetadata: Partial<FieldMetadataEntity>[] = [
|
|||||||
icon: 'IconCalendar',
|
icon: 'IconCalendar',
|
||||||
isNullable: true,
|
isNullable: true,
|
||||||
isCustom: false,
|
isCustom: false,
|
||||||
|
isSystem: true,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
defaultValue: { type: 'now' },
|
defaultValue: { type: 'now' },
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user