-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 "Add record" button in kanban view column headers dropdown #6649
Merged
lucasbordeau
merged 8 commits into
twentyhq:main
from
ehconitin:AddNewButtunInDropDownKanbaan
Aug 28, 2024
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7d5ecfa
added opportunity button in dropdown, also shared a hook for it
ehconitin 1679dac
more refatoring and code cleaning
ehconitin 841dbb4
preserve navigation state
ehconitin 483134c
Merge branch 'main' into AddNewButtunInDropDownKanbaan
lucasbordeau 7b3f61b
Merge branch 'twentyhq:main' into AddNewButtunInDropDownKanbaan
ehconitin 3cc12f2
changed add record position from dropdown to header
ehconitin e80a127
Merge branch 'main' into AddNewButtunInDropDownKanbaan
lucasbordeau ee54d98
Fix lint
lucasbordeau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider adding a debounce to prevent rapid consecutive clicks