@ -1,6 +1,8 @@
|
|||||||
|
import { useCallback } from 'react';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
import { mapBoardFieldDefinitionsToViewFields } from '@/companies/utils/mapBoardFieldDefinitionsToViewFields';
|
import { mapBoardFieldDefinitionsToViewFields } from '@/companies/utils/mapBoardFieldDefinitionsToViewFields';
|
||||||
|
import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord';
|
||||||
import {
|
import {
|
||||||
RecordBoard,
|
RecordBoard,
|
||||||
RecordBoardProps,
|
RecordBoardProps,
|
||||||
@ -8,6 +10,7 @@ import {
|
|||||||
import { RecordBoardEffect } from '@/object-record/record-board/components/RecordBoardEffect';
|
import { RecordBoardEffect } from '@/object-record/record-board/components/RecordBoardEffect';
|
||||||
import { BoardOptionsDropdownId } from '@/object-record/record-board/constants/BoardOptionsDropdownId';
|
import { BoardOptionsDropdownId } from '@/object-record/record-board/constants/BoardOptionsDropdownId';
|
||||||
import { RecordBoardOptionsDropdown } from '@/object-record/record-board/options/components/RecordBoardOptionsDropdown';
|
import { RecordBoardOptionsDropdown } from '@/object-record/record-board/options/components/RecordBoardOptionsDropdown';
|
||||||
|
import { BoardColumnDefinition } from '@/object-record/record-board/types/BoardColumnDefinition';
|
||||||
import { ViewBar } from '@/views/components/ViewBar';
|
import { ViewBar } from '@/views/components/ViewBar';
|
||||||
import { useViewFields } from '@/views/hooks/internal/useViewFields';
|
import { useViewFields } from '@/views/hooks/internal/useViewFields';
|
||||||
import { opportunitiesBoardOptions } from '~/pages/opportunities/opportunitiesBoardOptions';
|
import { opportunitiesBoardOptions } from '~/pages/opportunities/opportunitiesBoardOptions';
|
||||||
@ -37,12 +40,31 @@ export const CompanyBoard = ({
|
|||||||
|
|
||||||
const { persistViewFields } = useViewFields(viewBarId);
|
const { persistViewFields } = useViewFields(viewBarId);
|
||||||
|
|
||||||
|
const { createOneRecord } = useCreateOneRecord({
|
||||||
|
objectNameSingular: 'pipelineStep',
|
||||||
|
});
|
||||||
|
|
||||||
|
const onStageAdd = useCallback(
|
||||||
|
(stage: BoardColumnDefinition) => {
|
||||||
|
createOneRecord({
|
||||||
|
name: stage.title,
|
||||||
|
color: stage.colorCode,
|
||||||
|
position: stage.position,
|
||||||
|
id: stage.id,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[createOneRecord],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledContainer>
|
<StyledContainer>
|
||||||
<ViewBar
|
<ViewBar
|
||||||
viewBarId={viewBarId}
|
viewBarId={viewBarId}
|
||||||
optionsDropdownButton={
|
optionsDropdownButton={
|
||||||
<RecordBoardOptionsDropdown recordBoardId={recordBoardId} />
|
<RecordBoardOptionsDropdown
|
||||||
|
recordBoardId={recordBoardId}
|
||||||
|
onStageAdd={onStageAdd}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
optionsDropdownScopeId={BoardOptionsDropdownId}
|
optionsDropdownScopeId={BoardOptionsDropdownId}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -21,6 +21,7 @@ export const getObjectRecordIdentifier = ({
|
|||||||
name: record?.company?.name,
|
name: record?.company?.name,
|
||||||
avatarUrl: record.avatarUrl,
|
avatarUrl: record.avatarUrl,
|
||||||
avatarType: 'rounded',
|
avatarType: 'rounded',
|
||||||
|
linkToShowPage: `/opportunities/${record.id}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,13 +65,13 @@ export const getObjectRecordIdentifier = ({
|
|||||||
objectMetadataItem,
|
objectMetadataItem,
|
||||||
});
|
});
|
||||||
|
|
||||||
const linkToEntity = `${basePathToShowPage}${record.id}`;
|
const linkToShowPage = `${basePathToShowPage}${record.id}`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: record.id,
|
id: record.id,
|
||||||
name: labelIdentifierFieldValue,
|
name: labelIdentifierFieldValue,
|
||||||
avatarUrl,
|
avatarUrl,
|
||||||
avatarType,
|
avatarType,
|
||||||
linkToEntity,
|
linkToShowPage,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -22,7 +22,6 @@ import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
|||||||
import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
|
import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
|
||||||
import { MenuItemNavigate } from '@/ui/navigation/menu-item/components/MenuItemNavigate';
|
import { MenuItemNavigate } from '@/ui/navigation/menu-item/components/MenuItemNavigate';
|
||||||
import { MenuItemToggle } from '@/ui/navigation/menu-item/components/MenuItemToggle';
|
import { MenuItemToggle } from '@/ui/navigation/menu-item/components/MenuItemToggle';
|
||||||
import { ThemeColor } from '@/ui/theme/constants/colors';
|
|
||||||
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||||
import { ViewFieldsVisibilityDropdownSection } from '@/views/components/ViewFieldsVisibilityDropdownSection';
|
import { ViewFieldsVisibilityDropdownSection } from '@/views/components/ViewFieldsVisibilityDropdownSection';
|
||||||
import { useViewScopedStates } from '@/views/hooks/internal/useViewScopedStates';
|
import { useViewScopedStates } from '@/views/hooks/internal/useViewScopedStates';
|
||||||
@ -39,13 +38,6 @@ export type RecordBoardOptionsDropdownContentProps = {
|
|||||||
|
|
||||||
type BoardOptionsMenu = 'fields' | 'stage-creation' | 'stages';
|
type BoardOptionsMenu = 'fields' | 'stage-creation' | 'stages';
|
||||||
|
|
||||||
type ColumnForCreate = {
|
|
||||||
id: string;
|
|
||||||
colorCode: ThemeColor;
|
|
||||||
position: number;
|
|
||||||
title: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const RecordBoardOptionsDropdownContent = ({
|
export const RecordBoardOptionsDropdownContent = ({
|
||||||
onStageAdd,
|
onStageAdd,
|
||||||
recordBoardId,
|
recordBoardId,
|
||||||
@ -85,7 +77,7 @@ export const RecordBoardOptionsDropdownContent = ({
|
|||||||
if (currentMenu !== 'stage-creation' || !stageInputRef?.current?.value)
|
if (currentMenu !== 'stage-creation' || !stageInputRef?.current?.value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const columnToCreate: ColumnForCreate = {
|
const columnToCreate: BoardColumnDefinition = {
|
||||||
id: v4(),
|
id: v4(),
|
||||||
colorCode: 'gray',
|
colorCode: 'gray',
|
||||||
position: boardColumns.length,
|
position: boardColumns.length,
|
||||||
@ -143,7 +135,6 @@ export const RecordBoardOptionsDropdownContent = ({
|
|||||||
const name = viewEditInputRef.current?.value;
|
const name = viewEditInputRef.current?.value;
|
||||||
resetMenu();
|
resetMenu();
|
||||||
setViewEditMode('none');
|
setViewEditMode('none');
|
||||||
closeDropdown();
|
|
||||||
handleStageSubmit();
|
handleStageSubmit();
|
||||||
handleViewNameSubmit(name);
|
handleViewNameSubmit(name);
|
||||||
closeDropdown();
|
closeDropdown();
|
||||||
|
|||||||
@ -5,6 +5,5 @@ export type ObjectRecordIdentifier = {
|
|||||||
name: string;
|
name: string;
|
||||||
avatarUrl?: string | null;
|
avatarUrl?: string | null;
|
||||||
avatarType?: AvatarType | null;
|
avatarType?: AvatarType | null;
|
||||||
linkToEntity?: string;
|
|
||||||
linkToShowPage?: string;
|
linkToShowPage?: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -98,30 +98,38 @@ export const IconPicker = ({
|
|||||||
|
|
||||||
const { getIcons, getIcon } = useIcons();
|
const { getIcons, getIcon } = useIcons();
|
||||||
const icons = getIcons();
|
const icons = getIcons();
|
||||||
|
const matchingSearchIconKeys = useMemo(() => {
|
||||||
const iconKeys = useMemo(() => {
|
|
||||||
const filteredIconKeys = icons
|
const filteredIconKeys = icons
|
||||||
? Object.keys(icons).filter((iconKey) => {
|
? Object.keys(icons).filter((iconKey) => {
|
||||||
return (
|
if (searchString === '') {
|
||||||
iconKey !== selectedIconKey &&
|
return true;
|
||||||
(!searchString ||
|
}
|
||||||
[iconKey, convertIconKeyToLabel(iconKey)].some((label) =>
|
|
||||||
label.toLowerCase().includes(searchString.toLowerCase()),
|
const isMatchingSearchString = [
|
||||||
))
|
iconKey,
|
||||||
|
convertIconKeyToLabel(iconKey),
|
||||||
|
].some((label) =>
|
||||||
|
label.toLowerCase().includes(searchString.toLowerCase()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return isMatchingSearchString;
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
return (
|
const uniqueFilteredIconKeys = [
|
||||||
selectedIconKey
|
...new Set(
|
||||||
? [selectedIconKey, ...filteredIconKeys]
|
selectedIconKey
|
||||||
: filteredIconKeys
|
? [selectedIconKey, ...filteredIconKeys]
|
||||||
).slice(0, 25);
|
: filteredIconKeys,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
return uniqueFilteredIconKeys.slice(0, 25);
|
||||||
}, [icons, searchString, selectedIconKey]);
|
}, [icons, searchString, selectedIconKey]);
|
||||||
|
|
||||||
const iconKeys2d = useMemo(
|
const iconKeys2d = useMemo(
|
||||||
() => arrayToChunks(iconKeys.slice(), 5),
|
() => arrayToChunks(matchingSearchIconKeys.slice(), 5),
|
||||||
[iconKeys],
|
[matchingSearchIconKeys],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -151,7 +159,9 @@ export const IconPicker = ({
|
|||||||
<DropdownMenuSearchInput
|
<DropdownMenuSearchInput
|
||||||
placeholder="Search icon"
|
placeholder="Search icon"
|
||||||
autoFocus
|
autoFocus
|
||||||
onChange={(event) => setSearchString(event.target.value)}
|
onChange={(event) => {
|
||||||
|
setSearchString(event.target.value);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<div
|
<div
|
||||||
@ -164,7 +174,7 @@ export const IconPicker = ({
|
|||||||
>
|
>
|
||||||
<DropdownMenuItemsContainer>
|
<DropdownMenuItemsContainer>
|
||||||
<StyledMenuIconItemsContainer>
|
<StyledMenuIconItemsContainer>
|
||||||
{iconKeys.map((iconKey) => (
|
{matchingSearchIconKeys.map((iconKey) => (
|
||||||
<IconPickerIcon
|
<IconPickerIcon
|
||||||
key={iconKey}
|
key={iconKey}
|
||||||
iconKey={iconKey}
|
iconKey={iconKey}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { useRecoilState } from 'recoil';
|
|||||||
|
|
||||||
import { useDropdownStates } from '@/ui/layout/dropdown/hooks/internal/useDropdownStates';
|
import { useDropdownStates } from '@/ui/layout/dropdown/hooks/internal/useDropdownStates';
|
||||||
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
|
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
|
||||||
|
import { getScopeIdFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdFromComponentId';
|
||||||
|
|
||||||
export const useDropdown = (dropdownId?: string) => {
|
export const useDropdown = (dropdownId?: string) => {
|
||||||
const {
|
const {
|
||||||
@ -10,7 +11,7 @@ export const useDropdown = (dropdownId?: string) => {
|
|||||||
dropdownWidthState,
|
dropdownWidthState,
|
||||||
isDropdownOpenState,
|
isDropdownOpenState,
|
||||||
} = useDropdownStates({
|
} = useDropdownStates({
|
||||||
dropdownScopeId: `${dropdownId}-scope`,
|
dropdownScopeId: getScopeIdFromComponentId(dropdownId),
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|||||||
Reference in New Issue
Block a user