Hi Nilesh,
El 27/04/14 10:56, Nilesh Trivedi escribió:
> Thanks a lot, Ignacious. I have put the relevant code in a Gist here:
> https://gist.github.com/anonymous/11340654
>
> In short, Issue has many comments and each comment has a *parent_id*
> which points to another comment so that we can have a threaded
> discussion. Thus a comment belongs to a pcomment (parent) and has_many
> ccomments (children). For top level comments, parent_id will be NULL.
>
> I'm using *hobo_tree_table* plugin which create a nice expandable tree
> structure. Screenshot is attached.
>
> Now what I need is a way for replying to a particular comment. One part
> of the problem is the required controller/action. I need a route such
> as: POST to /issue/1/comments/3/comments: which will automatically set
> both *issue_id* and *parent_id* for the new comment.
>
> The current DRYML for adding a comment to an issue uses:
> *new_for_current_user(@issue.comments)* which sets issue_id correctly.
> But I need to set parent_id as well depending upon which comment was
> replied to.
By default Hobo uses the "with" attribute to set the context and it
automatically generates the action URL, but when working with something
custom it's just easier to write your own.
You should be able to create a form with "<form
action="/issue/#{issue.id}/comments/#{this.id}/comments"></form> inside
the tree table.
>
> The other part of the problem is the UI for it. Each comment should have
> a "Reply" button which displays an in-line form for making this POST
> call. This will be similar to Reddit's UI. You can type replies to many
> comments at once which means this form is dynamically inserted in the
> DOM upon clicking on "Reply". Hence, finding this a bit difficult.
>
> If a modal dialog was allowed for the reply form, this would have been
> much simpler (only one reply at one time so I can add the form in the
> DOM and make it visible when the user clicks on "Reply". But the
> requirements call for in-line forms, not modal popups/dialogs.
You can have a lot of hidden forms:
<form id="form1" class="hide"...></form>
<a class="btn" href="#" onclick="$('#form1').show(); return
false;">Reply</a>
That should get you started. Then you can improve this, for example:
- Extract the JS into a external JS file so you don't use onclick.
- Tell the button to make an Ajax request, so you don't have lots of
generated forms hidden.
- Have one hidden form in the bottom of the page, and use Javascript to
show a couple of inputs, then copy their values and submit the form...
This might not be such a good idea after all :P.
Warm regards,
Ignacio
>
>
> Regards
> Nilesh
>
>
>
> On Sat, Apr 26, 2014 at 11:06 PM, Ignacio Huerta <[email protected]
> <mailto:[email protected]>> wrote:
>
> Hi Nilesh,
>
> I don't remember any example Reddit style, but it should not be very
> hard to build. If you have trouble, please share the code that's failing
> and we'll try to give you a hand.
>
> What might be useful for you is this gist:
> https://gist.github.com/haslinger/7776874. Stefan built a nested and
> orderable tree not long ago with the Nestable JS library:
> http://dbushell.github.io/Nestable/. Very cool!
>
> Warm regards,
> Ignacio
>
> El 22/04/14 23:29, [email protected] <mailto:[email protected]>
> escribió:
> > Hi,
> >
> > I am new to Hobo and figuring out DRYML in particular. Are there any
> > examples of Hobo apps that provided threaded discussions like Reddit?
> >
> > I was able to modify the comment cards to display the child
> comments but
> > facing difficulties with adding an in-line for posting replies to a
> > particular comment.
> >
> > FWIW: I am using *acts_as_tree* as per this recipe:
> > http://hobocentral.net/tutorials/52-hierarchies-using-acts-as-tree
> >
> > regards
> > nilesh
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Hobo Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to [email protected]
> <mailto:hobousers%[email protected]>
> > <mailto:[email protected]
> <mailto:hobousers%[email protected]>>.
> > To post to this group, send email to [email protected]
> <mailto:[email protected]>
> > <mailto:[email protected]
> <mailto:[email protected]>>.
> > Visit this group at http://groups.google.com/group/hobousers.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in
> the Google Groups "Hobo Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/hobousers/rXddmB5a6FM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected]
> <mailto:hobousers%[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/hobousers.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Hobo Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/hobousers.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/hobousers.
For more options, visit https://groups.google.com/d/optout.