From f30b6901ddffa5e2a523f2b23953788d55286006 Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Tue, 24 Jun 2014 15:46:33 +0200 Subject: Managed leaf only selection (param any_item_selection to avoid) --- lib/AdminPanel/Shared/GUI.pm | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'lib/AdminPanel/Shared') diff --git a/lib/AdminPanel/Shared/GUI.pm b/lib/AdminPanel/Shared/GUI.pm index a31c451..f5fdc43 100644 --- a/lib/AdminPanel/Shared/GUI.pm +++ b/lib/AdminPanel/Shared/GUI.pm @@ -687,17 +687,26 @@ sub ask_fromTreeList { last; } elsif ($widget == $selectButton) { + $DB::single = 1; my $item = $treeWidget->selectedItem(); if ($info->{skip_path} && $info->{skip_path} != 0) { $choice = $item->label() if ($item); } else { - my $separator = exists $info->{item_separator} ? $info->{item_separator} : '/'; - if ($item) { - $choice = $item->label(); - my $parent = $item; - while($parent = $parent->parent()) { - $choice = $parent->label() . $separator . $choice ; + my $getChoice = 1; + if (!exists $info->{any_item_selection} || $info->{any_item_selection} != 0) { + if ($item) { + $getChoice = (!$item->hasChildren()); + } + } + if ($getChoice) { + my $separator = exists $info->{item_separator} ? $info->{item_separator} : '/'; + if ($item) { + $choice = $item->label(); + my $parent = $item; + while($parent = $parent->parent()) { + $choice = $parent->label() . $separator . $choice ; + } } } } -- cgit v1.2.1