[Rt-commit] r9895 - in rt/branches/3.6-EXPERIMENTAL-ABERDEEN:
lib/RT/Extension
audreyt at bestpractical.com
audreyt at bestpractical.com
Tue Dec 11 17:40:23 EST 2007
Author: audreyt
Date: Tue Dec 11 17:40:16 2007
New Revision: 9895
Modified:
rt/branches/3.6-EXPERIMENTAL-ABERDEEN/html/Admin/RuleManager/Modify.html
rt/branches/3.6-EXPERIMENTAL-ABERDEEN/html/Admin/RuleManager/index.html
rt/branches/3.6-EXPERIMENTAL-ABERDEEN/lib/RT/Extension/RuleManager.pm
Log:
* Finish UI with proper support for deletion.
Modified: rt/branches/3.6-EXPERIMENTAL-ABERDEEN/html/Admin/RuleManager/Modify.html
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-ABERDEEN/html/Admin/RuleManager/Modify.html (original)
+++ rt/branches/3.6-EXPERIMENTAL-ABERDEEN/html/Admin/RuleManager/Modify.html Tue Dec 11 17:40:16 2007
@@ -107,9 +107,9 @@
% if ($1 eq 'template') {
<textarea rows=10 cols=80 name="Argument"><% $default %></textarea>
% } elsif ($1 eq 'queue') {
-<& /Elements/SelectQueue, Name => 'Argument', Default => $default, ShowNullOption => 0 &>
+<& /Elements/SelectQueue, Name => 'Argument', Default => $default, ShowNullOption => 1 &>
% } elsif ($1 eq 'user') {
-<& /Elements/SelectOwner, Name => 'Argument', Default => $default, DefaultValue => 0 &>
+<& /Elements/SelectOwner, Name => 'Argument', Default => $default, DefaultValue => 1 &>
% } else {
<input name="Argument" value="<% $default %>" />
% }
@@ -144,7 +144,7 @@
}
else {
if ($id eq 'new') {
- $RuleObj = RT::Extension::RuleManager->create(Name => $Name);
+ $RuleObj = RT::Extension::RuleManager->create(%ARGS);
push @results, loc('Rule created.');
}
elsif ($id =~ /^\d+$/) {
Modified: rt/branches/3.6-EXPERIMENTAL-ABERDEEN/html/Admin/RuleManager/index.html
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-ABERDEEN/html/Admin/RuleManager/index.html (original)
+++ rt/branches/3.6-EXPERIMENTAL-ABERDEEN/html/Admin/RuleManager/index.html Tue Dec 11 17:40:16 2007
@@ -73,7 +73,12 @@
<a href="Modify.html?id=<%$rule->id%>"><% length($rule->Name) ? $rule->Name : '(#'.$rule->Id.')' %></a>
<br />
<tt>></tt> <strong><% $rule->Field %></strong> matches <strong><% $rule->PrettyPattern %></strong><br />
-<tt>=</tt> <% $rule->Handler %> <strong><% $rule->PrettyArgument %></strong>
+<tt>=</tt> <% $rule->Handler %>
+% if (length(my $arg = $rule->PrettyArgument)) {
+<strong><% $rule->PrettyArgument %></strong>
+% } else {
+<em>(<&|/l&>none</&>)</em>
+% }
% if ($rule->Final) {
<br />
<tt>+</tt> <em><&|/l&>Stop processing the rules after this one.</&></em>
@@ -81,20 +86,26 @@
</td>
<td style="white-space: nowrap" width="1"
% if ($rule->Id > 1) {
->[<a href="#"><&|/l&>Move up</&></a>]</td
+>[<a href="index.html?Raise=<% $rule->Id %>"><&|/l&>Move up</&></a>]</td
% }
>
<td style="white-space: nowrap" width="1"
% if ($rule->Id < @$rules) {
->[<a href="#"><&|/l&>Move down</&></a>]</td
+>[<a href="index.html?Raise=<% $rule->Id+1 %>"><&|/l&>Move down</&></a>]</td
% }
>
-<td style="white-space: nowrap" width="1">[<a href="#"><&|/l&>Delete</&></a>]</td>
+<td style="white-space: nowrap" width="1">[<a href="index.html?Delete=<% $rule->Id %>" onclick="return confirm('<&|/l&>Really delete this rule?</&>')"><&|/l&>Delete</&></a>]</td>
</tr>
%}
% }
</td></tr></table>
<%INIT>
require RT::Extension::RuleManager;
+RT::Extension::RuleManager->raise($Raise) if $Raise;
+RT::Extension::RuleManager->delete($Delete) if $Delete;
my $rules = RT::Extension::RuleManager->rules;
</%INIT>
+<%ARGS>
+$Raise => undef
+$Delete => undef
+</%ARGS>
Modified: rt/branches/3.6-EXPERIMENTAL-ABERDEEN/lib/RT/Extension/RuleManager.pm
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-ABERDEEN/lib/RT/Extension/RuleManager.pm (original)
+++ rt/branches/3.6-EXPERIMENTAL-ABERDEEN/lib/RT/Extension/RuleManager.pm Tue Dec 11 17:40:16 2007
@@ -51,6 +51,17 @@
@{$rules}[$id-1, $id-2] = @{$rules}[$id-2, $id-1];
$rules->[$id-1]{_pos} = $id-1;
$rules->[$id-2]{_pos} = $id-2;
+ $self->_save($rules);
+ return $id;
+}
+
+sub delete {
+ my $self = shift;
+ my $id = shift;
+ my $rules = $self->rules;
+ return undef if $id <= 0 or $id > @$rules;
+ splice @$rules, $id-1, 1;
+ $self->_save($rules);
return $id;
}
More information about the Rt-commit
mailing list