[Rt-commit] [rtir] 02/02: If you're displaying a single optional option, use a checkbox

Kevin Falcone falcone at bestpractical.com
Tue Jun 18 19:00:57 EDT 2013


This is an automated email from the git hooks/post-receive script.

falcone pushed a commit to branch 2.9/incident-children
in repository rtir.

commit 2631046ca59c514dd8b9d0823a7cc2b55965e3ef
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Tue Jun 18 18:46:23 2013 -0400

    If you're displaying a single optional option, use a checkbox
    
    This removes the weird "unselectable radio button" we currently use by
    default when lauching an Incident.  This runs into a bug #24156 where
    submitting the Investigation to add more attachments or without
    adding a Correspondent will lose the checked state of the radio button.
    Similarly, adding a different Incident in the Other box would present an
    unselected radio button.
    
    Both of these happen because the core RT handling of radio buttons
    assumes quite logically that radio buttons will have a single value.
    RTIR includes a text input with the same name as the radio button,
    causing this to be wrong and ColumnMap to fail to select the radio
    button.
    
    I've also added a note wondering why we have Radio Buttons here.
    As soon as you have a Multiple case, we use checkboxes (correctly) and
    if you're required with a single value we use a hidden input to force
    the value to be passed along.
    
    If we had a use case for this element where we presented 3 items and you
    could only choose one, then radio buttons would be sensible, but I
    haven't found that in the code.  The only way that happens is if you run
    RTIR allowing multiple Incident parents and then change the
    configuration.  In that case, the code doesn't behave as well as it
    could.
    
    We may be able to drop this code and remove the jQuery uncheckable
    plugin which would be nice.
---
 html/RTIR/Elements/SelectIncident | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/html/RTIR/Elements/SelectIncident b/html/RTIR/Elements/SelectIncident
index 112d8a4..24d00f2 100644
--- a/html/RTIR/Elements/SelectIncident
+++ b/html/RTIR/Elements/SelectIncident
@@ -102,9 +102,13 @@ my $query = RT::IR->Query(
 );
 my $format = RT->Config->Get('RTIRSearchResultFormats')->{'LinkIncident'};
 my ($dformat, $hide);
-if ( $config->{'Multiple'} ) {
+if ( $config->{'Multiple'} ||
+     ( @potential == 1 && !$config->{'Required'} ) ) {
     $dformat = "'__CheckBox.{$Name}__', $format";
 } elsif ( @potential > 1 || !$config->{'Required'} ) {
+# Do we actually use this case, except when you have multiple incidents but are configured for single?
+# You would need to have triggered one of the 2.[46] bugs allowing multiple Incident parents or changed your config.
+# Removing this would allow the removal of the uncheckable jQuery plugin.
     $dformat = "'__RadioButton.{$Name}__', $format";
 } else {
     ($dformat, $hide) = ($format, 1);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Rt-commit mailing list