[Rt-commit] rtir branch, 2.9-trunk, updated. 2.6.1rc1-386-gd7d8c89

Ruslan Zakirov ruz at bestpractical.com
Mon Sep 19 16:29:13 EDT 2011


The branch, 2.9-trunk has been updated
       via  d7d8c896f265981a9bdd6bb357e3fe9ca279cd74 (commit)
       via  f0fbb01ec04ccfa819d7e4a0c6c61f985cd8c3ac (commit)
       via  e422f631c3aa7d97f834f3cda233125685497406 (commit)
       via  fd96ff8d4af82c89f58b5a293441a38b61c7bd7b (commit)
      from  0583c622654743326300fa8a38267b174de2bdbf (commit)

Summary of changes:
 TODO.porting_over_RT4             |   19 ------
 html/RTIR/Create.html             |   23 +++++---
 html/RTIR/Update.html             |   16 +++++
 t/custom-fields/on-transactions.t |  118 +++++++++++++++++++++++++++++++++++++
 4 files changed, 148 insertions(+), 28 deletions(-)
 create mode 100644 t/custom-fields/on-transactions.t

- Log -----------------------------------------------------------------
commit fd96ff8d4af82c89f58b5a293441a38b61c7bd7b
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon Sep 19 22:50:01 2011 +0400

    switched over new query generators, no need in more

diff --git a/TODO.porting_over_RT4 b/TODO.porting_over_RT4
index 77fa9b9..42a4f88 100644
--- a/TODO.porting_over_RT4
+++ b/TODO.porting_over_RT4
@@ -29,8 +29,6 @@
 
 * re-use CSS squishing
 
-* Elements/ChildSummary and Elements/IncidentSummary share the same query
-
 * use latest simple search API in html/RTIR/index.html
 
 === INVESTIGATE

commit e422f631c3aa7d97f834f3cda233125685497406
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon Sep 19 22:51:29 2011 +0400

    custom fields on tickets' transactions in the UI

diff --git a/TODO.porting_over_RT4 b/TODO.porting_over_RT4
index 42a4f88..0e8d27d 100644
--- a/TODO.porting_over_RT4
+++ b/TODO.porting_over_RT4
@@ -19,8 +19,6 @@
 
 * scan code for hardcoded statuses
 
-* tranasaction custom fields
-
 === CLEANUP && REFACTORING
 
 * make Submit buttons names consistent with RT's
diff --git a/html/RTIR/Create.html b/html/RTIR/Create.html
index 5bc7deb..d5376ab 100644
--- a/html/RTIR/Create.html
+++ b/html/RTIR/Create.html
@@ -145,6 +145,9 @@
     QueueObj => $QueueObj,
     DefaultsFrom => $SplitObj || $IncidentObj,
   &>
+  <& /Ticket/Elements/EditTransactionCustomFields,
+    %ARGS, QueueObj => $QueueObj, InTable => 1,
+  &>
 </table></&></div>
 
 <div id="ticket-create-message">
@@ -413,18 +416,20 @@ unless ( $skip_create ) {
         push @results, loc( "You must enter an Incident ID" );
         $checks_failure = 1;
     }
+}
 
-    my $TicketCFs = $QueueObj->TicketCustomFields;
-    my ($status, @msg) = $m->comp('/Elements/ValidateCustomFields',
-        CustomFields => $TicketCFs,
+unless ( $skip_create ) {
+    my $ticket_status = $m->comp('/Elements/ValidateCustomFields',
+        CustomFields => $QueueObj->TicketCustomFields,,
+        ARGSRef      => \%ARGS,
+    );
+    my $txn_status = $m->comp('/Elements/ValidateCustomFields',
+        CustomFields => $QueueObj->TicketTransactionCustomFields,
         ARGSRef      => \%ARGS,
+        NamePrefix   => "Object-RT::Transaction--CustomField-",
     );
-    unless ( $status ) {
-        push @results, loc( "Invalid value(s) of the custom fields:" );
-        while (my $CF = $TicketCFs->Next) {
-            my $msg = $m->notes('InvalidField-' . $CF->Id) or next;
-            push @results, $CF->Name . ': ' . $msg;
-        }
+    unless ( $ticket_status && $txn_status ) {
+        push @results, loc( "Invalid value(s) of the custom fields" );
         $checks_failure = 1;
     }
 }
diff --git a/html/RTIR/Update.html b/html/RTIR/Update.html
index 9783522..3f3e643 100644
--- a/html/RTIR/Update.html
+++ b/html/RTIR/Update.html
@@ -85,6 +85,10 @@
     ],
 &>
 
+<& /Ticket/Elements/EditTransactionCustomFields,
+    %ARGS, TicketObj => $Ticket, InTable => 1,
+&>
+
 </table></&></div>
 
 <div id="ticket-update-message">
@@ -172,6 +176,18 @@ if ( $SubmitTicket ) {
 }
 
 if ( $SubmitTicket ) {
+    my $status = $m->comp('/Elements/ValidateCustomFields',
+        CustomFields => $Ticket->QueueObj->TicketTransactionCustomFields,
+        ARGSRef      => \%ARGS,
+        NamePrefix   => "Object-RT::Transaction--CustomField-",
+    );
+    unless ( $status ) {
+        push @results, loc( "Invalid value(s) of the custom fields" );
+        $checks_failure = 1;
+    }
+}
+
+if ( $SubmitTicket ) {
     $checks_failure += RT::IR->FilterRTAddresses(
         ARGSRef => \%ARGS,
         Fields => { UpdateCc => 'Cc', UpdateBcc => 'Bcc' },
diff --git a/t/custom-fields/on-transactions.t b/t/custom-fields/on-transactions.t
new file mode 100644
index 0000000..2967419
--- /dev/null
+++ b/t/custom-fields/on-transactions.t
@@ -0,0 +1,118 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use RT::IR::Test tests => 80;
+
+my $cf_name = 'test';
+my $cf;
+{
+    $cf = RT::CustomField->new( $RT::SystemUser );
+    my ($id, $msg) = $cf->Create(
+        Name       => $cf_name,
+        LookupType => 'RT::Queue-RT::Ticket-RT::Transaction',
+        Type       => 'FreeformSingle',
+        Pattern    => qr/(?#not a magic)^(?!magic).*$/,
+    );
+    ok( $id, "created custom field" ) or diag "error: $msg";
+
+    for my $q ('Incident Reports', 'Investigations', 'Incidents', 'Blocks') {
+        my $q_obj = RT::Queue->new($RT::SystemUser);
+        $q_obj->Load($q);
+        ok( $q_obj->id, "Loaded queue '$q'" );
+
+        my $OCF = RT::ObjectCustomField->new($RT::SystemUser);
+        my ($status, $msg) = $OCF->Create(
+            CustomField => $cf->id,
+            ObjectId    => $q_obj->id,
+        );
+        ok( $status && $OCF->id, 'Applied CF to the queue') or diag "error: $msg";
+    }
+
+    RT::IR::Test->add_rights( Principal => 'everyone', Right => ['SeeCustomField', 'ModifyCustomField']);
+    RT::IR->_FlushCustomFieldsCache;
+}
+
+RT::Test->started_ok;
+my $agent = default_agent();
+
+my $inc_id = $agent->create_incident( { Subject => "incident" } );
+
+my @tickets;
+foreach my $qname ('Incident Reports', 'Investigations', 'Blocks') {
+    $agent->goto_create_rtir_ticket( $qname );
+    my $form = $agent->form_name('TicketCreate');
+
+    my $input_name = 'Object-RT::Transaction--CustomField-'. $cf->id .'-Value';
+    my $input = $form->find_input( $input_name );
+    ok $input, 'input for the field is on the page';
+
+    $agent->field( Incident => $inc_id ); # for blocks
+    $agent->field( Requestors => 'rt-test at example.com' ); # for invs
+    $agent->field( $input_name => 'magic' );
+    $agent->click('Create');
+
+    $form = $agent->form_name('TicketCreate');
+    ok($form, 'still on create page');
+    $input = $form->find_input( $input_name );
+    ok $input, 'input for the field is on the page';
+
+    is $agent->value( $input_name ), 'magic', 'old value is there';
+    $agent->content_like( qr/not a magic/, 'error is there' );
+    $agent->field( $input_name => 'not magic' );
+    $agent->click('Create');
+
+    my $id = $agent->get_ticket_id;
+    ok $id, 'created a ticket';
+    push @tickets, $id;
+}
+
+foreach my $id ( @tickets ) {
+    my $ticket = RT::Ticket->new( RT->SystemUser );
+    $ticket->Load( $id );
+    is $ticket->id, $id, 'loaded ticket';
+
+    my $txn = $ticket->Transactions->First;
+    is $txn->Type, 'Create';
+    is $txn->FirstCustomFieldValue( $cf_name ), 'not magic', 'correct value';
+}
+
+
+foreach my $id ( @tickets ) {
+    $agent->goto_ticket( $id );
+    $agent->follow_link_ok({ text => 'Reply' });
+
+    my $form = $agent->form_name('TicketUpdate');
+
+    my $input_name = 'Object-RT::Transaction--CustomField-'. $cf->id .'-Value';
+    my $input = $form->find_input( $input_name );
+    ok $input, 'input for the field is on the page';
+
+    $agent->field( $input_name => 'magic' );
+    $agent->click('SubmitTicket');
+
+    $form = $agent->form_name('TicketUpdate');
+    ok($form, 'still on update page');
+    $input = $form->find_input( $input_name );
+    ok $input, 'input for the field is on the page';
+
+    is $agent->value( $input_name ), 'magic', 'old value is there';
+    $agent->content_like( qr/not a magic/, 'error is there' );
+    $agent->field( $input_name => 'not magic' );
+    $agent->field( UpdateContent => 'content' );
+    $agent->click('SubmitTicket');
+}
+
+foreach my $id ( @tickets ) {
+    my $ticket = RT::Ticket->new( RT->SystemUser );
+    $ticket->Load( $id );
+    is $ticket->id, $id, 'loaded ticket';
+
+    my $txns = $ticket->Transactions;
+    $txns->Limit( FIELD => 'Type', VALUE => 'Correspond' );
+    my $txn = $txns->First;
+    ok $txn, 'found correspond';
+    is $txn->FirstCustomFieldValue( $cf_name ), 'not magic', 'correct value';
+}
+

commit f0fbb01ec04ccfa819d7e4a0c6c61f985cd8c3ac
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon Sep 19 22:53:16 2011 +0400

    at the moment no very specific CFs except Constituency

diff --git a/TODO.porting_over_RT4 b/TODO.porting_over_RT4
index 0e8d27d..0f5b4d9 100644
--- a/TODO.porting_over_RT4
+++ b/TODO.porting_over_RT4
@@ -33,9 +33,6 @@
 
 * Rename some fields to variants with spaces
 
-* Custom fields in Incident display are very specific and mixed with
-  generic RT properties
-
 * Description CF in Incidents had Cols => 60 argument, check if we preserve behaviour
 (update: the answer is no. and seems there's no way to do this except hacking rt's
 /Elements/EditCustomField or /Elements/EditCustomFieldFreeform)

commit d7d8c896f265981a9bdd6bb357e3fe9ca279cd74
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Mon Sep 19 22:54:18 2011 +0400

    drop old TODO list
    
    there are no complaints about those items from users
    of 2.6.x

diff --git a/TODO.porting_over_RT4 b/TODO.porting_over_RT4
index 0f5b4d9..72dfe97 100644
--- a/TODO.porting_over_RT4
+++ b/TODO.porting_over_RT4
@@ -29,15 +29,3 @@
 
 * use latest simple search API in html/RTIR/index.html
 
-=== INVESTIGATE
-
-* Rename some fields to variants with spaces
-
-* Description CF in Incidents had Cols => 60 argument, check if we preserve behaviour
-(update: the answer is no. and seems there's no way to do this except hacking rt's
-/Elements/EditCustomField or /Elements/EditCustomFieldFreeform)
-
-* On edit State need special treating for Blocks
-* Constituency has special treating on edit depending on constituency propagation mode
-** These two custom fields are still massaged via callback and RTIR has special editor
-

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


More information about the Rt-commit mailing list