increment priority via bulk ticket update, #12901
authormark <mark>
Mon, 16 May 2011 23:28:19 +0000 (23:28 +0000)
committermark <mark>
Mon, 16 May 2011 23:28:19 +0000 (23:28 +0000)
rt/FREESIDE_MODIFIED
rt/lib/RT/Ticket_Vendor.pm [new file with mode: 0644]
rt/share/html/Search/Bulk.html

index c04e5e1..aa74d86 100644 (file)
@@ -35,6 +35,7 @@ lib/RT/SearchBuilder.pm #need DBIx::SearchBuilder >= 1.36 for Pg 8.1+
 lib/RT/Transaction_Overlay.pm #fix transaction custom fields
 lib/RT/Tickets_Overlay.pm #customfield date patch #SearchCustomerFields #this-month condition 
  lib/RT/Ticket_Overlay.pm #fix transaction custom fields
+lib/RT/Ticket_Vendor.pm #bulk increment priority
  lib/RT/Users_Overlay.pm
  lib/RT/Groups_Overlay.pm
 lib/RT/Date.pm #this-month condition
@@ -85,6 +86,7 @@ share/html/Elements/ShowLink_Checklist
  share/html/Elements/SelectCustomerClass #SearchCustomerFields
  share/html/Elements/SelectCustomerTag #SearchCustomerFields
 share/html/Prefs/SavedSearches.html #saved searches
+share/html/Search/Bulk.html #bulk increment priority
  share/html/Search/Build.html
 share/html/Search/Results.tsv #content-type bug fix
  share/html/Search/Elements/BuildFormatString
diff --git a/rt/lib/RT/Ticket_Vendor.pm b/rt/lib/RT/Ticket_Vendor.pm
new file mode 100644 (file)
index 0000000..604a84a
--- /dev/null
@@ -0,0 +1,16 @@
+package RT::Ticket;
+use strict;
+
+sub SetPriority {
+  # Special case: Pass a value starting with 'R' to set priority 
+  # relative to the current level.  Used for bulk updates, though 
+  # it can be used anywhere else too.
+  my $Ticket = shift;
+  my $value = shift;
+  if ( $value =~ /^R([+-]?\d+)$/ ) {
+    $value = $1 + ($Ticket->Priority || 0);
+  }
+  $Ticket->SUPER::SetPriority($value);
+}
+
+1;
index e2b7574..84f2c82 100755 (executable)
 <tr><td class="label"> <&|/l&>Make subject</&>: </td>
 <td class="value"> <input name="Subject" size="20" value="<% $ARGS{Subject} || '' %>"/> </td></tr>
 <tr><td class="label"> <&|/l&>Make priority</&>: </td>
-<td class="value"> <& /Elements/SelectPriority, Name => "Priority", Default => $ARGS{Priority} &> </td></tr>
+% my $rel = ($ARGS{Priority} =~ s/^R//);
+<td class="value"> <& /Elements/SelectPriority, Name => "Priority", Default => $ARGS{Priority} &> 
+<select name="Priority-Mode">
+<option value="absolute" <% !$rel && 'selected' %>>absolute</option>
+<option value="relative" <%  $rel && 'selected' %>>relative</option>
+</select>
+</td></tr>
 <tr><td class="label"> <&|/l&>Make queue</&>: </td>
 <td class="value"> <& /Elements/SelectQueue, Name => "Queue", Default => $ARGS{Queue} &> </td></tr>
 <tr><td class="label"> <&|/l&>Make Status</&>: </td>
@@ -283,7 +289,7 @@ $Page ||= 1;
 $Format ||= RT->Config->Get('DefaultSearchResultFormat');
 
 # inject _CHECKBOX to the first field.
-$Format =~ s/'?([^']+)'?,/'___CHECKBOX__$1',/;
+$Format =~ s/'?([^']+)'?,/'___CHECKBOX__$1',/;      #'
 
 my $Tickets = RT::Tickets->new( $session{'CurrentUser'} );
 $Tickets->FromSQL($Query);
@@ -332,6 +338,13 @@ my $cf_del_keys;
 my $cf_add_keys;
 @$cf_add_keys = grep { /^Bulk-Add-CustomField/ } keys %ARGS;
 
+if ( defined($ARGS{'Priority'})
+     and ($ARGS{'Priority-Mode'} || '') eq 'relative' ) {
+    # magic in Ticket::SetPriority
+    $ARGS{'Priority'} = 'R'.$ARGS{'Priority'};
+}
+delete $ARGS{'Priority-Mode'};
+
 unless ( $ARGS{'AddMoreAttach'} ) {
     # Add session attachments if any to be processed by ProcessUpdateMessage
     $ARGS{'UpdateAttachments'} = $session{'Attachments'} if ( $session{'Attachments'} );