diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | lib/VNDB/DB/Tags.pm | 8 | ||||
-rw-r--r-- | lib/VNDB/Func.pm | 4 | ||||
-rw-r--r-- | lib/VNDB/Handler/Traits.pm | 2 |
4 files changed, 9 insertions, 6 deletions
@@ -1,5 +1,6 @@ 2.20 - ? - Order the VNs listed on char browser by release date + - Order the traits groups on /i by their 'order' column - Bugfix: don't accidentally remove char traits when editing - Bugfix: fixed possible SQL table name clash on history browser - Bugfix: properly announce chars and traits in Multi::IRC diff --git a/lib/VNDB/DB/Tags.pm b/lib/VNDB/DB/Tags.pm index eee73f10..37411a62 100644 --- a/lib/VNDB/DB/Tags.pm +++ b/lib/VNDB/DB/Tags.pm @@ -93,19 +93,21 @@ sub dbTagGet { sub dbTTTree { my($self, $type, $id, $lvl, $back) = @_; $lvl ||= 15; + my $xtra = $type eq 'trait' ? ', "order"' : ''; + my $xtra2 = $type eq 'trait' ? ', t."order"' : ''; my $r = $self->dbAll(qq| WITH RECURSIVE thetree(lvl, id, parent, name, c_items) AS ( - SELECT ?::integer, id, 0, name, c_items + SELECT ?::integer, id, 0, name, c_items$xtra FROM ${type}s !W UNION ALL - SELECT tt.lvl-1, t.id, tt.id, t.name, t.c_items + SELECT tt.lvl-1, t.id, tt.id, t.name, t.c_items$xtra2 FROM thetree tt JOIN ${type}s_parents tp ON !s JOIN ${type}s t ON !s WHERE tt.lvl > 0 AND t.state = 2 - ) SELECT DISTINCT id, parent, name, c_items FROM thetree ORDER BY name|, $lvl, + ) SELECT DISTINCT id, parent, name, c_items$xtra FROM thetree ORDER BY name|, $lvl, $id ? {'id = ?' => $id} : {"NOT EXISTS(SELECT 1 FROM ${type}s_parents WHERE $type = id)" => 1, 'state = 2' => 1}, !$back ? ('tp.parent = tt.id', "t.id = tp.$type") : ("tp.$type = tt.id", 't.id = tp.parent') ); diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm index 64b56625..67cd3f7e 100644 --- a/lib/VNDB/Func.pm +++ b/lib/VNDB/Func.pm @@ -139,12 +139,12 @@ sub _parenttags { # a child tags/traits box sub childtags { - my($self, $title, $type, $t) = @_; + my($self, $title, $type, $t, $order) = @_; div class => 'mainbox'; h1 $title; ul class => 'tagtree'; - for my $p (sort { @{$b->{'sub'}} <=> @{$a->{'sub'}} } @{$t->{childs}}) { + for my $p (sort { !$order ? @{$b->{'sub'}} <=> @{$a->{'sub'}} : $a->{$order} <=> $b->{$order} } @{$t->{childs}}) { li; a href => "/$type$p->{id}", $p->{name}; b class => 'grayedout', " ($p->{c_items})" if $p->{c_items}; diff --git a/lib/VNDB/Handler/Traits.pm b/lib/VNDB/Handler/Traits.pm index 887890b6..3e08f6bf 100644 --- a/lib/VNDB/Handler/Traits.pm +++ b/lib/VNDB/Handler/Traits.pm @@ -337,7 +337,7 @@ sub traitindex { end; my $t = $self->dbTTTree(trait => 0, 2); - childtags($self, mt('_traiti_tree'), 'i', {childs => $t}); + childtags($self, mt('_traiti_tree'), 'i', {childs => $t}, 'order'); table class => 'mainbox threelayout'; Tr; |