-
Notifications
You must be signed in to change notification settings - Fork 59
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
(feat) O3-3165: Add modal confirmation modal when deleting repeated question #267
Conversation
Size Change: -446 kB (-30.07%) 🎉 Total Size: 1.04 MB
ℹ️ View Unchanged
|
f1727b1
to
a02f1bb
Compare
The "delete" button of the modal should be coloured red. |
@samuelmale should we also show a snackbar/toast message after the user has pressed the confirm button on the modal? |
4a447cc
to
0e15898
Compare
0e15898
to
94fc5d1
Compare
src/form-engine.component.tsx
Outdated
@@ -69,6 +76,10 @@ export interface FormSubmissionHandler { | |||
validate: (values) => boolean; | |||
} | |||
|
|||
const functionStore = createGlobalStore<HandleConfirmDeletionFunctionStore | null>('functionStore', { |
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.
I think rather than using a global store for this, it makes more sense to use a React context. Context's are local to a React tree, so we have fewer issues around naming conflicts, etc. Global stores are for things we need to be shared across different React trees, but here I don't see a reason for it.
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.
Thanks, Ian. I've updated to using context instead, as suggested.
Could you please review the context part? I hope I've implemented it right.
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.
LGTM. I might rename the context ExternalFunctionContext
or something so it's reusable for other similar functions (since I imagine we'll need something like this for other uses). Nice job!
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.
Gotcha. I changed the context name and pulled it out of the components/repeat
nested folder into the root of src, because it looked wrong to have it nested there when made generic.
20c259d
to
7cc4ac3
Compare
@samuelmale Any objections to merging this? |
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.
LGTM! Nice work @NethmiRodrigo
* (feat): add modal for confirmation when deleting question * update test cases * rename components to convention * remove style sheet and update carbon version * (fix): rename selectedQuestion state * (fix): change primary button color of modal * (refactor) Move modal to patient chart and have fallback for no modal * (refactor): add confirmation modal handler as prop * (fix): add error handler * (fix): Replace global store with react context * (refactor): Changed context name to be more generic * Slightly cleaner @carbon/react version pinning --------- Co-authored-by: Ian <ian.c.bacher@gmail.com>
Requirements
Summary
This PR implements the functionality of triggering a confirmation modal whenever a user tries to delete a obsGroup repeated rendering question.
The
form-engine-component
has been updated to accept a new prop for the on click handler when deleting a question. Based on the prop, the component either calls the function passed in as the prop (which renders the modal) or proceeds with the deletion of the question (without showing a modal).Screenshots
Related Issue
Jira Ticket
Related PR
Other
While this PR covers the intended functionality, it does bring forth some issues,