-
Notifications
You must be signed in to change notification settings - Fork 308
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
Avoid creating multiple forms #2883
Conversation
d7142eb
to
cdc316b
Compare
@@ -48,6 +53,10 @@ export default class TrialMatchTable extends React.Component<ITrialMatchProps> { | |||
} | |||
|
|||
@observable showTrialFeedback = false; | |||
@observable selectedTrial: ISelectedTrial = { |
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.
by default this should be undefined
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.
Updated
@@ -196,6 +196,12 @@ export default class TrialMatchTable extends React.Component<ITrialMatchProps> { | |||
); | |||
} | |||
|
|||
public openFeedbackForm(nctId: string, protocolNo: string) { | |||
this.showTrialFeedback = true; |
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.
instead of having a flag, you can just can just have selectedTrialFeedbackFormData which is either undefined (hide) or shown (populated). In general, it's best not to update multiple properties like 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.
Removed the flag
@@ -196,6 +196,12 @@ export default class TrialMatchTable extends React.Component<ITrialMatchProps> { | |||
); | |||
} | |||
|
|||
public openFeedbackForm(nctId: string, protocolNo: string) { |
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.
this modifies mobx state and so should have @action decorator
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.
Added @action
efa26f3
to
7c5a0af
Compare
7c5a0af
to
d0cd18b
Compare
@@ -335,6 +339,17 @@ export default class TrialMatchTable extends React.Component<ITrialMatchProps> { | |||
title="OncoKB Matched Trials General Feedback" | |||
userEmailAddress={AppConfig.serverConfig.user_email_address} | |||
/> | |||
{ this.selectedTrialFeedbackFormData && | |||
<TrialMatchFeedback | |||
show={!!this.selectedTrialFeedbackFormData} |
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.
don't need show prop and internal logic anymore.
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.
{ this.selectedTrialFeedbackFormData && | ||
<TrialMatchFeedback | ||
show={!!this.selectedTrialFeedbackFormData} | ||
onHide={() => !!(this.selectedTrialFeedbackFormData=undefined)} |
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.
onHide also modifies state so should be action. What I would do is change openFeedbackForm to openCloseFeedbackForm and have it accept undefined if it's close
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.
Updated
c05d1e1
to
aa786e3
Compare
aa786e3
to
cea7ec0
Compare
Avoid creating multiple popup modals