maiyaporn / angular2-wizard

Angular2 - Form Wizard Component
118 stars 119 forks source link

How to handle error case on Done? #6

Open jaymojnidar opened 7 years ago

jaymojnidar commented 7 years ago

Great work!

I am running an issue with user clicking on the Done button. In my case, when the user clicks on Done, I run a http post in my onComplete function. If there is an error, I set isCompleted to false in my code. So, that I can continue to display the form for user to correct. But, the Prev, Next, and Done buttons are not displayed.

Thank you for your help!

maiyaporn commented 7 years ago

Nice catch. I overlook this scenario. The current behavior right now will hide all navigation buttons after user click done. The isCompleted property cannot be set from outside the component.

I will make changes to allow managing the isCompleted property. It will not hide all the buttons by default.

sree-mohan commented 7 years ago

Eagerly waiting for this update. Great work !

maiyaporn commented 7 years ago

There are a few issues that I need to figure out to implement this. I was a bit busy these last two weeks, so I haven't started anything. I will try to do this asap. If anyone has any suggestion how to get this done, feel free to let me know. PR is also welcome.

micahcourey commented 7 years ago

I submitted a pull request for this issue. I added a method to handle server errors after the user submits. To invoke it you just need to add "forceStep = 1" to the error handler portion of your post method or replace 1 with whichever step you want to revert the user too. the method also sets isCompleted back to false so that the buttons return. I have this implemented on my app and I display the server error on the corresponding input field and then revert the user to that step. Hope this works for you guys, let me know if you have any suggestions for improvement or questions about the implementation.