[Rt-commit] rt branch, 4.0/apply-scrips-to-multiple-queues, updated. rt-4.0.4-192-g9ed40da
Ruslan Zakirov
ruz at bestpractical.com
Fri Jan 20 13:21:31 EST 2012
The branch, 4.0/apply-scrips-to-multiple-queues has been updated
via 9ed40dab7c8096262fe8d8a0d69695814f0f8306 (commit)
via 49bc5c13ebbf1636fc0dde9351394428f898e340 (commit)
via 773f7ac21a9089442dbcfda34024436079196784 (commit)
via de648dd649b41cad1171134cb9a7a2fed5b84309 (commit)
via 9caf77cd9122eb61e350a80c084b6907408d8b86 (commit)
via 56c6ccc8ab3ff20b64bb76e69f7ffe3d6fd2a27a (commit)
from 3925ccf07fb16bd1f97e2201ecdccfa6263f8d5c (commit)
Summary of changes:
sbin/rt-validator.in | 20 ++++-
share/html/Admin/Scrips/Elements/EditBasics | 5 +-
.../Admin/{ => Scrips}/Elements/SelectTemplate | 65 +++++++++-----
share/html/Admin/Scrips/Modify.html | 11 +--
.../{Articles/Classes => Scrips}/Objects.html | 93 +++++++++-----------
share/html/Elements/RT__Queue/ColumnMap | 9 ++
share/html/Elements/Tabs | 16 +++-
7 files changed, 134 insertions(+), 85 deletions(-)
copy share/html/Admin/{ => Scrips}/Elements/SelectTemplate (63%)
copy share/html/Admin/{Articles/Classes => Scrips}/Objects.html (60%)
- Log -----------------------------------------------------------------
commit 56c6ccc8ab3ff20b64bb76e69f7ffe3d6fd2a27a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Jan 20 03:45:28 2012 +0400
update validator, check ObjectScrips
diff --git a/sbin/rt-validator.in b/sbin/rt-validator.in
index dc79c35..c2fc788 100644
--- a/sbin/rt-validator.in
+++ b/sbin/rt-validator.in
@@ -138,6 +138,7 @@ my @models = qw(
ScripAction
ScripCondition
Scrip
+ ObjectScrip
Template
Ticket
Transaction
@@ -160,6 +161,7 @@ $redo_on{'Delete'} = {
Queues => [],
Scrips => [],
+ ObjectScrips => [],
ScripActions => [],
ScripConditions => [],
Templates => [],
@@ -800,9 +802,6 @@ push @CHECKS, Templates => sub {
push @CHECKS, Scrips => sub {
check_integrity(
- 'Scrips', 'Queue' => 'Queues', 'id',
- );
- check_integrity(
'Scrips', 'ScripCondition' => 'ScripConditions', 'id',
);
check_integrity(
@@ -811,6 +810,12 @@ push @CHECKS, Scrips => sub {
check_integrity(
'Scrips', 'Template' => 'Templates', 'id',
);
+ check_integrity(
+ 'ObjectScrips', 'Scrip' => 'Scrips', 'id',
+ );
+ check_integrity(
+ 'ObjectScrips', 'ObjectId' => 'Queues', 'id',
+ );
};
push @CHECKS, Attributes => sub {
@@ -920,6 +925,15 @@ while ( my $check = shift @do_check ) {
}
}
+=head2 check_integrity
+
+Takes two (table name, column(s)) pairs. First pair
+is reference we check and second is destination that
+must exist. Array reference can be used for multiple
+columns.
+
+=cut
+
sub check_integrity {
my ($stable, @scols) = (shift, shift);
my ($ttable, @tcols) = (shift, shift);
commit 9caf77cd9122eb61e350a80c084b6907408d8b86
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Jan 20 18:49:22 2012 +0400
change Create links for scrips
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index b7cc760..eb64b9d 100755
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -156,7 +156,7 @@ my $build_admin_menu = sub {
my $scrips = $admin_global->child( scrips => title => loc('Scrips'), path => '/Admin/Global/Scrips.html', description => loc('Modify scrips which apply to all queues') );
$scrips->child( select => title => loc('Select'), path => "/Admin/Global/Scrips.html" );
- $scrips->child( create => title => loc('Create'), path => "/Admin/Global/Scrip.html?Create=1" );
+ $scrips->child( create => title => loc('Create'), path => "/Admin/Scrip/Create.html" );
my $templates = $admin_global->child( templates => title => loc('Templates'), path => '/Admin/Global/Templates.html', description => loc('Edit system templates') );
$templates->child( select => title => loc('Select'), path => "/Admin/Global/Templates.html" );
$templates->child( create => title => loc('Create'), path => "/Admin/Global/Template.html?Create=1" );
@@ -273,7 +273,7 @@ my $build_admin_menu = sub {
my $scrips = $queue->child( scrips => title => loc('Scrips'), path => "/Admin/Queues/Scrips.html?id=" . $id);
$scrips->child( select => title => loc('Select'), path => "/Admin/Queues/Scrips.html?id=" . $id );
- $scrips->child( create => title => loc('Create'), path => "/Admin/Queues/Scrip.html?Create=1;Queue=" . $id);
+ $scrips->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html?Queue=" . $id);
my $ticket_cfs = $queue->child( 'ticket-custom-fields' => title => loc('Ticket Custom Fields'),
path => '/Admin/Queues/CustomFields.html?SubType=RT::Ticket&id=' . $id );
commit de648dd649b41cad1171134cb9a7a2fed5b84309
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Jan 20 21:20:21 2012 +0400
Admin/Scrips/Objects.html page
diff --git a/share/html/Admin/Scrips/Objects.html b/share/html/Admin/Scrips/Objects.html
new file mode 100644
index 0000000..0324ab8
--- /dev/null
+++ b/share/html/Admin/Scrips/Objects.html
@@ -0,0 +1,145 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<& /Admin/Elements/Header, Title => $title &>
+<& /Elements/Tabs &>
+<& /Elements/ListActions &>
+
+<form action="Objects.html" method="post">
+<input type="hidden" class="hidden" name="id" value="<% $id %>" />
+
+% if ( $is_global ) {
+<h2><&|/l&>Applies to all objects</&></h2>
+<input type="checkbox" name="RemoveScrip-<% $id %>" value="0" />
+<&|/l&>check this box to remove this scrip from all objects and be able to choose specific objects.</&>
+% } else {
+<h2><% loc('Stage') %></h2>
+<& /Admin/Elements/SelectStage, Default => $Stage &>
+
+<h2><&|/l&>Apply globally</&></h2>
+
+<input type="checkbox" name="AddScrip-<% $id %>" value="0" />
+<&|/l&>check this box to apply this scrip to all objects.</&>
+
+<h2><&|/l&>Selected objects</&></h2>
+<& /Elements/CollectionList,
+ OrderBy => 'id',
+ Order => 'ASC',
+ %ARGS,
+ Collection => $applied,
+ Rows => 0,
+ Page => 1,
+ Format => $format,
+ DisplayFormat => "'__CheckBox.{RemoveScrip-$id}__','__ScripStage.{$id}__',". $format,
+ AllowSorting => 0,
+ ShowEmpty => 0,
+ PassArguments => [
+ qw(id Stage Format Rows Page Order OrderBy),
+ ],
+&>
+
+<h2><&|/l&>Unselected objects</&></h2>
+<& /Elements/CollectionList,
+ OrderBy => 'Name',
+ Order => 'ASC',
+ %ARGS,
+ Collection => $not_applied,
+ Rows => 50,
+ Format => $format,
+ DisplayFormat => "'__CheckBox.{AddScrip-". $id ."}__',". $format,
+ AllowSorting => 1,
+ ShowEmpty => 0,
+ PassArguments => [
+ qw(id Stage Format Rows Page Order OrderBy),
+ ],
+&>
+
+% }
+
+<& /Elements/Submit, Name => 'Update' &>
+</form>
+
+<%ARGS>
+$id => undef
+$Stage => undef
+$Update => 0
+</%ARGS>
+<%INIT>
+my $scrip = RT::Scrip->new( $session{'CurrentUser'} );
+$scrip->Load($id) or Abort(loc("Could not load scrip #[_1]", $id));
+$id = $scrip->id;
+
+if ( $Update ) {
+ my (@results);
+ if ( defined (my $del = $ARGS{"RemoveScrip-$id"}) ) {
+ foreach my $id ( ref $del? (@$del) : ($del) ) {
+ my ($status, $msg) = $scrip->RemoveFromObject( $id );
+ push @results, $msg;
+ }
+ }
+ if ( defined (my $add = $ARGS{"AddScrip-$id"}) ) {
+ foreach my $id ( ref $add? (@$add) : ($add) ) {
+ my ($status, $msg) = $scrip->AddToObject( $id, Stage => $Stage );
+ push @results, $msg;
+ }
+ }
+ MaybeRedirectForResults(
+ Actions => \@results,
+ Arguments => { id => $id },
+ );
+}
+
+my $is_global = $scrip->IsGlobal;
+
+my $applied = $scrip->AddedTo;
+my $not_applied = $scrip->NotAddedTo;
+
+my $format = RT->Config->Get('AdminSearchResultFormat')->{'Queues'};
+
+my $title = loc('Modify associated objects for scrip #[_1]', $id);
+
+</%INIT>
diff --git a/share/html/Elements/RT__Queue/ColumnMap b/share/html/Elements/RT__Queue/ColumnMap
index 20473b8..c8a94a3 100644
--- a/share/html/Elements/RT__Queue/ColumnMap
+++ b/share/html/Elements/RT__Queue/ColumnMap
@@ -84,6 +84,15 @@ my $COLUMN_MAP = {
title => 'Encrypt', # loc
value => sub { return $_[0]->Encrypt? $_[0]->loc('yes') : $_[0]->loc('no') },
},
+ ScripStage => {
+ title => 'Stage', # loc
+ value => sub {
+ my $sid = $_[-1];
+ my $os = RT::ObjectScrip->new( $_[0]->CurrentUser );
+ $os->LoadByCols( Scrip => $_[-1], ObjectId => $_[0]->id );
+ return $os->Stage;
+ },
+ }
};
foreach my $field (qw(
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index eb64b9d..c0a54ea 100755
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -338,6 +338,18 @@ my $build_admin_menu = sub {
}
+ if ( $request_path =~ m{^/Admin/Scrips/} ) {
+ if ( $m->request_args->{'id'} && $m->request_args->{'id'} =~ /^\d+$/ ) {
+ my $id = $m->request_args->{'id'};
+ my $obj = RT::Scrip->new( $session{'CurrentUser'} );
+ $obj->Load($id);
+
+ my $tabs = PageMenu();
+ $tabs->child( basics => title => loc('Basics') => path => "/Admin/Scrips/Modify.html?id=".$id );
+ $tabs->child( 'added-to' => title => loc('Added to'), path => "/Admin/Scrips/Objects.html?id=" . $id );
+ }
+ }
+
if ( $request_path =~ m{^/Admin/Global/(Scrip|Template)s?\.html} ) {
my $type = $1;
my $tabs = PageMenu();
commit 773f7ac21a9089442dbcfda34024436079196784
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Jan 20 21:45:15 2012 +0400
delete debugging statements
diff --git a/share/html/Admin/Scrips/Modify.html b/share/html/Admin/Scrips/Modify.html
index c0b2528..84ac58a 100755
--- a/share/html/Admin/Scrips/Modify.html
+++ b/share/html/Admin/Scrips/Modify.html
@@ -98,9 +98,6 @@ $id => undef
$Update => undef
</%ARGS>
<%INIT>
-use Data::Dumper;
-print STDERR Dumper \%ARGS;
-
my $scrip = RT::Scrip->new( $session{'CurrentUser'} );
$scrip->Load( $id );
Abort(loc("Couldn't load scrip #[_1]", $id))
commit 49bc5c13ebbf1636fc0dde9351394428f898e340
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Jan 20 21:47:03 2012 +0400
link a few pages right from inside Modify.html
diff --git a/share/html/Admin/Scrips/Modify.html b/share/html/Admin/Scrips/Modify.html
index 84ac58a..2aa8564 100755
--- a/share/html/Admin/Scrips/Modify.html
+++ b/share/html/Admin/Scrips/Modify.html
@@ -58,15 +58,17 @@
<& Elements/EditBasics, %ARGS, Scrip => $scrip &>
% if ( $added_to_any ) {
-<tr><td class="label"><&|/l&>Added</&>:</td><td class="value">\
+<tr><td class="label"><a href="Objects.html?id=<% $id %>"><&|/l&>Added</&></a>:</td>
+<td class="value">\
% if ( $scrip->IsGlobal ) {
-<% loc('Global') %>
+<a href="<% RT->Config->Get('WebPath') %>/Admin/Global/Scrips.html"><% loc('Global') %></a>
% } else {
% my $added_to = $scrip->AddedTo;
% my $found = 0;
% while ( my $queue = $added_to->Next ) {
% $m->out(', ') if $found++;
-<% $queue->Name %>
+<a href="<% RT->Config->Get('WebPath') %>/Admin/Queues/Scrips.html?id=<% $queue->id %>">\
+<% $queue->Name %></a>\
% last if $found == 10;
% }
% $m->out(', ...') if $found == 10;
commit 9ed40dab7c8096262fe8d8a0d69695814f0f8306
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Jan 20 22:20:57 2012 +0400
new templates picker that accounts multiple queues
diff --git a/share/html/Admin/Scrips/Elements/EditBasics b/share/html/Admin/Scrips/Elements/EditBasics
index c1864b5..04d26a9 100644
--- a/share/html/Admin/Scrips/Elements/EditBasics
+++ b/share/html/Admin/Scrips/Elements/EditBasics
@@ -15,12 +15,13 @@
&></td></tr>
<tr><td class="label"><&|/l&>Template</&>:</td><td class="value">\
-<& /Admin/Elements/SelectTemplate,
- Default => $ARGS{"Template"} || $Scrip->TemplateObj->Id,
+<& SelectTemplate,
+ Default => $ARGS{"Template"}, Scrip => $Scrip, Queue => $Queue,
&></td></tr>
<%ARGS>
$Scrip
+$Queue => undef
</%ARGS>
<%INIT>
</%INIT>
diff --git a/share/html/Admin/Scrips/Elements/SelectTemplate b/share/html/Admin/Scrips/Elements/SelectTemplate
new file mode 100755
index 0000000..c72fd9b
--- /dev/null
+++ b/share/html/Admin/Scrips/Elements/SelectTemplate
@@ -0,0 +1,100 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<select name="<% $Name %>">
+<option value=""><% $current || '-' %></option>
+% foreach my $name ( @list ) {
+<option value="<% $name %>" \
+ <% lc($Default||'') eq lc $name ? 'selected="selected"' : '' |n %>
+><% loc($name) %></option>
+% }
+</select>
+
+<%ARGS>
+$Name => 'Template'
+$Queue => undef
+$Scrip => undef
+$Default => undef
+</%ARGS>
+<%INIT>
+
+my $current;
+$current = $Scrip->TemplateObj->Name if $Scrip;
+
+my $global = RT::Templates->new($session{'CurrentUser'});
+$global->LimitToGlobal;
+
+my %global;
+$global{ lc $_ } = $_ foreach map $_->Name, @{ $global->ItemsArrayRef };
+
+my @queues;
+if ( $Scrip && $Scrip->id ) {
+ @queues = @{ $Scrip->AddedTo->ItemsArrayRef };
+}
+elsif ( $Queue && $Queue->id ) {
+ @queues = ($Queue);
+}
+
+my (%names, %counters);
+foreach my $queue ( @queues ) {
+ my $templates = RT::Templates->new($session{'CurrentUser'});
+ $templates->LimitToQueue( $queue->id );
+ foreach my $name ( map $_->Name, @{ $templates->ItemsArrayRef } ) {
+ next if $global{ lc $name };
+ $counters{ lc $name }++;
+ $names{lc $name} = $name;
+ }
+}
+delete $counters{ $_ }
+ foreach grep $counters{$_} != @queues,
+ keys %counters;
+
+my @list =
+ sort { lc loc($a) cmp lc loc($b) }
+ map $global{$_} || $names{$_},
+ keys %global, keys %counters;
+</%INIT>
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list