Commit f6283ae9 authored by Stefan Tauner's avatar Stefan Tauner
Browse files

FIJITestsViewer: allow user to update autocomplete entries

If the values of the autocomplete widget is generated by a function
we add an button so that the user can trigger an update of the values.
The current use case is to update available UARTs.

However, since we do not share controls between tabs the choices
get out of sync which will confuse users...

Also, using something else instead of the CODE reference to trigger
this new behavior, e.g., a dedicated settings field, might be in order
but is currently not necessary.
parent 5e955b86
......@@ -619,18 +619,48 @@ sub _populate_widget {
);
} elsif (defined($type) && $type eq 'autocomplete') {
my $options = TESTCONSTMAP->{$k}->{'values'};
my $base;
if (defined $options && ref($options) eq "CODE") {
$options = $options->();
# If we can call some code to fetch the values we want to
# add an update bottom next to the entry field.
# To that end we create an intermediate frame here if need be.
$base = $page->Frame();
} else {
$base = $page;
}
$entry = $page->CompleteEntry(
my $complete = $base->CompleteEntry(
'-choices' => $options,
);
if ($base != $page) {
$complete->grid(
-row => 0,
-column => 0,
-sticky => "ew",
);
$base->gridColumnconfigure(0, -weight => 1);
my $b = $base->Button(
-text => 'Update Choices',
-command => sub {
$complete->configure('-choices', TESTCONSTMAP->{$k}->{'values'}->());
},
)->grid(
-row => 0,
-column => 1,
-sticky => "w",
);
$entry = $base;
} else {
$entry = $complete;
}
# Whatever our entry is, we want it in the 2nd column on the left
$entry->grid(
-row => $row,
-column => 2,
'-sticky' => 'ew'
);
} elsif (defined($type) && $type eq 'dropdown') {
my $options = TESTCONSTMAP->{$k}->{'values'};
$options = $activation_values if defined($activation_func);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment