[Rt-commit] r9875 - in rt/branches/3.6-EXPERIMENTAL-ABERDEEN:
lib/RT/Extension
audreyt at bestpractical.com
audreyt at bestpractical.com
Mon Dec 10 15:17:44 EST 2007
Author: audreyt
Date: Mon Dec 10 15:17:38 2007
New Revision: 9875
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:
* Finished mock-UI of RuleManager. Now the backend semantic begins!
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 Mon Dec 10 15:17:38 2007
@@ -72,7 +72,7 @@
<td>
<& SELF:Select,
Name => 'Field',
- Options => [RT::Extension::RuleManager::FieldOptions],
+ Options => [RT::Extension::RuleManager::FieldOptions()],
Default => ($Create ? '' : $RuleObj->Field),
&>
</td>
@@ -90,18 +90,29 @@
<td>
<& SELF:Select,
Name => 'Handler',
- Options => [RT::Extension::RuleManager::HandlerOptions],
+ Options => [RT::Extension::RuleManager::HandlerOptions()],
Default => ($Create ? '' : $RuleObj->Handler),
Refresh => 1,
&>
</td>
</tr>
-% if (!$Create and $RuleObj->Handler =~ /:$/) {
+% if (!$Create and $RuleObj->Handler =~ /(\w+):$/) {
+% my $default = ($Create) ? '' : $RuleObj->Argument ;
<tr><td align="right">
<&|/l&>Argument</&>:
</td>
-<td><input name="Argument" value="<% ($Create) ? "" : $RuleObj->Argument %>" /></td>
+<td>
+% 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 &>
+% } elsif ($1 eq 'user') {
+<& /Elements/SelectOwner, Name => 'Argument', Default => $default, DefaultValue => 0 &>
+% } else {
+<input name="Argument" value="<% $default %>" />
+% }
+</td>
</tr>
% }
@@ -150,7 +161,7 @@
if ($RuleObj and $RuleObj->Id) {
$ARGS{Final} = '' unless $ARGS{Final};
- $RuleObj->UpdateRecordObject(\%ARGS);
+ push @results, loc('Rule saved.') if $RuleObj->UpdateRecordObject(\%ARGS);
}
</%INIT>
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 Mon Dec 10 15:17:38 2007
@@ -62,23 +62,38 @@
-->
<h2><&|/l&>Select a rule</&>:</h2>
-<ul>
%if (@$rules == 0) {
<li><em><&|/l&>No rules found.</&></em></li>
-% }
+% } else {
+<table border=0 cellpadding=0 cellspacing=0>
%for my $rule (@$rules) {
-<li>
+<tr valign="top"><td>
+<% $rule->Id %>.
+</td><td>
<a href="Modify.html?id=<%$rule->id%>"><% length($rule->Name) ? $rule->Name : '(#'.$rule->Id.')' %></a>
<br />
-<% $rule->Field %> matches <<tt><% $rule->PrettyPattern %></tt>><br />
-= <% $rule->Handler %> <% $rule->PrettyArgument %>
+<tt>?</tt> <strong><% $rule->Field %></strong> matches <tt><strong><% $rule->PrettyPattern %></strong></tt><br />
+<tt>=</tt> <% $rule->Handler %> <strong><% $rule->PrettyArgument %></strong>
% if ($rule->Final) {
<br />
-+ <em><&|/l&>Stop processing the rules after this one.</&></em>
+<tt>+</tt> <&|/l&>Stop processing the rules after this one.</&>
+% }
+</td>
+<td style="white-space: nowrap" width="1"
+% if ($rule->Id > 1) {
+>[<a href="#"><&|/l&>Move up</&></a>]</td
% }
-</li>
+>
+<td style="white-space: nowrap" width="1"
+% if ($rule->Id < @$rules) {
+>[<a href="#"><&|/l&>Move down</&></a>]</td
+% }
+>
+<td style="white-space: nowrap" width="1">[<a href="#"><&|/l&>Delete</&></a>]</td>
+</tr>
%}
-</ul>
+% }
+</td></tr></table>
<%INIT>
require RT::Extension::RuleManager;
my $rules = RT::Extension::RuleManager->rules;
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 Mon Dec 10 15:17:38 2007
@@ -121,15 +121,46 @@
my $updated;
foreach my $field (Fields) {
exists $args->{$field} or next;
- $updated = 1;
+ $updated ||= ($self->{$field} ne $args->{$field});
$self->{$field} = $args->{$field};
}
RT::Extension::RuleManager->_save($self->{_root}) if $updated;
+ return $updated;
}
sub PrettyArgument {
my $self = shift;
- ($self->Handler =~ /:$/) ? $self->Argument : '';
+ if ($self->Handler =~ /(\w+):$/) {
+ if ($1 eq 'template') {
+ my ($first_line, $rest) = split(/[\r\n]+/, $self->Argument, 2);
+ chomp $first_line;
+ if (length($first_line) > 40) {
+ return substr($first_line, 0, 40) . '...';
+ }
+ elsif ($rest =~ /\S/) {
+ return "$first_line...";
+ }
+ else {
+ return $first_line;
+ }
+ }
+ elsif ($1 eq 'user') {
+ my $user = RT::User->new($RT::SystemUser);
+ $user->Load($self->Argument);
+ return $user->Name;
+ }
+ elsif ($1 eq 'queue') {
+ my $queue = RT::Queue->new($RT::SystemUser);
+ $queue->Load($self->Argument);
+ return $queue->Name;
+ }
+ else {
+ return $self->Argument;
+ }
+ }
+ else {
+ '';
+ }
}
sub PrettyPattern {
More information about the Rt-commit
mailing list