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

Added table record mock mode with companies #2715

Merged
merged 3 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Next Next commit
wip
  • Loading branch information
lucasbordeau committed Nov 24, 2023
commit 8cdd5fa63dadd1b2da1e33834cdf738352bbd60b
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ export const RecordTableContainer = ({
<ViewScope
viewScopeId={viewScopeId}
onViewFieldsChange={(viewFields) => {
console.log({
viewFields,
columnDefinitions,
});
setTableColumns(
mapViewFieldsToColumnDefinitions(viewFields, columnDefinitions),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import styled from '@emotion/styled';
Copy link
Member

Choose a reason for hiding this comment

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

I feel we should not re-add this to object-record folder and create a separated company-record-table-mock module

import { useRecoilCallback } from 'recoil';

import { useComputeDefinitionsFromFieldMetadata } from '@/object-metadata/hooks/useComputeDefinitionsFromFieldMetadata';
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
import { RecordTableMockModeEffect } from '@/object-record/components/RecordTableMockModeEffect';
import { RecordTable } from '@/ui/object/record-table/components/RecordTable';
import { TableOptionsDropdownId } from '@/ui/object/record-table/constants/TableOptionsDropdownId';
import { useRecordTable } from '@/ui/object/record-table/hooks/useRecordTable';
import { TableOptionsDropdown } from '@/ui/object/record-table/options/components/TableOptionsDropdown';
import { RecordTableScope } from '@/ui/object/record-table/scopes/RecordTableScope';
import { ViewBar } from '@/views/components/ViewBar';
import { useViewFields } from '@/views/hooks/internal/useViewFields';
import { ViewScope } from '@/views/scopes/ViewScope';
import { mapColumnDefinitionsToViewFields } from '@/views/utils/mapColumnDefinitionToViewField';
import { mapViewFiltersToFilters } from '@/views/utils/mapViewFiltersToFilters';
import { mapViewSortsToSorts } from '@/views/utils/mapViewSortsToSorts';

const StyledContainer = styled.div`
display: flex;
flex-direction: column;
height: 100%;
overflow: auto;
`;

export const RecordTableContainerMockMode = ({
objectNamePlural,
}: {
objectNamePlural: string;
}) => {
const { objectMetadataItem: foundObjectMetadataItem } = useObjectMetadataItem(
{
objectNamePlural,
},
);
const { columnDefinitions } = useComputeDefinitionsFromFieldMetadata(
foundObjectMetadataItem,
);

const tableScopeId = objectNamePlural ?? '';
const viewScopeId = objectNamePlural ?? '';

const { persistViewFields } = useViewFields(viewScopeId);

const { setTableFilters, setTableSorts, setTableColumns } = useRecordTable({
Copy link
Member

Choose a reason for hiding this comment

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

Unused variable

recordTableScopeId: tableScopeId,
});

const updateEntity = () => {};

return (
<ViewScope
viewScopeId={viewScopeId}
onViewFieldsChange={() => {}}
onViewFiltersChange={(viewFilters) => {
setTableFilters(mapViewFiltersToFilters(viewFilters));
}}
onViewSortsChange={(viewSorts) => {
setTableSorts(mapViewSortsToSorts(viewSorts));
}}
>
<StyledContainer>
<RecordTableScope
recordTableScopeId={tableScopeId}
onColumnsChange={useRecoilCallback(() => (columns) => {
persistViewFields(mapColumnDefinitionsToViewFields(columns));
})}
>
<ViewBar
optionsDropdownButton={<TableOptionsDropdown />}
optionsDropdownScopeId={TableOptionsDropdownId}
/>
<RecordTableMockModeEffect />
<RecordTable updateEntityMutation={updateEntity} />
</RecordTableScope>
</StyledContainer>
</ViewScope>
);
};
12 changes: 12 additions & 0 deletions front/src/modules/object-record/components/RecordTableEffect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ export const RecordTableEffect = () => {
} = useView();

useEffect(() => {
console.log({
basePathToShowPage,
labelIdentifierFieldMetadataId,
});

if (basePathToShowPage && labelIdentifierFieldMetadataId) {
setObjectMetadataConfig?.({
basePathToShowPage,
Expand Down Expand Up @@ -66,6 +71,13 @@ export const RecordTableEffect = () => {
);

setAvailableTableColumns(availableTableColumns);

console.log({
objectMetadataItem,
columnDefinitions,
filterDefinitions,
sortDefinitions,
});
}, [
setViewObjectMetadataId,
setViewType,
Expand Down
Loading
Loading