Skip Menu |

This queue is for tickets about the HTML-PopupTreeSelect CPAN distribution.

Report information
The Basics
Id: 6025
Status: resolved
Priority: 0/
Queue: HTML-PopupTreeSelect

People
Owner: Nobody in particular
Requestors: cnandor [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)

Attachments
HTML-PopupTreeSelect-patch.tar.gz
PopupTreeSelect.pm.2.diff



Subject: Multiple roots?
I need multiple root categories. By allowing an array to be passed to _output_node and looping over it, that seems to accomplish what I need. Here's a patch. Thanks.
--- PopupTreeSelect.pm Thu Sep 11 14:11:36 2003 +++ /usr/local/lib/perl5/site_perl/5.8.2/HTML/PopupTreeSelect.pm Thu Apr 15 08:05:46 2004 @@ -325,9 +325,18 @@ # recursively add nodes to the output loop sub _output_node { my ($self, %arg) = @_; - my $node = $arg{node}; + my $node1 = $arg{node}; + my @nodes; + if (ref $node1 eq 'ARRAY') { + @nodes = @$node1; + } else { + @nodes = ($node1); + } + + for my $node (@nodes) { my $id = next_id(); + push @{$arg{loop}}, { label => $node->{label}, value => $node->{value}, id => $id, @@ -343,7 +352,7 @@ } push @{$arg{loop}}, { end_block => 1 }; } - + } } {
This looks reasonable to me. It needs two things before I'll commit it: docs and tests. Thanks, -sam
[SAMTREGAR - Thu Apr 15 13:20:51 2004]: Show quoted text
> This looks reasonable to me. It needs two things before I'll commit > it: > docs and tests.
OK. I'll work on those hopefully today and tomorrow (for this patch, and the other). Thanks, -- Chris Nandor pudge@pobox.com http://pudge.net/ Open Source Development Network pudge@osdn.com http://osdn.com/
[SAMTREGAR - Thu Apr 15 13:20:51 2004]: Show quoted text
> This looks reasonable to me. It needs two things before I'll commit > it: > docs and tests.
Here's a patch file, along with the complete modified files, and a README describing it all. I also threw in a few modified popup images, if you want them (though they are probably owned by Apple ...). This includes both the multiple roots patch as described for this report, and the subclassing patch for the other report, plus a small patch to make nodes able to access information about their parents. For the latter, there's a small example in test.pl; I use it for other things in my own code. I added docs and tests for it all, except no docs for the parent thing, because there is really no documentation of the inner workings of the template, and I didn't want to start any. :-) Thanks, and let me know if there's anything else you need. -- Chris Nandor pudge@pobox.com http://pudge.net/ Open Source Development Network pudge@osdn.com http://osdn.com/

Message body not shown because it is not plain text.

Two questions. Why did you do this: parent => [ grep $_, $arg{parent} ] Isn't that the same thing as: parent => [ $arg{parent} ] Or am I missing something? Second, I think this creates a circular reference since children pointing to parents usually does. Won't this cause the module to leak memory on each invocation? If so I could fix it with Scalar::Utils::weaken() or by dropping this var altogether, since I don't use it. Please advise. ;) -sam
You're right about it not creating a circular loop. That was just a knee-jerk reaction based on seeing a node pointing at a parent. I've put in your patch with one fix: the parent stuff is optional and defaults to off. Pass 'parent_var => 1' to new() to turn it on. I hope that will be acceptable. Thanks, -sam