fpdcc / ccfp-asset-dashboard

CCFP Asset Dashboard
0 stars 1 forks source link

Add success and error messages to the ajax responses #122

Closed smcalilly closed 2 years ago

smcalilly commented 2 years ago

Overview

Closes:

Notes

We might want to improve the success messages when the page reloads. The message shows up and the page reloads, which kinda seems like the action is done, but the page is still reloading and we don't want users to use the page during that. Maybe adding the success message near the "save asset" button, plus giving a loading indicator would be more helpful...thoughts?

Testing Instructions

smcalilly commented 2 years ago

What if you saved that message to the session and check for messages when the page loads, clearing them from the session after they're rendered?

@hancush do you know of any DataMade examples that do this? I'm having a hard time finding the best way to do this. This is the best I can find in SO. I'm not sure the best way to access the session in a generic view?

Perhaps for successful responses, we can do something similar to what you're doing in the CIP planner, instead of using a message-like thing in the template? Like how you're showing that the portfolio saved where the button is. And then for error messages, we can show the message in the Django template, since that seems natural and isn't dependent on a page reload.

hancush commented 2 years ago

That would work, @smcalilly! I like the pragmatism.

smcalilly commented 2 years ago

@hancush I made these changes:

smcalilly commented 2 years ago

@hancush I made the requested changes. I'm not sure how to render the message only after it reloads since adding that to state will show the component. Do you have any ideas, or is this ok as is?

Add and delete some assets to see it in action: https://ccfp-asset-d-ajax-messa-ukywag.herokuapp.com/projects/phases/edit/4/assets/