@ -14,18 +14,21 @@ import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { getCompaniesMock } from '~/testing/mock-data/companies';
|
||||
import { generatedMockObjectMetadataItems } from '~/testing/mock-data/objectMetadataItems';
|
||||
import { getPeopleMock } from '~/testing/mock-data/people';
|
||||
import { mockedTasks } from '~/testing/mock-data/tasks';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
const RecordMockSetterEffect = ({
|
||||
companies,
|
||||
people,
|
||||
tasks,
|
||||
}: {
|
||||
companies: ObjectRecord[];
|
||||
people: ObjectRecord[];
|
||||
tasks: ObjectRecord[];
|
||||
}) => {
|
||||
const setRecordValue = useSetRecordValue();
|
||||
|
||||
const setRecordInBothStores = useRecoilCallback(
|
||||
const setRecordInStores = useRecoilCallback(
|
||||
({ set }) =>
|
||||
(record: ObjectRecord) => {
|
||||
set(recordStoreFamilyState(record.id), record);
|
||||
@ -36,20 +39,24 @@ const RecordMockSetterEffect = ({
|
||||
|
||||
useEffect(() => {
|
||||
for (const company of companies) {
|
||||
setRecordInBothStores(company);
|
||||
setRecordInStores(company);
|
||||
}
|
||||
|
||||
for (const person of people) {
|
||||
setRecordInBothStores(person);
|
||||
setRecordInStores(person);
|
||||
}
|
||||
}, [setRecordInBothStores, companies, people]);
|
||||
|
||||
for (const task of tasks) {
|
||||
setRecordInStores(task);
|
||||
}
|
||||
}, [companies, people, tasks, setRecordInStores]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export const getFieldDecorator =
|
||||
(
|
||||
objectNameSingular: 'company' | 'person',
|
||||
objectNameSingular: 'company' | 'person' | 'task',
|
||||
fieldName: string,
|
||||
fieldValue?: any,
|
||||
): Decorator =>
|
||||
@ -74,7 +81,19 @@ export const getFieldDecorator =
|
||||
]
|
||||
: peopleMock;
|
||||
|
||||
const record = objectNameSingular === 'company' ? companies[0] : people[0];
|
||||
const tasksMock = mockedTasks;
|
||||
|
||||
const tasks =
|
||||
objectNameSingular === 'task'
|
||||
? [{ ...tasksMock[0], [fieldName]: fieldValue }, ...tasksMock.slice(1)]
|
||||
: tasksMock;
|
||||
|
||||
const record =
|
||||
objectNameSingular === 'company'
|
||||
? companies[0]
|
||||
: objectNameSingular === 'person'
|
||||
? people[0]
|
||||
: tasks[0];
|
||||
|
||||
if (isDefined(fieldValue)) {
|
||||
(record as any)[fieldName] = fieldValue;
|
||||
@ -113,13 +132,17 @@ export const getFieldDecorator =
|
||||
isLabelIdentifier,
|
||||
fieldDefinition: formatFieldMetadataItemAsColumnDefinition({
|
||||
field: fieldMetadataItem,
|
||||
position: record.position ?? 0,
|
||||
position: 0,
|
||||
objectMetadataItem,
|
||||
}),
|
||||
hotkeyScope: 'hotkey-scope',
|
||||
}}
|
||||
>
|
||||
<RecordMockSetterEffect companies={companies} people={people} />
|
||||
<RecordMockSetterEffect
|
||||
companies={companies}
|
||||
people={people}
|
||||
tasks={tasks}
|
||||
/>
|
||||
<Story />
|
||||
</FieldContext.Provider>
|
||||
</RecordFieldValueSelectorContextProvider>
|
||||
|
||||
@ -7936,6 +7936,75 @@ export const mockedStandardObjectMetadataQueryResult: ObjectMetadataItemsQuery =
|
||||
"fromRelationMetadata": null,
|
||||
"toRelationMetadata": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"__typename": "fieldEdge",
|
||||
"node": {
|
||||
"__typename": "field",
|
||||
"id": "af19a3ba-b725-4b9d-a0b7-8bf6b04fadds",
|
||||
"type": "MULTI_SELECT",
|
||||
"name": "testMultiSelect",
|
||||
"label": "Test Multi Select",
|
||||
"description": "Test Multi Select",
|
||||
"icon": "IconSelect",
|
||||
"isCustom": false,
|
||||
"isActive": true,
|
||||
"isSystem": true,
|
||||
"isNullable": false,
|
||||
"createdAt": "2024-08-02T16:00:05.938Z",
|
||||
"updatedAt": "2024-08-02T16:00:05.938Z",
|
||||
"defaultValue": null,
|
||||
"options": null,
|
||||
"relationDefinition": null,
|
||||
"fromRelationMetadata": null,
|
||||
"toRelationMetadata": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"__typename": "fieldEdge",
|
||||
"node": {
|
||||
"__typename": "field",
|
||||
"id": "tt929592-4f74-419e-8b26-6d216859078f",
|
||||
"type": "RAW_JSON",
|
||||
"name": "testRawJson",
|
||||
"label": "Test Raw Json",
|
||||
"description": "Json value for event details",
|
||||
"icon": "IconListDetails",
|
||||
"isCustom": false,
|
||||
"isActive": true,
|
||||
"isSystem": true,
|
||||
"isNullable": true,
|
||||
"createdAt": "2024-08-02T16:00:05.938Z",
|
||||
"updatedAt": "2024-08-02T16:00:05.938Z",
|
||||
"defaultValue": null,
|
||||
"options": null,
|
||||
"relationDefinition": null,
|
||||
"fromRelationMetadata": null,
|
||||
"toRelationMetadata": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"__typename": "fieldEdge",
|
||||
"node": {
|
||||
"__typename": "field",
|
||||
"id": "vv929592-4f74-419e-8b26-6d216859078f",
|
||||
"type": "RATING",
|
||||
"name": "testRating",
|
||||
"label": "Rating",
|
||||
"description": "Rating value",
|
||||
"icon": "IconListDetails",
|
||||
"isCustom": false,
|
||||
"isActive": true,
|
||||
"isSystem": true,
|
||||
"isNullable": true,
|
||||
"createdAt": "2024-08-02T16:00:05.938Z",
|
||||
"updatedAt": "2024-08-02T16:00:05.938Z",
|
||||
"defaultValue": null,
|
||||
"options": null,
|
||||
"relationDefinition": null,
|
||||
"fromRelationMetadata": null,
|
||||
"toRelationMetadata": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"__typename": "fieldEdge",
|
||||
|
||||
@ -132,6 +132,37 @@ export const peopleQueryResult: { people: RecordGqlConnection } = {
|
||||
secondaryLinks: null,
|
||||
},
|
||||
},
|
||||
testSelect: {
|
||||
__typename: 'Select',
|
||||
value: 'Option 1',
|
||||
label: 'Option 1',
|
||||
},
|
||||
testMultiSelect: {
|
||||
__typename: 'MultiSelect',
|
||||
values: [
|
||||
{
|
||||
__typename: 'Select',
|
||||
value: 'Option 1',
|
||||
label: 'Option 1',
|
||||
},
|
||||
],
|
||||
},
|
||||
testRating: {
|
||||
__typename: 'Rating',
|
||||
value: 3,
|
||||
},
|
||||
testJson: {
|
||||
__typename: 'Json',
|
||||
value: {
|
||||
key: 'value',
|
||||
},
|
||||
},
|
||||
testActor: {
|
||||
__typename: 'Actor',
|
||||
source: 'MANUAL',
|
||||
workspaceMemberId: '20202020-0687-4c41-b707-ed1bfca972a7',
|
||||
name: 'Tim Apple',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -228,6 +259,37 @@ export const peopleQueryResult: { people: RecordGqlConnection } = {
|
||||
secondaryLinks: null,
|
||||
},
|
||||
},
|
||||
testSelect: {
|
||||
__typename: 'Select',
|
||||
value: 'Option 1',
|
||||
label: 'Option 1',
|
||||
},
|
||||
testMultiSelect: {
|
||||
__typename: 'MultiSelect',
|
||||
values: [
|
||||
{
|
||||
__typename: 'Select',
|
||||
value: 'Option 1',
|
||||
label: 'Option 1',
|
||||
},
|
||||
],
|
||||
},
|
||||
testRating: {
|
||||
__typename: 'Rating',
|
||||
value: 3,
|
||||
},
|
||||
testJson: {
|
||||
__typename: 'Json',
|
||||
value: {
|
||||
key: 'value',
|
||||
},
|
||||
},
|
||||
testActor: {
|
||||
__typename: 'Actor',
|
||||
source: 'MANUAL',
|
||||
workspaceMemberId: '20202020-0687-4c41-b707-ed1bfca972a7',
|
||||
name: 'Tim Apple',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user