-
Notifications
You must be signed in to change notification settings - Fork 4
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
Fix various things in the crash recommendations form #1542
Conversation
recommendations_partners: { data: { partner_id: $partner_id } } | ||
} | ||
) { | ||
insert_recommendations(objects: [$recommendationRecord]) { |
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.
previously we had a bug where if you created a recommendation by just filling out the status, a recommendation record would be created along with a partner record that just had null as the partner id, so then you would end up with something that looks like this
we dont want to create a partner record until the user actually adds a partner. so im changing this mutation to use an object variable that may or may not contain partner data so we arent creating empty partners
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.
Makes sense - thanks for tightening this up for less cruft in the DB.
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 for fixing this. Would you rename the Add
button to Save
? And can you disable the button until the input has been modified?
One other tiny detail—would you mind removing the colon (:
) from the Coordination Parter and Status labels?
onAdd={onAdd} | ||
onEdit={onEdit} | ||
/> | ||
{doesRecommendationRecordExist && ( |
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.
dont show the update section until a recommendation has been created
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.
would you hide this field until rec_text
is not null? otherwise this appears after you save a coordination parter or status.
@@ -15,23 +15,9 @@ export const GET_RECOMMENDATION_LOOKUPS = gql` | |||
|
|||
export const INSERT_RECOMMENDATION = gql` | |||
mutation InsertRecommendation( | |||
$text: 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.
mutation was failing silently if you try to create a recommendation by first adding recommendation text because this mutation was expecting the variable text
but we were feeding it rec_text
const valuesObject = { | ||
recommendations_partners: { | ||
// Mutation expects lookup IDs as integers | ||
data: { [field]: parseInt(selectedItem.id) }, |
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.
alternatively i could have this valuesObject
conditionally formatted based on whether doesRecommendationRecordExist
, so it only gets this nested insert format if the rec record doesnt exist yet, and we wouldnt have to specify valuesObject.recommendations_partners.data
in the onAddPartner
function
@@ -74,7 +75,7 @@ const Recommendations = ({ crashPk, recommendation, refetch }) => { | |||
const onAddPartner = valuesObject => { | |||
const recommendationPartnerRecord = { | |||
recommendationRecordId, | |||
...valuesObject, | |||
...valuesObject.recommendations_partners.data, |
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.
dont want that nested insert format if the recommendation record already exists and we are only inserting a partner record. like i mentioned in the comment above, i could handle this logic in that component instead and format the valuesObject there based on whether the recommendation record exists yet
@johnclary the issue says to have visual feedback when the form is saving (does this mean a spinner?) so i guess you mean whenever the user clicks the add button or edits and saves, but none of our other components like notes or related records tables have any kind of feedback when you edit fields? could you expand maybe on what you would want to see? personally i think its fine as is |
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 is absolutely an improvement. Thank you @roseeichelmann!
I have been thinking about the possibilities you raised about using logic in the component to control the use of the nested record creation in the graphql. I am not sure, so don't give this too much weight, but I think I like it the way you have it. Simpler code, less deeply buried logic, and the application seems to be working as I would expect it. I like it!
recommendations_partners: { data: { partner_id: $partner_id } } | ||
} | ||
) { | ||
insert_recommendations(objects: [$recommendationRecord]) { |
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.
Makes sense - thanks for tightening this up for less cruft in the DB.
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 I am following the alternative way of doing this, but the way you have it here makes sense to me. Thank you for fixing the silent failure, I tried adding things in different order and it all checks out
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 @roseeichelmann!
I think that back when i created this issue i did not realize that editing the coordination partners or status input triggers an insert/update immediately—which was adding to my confusion about potential bugginess.
I requested feedback in order to tighten up the save behavior of the text and text updates.
I agree we can leaving the loading feedback out of scope. If we were going to do a bigger refactor of this form, it would be great to rework this so that it behaves like one big form—you edit any field then click "Save" to save changes. I'd also like to make the parters and status inputs look like normal bootstrap inputs (with outlines, focus effects, etc), but the i can see multiselect library doesn't make that easy. It'd be nice to replace it with react-select for a superior UX. I'll drop that in a backlog issue.
onAdd={onAdd} | ||
onEdit={onEdit} | ||
/> | ||
{doesRecommendationRecordExist && ( |
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.
would you hide this field until rec_text
is not null? otherwise this appears after you save a coordination parter or status.
recommendations_partners: { data: { partner_id: $partner_id } } | ||
} | ||
) { | ||
insert_recommendations(objects: [$recommendationRecord]) { |
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 for fixing this. Would you rename the Add
button to Save
? And can you disable the button until the input has been modified?
One other tiny detail—would you mind removing the colon (:
) from the Coordination Parter and Status labels?
@@ -42,7 +44,7 @@ const RecommendationTextInput = ({ | |||
}; | |||
|
|||
// Recommendation record does not exist yet, adding a value will create record | |||
const isAddingRecommendation = | |||
const isCreatingRecord = |
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.
make it more apparent that we are talking about this is going to create a recommendation record, not talking about just adding recommendation text
partner_id: { | ||
label: "Coordination Partner:", | ||
lookupOptions: "atd__coordination_partners_lkp", | ||
key: "coord_partner_desc", |
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 was a duplication pretty much of the first object and its not actually doing anything?
|
||
const isEmptyString = !inputValue.trim(); | ||
// Save null to database if user entered empty string or only spaces/newlines | ||
const valuesObject = { [field]: isEmptyString ? null : inputValue }; |
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.
previously we were allowing empty strings to be saved to the database.
@johnclary this is ready for re-review! i agree about making this one big form in the future. i disabled the save button until there is input and also made it so that users cant save empty strings to the database, including just spaces or newlines. question though, what if someone has rec text and update text, then they delete whats in the rec text. do we want the update section to still disappear even though it has content or should it show? currently i have it so that the update section will always show up if there is update text |
…on text, fix border showing up underneath recommendation when there is no update section
I was re-testing this PR after the changes, and your comment made me want to try "deleting" the rec text, by updating it to be an empty string. It feels weird having the text flash again before the area turning into an input again. But I dont know how often the recommendation text would be deleted vs being updated. So maybe its not worth trying to fix the UX right now |
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 @roseeichelmann !!
Associated issues
Closes cityofaustin/atd-data-tech#18468
Testing
URL to test:
Netlify
Steps to test:
Ship list