refactor: index ViewField by viewId and key (#1416)
* refactor: index ViewField by viewId and key Closes #1413 * refactor: rename ViewField properties
This commit is contained in:
@ -9,10 +9,10 @@ export const hiddenTableColumnsScopedSelector = selectorFamily({
|
||||
(scopeId: string) =>
|
||||
({ get }) => {
|
||||
const columns = get(tableColumnsScopedState(scopeId));
|
||||
const columnLabels = columns.map(({ label }) => label);
|
||||
const columnKeys = columns.map(({ key }) => key);
|
||||
const otherAvailableColumns = get(
|
||||
availableTableColumnsScopedState(scopeId),
|
||||
).filter(({ label }) => !columnLabels.includes(label));
|
||||
).filter(({ key }) => !columnKeys.includes(key));
|
||||
|
||||
return [
|
||||
...columns.filter((column) => !column.isVisible),
|
||||
|
||||
@ -5,12 +5,12 @@ import type { ViewFieldMetadata } from '@/ui/editable-field/types/ViewField';
|
||||
import type { ColumnDefinition } from '../../types/ColumnDefinition';
|
||||
import { savedTableColumnsScopedState } from '../savedTableColumnsScopedState';
|
||||
|
||||
export const savedTableColumnsByIdScopedSelector = selectorFamily({
|
||||
key: 'savedTableColumnsByIdScopedSelector',
|
||||
export const savedTableColumnsByKeyScopedSelector = selectorFamily({
|
||||
key: 'savedTableColumnsByKeyScopedSelector',
|
||||
get:
|
||||
(viewId: string | undefined) =>
|
||||
({ get }) =>
|
||||
get(savedTableColumnsScopedState(viewId)).reduce<
|
||||
Record<string, ColumnDefinition<ViewFieldMetadata>>
|
||||
>((result, column) => ({ ...result, [column.id]: column }), {}),
|
||||
>((result, column) => ({ ...result, [column.key]: column }), {}),
|
||||
});
|
||||
@ -5,12 +5,12 @@ import type { ViewFieldMetadata } from '@/ui/editable-field/types/ViewField';
|
||||
import type { ColumnDefinition } from '../../types/ColumnDefinition';
|
||||
import { tableColumnsScopedState } from '../tableColumnsScopedState';
|
||||
|
||||
export const tableColumnsByIdScopedSelector = selectorFamily({
|
||||
key: 'tableColumnsByIdScopedSelector',
|
||||
export const tableColumnsByKeyScopedSelector = selectorFamily({
|
||||
key: 'tableColumnsByKeyScopedSelector',
|
||||
get:
|
||||
(scopeId: string) =>
|
||||
({ get }) =>
|
||||
get(tableColumnsScopedState(scopeId)).reduce<
|
||||
Record<string, ColumnDefinition<ViewFieldMetadata>>
|
||||
>((result, column) => ({ ...result, [column.id]: column }), {}),
|
||||
>((result, column) => ({ ...result, [column.key]: column }), {}),
|
||||
});
|
||||
Reference in New Issue
Block a user