-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Study Contribution #26
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
10 commits
Select commit
Hold shift + click to select a range
a6850de
Rendering of study form in tag view
cbolles 08e9268
Cleanup CSS settings
cbolles c77fd4e
Fix spacing on buttons
cbolles e9a383a
Breaking up tag form page
cbolles 1ae42d9
Fix setting of width in entry view
cbolles e614fea
Ability to collect tags
cbolles 18a3ecb
Add in notification when tagging is complete
cbolles 724c1f8
Fix formatting
cbolles b983624
Remove un-used import
cbolles 76c6b57
Consolidate tag files
cbolles 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 was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
packages/client/src/components/contribute/NoTagNotification.component.tsx
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,14 @@ | ||
| import { Stack, Typography } from '@mui/material'; | ||
|
|
||
| export interface NoTagNotificationProps { | ||
| studyName: string; | ||
| } | ||
|
|
||
| export const NoTagNotification: React.FC<NoTagNotificationProps> = ({ studyName }) => { | ||
| return ( | ||
| <Stack direction="column" sx={{ margin: 'auto', maxWidth: 750, alignItems: 'center' }} spacing={2}> | ||
| <Typography variant="h2">No tags Remaining</Typography> | ||
| <Typography variant="body1">No tags left for "{studyName}", please check back later</Typography> | ||
| </Stack> | ||
| ); | ||
| }; |
64 changes: 64 additions & 0 deletions
64
packages/client/src/components/contribute/TagForm.component.tsx
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,64 @@ | ||
| import { JsonForms } from '@jsonforms/react'; | ||
| import { Study } from '../../graphql/graphql'; | ||
| import { materialRenderers } from '@jsonforms/material-renderers'; | ||
| import { SetStateAction, useState, Dispatch } from 'react'; | ||
| import { Box, Stack, Button } from '@mui/material'; | ||
| import { ErrorObject } from 'ajv'; | ||
|
|
||
| export interface TagFormProps { | ||
| study: Study; | ||
| setTagData: Dispatch<SetStateAction<any>>; | ||
| } | ||
|
|
||
| export const TagForm: React.FC<TagFormProps> = (props) => { | ||
| const [data, setData] = useState<any>({}); | ||
| const [dataValid, setDataValid] = useState<boolean>(false); | ||
|
|
||
| const handleFormChange = (data: any, errors: ErrorObject[] | undefined) => { | ||
| setData(data); | ||
|
|
||
| // No errors, data could be submitted | ||
| if (!errors || errors.length === 0) { | ||
| setDataValid(true); | ||
| } else { | ||
| setDataValid(false); | ||
| } | ||
| }; | ||
|
|
||
| const handleSubmit = () => { | ||
| // Ideally should not get here | ||
| if (!dataValid) { | ||
| return; | ||
| } | ||
| props.setTagData(data); | ||
|
|
||
| // Get ready for the next tag | ||
| handleClear(); | ||
| }; | ||
|
|
||
| const handleClear = () => { | ||
| setData({}); | ||
| }; | ||
|
|
||
| return ( | ||
| <Box sx={{ maxWidth: 500 }}> | ||
| <Stack direction="column" spacing={2}> | ||
| <JsonForms | ||
| schema={props.study.tagSchema.dataSchema} | ||
| uischema={props.study.tagSchema.uiSchema} | ||
| data={data} | ||
| onChange={({ data, errors }) => handleFormChange(data, errors)} | ||
| renderers={materialRenderers} | ||
| /> | ||
| <Stack direction="row"> | ||
| <Button variant="outlined" onClick={handleSubmit} disabled={!dataValid}> | ||
| Submit | ||
| </Button> | ||
| <Button variant="outlined" onClick={handleClear}> | ||
| Clear | ||
| </Button> | ||
| </Stack> | ||
| </Stack> | ||
| </Box> | ||
| ); | ||
| }; |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
| mutation createTags($study: ID!, $entries: [ID!]!) { | ||
| createTags(study: $study, entries: $entries) { | ||
| _id | ||
| } | ||
| } | ||
|
|
||
| mutation assignTag($study: ID!) { | ||
| assignTag(study: $study) { | ||
| _id, | ||
| entry { | ||
| _id, | ||
| organization, | ||
| entryID, | ||
| contentType, | ||
| dataset, | ||
| creator, | ||
| dateCreated, | ||
| meta, | ||
| signedUrl, | ||
| signedUrlExpiration | ||
| } | ||
| } | ||
| } | ||
|
|
||
| mutation completeTag($tag: ID!, $data: JSON!) { | ||
| completeTag(tag: $tag, data: $data) | ||
| } |
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.