Manage replies on the client side
The 'reply' link associated with a comment now carries some information about the comment which is used to generate the reply form. No need to make a callback to the server.
I did not delete the old reply controller code but I think it should go away.
This is a WIP, extracted from a project so there may be some rough edges, like I wrote the HAML templates without testing them (scandal!) and we may want to improve the reply template styling (it is currently done in my client app).
Tell me what you think!
Hey!
So, I like the idea that the reply can be handled in the client side, but I don't like the js dependency this adds. It's intentionally made in a "dumb" way using the server so that we don't have to add a javascript on the gem for that simple functionality.
Because of that I'm not sure wether this is the best option. Opinio's idea was never to be a drop in solution, but a comments engine to be built upon.
For example, we can add this small javascript that handles the reply logic, but anyone that actually uses the gem will generate the views and customize them to their needs eventually making that small javascript unnecessary. I always thought the default views/behavior to be just throw aways that work, guide people on customizing them and then get replaced/updated with the actual views.
Right now all the javascript things are using the default rails behavior, and I think unless we make a really good drop in solution, we don't need to add an extra step of adding this javascript to the user's manifest since It'll very likely be replaced.
As for the PR itself, the ERB code is rendering the data attributes incorrectly as a hash, and with the new reply template, we end up with duplicate ids on the DOM, breaking the current cucumber feature.
Please, share your thoughts on this... Thanks!
I will have to recheck the erb code, it was a quick cut&paste from my own generated template.
We can get rid of the JS require by inlining the JS in the comment helper.
Personally I really hated the way the reply worked (single box at the end of the comments list), which is why I did it in thread and I am pretty sure most people see it that way.
I think we would increase Opinio adoption rate a lot if it was a bit more opinionated regarding its view and used bootstrap media classes.
It is your gem and you pick the vision you have for it but I think having an official bootstrap approved/drop in way to manage comments in a rails app would be great.
Yeah, I thought about making it a full comments drop in solution, with templates for foundation, bootstrap, etc.
I guess I'm always a little against it because normally you end up with crap code that you have to remove and make your own anyways.
I'll give it a thought and maybe I can do a big change in the direction of this gem.
Thanks a lot for the insights :)