[Bps-public-commit] rt-extension-notificationmatrix branch, master, created. 9e08cdf55e47b592658f77ad7badcf3f4126113f
Chia-liang Kao
clkao at bestpractical.com
Mon Jun 14 09:46:50 EDT 2010
The branch, master has been created
at 9e08cdf55e47b592658f77ad7badcf3f4126113f (commit)
- Log -----------------------------------------------------------------
commit 6f7a60786be3d544afaf43199fc9617b89d55668
Author: Chia-liang Kao <clkao at clkao.org>
Date: Mon Jun 14 18:15:19 2010 +0800
first cut of notification matrix UI
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..dcc22e8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,15 @@
+META.yml
+Makefile
+Makefile.old
+MANIFEST
+MANIFEST.bak
+SIGNATURE
+blib/
+inc/
+mason*/
+pm_to_blib
+var/
+*.swp
+*.swo
+.prove
+*~
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644
index 0000000..f1ecb28
--- /dev/null
+++ b/Makefile.PL
@@ -0,0 +1,4 @@
+use inc::Module::Install;
+RTx('RT-Extension-NotificationMatrix');
+WriteAll();
+
diff --git a/html/Admin/Queues/NotificationMatrix.html b/html/Admin/Queues/NotificationMatrix.html
new file mode 100644
index 0000000..4917af2
--- /dev/null
+++ b/html/Admin/Queues/NotificationMatrix.html
@@ -0,0 +1,64 @@
+<& /Admin/Elements/Header, Title => $title &>
+<& /Admin/Elements/QueueTabs, id => $QueueObj->id,
+ QueueObj => $QueueObj,
+ current_tab => 'Admin/Queues/NotificationMatrix.html?id='.$id,
+ Title => $title &>
+<form>
+<input type="hidden" name="SetMatrix" value="1">
+<table class="notification-matrix">
+<tr>
+<th>\</th>
+% for my $Group (@groups) {
+ <th><% $Group->SelfDescription %></th>
+% }
+</tr>
+% for my $action (@actions) {
+<tr>
+<th><% $action %></th>
+% for my $Group (@groups) {
+<td><input type="checkbox" name="NM-<% $action %>-<% $Group->Id %>" <% $matrix_hash->{$action}{$Group->Id} ? 'checked' : '' %> />
+</td>
+% }
+</tr>
+% }
+
+</table>
+<& /Elements/Submit, Name => "Save", Label => loc('Save Changes') &>
+</form>
+<%init>
+
+my $QueueObj = RT::Queue->new($session{'CurrentUser'});
+$QueueObj->Load($id);
+
+my $title;
+
+if ($QueueObj->id) {
+ $title = loc("Modify notification matrix for queue [_1]", $QueueObj->Name);
+} else {
+ Abort(loc("Queue [_1] not found",$id));
+}
+
+my $Groups = RT::Groups->new($session{'CurrentUser'});
+$Groups->LimitToRolesForQueue($QueueObj->Id);
+
+my @groups = @{ $Groups->ItemsArrayRef };
+
+my @actions = qw(TicketCreated OnComment OnResolve);
+
+my $matrix;
+
+if ($ARGS{SetMatrix}) {
+ for my $action (@actions) {
+ $matrix->{$action} = [ map { s/NM-\Q$action\E-// ? $_ : () } keys %ARGS ];
+ }
+ $QueueObj->SetAttribute(Name => 'NotificationMatrix', Description => 'Notification Matrix Internal Data', Content => $matrix);
+}
+else {
+ $matrix = $QueueObj->FirstAttribute('NotificationMatrix') || {};
+}
+
+my $matrix_hash = { map { $_ => { map { $_ => 1 } @{$matrix->{$_}} } } keys %$matrix };
+</%init>
+<%args>
+$id => 1 #some identifier that a Queue could
+</%args>
diff --git a/html/test.html b/html/test.html
new file mode 100644
index 0000000..c416592
--- /dev/null
+++ b/html/test.html
@@ -0,0 +1,24 @@
+<& /Admin/Elements/Header, Title => $title &>
+<& /Admin/Elements/QueueTabs, id => $QueueObj->id,
+ QueueObj => $QueueObj,
+ current_tab => 'Admin/Queues/Scrips.html?id='.$id,
+ current_subtab => 'Admin/Queues/Scrips.html?id='.$id,
+ subtabs => $subtabs,
+ Title => $title &>
+
+<%init>
+
+my $QueueObj = RT::Queue->new($session{'CurrentUser'});
+$QueueObj->Load($id);
+
+my $title;
+
+if ($QueueObj->id) {
+ $title = loc("Modify notification matrix for queue [_1]", $QueueObj->Name);
+} else {
+ Abort(loc("Queue [_1] not found",$id));
+}
+</%init>
+<%args>
+$id => 1 #some identifier that a Queue could
+</%args>
diff --git a/lib/RT/Extension/NotificationMatrix.pm b/lib/RT/Extension/NotificationMatrix.pm
new file mode 100644
index 0000000..0b09da9
--- /dev/null
+++ b/lib/RT/Extension/NotificationMatrix.pm
@@ -0,0 +1,13 @@
+use warnings;
+use strict;
+
+package RT::Extension::NotificationMatrix;
+our $VERSION = '1.6';
+
+RT::Ruleset->Add(
+ Name => 'NotificationMatrix',
+ Rules => [
+ 'RT::Extension::NotificationMatrix::Notify',
+ ]);
+
+1;
diff --git a/lib/RT/Extension/NotificationMatrix/Notify.pm b/lib/RT/Extension/NotificationMatrix/Notify.pm
new file mode 100644
index 0000000..6d1c893
--- /dev/null
+++ b/lib/RT/Extension/NotificationMatrix/Notify.pm
@@ -0,0 +1,15 @@
+package RT::Extension::WF::AccountRequest::Approval;
+use strict;
+use warnings;
+
+use base 'RT::Rule';
+
+sub Prepare {
+ return 0;
+}
+
+sub Commit {
+
+}
+
+1;
commit daac1736da0bbcb8dde45842b9236d07927899ba
Author: Chia-liang Kao <clkao at clkao.org>
Date: Mon Jun 14 19:23:58 2010 +0800
fix attribute loading
diff --git a/html/Admin/Queues/NotificationMatrix.html b/html/Admin/Queues/NotificationMatrix.html
index 4917af2..c10b6c1 100644
--- a/html/Admin/Queues/NotificationMatrix.html
+++ b/html/Admin/Queues/NotificationMatrix.html
@@ -54,7 +54,8 @@ if ($ARGS{SetMatrix}) {
$QueueObj->SetAttribute(Name => 'NotificationMatrix', Description => 'Notification Matrix Internal Data', Content => $matrix);
}
else {
- $matrix = $QueueObj->FirstAttribute('NotificationMatrix') || {};
+ my $attr = $QueueObj->FirstAttribute('NotificationMatrix');
+ $matrix = $attr ? $attr->Content : {};
}
my $matrix_hash = { map { $_ => { map { $_ => 1 } @{$matrix->{$_}} } } keys %$matrix };
commit 9e08cdf55e47b592658f77ad7badcf3f4126113f
Author: Chia-liang Kao <clkao at clkao.org>
Date: Mon Jun 14 20:03:37 2010 +0800
UI for adding userdefined groups into the matrix.
diff --git a/html/Admin/Queues/NotificationMatrix.html b/html/Admin/Queues/NotificationMatrix.html
index c10b6c1..5d0a770 100644
--- a/html/Admin/Queues/NotificationMatrix.html
+++ b/html/Admin/Queues/NotificationMatrix.html
@@ -3,7 +3,28 @@
QueueObj => $QueueObj,
current_tab => 'Admin/Queues/NotificationMatrix.html?id='.$id,
Title => $title &>
-<form>
+
+<form method="post">
+Find User defined groups:
+<input name="GroupString" value="<% $GroupString %>">
+<& /Elements/Submit, Name => "Save", Label => loc('Search') &>
+
+</form>
+
+% if ($UserGroups) {
+<form method="post">
+<input type="hidden" name="SelectUserGroup" value="1">
+
+% while (my $Group = $UserGroups->Next()) {
+ <input type="checkbox" name="SelectUserGroup-<% $Group->Id %>"><% $Group->SelfDescription %><br>
+% }
+<& /Elements/Submit, Name => "Save", Label => loc('Subscribe to Queue notification') &>
+
+% }
+
+</form>
+
+<form method="post">
<input type="hidden" name="SetMatrix" value="1">
<table class="notification-matrix">
<tr>
@@ -46,6 +67,22 @@ my @groups = @{ $Groups->ItemsArrayRef };
my @actions = qw(TicketCreated OnComment OnResolve);
my $matrix;
+my $UserGroups;
+if ($GroupString) {
+ $UserGroups = RT::Groups->new($session{'CurrentUser'});
+ $UserGroups->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'UserDefined');
+ $UserGroups->Limit(FIELD => 'Name',
+ VALUE => $GroupString,
+ OPERATOR => 'LIKE');
+}
+
+if ($ARGS{SelectUserGroup}) {
+ for (map { s/SelectUserGroup-// ? $_ : () } keys %ARGS) {
+ my $group = RT::Group->new($session{'CurrentUser'});
+ $group->LoadUserDefinedGroup($_);
+ push @groups, $group if $group->Id;
+ }
+}
if ($ARGS{SetMatrix}) {
for my $action (@actions) {
@@ -58,8 +95,22 @@ else {
$matrix = $attr ? $attr->Content : {};
}
+my $group_hash = { map { $_->Id => 1 } @groups };
my $matrix_hash = { map { $_ => { map { $_ => 1 } @{$matrix->{$_}} } } keys %$matrix };
+
+use List::MoreUtils qw(uniq);
+
+
+for (uniq map { @{$matrix->{$_}} } keys %$matrix) {
+ unless ($group_hash->{$_}) {
+ my $group = RT::Group->new($session{'CurrentUser'});
+ $group->LoadUserDefinedGroup($_);
+ push @groups, $group if $group->Id;
+ }
+}
+
</%init>
<%args>
$id => 1 #some identifier that a Queue could
+$GroupString => ''
</%args>
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list