[Rt-commit] rt branch, 4.4/pass-single-cf-defaults, created. rt-4.4.0-272-gf6a78a2

Jim Brandt jbrandt at bestpractical.com
Tue Jul 19 10:18:32 EDT 2016


The branch, 4.4/pass-single-cf-defaults has been created
        at  f6a78a2f754a2f67631c6c66775359f1e2671a87 (commit)

- Log -----------------------------------------------------------------
commit 803da618e41839a38fa05fc03c86bc2bc9f24eb9
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Jul 19 09:31:42 2016 -0400

    Add a test for passing in a CF value to Modify in the URL
    
    RT users sometimes provide links to the Modify page with a
    custom field value populated via the link to make it easy to
    click, then submit an update. Add a test to validate that this
    default value is selected when the page is rendered.

diff --git a/t/web/cf_select_one.t b/t/web/cf_select_one.t
index f70486f..ce11833 100644
--- a/t/web/cf_select_one.t
+++ b/t/web/cf_select_one.t
@@ -151,6 +151,13 @@ diag "check that we can set empty value when the current is 0";
        undef, 'API returns correct value';
 }
 
+diag "check that a default value is displayed";
+{
+    my $default_ticket_id = RT::Test->create_ticket(Queue => 'General');
+    $m->get_ok("/Ticket/Modify.html?id=" . $default_ticket_id->Id . "&CustomField-$cfid=qwe");
+    $m->content_like(qr/\<option value="qwe"\s+selected="selected"/, 'Default value is selected');
+}
+
 diag 'retain selected cf values when adding attachments';
 {
     my ( $ticket, $id );

commit 6cec0e78ecf911064f7f1fc2a8ccd24e0e0c46f7
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Jul 19 10:01:16 2016 -0400

    Pass %ARGS to EditCustomFields
    
    EditCustomFields has code to pull out CF values in the form
    CustomField-123 from ARGS, but ARGS was not passed from Modify.html
    so any passed-in arguments were not available.

diff --git a/share/html/Ticket/Modify.html b/share/html/Ticket/Modify.html
index f57da09..937d76c 100644
--- a/share/html/Ticket/Modify.html
+++ b/share/html/Ticket/Modify.html
@@ -58,12 +58,12 @@
 <&| /Widgets/TitleBox, title => loc('Modify ticket #[_1]',$TicketObj->Id), class=>'ticket-info-basics' &>
 <table>
 <& Elements/EditBasics, TicketObj => $TicketObj, defaults => \%ARGS, InTable => 1 &>
-<& /Elements/EditCustomFields, Object => $TicketObj, Grouping => 'Basics', InTable => 1 &>
+<& /Elements/EditCustomFields, %ARGS, Object => $TicketObj, Grouping => 'Basics', InTable => 1 &>
 </table>
 </&>
 % $m->callback( CallbackName => 'AfterBasics', Ticket => $TicketObj );
 
-<& /Elements/EditCustomFieldCustomGroupings, Object => $TicketObj, AsTable => !!RT->Config->Get('EditCustomFieldsSingleColumn', $session{'CurrentUser'}) &>
+<& /Elements/EditCustomFieldCustomGroupings, %ARGS, Object => $TicketObj, AsTable => !!RT->Config->Get('EditCustomFieldsSingleColumn', $session{'CurrentUser'}) &>
 
 <& /Elements/Submit, Name => 'SubmitTicket', Label => loc('Save Changes'), Caption => loc("If you've updated anything above, be sure to"), color => "#993333" &>
 </form>

commit f6a78a2f754a2f67631c6c66775359f1e2671a87
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Jul 19 10:06:03 2016 -0400

    Support single default values as well as lists
    
    806ee09e8 added support for defaults in list-type CFs
    like multiple checkboxes by changing $Defaults in ARGS
    to @Defaults. However, this meant values passed as $Default
    were then not processed. Add support for both modes.

diff --git a/share/html/Elements/EditCustomFieldSelect b/share/html/Elements/EditCustomFieldSelect
index 83d0458..6d3ac6b 100644
--- a/share/html/Elements/EditCustomFieldSelect
+++ b/share/html/Elements/EditCustomFieldSelect
@@ -112,6 +112,11 @@ if ( $RenderType eq 'Dropdown' ) {
     $Rows = 0;
 }
 
+# Process scalar values for Default
+if ( $Default and !@Default ){
+    push @Default, $Default;
+}
+
 my ($checktype, $name);
 if ( $MaxValues == 1 and $RenderType eq 'List' ) {
     ($checktype, $name) = ('radio', $Name || $NamePrefix . $CustomField->Id . '-Value');
@@ -153,6 +158,7 @@ $NamePrefix => undef
 $Name => undef
 $BasedOnName => undef
 @Default => ()
+$Default => undef
 $Values => undef
 $Multiple => 0
 $Rows => undef

-----------------------------------------------------------------------


More information about the rt-commit mailing list