-
Notifications
You must be signed in to change notification settings - Fork 41
Add an Add and Delete tree ranks option #4257
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
Merged
Merged
Changes from all commits
Commits
Show all changes
110 commits
Select commit
Hold shift + click to select a range
6df778e
init api for adding and deleting tree ranks
acwhite211 d17e266
init unit test for adding/deleting ranks
acwhite211 fc664ad
unit test fixing and api parameter addition
acwhite211 5125989
fix more unit tests
acwhite211 d40fb84
fix delete rank unit test
acwhite211 c08cbb8
fix call to set_fullnames
acwhite211 62e902e
add edit_ranks permission
acwhite211 e4b9dbb
fix openapi schema
acwhite211 024efa0
reconfigure HttpResponseBadRequest responses
acwhite211 d031ff5
change wrapper for rank edit functions
acwhite211 2dc4ba8
add fullname tests
acwhite211 0c6b825
Merge remote-tracking branch 'origin/production' into add_delete_tree…
CarolineDenis 1ff3385
get tree by name or id
acwhite211 19bc954
Add a button to add new ranks in trees
CarolineDenis 77223ec
add test of parents of child nodes
acwhite211 2625e45
Remove code
CarolineDenis 0424b56
Merge branch 'add_delete_tree_rank_api' of https://github.com/specify…
acwhite211 67c61f6
add treeName to api schema
acwhite211 051af5c
retract required fields
acwhite211 b171bc8
Change variable name
CarolineDenis 2b73d71
Lint code with ESLint and Prettier
CarolineDenis b70bbe0
add extra params to add_tree_rank api
acwhite211 24cb1db
Merge branch 'add_delete_tree_rank_api' of https://github.com/specify…
acwhite211 79fe45f
add business rules for adding/deleting trees
acwhite211 46cd29c
Refactor add rank feature
CarolineDenis a6c98e3
Revert unecessary cahnges
CarolineDenis 7ec54c6
Use tree id
CarolineDenis 1d6a189
Remove tree name
CarolineDenis f82eaaa
add tree def dependent fields to help deletion blocker
acwhite211 b2940ad
Merge branch 'add_delete_tree_rank_api' of https://github.com/specify…
acwhite211 f5173a6
treedefitems typo fix
acwhite211 77e53ae
Code improvement, deletion of previous logic for treeDefItems
CarolineDenis a045b1d
Lint code with ESLint and Prettier
CarolineDenis 947d9d2
Remove addRank function
CarolineDenis 62fbee2
fix tree dependent fields
acwhite211 0258dab
filter_rank_deletion_exception
acwhite211 29cbb77
fix delete_blockers filter
acwhite211 6693ab9
tree ranks bussiness rules init
acwhite211 e696d4e
raise exception for parent id not given
acwhite211 bd35e0f
test assign parent to treeResource
CarolineDenis cf67f55
Lint code with ESLint and Prettier
CarolineDenis 907da38
Set parent on continue
CarolineDenis 97139a2
Lint code with ESLint and Prettier
CarolineDenis 5fcf3b4
param and exception fixes
acwhite211 173eeae
Assign parent to new rank with parent id
CarolineDenis f8c45a4
Remove import
CarolineDenis 6d2c8a1
Lint code with ESLint and Prettier
CarolineDenis 60977fa
Erase console log
CarolineDenis 542b3fd
fix rankid error
acwhite211 1191f92
working tree rank tests using resource api
acwhite211 8eb677f
Simplify code and check for permissions
CarolineDenis ef98956
Lint code with ESLint and Prettier
CarolineDenis 6a658f7
code cleanup, remove old view funciton
acwhite211 9538ec5
remove old urls
acwhite211 d64c7d0
revert change to the simple api unit test
acwhite211 d5b5f6c
fix delete with avant_delete()
acwhite211 d189e7f
cleanup old tree_views code
acwhite211 1ed635c
use is_instance_of_tree_def_item in tree_rules
acwhite211 691e798
fix treedef error
acwhite211 d549285
add_tree_rank description update
acwhite211 21a2361
naming change
CarolineDenis 817b5bf
Lint code with ESLint and Prettier
CarolineDenis 7ba0ac2
add orm_signal_handler_with_kwargs
acwhite211 4dbf9b6
Reload after rank deletion
CarolineDenis 45eb9a8
Add root rank as default to add new rank
CarolineDenis a25fbd3
set_rank_id code cleanup
acwhite211 82d801f
fix workbench unit test exception
acwhite211 c41707c
simplify set_rank_id function params
acwhite211 c0559c0
pass treeDef to rank resource api call
acwhite211 05a8592
require treedef before adding rank
acwhite211 171562f
Add form to add rank componenent
CarolineDenis 3a548c3
Remove prop
CarolineDenis a822430
abstract orm_signal_handler
acwhite211 ac04d0a
unify orm_signal_handler
acwhite211 3d0cac8
Merge branch 'add_delete_tree_rank_api' of https://github.com/specify…
acwhite211 816337a
tree_extras models import change
acwhite211 13a0d48
pre_constraints_delete
acwhite211 5906c01
verify_rank_parent_chain_integretity
acwhite211 d529551
typo fix
acwhite211 0a47ccf
Merge remote-tracking branch 'origin/production' into add_delete_tree…
CarolineDenis 175144c
check rank item count
acwhite211 3d3a7f6
add to url.py file
acwhite211 1d76fa9
Display Delete Blocker when delete used rank
CarolineDenis 83a9dd8
Define ranks in lower case
CarolineDenis e5e850b
Simplify parent child rank
CarolineDenis 15a49ac
Remove unecessary code
CarolineDenis 36585f4
Fix exclude id
CarolineDenis db81246
Remove check fro str
CarolineDenis e482c7c
Remove unecessary treedef
CarolineDenis c1c56b8
Remove unecessary code
CarolineDenis 6b751a3
Remove unecessary default since expection raised above
CarolineDenis de41d27
Raise warning when treedef none
CarolineDenis 962be5d
Chnge string
CarolineDenis 381d30e
Fix if statement
CarolineDenis cd8ea33
Remove unecessary check
CarolineDenis 59b88ea
Remove checks
CarolineDenis f8f9734
Remove unecessary warning raise
CarolineDenis 4a3b8b8
Raise expection when rank ids none
CarolineDenis e4f8f2d
Remove warning
CarolineDenis c0d86e8
remove unused code
acwhite211 05c5e73
simplify tree rank code
acwhite211 005b271
remove leftover code
acwhite211 605e2b6
Merge branch 'production' into add_delete_tree_rank_api
acwhite211 9880e02
Lint code with ESLint and Prettier
acwhite211 20e66ac
create abstract TreeRank model for save and delete logic override
acwhite211 fb53e79
Merge branch 'production' into add_delete_tree_rank_api
acwhite211 87182f0
Merge remote-tracking branch 'origin/production' into add_delete_tree…
CarolineDenis cb7b862
Lint code with ESLint and Prettier
CarolineDenis 86d1729
Merge branch 'production' into add_delete_tree_rank_api
acwhite211 3a92011
Merge branch 'production' into add_delete_tree_rank_api
acwhite211 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
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
106 changes: 106 additions & 0 deletions
106
specifyweb/frontend/js_src/lib/components/TreeView/AddRank.tsx
CarolineDenis marked this conversation as resolved.
Show resolved
Hide resolved
CarolineDenis marked this conversation as resolved.
Show resolved
Hide resolved
CarolineDenis marked this conversation as resolved.
Show resolved
Hide resolved
acwhite211 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,106 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { commonText } from '../../localization/common'; | ||
| import { interactionsText } from '../../localization/interactions'; | ||
| import { treeText } from '../../localization/tree'; | ||
| import type { RA } from '../../utils/types'; | ||
| import { Button } from '../Atoms/Button'; | ||
| import { Form, Label, Select } from '../Atoms/Form'; | ||
| import type { | ||
| FilterTablesByEndsWith, | ||
| SerializedResource, | ||
| } from '../DataModel/helperTypes'; | ||
| import { tables } from '../DataModel/tables'; | ||
| import { ResourceView } from '../Forms/ResourceView'; | ||
| import { Dialog } from '../Molecules/Dialog'; | ||
| import { Submit } from '../Atoms/Submit'; | ||
| import { useId } from '../../hooks/useId'; | ||
|
|
||
| export function AddRank({ | ||
| treeDefinitionItems, | ||
| }: { | ||
| readonly treeDefinitionItems: RA< | ||
| SerializedResource<FilterTablesByEndsWith<'TreeDefItem'>> | ||
| >; | ||
| }): JSX.Element { | ||
| const [state, setState] = React.useState<'add' | 'initial' | 'parent'>( | ||
| 'initial' | ||
| ); | ||
|
|
||
| const [parentRank, setParentRank] = React.useState( | ||
| treeDefinitionItems[0].resource_uri | ||
| ); | ||
|
|
||
| const treeDef = treeDefinitionItems[0].treeDef; | ||
|
|
||
| const treeResource = React.useMemo(() => { | ||
| const resource = new tables[treeDefinitionItems[0]._tableName].Resource(); | ||
| resource.set('treeDef', treeDef); | ||
| return resource; | ||
| }, [treeDef]); | ||
| const id = useId('add-rank'); | ||
|
|
||
| return ( | ||
| <> | ||
| <Button.Icon | ||
| icon="plus" | ||
| title={treeText.addNewRank()} | ||
| onClick={() => setState('parent')} | ||
| /> | ||
| {state === 'parent' && ( | ||
| <Dialog | ||
| buttons={ | ||
| <> | ||
| <Button.DialogClose>{commonText.cancel()}</Button.DialogClose> | ||
| <Submit.Save | ||
| onClick={() => { | ||
| treeResource.set('parent', parentRank); | ||
| setState('add'); | ||
| }} | ||
| form={id('form')} | ||
| > | ||
| {interactionsText.continue()} | ||
| </Submit.Save> | ||
| </> | ||
| } | ||
| header={treeText.chooseParentRank()} | ||
| onClose={() => setState('initial')} | ||
| > | ||
| <Form id={id('form')}> | ||
| <Label.Block className="gap-2"> | ||
| {treeText.chooseParentRank()} | ||
CarolineDenis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <Select | ||
| className="w-full min-w-[theme(spacing.40)]" | ||
| value={parentRank} | ||
| onChange={({ target }): void => { | ||
| setParentRank(target.value); | ||
| }} | ||
| > | ||
| {treeDefinitionItems.map((rank, index) => ( | ||
| <option key={index} value={rank.resource_uri}> | ||
| {rank.name} | ||
| </option> | ||
| ))} | ||
| </Select> | ||
| </Label.Block> | ||
| </Form> | ||
| </Dialog> | ||
| )} | ||
| {state === 'add' && ( | ||
| <ResourceView | ||
| dialog="modal" | ||
| isDependent={false} | ||
| isSubForm={false} | ||
| resource={treeResource} | ||
| title={treeText.addNewRank()} | ||
| onAdd={undefined} | ||
| onClose={(): void => setState('initial')} | ||
| onDeleted={undefined} | ||
| onSaved={() => { | ||
| globalThis.location.reload(); | ||
| }} | ||
| /> | ||
| )} | ||
| </> | ||
| ); | ||
| } | ||
CarolineDenis marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.