-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added "Add record" button in kanban view column headers dropdown (#6649)
Closes #4629 Refactored `RecordBoardColumnNewOpportunityButton` and `RecordBoardColumnNewButton` to use the same logic in dropdown. I kept those hooks inside `record-board-column` where these buttons are. Let me know if it should be placed somewhere else. Also Added navigation state preservation when clicked on `edit from settings` Thanks :) --------- Co-authored-by: Lucas Bordeau <[email protected]>
- Loading branch information
1 parent
ff1adb0
commit e2eaffc
Showing
9 changed files
with
212 additions
and
103 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...ject-record/record-board/record-board-column/components/RecordBoardColumnDropdownMenu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...y-front/src/modules/object-record/record-board/record-board-column/hooks/useAddNewCard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { RecordBoardContext } from '@/object-record/record-board/contexts/RecordBoardContext'; | ||
import { RecordBoardColumnContext } from '@/object-record/record-board/record-board-column/contexts/RecordBoardColumnContext'; | ||
import { useContext } from 'react'; | ||
|
||
export const useAddNewCard = (position: string) => { | ||
const { columnDefinition } = useContext(RecordBoardColumnContext); | ||
const { createOneRecord, selectFieldMetadataItem } = | ||
useContext(RecordBoardContext); | ||
|
||
const handleAddNewCardClick = () => { | ||
createOneRecord({ | ||
[selectFieldMetadataItem.name]: columnDefinition.value, | ||
position: position, | ||
}); | ||
}; | ||
|
||
return { | ||
handleAddNewCardClick, | ||
}; | ||
}; |
68 changes: 68 additions & 0 deletions
68
.../src/modules/object-record/record-board/record-board-column/hooks/useAddNewOpportunity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { RecordBoardContext } from '@/object-record/record-board/contexts/RecordBoardContext'; | ||
import { RecordBoardColumnContext } from '@/object-record/record-board/record-board-column/contexts/RecordBoardColumnContext'; | ||
import { useEntitySelectSearch } from '@/object-record/relation-picker/hooks/useEntitySelectSearch'; | ||
import { EntityForSelect } from '@/object-record/relation-picker/types/EntityForSelect'; | ||
import { RelationPickerHotkeyScope } from '@/object-record/relation-picker/types/RelationPickerHotkeyScope'; | ||
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope'; | ||
import { useCallback, useContext, useState } from 'react'; | ||
|
||
export const useAddNewOpportunity = (position: string) => { | ||
const [isCreatingCard, setIsCreatingCard] = useState(false); | ||
|
||
const { columnDefinition } = useContext(RecordBoardColumnContext); | ||
const { createOneRecord, selectFieldMetadataItem } = | ||
useContext(RecordBoardContext); | ||
|
||
const { | ||
goBackToPreviousHotkeyScope, | ||
setHotkeyScopeAndMemorizePreviousScope, | ||
} = usePreviousHotkeyScope(); | ||
const { resetSearchFilter } = useEntitySelectSearch({ | ||
relationPickerScopeId: 'relation-picker', | ||
}); | ||
|
||
const handleEntitySelect = useCallback( | ||
(company?: EntityForSelect) => { | ||
setIsCreatingCard(false); | ||
goBackToPreviousHotkeyScope(); | ||
resetSearchFilter(); | ||
|
||
if (company !== undefined) { | ||
createOneRecord({ | ||
name: company.name, | ||
companyId: company.id, | ||
position: position, | ||
[selectFieldMetadataItem.name]: columnDefinition.value, | ||
}); | ||
} | ||
}, | ||
[ | ||
columnDefinition, | ||
createOneRecord, | ||
goBackToPreviousHotkeyScope, | ||
resetSearchFilter, | ||
selectFieldMetadataItem, | ||
position, | ||
], | ||
); | ||
|
||
const handleAddNewOpportunityClick = useCallback(() => { | ||
setIsCreatingCard(true); | ||
setHotkeyScopeAndMemorizePreviousScope( | ||
RelationPickerHotkeyScope.RelationPicker, | ||
); | ||
}, [setHotkeyScopeAndMemorizePreviousScope]); | ||
|
||
const handleCancel = useCallback(() => { | ||
resetSearchFilter(); | ||
goBackToPreviousHotkeyScope(); | ||
setIsCreatingCard(false); | ||
}, [goBackToPreviousHotkeyScope, resetSearchFilter]); | ||
|
||
return { | ||
isCreatingCard, | ||
handleEntitySelect, | ||
handleAddNewOpportunityClick, | ||
handleCancel, | ||
}; | ||
}; |
Oops, something went wrong.