Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/generic editable cell all types #987

Merged
merged 25 commits into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@
"workerDirectory": "public"
},
"nyc": {
"statements": 70,
"lines": 70,
"statements": 65,
"lines": 65,
"functions": 60,
"exclude": [
"src/generated/**/*"
Expand Down
2 changes: 1 addition & 1 deletion front/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { AppInternalHooks } from '~/sync-hooks/AppInternalHooks';
import { SignInUp } from './pages/auth/SignInUp';

// TEMP FEATURE FLAG FOR VIEW FIELDS
export const ACTIVATE_VIEW_FIELDS = false;
export const ACTIVATE_VIEW_FIELDS = true;

export function App() {
return (
Expand Down

This file was deleted.

105 changes: 105 additions & 0 deletions front/src/modules/companies/constants/companyViewFields.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import {
IconBuildingSkyscraper,
IconCalendarEvent,
IconLink,
IconMap,
IconUser,
IconUsers,
} from '@/ui/icon/index';
import { Entity } from '@/ui/relation-picker/types/EntityTypeForSelect';
import {
ViewFieldChipMetadata,
ViewFieldDateMetadata,
ViewFieldDefinition,
ViewFieldMetadata,
ViewFieldNumberMetadata,
ViewFieldRelationMetadata,
ViewFieldTextMetadata,
ViewFieldURLMetadata,
} from '@/ui/table/types/ViewField';

export const companyViewFields: ViewFieldDefinition<ViewFieldMetadata>[] = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ViewFieldDefinition => ViewField ?

{
id: 'name',
columnLabel: 'Name',
columnIcon: <IconBuildingSkyscraper />,
columnSize: 180,
columnOrder: 1,
metadata: {
type: 'chip',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have put the type in view field, not in metadata

urlFieldName: 'domainName',
contentFieldName: 'name',
relationType: Entity.Company,
},
} as ViewFieldDefinition<ViewFieldChipMetadata>,
{
id: 'domainName',
columnLabel: 'URL',
columnIcon: <IconLink />,
columnSize: 100,
columnOrder: 2,
metadata: {
type: 'url',
fieldName: 'domainName',
placeHolder: 'example.com',
},
} as ViewFieldDefinition<ViewFieldURLMetadata>,
{
id: 'accountOwner',
columnLabel: 'Account Owner',
columnIcon: <IconUser />,
columnSize: 150,
columnOrder: 3,
metadata: {
type: 'relation',
fieldName: 'accountOwner',
relationType: Entity.User,
},
} satisfies ViewFieldDefinition<ViewFieldRelationMetadata>,
{
id: 'createdAt',
columnLabel: 'Creation',
columnIcon: <IconCalendarEvent />,
columnSize: 150,
columnOrder: 4,
metadata: {
type: 'date',
fieldName: 'createdAt',
},
} satisfies ViewFieldDefinition<ViewFieldDateMetadata>,
{
id: 'employees',
columnLabel: 'Employees',
columnIcon: <IconUsers />,
columnSize: 150,
columnOrder: 5,
metadata: {
type: 'number',
fieldName: 'employees',
},
} satisfies ViewFieldDefinition<ViewFieldNumberMetadata>,
{
id: 'linkedin',
columnLabel: 'LinkedIn',
columnIcon: <IconMap />,
columnSize: 170,
columnOrder: 6,
metadata: {
type: 'url',
fieldName: 'linkedinUrl',
placeHolder: 'LinkedIn URL',
},
} satisfies ViewFieldDefinition<ViewFieldURLMetadata>,
{
id: 'address',
columnLabel: 'Address',
columnIcon: <IconMap />,
columnSize: 170,
columnOrder: 7,
metadata: {
type: 'text',
fieldName: 'address',
placeHolder: 'Address',
},
} satisfies ViewFieldDefinition<ViewFieldTextMetadata>,
];
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,20 @@ export function CompanyCreatedAtEditableField({ company }: OwnProps) {
setInternalValue(company.createdAt);
}, [company.createdAt]);

// TODO: refactor change and submit
async function handleChange(newValue: string) {
setInternalValue(newValue);

await updateCompany({
variables: {
where: {
id: company.id,
},
data: {
createdAt: newValue ?? '',
},
},
});
}

async function handleSubmit() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useCallback, useMemo, useState } from 'react';

import { companyViewFields } from '@/companies/constants/companyFieldMetadataArray';
import { companyViewFields } from '@/companies/constants/companyViewFields';
import { CompaniesSelectedSortType, defaultOrderBy } from '@/companies/queries';
import { GenericEntityTableData } from '@/people/components/GenericEntityTableData';
import { reduceSortsToOrderBy } from '@/ui/filter-n-sort/helpers';
import { filtersScopedState } from '@/ui/filter-n-sort/states/filtersScopedState';
import { turnFilterIntoWhereClause } from '@/ui/filter-n-sort/utils/turnFilterIntoWhereClause';
import { IconList } from '@/ui/icon';
import { useRecoilScopedValue } from '@/ui/recoil-scope/hooks/useRecoilScopedValue';
import { EntityTable } from '@/ui/table/components/EntityTableV2';
import { GenericEntityTableData } from '@/ui/table/components/GenericEntityTableData';
import { TableContext } from '@/ui/table/states/TableContext';
import {
CompanyOrderByWithRelationInput,
Expand Down
52 changes: 0 additions & 52 deletions front/src/modules/people/constants/peopleFieldMetadataArray.tsx

This file was deleted.

122 changes: 122 additions & 0 deletions front/src/modules/people/constants/peopleViewFields.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import {
IconBrandLinkedin,
IconBriefcase,
IconBuildingSkyscraper,
IconCalendarEvent,
IconMail,
IconMap,
IconPhone,
IconUser,
} from '@/ui/icon/index';
import { Entity } from '@/ui/relation-picker/types/EntityTypeForSelect';
import {
ViewFieldDateMetadata,
ViewFieldDefinition,
ViewFieldDoubleTextChipMetadata,
ViewFieldMetadata,
ViewFieldPhoneMetadata,
ViewFieldRelationMetadata,
ViewFieldTextMetadata,
ViewFieldURLMetadata,
} from '@/ui/table/types/ViewField';

export const peopleViewFields: ViewFieldDefinition<ViewFieldMetadata>[] = [
{
id: 'displayName',
columnLabel: 'People',
columnIcon: <IconUser />,
columnSize: 210,
columnOrder: 1,
metadata: {
type: 'double-text-chip',
firstValueFieldName: 'firstName',
secondValueFieldName: 'lastName',
firstValuePlaceholder: 'First name',
secondValuePlaceholder: 'Last name',
entityType: Entity.Person,
},
} satisfies ViewFieldDefinition<ViewFieldDoubleTextChipMetadata>,
{
id: 'email',
columnLabel: 'Email',
columnIcon: <IconMail />,
columnSize: 150,
columnOrder: 2,
metadata: {
type: 'text',
fieldName: 'email',
placeHolder: 'Email',
},
} satisfies ViewFieldDefinition<ViewFieldTextMetadata>,
{
id: 'company',
columnLabel: 'Company',
columnIcon: <IconBuildingSkyscraper />,
columnSize: 150,
columnOrder: 3,
metadata: {
type: 'relation',
fieldName: 'company',
relationType: Entity.Company,
},
} satisfies ViewFieldDefinition<ViewFieldRelationMetadata>,
{
id: 'phone',
columnLabel: 'Phone',
columnIcon: <IconPhone />,
columnSize: 150,
columnOrder: 4,
metadata: {
type: 'phone',
fieldName: 'phone',
placeHolder: 'Phone',
},
} satisfies ViewFieldDefinition<ViewFieldPhoneMetadata>,
{
id: 'createdAt',
columnLabel: 'Creation',
columnIcon: <IconCalendarEvent />,
columnSize: 150,
columnOrder: 5,
metadata: {
type: 'date',
fieldName: 'createdAt',
},
} satisfies ViewFieldDefinition<ViewFieldDateMetadata>,
{
id: 'city',
columnLabel: 'City',
columnIcon: <IconMap />,
columnSize: 150,
columnOrder: 6,
metadata: {
type: 'text',
fieldName: 'city',
placeHolder: 'City',
},
} satisfies ViewFieldDefinition<ViewFieldTextMetadata>,
{
id: 'jobTitle',
columnLabel: 'Job title',
columnIcon: <IconBriefcase />,
columnSize: 150,
columnOrder: 7,
metadata: {
type: 'text',
fieldName: 'jobTitle',
placeHolder: 'Job title',
},
} satisfies ViewFieldDefinition<ViewFieldTextMetadata>,
{
id: 'linkedin',
columnLabel: 'LinkedIn',
columnIcon: <IconBrandLinkedin />,
columnSize: 150,
columnOrder: 8,
metadata: {
type: 'url',
fieldName: 'linkedinUrl',
placeHolder: 'LinkedIn',
},
} satisfies ViewFieldDefinition<ViewFieldURLMetadata>,
];
Loading