[Rt-commit] rt branch, 4.0/apply-scrips-to-multiple-queues, updated. rt-4.0.4-186-g3925ccf

Ruslan Zakirov ruz at bestpractical.com
Sat Jan 14 18:41:44 EST 2012


The branch, 4.0/apply-scrips-to-multiple-queues has been updated
       via  3925ccf07fb16bd1f97e2201ecdccfa6263f8d5c (commit)
       via  2c9328dd68a4913b148003e4ddac22f6578f257f (commit)
       via  63d6785cc1848b127f9336aed3864c52ef1e39e5 (commit)
       via  2886c7ffcbdfe7c7e96bc9eb141ac2bc88e30427 (commit)
      from  00c46f0681f1a28a55b3b823c4fad4449e739af0 (commit)

Summary of changes:
 etc/RT_Config.pm.in                             |    4 +-
 share/html/Admin/Elements/EditScrip             |  243 -----------------------
 share/html/Admin/Global/Scrip.html              |   63 ------
 share/html/Admin/Queues/Scrip.html              |   77 -------
 share/html/Admin/Scrips/Create.html             |   90 +++++++++
 share/html/Admin/Scrips/Elements/EditBasics     |   26 +++
 share/html/Admin/Scrips/Elements/EditCustomCode |   30 +++
 share/html/Admin/Scrips/Modify.html             |  140 +++++++++++++
 share/html/Admin/Scrips/index.html              |   23 +++
 share/html/Elements/RT__Scrip/ColumnMap         |   14 --
 share/html/Elements/Tabs                        |    6 +
 11 files changed, 317 insertions(+), 399 deletions(-)
 delete mode 100755 share/html/Admin/Elements/EditScrip
 delete mode 100755 share/html/Admin/Global/Scrip.html
 delete mode 100755 share/html/Admin/Queues/Scrip.html
 create mode 100644 share/html/Admin/Scrips/Create.html
 create mode 100644 share/html/Admin/Scrips/Elements/EditBasics
 create mode 100644 share/html/Admin/Scrips/Elements/EditCustomCode
 create mode 100755 share/html/Admin/Scrips/Modify.html
 create mode 100644 share/html/Admin/Scrips/index.html

- Log -----------------------------------------------------------------
commit 2886c7ffcbdfe7c7e96bc9eb141ac2bc88e30427
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Jan 13 16:18:46 2012 +0400

    add Admin/Scrips/ dir with index

diff --git a/share/html/Admin/Scrips/index.html b/share/html/Admin/Scrips/index.html
new file mode 100644
index 0000000..ea816d2
--- /dev/null
+++ b/share/html/Admin/Scrips/index.html
@@ -0,0 +1,23 @@
+<& /Admin/Elements/Header, Title => loc('Select a Scrip') &>
+<& /Elements/Tabs &>
+
+<& /Elements/CollectionList,
+    OrderBy       => 'Description',
+    Order         => 'ASC',
+    Rows          => 50,
+    %ARGS,
+    Collection    => $scrips,
+    Format        => $Format,
+    AllowSorting  => 1,
+&>
+<%args>
+$Format => undef
+</%args>
+<%INIT>
+my $scrips = RT::Scrips->new( $session{'CurrentUser'} );
+$scrips->UnLimit;
+
+$m->callback(CallbackName => 'Massage', Scrips => $scrips);
+
+$Format ||= RT->Config->Get('AdminSearchResultFormat')->{'Scrips'};
+</%INIT>
\ No newline at end of file
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 0f65c5b..e7a98a5 100755
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -146,6 +146,12 @@ my $build_admin_menu = sub {
             $cfs->child( create => title => loc('Create'), path => "/Admin/CustomFields/Modify.html?Create=1" );
         }
 
+        if ( $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'ModifyScrips' ) ) {
+            my $cfs = $admin->child( 'scrips' => title => loc('Scrips'), path => '/Admin/Scrips/', description => loc('Manage scrips') );
+            $cfs->child( select => title => loc('Select'), path   => "/Admin/Scrips/" );
+            $cfs->child( create => title => loc('Create'), path => "/Admin/Scrips/Modify.html?Create=1" );
+        }
+
         my $admin_global = $admin->child( global => title => loc('Global'), path   => '/Admin/Global/', description => loc('Manage properties and configuration which apply to all queues') );
 
         my $scrips = $admin_global->child( scrips => title => loc('Scrips'), path => '/Admin/Global/Scrips.html', description => loc('Modify scrips which apply to all queues') );

commit 63d6785cc1848b127f9336aed3864c52ef1e39e5
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Jan 13 21:46:32 2012 +0400

    Move scrip editor into one place

diff --git a/share/html/Admin/Queues/Scrip.html b/share/html/Admin/Queues/Scrip.html
deleted file mode 100755
index 0948942..0000000
--- a/share/html/Admin/Queues/Scrip.html
+++ /dev/null
@@ -1,77 +0,0 @@
-%# 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, actions => \@results &>
-<& /Admin/Elements/EditScrip, title => $title,  %ARGS, id => $id &>
-
-<%init>
-my $QueueObj = RT::Queue->new( $session{'CurrentUser'} );
-$QueueObj->Load( $Queue );
-unless( $QueueObj->id ) {
-    Abort(loc("Queue [_1] not found", $id));
-}
-
-my ($title);
-
-($id, my @results) = $m->comp( '/Admin/Elements/EditScrip:Process', %ARGS );
-
-if ( $id ) {
-    $title = loc("Modify a scrip for queue [_1]", $QueueObj->Name);
-} else {
-    $title = loc("Create a scrip for queue [_1]", $QueueObj->Name);
-}
-
-
-</%init>
-
-<%ARGS>
-$id => undef
-$Queue => undef
-</%ARGS>
diff --git a/share/html/Admin/Global/Scrip.html b/share/html/Admin/Scrips/Modify.html
similarity index 100%
rename from share/html/Admin/Global/Scrip.html
rename to share/html/Admin/Scrips/Modify.html

commit 2c9328dd68a4913b148003e4ddac22f6578f257f
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Jan 13 21:49:12 2012 +0400

    we don't need AdminURL column map

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 11fef03..511b152 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2466,8 +2466,8 @@ Set(%AdminSearchResultFormat,
         .q{,__AppliedTo__, __FriendlyType__, __FriendlyPattern__},
 
     Scrips =>
-        q{'<a href="__WebPath__/__AdminURL__">__id__</a>/TITLE:#'}
-        .q{,'<a href="__WebPath__/__AdminURL__">__Description__</a>/TITLE:Description'}
+        q{'<a href="__WebPath__/Admin/Scrips/Modify.html?id=__id__">__id__</a>/TITLE:#'}
+        .q{,'<a href="__WebPath__/Admin/Scrips/Modify.html?id=__id__">__Description__</a>/TITLE:Description'}
         .q{, __Condition__, __Action__, __Template__},
 
     Templates =>
diff --git a/share/html/Elements/RT__Scrip/ColumnMap b/share/html/Elements/RT__Scrip/ColumnMap
index ca35068..eb47a15 100644
--- a/share/html/Elements/RT__Scrip/ColumnMap
+++ b/share/html/Elements/RT__Scrip/ColumnMap
@@ -93,20 +93,6 @@ my $COLUMN_MAP = {
 	attribute => 'Description',
 	value     => sub { return $_[0]->Description() },
     },
-
-    AdminURL => {
-	value     => sub {
-            my $queue = $_[0]->AddedTo->First;
-            my $res = 'Admin';
-            if ( $queue ) {
-                $res .= '/Queues/Scrip.html?Queue='. $queue->id .'&';
-            } else {
-                $res .= '/Global/Scrip.html?';
-            }
-            $res .= 'id='. $_[0]->id;
-            return $res;
-        },
-    },
     RemoveCheckBox => {
         title => sub {
             my $name = 'RemoveScrip';

commit 3925ccf07fb16bd1f97e2201ecdccfa6263f8d5c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sun Jan 15 03:38:46 2012 +0400

    turn EditScrip into Create and Modify html comps
    
    EditScrip was used in two places, now it's one, so
    it's not required.
    
    Create and Modify are different for scrips, so we
    split them up and use smaller components for common
    ports.

diff --git a/share/html/Admin/Elements/EditScrip b/share/html/Admin/Elements/EditScrip
deleted file mode 100755
index 8989f31..0000000
--- a/share/html/Admin/Elements/EditScrip
+++ /dev/null
@@ -1,243 +0,0 @@
-%# 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 }}}
-<& /Elements/ListActions, actions => \@actions &>
-  
-<form method="post" action="Scrip.html" id="ModifyScrip" name="ModifyScrip">
-<input type="hidden" class="hidden" name="id" value="<% $id %>" />
-<input type="hidden" class="hidden" name="Queue" value="<% $Queue %>" />
-
-<&| /Widgets/TitleBox, title => loc('Scrip Fields') &>
-<table>
-
-<tr><td class="label"><&|/l&>Description</&>:</td><td class="value">\
-<input name="Scrip-<% $id %>-Description" \
-    size="60" \
-    value="<% $ARGS{"Scrip-$id-Description"} || $scrip->Description || '' %>" />
-</td></tr>
-
-<tr><td class="label"><&|/l&>Condition</&>:</td><td class="value">\
-<& /Admin/Elements/SelectScripCondition,
-    Name => "Scrip-$id-ScripCondition",
-    Default => $ARGS{"Scrip-$id-ScripCondition"} || $scrip->ConditionObj->Id,
-&></td></tr>
-
-<tr><td class="label"><&|/l&>Action</&>:</td><td class="value">\
-<& /Admin/Elements/SelectScripAction,
-    Name => "Scrip-$id-ScripAction",
-    Default => $ARGS{"Scrip-$id-ScripAction"} || $scrip->ActionObj->Id,
-&></td></tr>
-
-<tr><td class="label"><&|/l&>Template</&>:</td><td class="value">\
-<& /Admin/Elements/SelectTemplate,
-    Name => "Scrip-$id-Template",
-    Default => $ARGS{"Scrip-$id-Template"} || $scrip->TemplateObj->Id,
-    Queue => $Queue,
-&></td></tr>
-
-% if ( $id eq 'new' ) {
-<tr><td class="label"><&|/l&>Stage</&>:</td><td class="value">\
-<& /Admin/Elements/SelectStage,
-    Name => "Scrip-$id-Stage",
-    Default => $ARGS{"Scrip-$id-Stage"},
-&></td></tr>
-% }
-
-% if ( $id ne 'new' && $added_to_any ) {
-<tr><td class="label"><&|/l&>Added</&>:</td><td class="value">\
-% if ( $scrip->IsGlobal ) {
-<% loc('Global') %>
-% } else {
-% my $added_to = $scrip->AddedTo;
-% my $found = 0;
-% while ( my $queue = $added_to->Next ) {
-% $m->out(', ') if $found++;
-<% $queue->Name %>
-% last if $found == 10;
-% }
-% $m->out(', ...') if $found == 10;
-% }
-<td></tr>
-% }
-
-% if ( $id eq 'new' || $added_to_any  ) {
-<tr><td class="label"> </td><td>
-<input type="hidden" class="hidden" name="SetEnabled" value="1" />
-<input type="checkbox" class="checkbox" name="Scrip-<% $id %>-Enabled" value="1" <% $EnabledChecked |n%> />
-<label for="Scrip-<% $id %>-Enabled"><&|/l&>Enabled (Unchecking this box disables this scrip)</&></label>
-</td></tr>
-% }
-
-</table>
-</&>
-
-% if ($session{CurrentUser}->HasRight(Object => $RT::System, Right => 'ExecuteCode')) {
-<& /Elements/Submit,
-    Label => $SubmitLabel,
-    Reset => 1,
-&><br />
-
-<&| /Widgets/TitleBox, title => loc('User Defined conditions and actions') &>
-<table>
-<tr><td colspan="2">
-<i><&|/l&>(Use these fields when you choose 'User Defined' for a condition or action)</&></i>
-</td></tr>
-
-<tr><td class="labeltop"><&|/l&>Custom condition</&>:</td><td class="value">
-% my $code = $ARGS{"Scrip-$id-CustomIsApplicableCode"} || $scrip->CustomIsApplicableCode || '';
-% my $lines = @{[ $code =~ /\n/gs ]} + 3;
-% $lines = $min_lines if $lines < $min_lines;
-<textarea cols="80" rows="<% $lines %>" name="Scrip-<% $id %>-CustomIsApplicableCode"><% $code %></textarea>
-</td></tr>
-
-<tr><td class="labeltop"><&|/l&>Custom action preparation code</&>:</td><td class="value">
-% $code = $ARGS{"Scrip-$id-CustomPrepareCode"} || $scrip->CustomPrepareCode || '';
-% $lines = @{[ $code =~ /\n/gs ]} + 3;
-% $lines = $min_lines if $lines < $min_lines;
-<textarea cols="80" rows="<% $lines %>" name="Scrip-<% $id %>-CustomPrepareCode"><% $code %></textarea>
-</td></tr>
-
-<tr><td class="labeltop"><&|/l&>Custom action cleanup code</&>:</td><td class="value">
-% $code = $ARGS{"Scrip-$id-CustomCommitCode"} || $scrip->CustomCommitCode || '';
-% $lines = @{[ $code =~ /\n/gs ]} + 3;
-% $lines = $min_lines if $lines < $min_lines;
-<textarea cols="80" rows="<% $lines %>" name="Scrip-<% $id || '' %>-CustomCommitCode"><% $code %></textarea>
-</td></tr>
-
-</table>
-</&>
-
-% }
-
-<& /Elements/Submit,
-    Label => $SubmitLabel,
-    Reset => 1,
-&>
-
-</form>
-<%init>
-
-my (@actions, $SubmitLabel);
-my $scrip = RT::Scrip->new( $session{'CurrentUser'} );
-
-if ( $id ) {
-    $scrip->Load( $id );
-    unless ( $id = $scrip->id ) {
-        push @actions, loc("Couldn't load scrip #[_1]", $id);
-    }
-    $SubmitLabel = loc('Save Changes');
-}
-
-my $EnabledChecked = qq[checked="checked"];
-my $added_to_any = 0;
-
-unless ( $id ) {
-    $id = 'new';
-    $SubmitLabel = loc('Create');
-}
-else {
-    my $disabled = $scrip->Disabled;
-    $added_to_any = 1 if defined $disabled;
-    $EnabledChecked = '' if $disabled;
-}
-
-my $min_lines = 10;
-
-my ($ok, $msg) = $scrip->CompileCheck;
-push @actions, $msg if !$ok;
-
-</%init>
-
-<%ARGS>
-$id => undef
-$title => undef
-$Queue => 0
-</%ARGS>
-
-<%METHOD Process>
-<%ARGS>
-$id => undef
-$Queue => undef
-</%ARGS>
-<%INIT>
-return ($id) unless $id;
-
-my $scrip = RT::Scrip->new( $session{'CurrentUser'} );
-if ( $id eq 'new' ) {
-    return $scrip->Create(
-        Queue                  => $Queue,
-        ScripAction            => $ARGS{"Scrip-new-ScripAction"},
-        ScripCondition         => $ARGS{"Scrip-new-ScripCondition"},
-        Template               => $ARGS{"Scrip-new-Template"},
-        Description            => $ARGS{"Scrip-new-Description"},
-        CustomPrepareCode      => $ARGS{"Scrip-new-CustomPrepareCode"},
-        CustomCommitCode       => $ARGS{"Scrip-new-CustomCommitCode"},
-        CustomIsApplicableCode => $ARGS{"Scrip-new-CustomIsApplicableCode"},
-        Stage                  => $ARGS{"Scrip-new-Stage"},
-        Disabled               => $ARGS{"Scrip-new-Enabled"}? 0 : 1,
-    );
-}
-else {
-    $scrip->Load( $id );
-    return (undef, loc("Couldn't load scrip #[_1]", $id))
-        unless $scrip->id;
-
-    $ARGS{"Scrip-$id-Disabled"} = $ARGS{"Scrip-$id-Enabled"}? 0 : 1
-        if $ARGS{"SetEnabled"};
-
-    my @attribs = qw(ScripAction ScripCondition Template Stage
-        Description CustomPrepareCode CustomCommitCode CustomIsApplicableCode Disabled);
-    my @results = UpdateRecordObject(
-        AttributesRef   => \@attribs,
-        AttributePrefix => 'Scrip-'.$scrip->Id,
-        Object          => $scrip,
-        ARGSRef         => \%ARGS
-    );
-    return ($scrip->id, @results);
-}
-</%INIT>
-</%METHOD>
diff --git a/share/html/Admin/Scrips/Create.html b/share/html/Admin/Scrips/Create.html
new file mode 100644
index 0000000..732997d
--- /dev/null
+++ b/share/html/Admin/Scrips/Create.html
@@ -0,0 +1,90 @@
+<& /Admin/Elements/Header, Title => $title &>
+<& /Elements/Tabs &>
+<& /Elements/ListActions, actions => \@results &>
+
+<form method="post" action="Create.html" id="CreateScrip" name="CreateScrip">
+<input type="hidden" class="hidden" name="Queue" value="<% $Queue %>" />
+
+<&| /Widgets/TitleBox, title => loc('Basics') &>
+<table>
+
+<& Elements/EditBasics, %ARGS, Scrip => $scrip &>
+
+<tr><td class="label"><&|/l&>Stage</&>:</td><td class="value">\
+<& /Admin/Elements/SelectStage, Default => $ARGS{"Stage"} &></td></tr>
+
+<tr><td class="label"> </td><td>
+<input type="hidden" class="hidden" name="SetEnabled" value="1" />
+<input type="checkbox" class="checkbox" name="Enabled" value="1" <% $ARGS{'Enabled'}? 'checked="checked"': '' |n%> />
+<label for="Enabled"><&|/l&>Enabled (Unchecking this box disables this scrip)</&></label>
+</td></tr>
+
+</table>
+</&>
+
+<& /Elements/Submit,
+    Label => loc('Create'),
+    Name => 'Create',
+&>
+
+% if ($session{CurrentUser}->HasRight(Object => $RT::System, Right => 'ExecuteCode')) {
+<& Elements/EditCustomCode, %ARGS, Scrip => $scrip &>
+<& /Elements/Submit,
+    Label => loc('Create'),
+    Name => 'Create',
+&>
+% }
+
+</form>
+<%ARGS>
+$Queue => 0
+$Create => undef
+</%ARGS>
+<%INIT>
+my @results;
+
+$ARGS{'Enabled'} = 1 unless $ARGS{'SetEnabled'};
+
+my $queue_obj;
+if ( $Queue ) {
+    $queue_obj = RT::Queue->new( $session{'CurrentUser'} );
+    $queue_obj->Load( $Queue );
+    Abort( loc("Couldn't load queue [_1]", $Queue) )
+        unless $queue_obj->id;
+}
+
+my $title;
+if ( $queue_obj ) {
+    $title = loc('Create a scrip and add to queue [_1]', $queue_obj->Name );
+} else {
+    $title = loc('Create a global scrip');
+}
+
+my $scrip = RT::Scrip->new( $session{'CurrentUser'} );
+if ( $Create ) {
+    my ($status, $msg) = $scrip->Create(
+        Description            => $ARGS{"Description"},
+
+        Queue                  => $Queue || 0,
+        Stage                  => $ARGS{"Stage"},
+
+        ScripAction            => $ARGS{"ScripAction"},
+        ScripCondition         => $ARGS{"ScripCondition"},
+        Template               => $ARGS{"Template"},
+
+        CustomPrepareCode      => $ARGS{"CustomPrepareCode"},
+        CustomCommitCode       => $ARGS{"CustomCommitCode"},
+        CustomIsApplicableCode => $ARGS{"CustomIsApplicableCode"},
+    );
+
+    MaybeRedirectForResults(
+        Force     => 1,
+        Actions   => [ $msg ],
+        Path      => 'Admin/Scrips/Modify.html',
+        Arguments => { id => $scrip->id },
+    ) if $status;
+
+    push @results, $msg;
+}
+
+</%INIT>
\ No newline at end of file
diff --git a/share/html/Admin/Scrips/Elements/EditBasics b/share/html/Admin/Scrips/Elements/EditBasics
new file mode 100644
index 0000000..c1864b5
--- /dev/null
+++ b/share/html/Admin/Scrips/Elements/EditBasics
@@ -0,0 +1,26 @@
+<tr><td class="label"><&|/l&>Description</&>:</td><td class="value">\
+<input name="Description" \
+    size="60" \
+    value="<% $ARGS{"Description"} || $Scrip->Description || '' %>" />
+</td></tr>
+
+<tr><td class="label"><&|/l&>Condition</&>:</td><td class="value">\
+<& /Admin/Elements/SelectScripCondition,
+    Default => $ARGS{"ScripCondition"} || $Scrip->ConditionObj->Id,
+&></td></tr>
+
+<tr><td class="label"><&|/l&>Action</&>:</td><td class="value">\
+<& /Admin/Elements/SelectScripAction,
+    Default => $ARGS{"ScripAction"} || $Scrip->ActionObj->Id,
+&></td></tr>
+
+<tr><td class="label"><&|/l&>Template</&>:</td><td class="value">\
+<& /Admin/Elements/SelectTemplate,
+    Default => $ARGS{"Template"} || $Scrip->TemplateObj->Id,
+&></td></tr>
+
+<%ARGS>
+$Scrip
+</%ARGS>
+<%INIT>
+</%INIT>
diff --git a/share/html/Admin/Scrips/Elements/EditCustomCode b/share/html/Admin/Scrips/Elements/EditCustomCode
new file mode 100644
index 0000000..184ecd8
--- /dev/null
+++ b/share/html/Admin/Scrips/Elements/EditCustomCode
@@ -0,0 +1,30 @@
+<&| /Widgets/TitleBox, title => loc('User Defined conditions and results') &>
+
+<table>
+<tr><td colspan="2" class="comment">
+<i><&|/l&>(Use these fields when you choose 'User Defined' for a condition or action)</&></i>
+</td></tr>
+
+% while ( my ($method, $desc) = splice @list, 0, 2 ) {
+<tr><td class="labeltop"><% $desc %>:</td><td class="value">
+% my $code = $ARGS{ $method } || $Scrip->$method() || '';
+% my $lines = @{[ $code =~ /\n/gs ]} + 3;
+% $lines = $min_lines if $lines < $min_lines;
+<textarea cols="80" rows="<% $lines %>" name="<% $method %>"><% $code %></textarea>
+</td></tr>
+% }
+
+</table>
+</&>
+<%ARGS>
+$Scrip
+</%ARGS>
+<%INIT>
+my @list = (
+    CustomIsApplicableCode => loc('Custom condition'),
+    CustomPrepareCode      => loc('Custom action preparation code'),
+    CustomCommitCode       => loc('Custom action cleanup code'),
+);
+
+my $min_lines = 10;
+</%INIT>
diff --git a/share/html/Admin/Scrips/Modify.html b/share/html/Admin/Scrips/Modify.html
index 482dfb3..c0b2528 100755
--- a/share/html/Admin/Scrips/Modify.html
+++ b/share/html/Admin/Scrips/Modify.html
@@ -45,19 +45,96 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<& /Admin/Elements/Header, Title => $title &>
+<& /Admin/Elements/Header, Title => loc("Modify scrip #[_1]", $id) &>
 <& /Elements/Tabs &>
 <& /Elements/ListActions, actions => \@results &>
-<& /Admin/Elements/EditScrip, title => $title,  %ARGS, id => $id &>
 
-<%init>
-my ($id, @results) = $m->comp( '/Admin/Elements/EditScrip:Process', %ARGS );
+<form method="post" action="Modify.html" id="ModifyScrip" name="ModifyScrip">
+<input type="hidden" class="hidden" name="id" value="<% $id %>" />
 
-my ($title);
-if ( $id ) {
-    $title = loc("Modify a scrip that applies to all queues");
-}
-else {
-    $title = loc("Add a scrip which will apply to all queues");
+<&| /Widgets/TitleBox, title => loc('Basics') &>
+<table>
+
+<& Elements/EditBasics, %ARGS, Scrip => $scrip &>
+
+% if ( $added_to_any ) {
+<tr><td class="label"><&|/l&>Added</&>:</td><td class="value">\
+% if ( $scrip->IsGlobal ) {
+<% loc('Global') %>
+% } else {
+% my $added_to = $scrip->AddedTo;
+% my $found = 0;
+% while ( my $queue = $added_to->Next ) {
+% $m->out(', ') if $found++;
+<% $queue->Name %>
+% last if $found == 10;
+% }
+% $m->out(', ...') if $found == 10;
+% }
+<td></tr>
+% }
+
+% if ( $added_to_any  ) {
+<tr><td class="label"> </td><td>
+<input type="hidden" class="hidden" name="SetEnabled" value="1" />
+<input type="checkbox" class="checkbox" name="Enabled" value="1" <% $EnabledChecked |n%> />
+<label for="Enabled"><&|/l&>Enabled (Unchecking this box disables this scrip)</&></label>
+</td></tr>
+% }
+
+</table>
+</&>
+
+<& /Elements/Submit, Label => loc('Save Changes'), Name => 'Update', Reset => 1 &>
+
+% if ($session{CurrentUser}->HasRight(Object => $RT::System, Right => 'ExecuteCode')) {
+<& Elements/EditCustomCode, %ARGS, Scrip => $scrip &>
+<& /Elements/Submit, Label => loc('Save Changes'), Name => 'Update', Reset => 1 &>
+% }
+
+</form>
+<%ARGS>
+$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))
+    unless $scrip->id;
+
+my $disabled = $scrip->Disabled;
+my $added_to_any = 0;
+$added_to_any = 1 if defined $disabled;
+
+if ( $Update ) {
+    my @attribs = qw(
+        Description
+        ScripAction ScripCondition Template
+        CustomPrepareCode CustomCommitCode CustomIsApplicableCode
+    );
+    if ( $ARGS{'SetEnabled'} && $added_to_any ) {
+        push @attribs, 'Disabled';
+        $ARGS{"Disabled"} = $ARGS{"Enabled"}? 0 : 1;
+    }
+    my @results = UpdateRecordObject(
+        AttributesRef   => \@attribs,
+        Object          => $scrip,
+        ARGSRef         => \%ARGS
+    );
+    MaybeRedirectForResults(
+        Actions   => \@results,
+        Arguments => { id => $scrip->id },
+    );
 }
-</%init>
+
+my $EnabledChecked = qq[checked="checked"];
+$EnabledChecked = '' if $disabled;
+
+my @results;
+my ($ok, $msg) = $scrip->CompileCheck;
+push @results, $msg if !$ok;
+</%INIT>
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index e7a98a5..b7cc760 100755
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -149,7 +149,7 @@ my $build_admin_menu = sub {
         if ( $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'ModifyScrips' ) ) {
             my $cfs = $admin->child( 'scrips' => title => loc('Scrips'), path => '/Admin/Scrips/', description => loc('Manage scrips') );
             $cfs->child( select => title => loc('Select'), path   => "/Admin/Scrips/" );
-            $cfs->child( create => title => loc('Create'), path => "/Admin/Scrips/Modify.html?Create=1" );
+            $cfs->child( create => title => loc('Create'), path => "/Admin/Scrips/Create.html" );
         }
 
         my $admin_global = $admin->child( global => title => loc('Global'), path   => '/Admin/Global/', description => loc('Manage properties and configuration which apply to all queues') );

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


More information about the Rt-commit mailing list