Skip to content

Commit

Permalink
Merge pull request #52 from agentlab/issue-51-base-table-visibility-s…
Browse files Browse the repository at this point in the history
…ettings

GH-51 Fix column visibility settings
  • Loading branch information
amivanoff authored Dec 31, 2021
2 parents 8104f03 + ce71405 commit 917499e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 150 deletions.
6 changes: 3 additions & 3 deletions src/BaseTable/hooks/useColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const useColumns = ({
}),
[schemaProperties, viewKind, viewKindElement, viewDescr, viewDescrElement],
);
//говно - надо поменять

const setColumnsVisible = useCallback(
(idxs: any) =>
setVisibleColumns((prevVisibleColumns: any) => {
Expand All @@ -56,8 +56,8 @@ export const useColumns = ({
);

const menuItems = useMemo(
() => getConfigMenuItems({ columns: parsedColumns, setColumnsVisible }),
[parsedColumns, setColumnsVisible],
() => getConfigMenuItems({ columns: visibleColumns, setColumnsVisible }),
[visibleColumns, setColumnsVisible],
);
const systemColumn = useMemo(() => getSystemColumn({ menuItems }), [menuItems]);
const selectionColumn = useMemo(
Expand Down
5 changes: 4 additions & 1 deletion src/BaseTable/utils/createColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { JsObject } from '@agentlab/sparql-jsld-client';
import { EditableCell } from '../components/cells/EditableTableCell';
import { createViewKindElement } from './createViewKindElement';
import { getColumnFilterProps } from './getFilterColumnProps';
import isEmpty from 'lodash/isEmpty';

type Props = {
property: string;
Expand All @@ -23,11 +24,13 @@ export const createColumn = ({
viewDescr,
viewDescrElement,
}: Props) => {
const order = viewKindElement?.options?.order || [];
const options = viewKindElement?.options?.[property] || {};
const disabled = (isEmpty(options) && !order.includes(property)) || !!options?.disabled;
const newColumn: JsObject = {
editable: false,
hidden: false,
disabled: false,
disabled,
width: 200,
resizable: true,
title: propertySchema.title || property,
Expand Down
149 changes: 3 additions & 146 deletions stories/TableRemoteMktp.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,39 +114,7 @@ const viewKinds = [
resizeableHeader: true,
style: { height: '100%' },
multiSelect: true,
order: [
'imageUrl',
'name',
'amountValueMoving30',
'commentsCount',
'price',
/*'saleValue',
'categoryPopularity',
'starsValue',
'questionsCount',
'lastMonthSalesAmount',
'lastMonthSalesValue',
'perMonthSalesAmount',
'perMonthSalesValue',
'prevMonthSalesAmount',
'prevMonthSalesValue',
'salesAmountDiff',
'totalSales',
'totalSalesDiff',
'stocks',
'stocksDiffOrders',
'stocksDiffReturns',
'country',
'brand',
'seller',
'identifier',
'rootId',
'photosCount',
'firstParsedAt',
'lastMonthParsedAt',
'parsedAt',
'prevParsedAt',*/
],
order: ['imageUrl', 'name', 'amountValueMoving30', 'commentsCount', 'price'],
imageUrl: {
width: 100,
formatter: 'image',
Expand Down Expand Up @@ -174,124 +142,13 @@ const viewKinds = [
sortable: true,
editable: false,
},
/*identifier: {
identifier: {
formatter: 'link',
//dataToFormatter: { link: 'identifier' },
sortable: true,
editable: false,
disabled: true,
},
country: {
width: 60,
sortable: true,
editable: false,
},
brand: {
formatter: 'link',
sortable: true,
editable: false,
},
saleValue: {
width: 60,
sortable: true,
editable: false,
},
seller: {
formatter: 'link',
sortable: true,
editable: false,
},
categoryPopularity: {
width: 100,
editable: false,
},
starsValue: {
width: 100,
sortable: true,
editable: false,
},
questionsCount: {
width: 100,
sortable: true,
editable: false,
},
lastMonthSalesAmount: {
width: 150,
sortable: true,
editable: false,
},
lastMonthSalesValue: {
width: 150,
sortable: true,
editable: false,
},
perMonthSalesAmount: {
width: 150,
sortable: true,
editable: false,
},
perMonthSalesValue: {
width: 150,
sortable: true,
editable: false,
},
prevMonthSalesAmount: {
width: 150,
sortable: true,
editable: false,
},
prevMonthSalesValue: {
width: 150,
sortable: true,
editable: false,
},
salesAmountDiff: {
width: 150,
sortable: true,
editable: false,
},
totalSales: {
width: 100,
sortable: true,
editable: false,
},
totalSalesDiff: {
width: 150,
sortable: true,
editable: false,
},
stocks: {
width: 100,
sortable: true,
editable: false,
},
stocksDiffOrders: {
width: 100,
sortable: true,
editable: false,
},
stocksDiffReturns: {
width: 100,
sortable: true,
editable: false,
},
rootId: {
editable: false,
},
photosCount: {
editable: false,
},
firstParsedAt: {
editable: false,
},
lastMonthParsedAt: {
editable: false,
},
parsedAt: {
editable: false,
},
prevParsedAt: {
editable: false,
},*/
},
},
],
Expand Down

0 comments on commit 917499e

Please sign in to comment.