[Rt-commit] r16473 - in rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas: .
ruz at bestpractical.com
ruz at bestpractical.com
Tue Oct 21 22:16:33 EDT 2008
Author: ruz
Date: Tue Oct 21 22:16:33 2008
New Revision: 16473
Added:
rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/
rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/Elements/
rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/Elements/Tabs
rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/Interface.html
rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/Modify.html
rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/Transitions.html
rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/index.html
Log:
* add admin interface for status schemas
Added: rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/Elements/Tabs
==============================================================================
--- (empty file)
+++ rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/Elements/Tabs Tue Oct 21 22:16:33 2008
@@ -0,0 +1,39 @@
+<& /Admin/Elements/SystemTabs,
+ title => $title,
+ current_tab => "$base/index.html",
+ current_subtab => "$base/Modify.html?$qs_name",
+ subtabs => $subtabs,
+&>
+<%INIT>
+my $base = "Admin/Global/StatusSchemas";
+my $qs_name = $m->comp( '/Elements/QueryString', name => $schema->name );
+$current_tab .= "?$qs_name";
+my $subtabs = {
+ A => {
+ title => _("Status schema '%1'", $schema->name),
+ path => "$base/Modify.html?$qs_name",
+ current_subtab => $current_tab,
+ subtabs => {
+ A => {
+ title => _("Statuses"),
+ path => "$base/Modify.html?$qs_name",
+ },
+ B => {
+ title => _("Transitions"),
+ path => "$base/Transitions.html?$qs_name",
+ },
+ C => {
+ title => _("Interface"),
+ path => "$base/Interface.html?$qs_name",
+ },
+ },
+ },
+};
+
+</%INIT>
+
+<%ARGS>
+$schema
+$title => undef
+$current_tab => 'Admin/Global/StatusSchemas/Modify.html'
+</%ARGS>
Added: rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/Interface.html
==============================================================================
--- (empty file)
+++ rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/Interface.html Tue Oct 21 22:16:33 2008
@@ -0,0 +1,90 @@
+<&| /Admin/Elements/Header, title => $title &>
+
+<& Elements/Tabs,
+ title => $title,
+ schema => $schema,
+ current_tab => 'Admin/Global/StatusSchemas/Interface.html',
+&>
+
+<& /Elements/ListActions, actions => \@results &>
+
+<form action="<% RT->config->get('WebPath') %>/Admin/Global/StatusSchemas/Interface.html" method="post">
+<input type="hidden" name="name" value="<% $name %>" />
+
+<&| /Widgets/TitleBox, title => _('Transition labels') &>
+<table>
+<tr><th><% _('From') %></th><th> </th><th><% _('To') %></th><th><% _('Label') %></th></tr>
+% foreach my $from ( @valid ) {
+% my @next = $schema->transitions( $from );
+<tr><td rowspan="<% @next +0 %>"><% _($from) %></td><td rowspan="<% @next +0 %>">→</td>
+% foreach my $to ( @next ) {
+% $m->out('<tr>') if $to ne $next[0];
+<td><% _($to) %></td>
+<td><input type="text" name="<% $from .'->(tl)->'. $to %>" value="<% $schema->transition_label( $from => $to ) %>" /></td></tr>
+% }
+<tr><td colspan="4"> </td></tr>
+% }
+</table>
+</&>
+
+<&| /Widgets/TitleBox, title => _('Ticket actions on transitions') &>
+<table>
+<tr><th><% _('From') %></th><th> </th><th><% _('To') %></th><th><% _('Action') %></th></tr>
+% foreach my $from ( @valid ) {
+% my @next = $schema->transitions( $from );
+<tr><td rowspan="<% @next +0 %>"><% _($from) %></td><td rowspan="<% @next +0 %>">→</td>
+% foreach my $to ( @next ) {
+% $m->out('<tr>') if $to ne $next[0];
+% my $cur = $schema->transition_action( $from => $to );
+<td><% _($to) %></td>
+<td><select name="<% $from .'->(ta)->'. $to %>">
+<option value="" <% $cur? '': 'selected="selected"' |n %>><% _('no action') %></option>
+<option value="hide" <% $cur eq 'hide'? 'selected="selected"': '' |n %> ><% _('hide') %></option>
+<option value="comment" <% $cur eq 'comment'? 'selected="selected"': '' |n %> ><% _('comment') %></option>
+<option value="respond" <% $cur eq 'respond'? 'selected="selected"': '' |n %> ><% _('correspond') %></option>
+</select></td>
+</tr>
+% }
+<tr><td colspan="4"> </td></tr>
+% }
+</table>
+</&>
+
+<& /Elements/Submit, label => _('Update'), name => 'update' &>
+</form>
+
+</&>
+
+<%INIT>
+my $title = _("Modify transitions for schema '%1'", $name);
+
+use RT::StatusSchema;
+my $schema = RT::StatusSchema->new->load( $name );
+unless ( $schema ) {
+ Jifty->web->redirect(
+ RT->config->get('WebPath')
+ . '/Admin/Global/StatusSchemas/index.html'
+ );
+}
+
+my @valid = $schema->valid;
+
+my @results;
+if ( $update ) {
+ my %tmp = ();
+ foreach my $from ( @valid ) {
+ foreach my $to ( @valid ) {
+ next if $from eq $to;
+ $tmp{ $from .' -> '. $to }[0] = $ARGS{ $from .'->(tl)->'. $to };
+ $tmp{ $from .' -> '. $to }[1] = $ARGS{ $from .'->(ta)->'. $to };
+ }
+ }
+ my ($status, $msg) = $schema->set_actions( %tmp );
+ push @results, $msg if $msg;
+}
+
+</%INIT>
+<%ARGS>
+$name => undef
+$update => undef
+</%ARGS>
Added: rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/Modify.html
==============================================================================
--- (empty file)
+++ rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/Modify.html Tue Oct 21 22:16:33 2008
@@ -0,0 +1,59 @@
+<&| /Admin/Elements/Header, title => $title &>
+
+<& Elements/Tabs,
+ title => $title,
+ schema => $schema,
+ current_tab => 'Admin/Global/StatusSchemas/Modify.html',
+&>
+
+<& /Elements/ListActions, actions => \@results &>
+
+<form action="<% RT->config->get('WebPath') %>/Admin/Global/StatusSchemas/Modify.html" method="post">
+<input type="hidden" name="name" value="<% $name %>" />
+
+% foreach my $type (qw(Initial Active Inactive)) { # loc
+% my $method = lc $type;
+<% _($type) %>: <input name="<% $method %>" value="<% $ARGS{ $method } || join ', ', $schema->$method() %>" size="40" /><br />
+% }
+
+<& /Elements/Submit, label => _('Update'), name => 'update' &>
+</form>
+
+</&>
+
+<%INIT>
+my $title = _("Modify system status schemas", $name);
+
+use RT::StatusSchema;
+my $schema = RT::StatusSchema->new->load( $name );
+unless ( $schema ) {
+ Jifty->web->redirect(
+ RT->config->get('WebPath')
+ . '/Admin/Global/StatusSchemas/index.html'
+ );
+}
+
+my @results;
+if ( $update ) {
+ my %tmp;
+ foreach my $type ( qw(initial active inactive) ) {
+ $tmp{ $type } = [
+ grep length && defined,
+ map { s/^\s+//; s/\s+$//; $_}
+ split /\s*,\s*/,
+ $ARGS{ $type } || ''
+ ];
+ }
+ my ($status, $msg) = $schema->set_statuses( %tmp );
+ push @results, $msg if $msg;
+
+ foreach my $type ( qw(initial active inactive) ) {
+ $ARGS{ $type } = join ', ', $schema->$type();
+ }
+}
+
+</%INIT>
+<%ARGS>
+$name => undef
+$update => undef
+</%ARGS>
Added: rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/Transitions.html
==============================================================================
--- (empty file)
+++ rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/Transitions.html Tue Oct 21 22:16:33 2008
@@ -0,0 +1,63 @@
+<&| /Admin/Elements/Header, title => $title &>
+
+<& Elements/Tabs,
+ title => $title,
+ schema => $schema,
+ current_tab => 'Admin/Global/StatusSchemas/Transitions.html',
+&>
+
+<& /Elements/ListActions, actions => \@results &>
+
+<form action="<% RT->config->get('WebPath') %>/Admin/Global/StatusSchemas/Transitions.html" method="post">
+<input type="hidden" name="name" value="<% $name %>" />
+
+<table>
+<tr><th><% _('From') %></th><th rowspan="<% @valid + 1 %>">→</th><th colspan="<% @valid + 0 %>"><% _('To (check valid transitions)') %></th></tr>
+% foreach my $from ( @valid ) {
+<tr><th><% _($from) %></th>
+% foreach my $to ( @valid ) {
+% my $checked = grep $_ eq $to, $schema->transitions( $from );
+% if ( $from ne $to ) {
+<td><nobr><input type="checkbox" name="<% $from .'->' %>" value="<% $to %>" <% $checked? 'checked="checked"': '' |n %> /> <% _($to) %></nobr></td>
+% } else {
+<td> </td>
+% }
+% } }
+</table>
+
+<& /Elements/Submit, label => _('Update'), name => 'update' &>
+</form>
+
+</&>
+
+<%INIT>
+my $title = _("Modify transitions for schema '%1'", $name);
+
+use RT::StatusSchema;
+my $schema = RT::StatusSchema->new->load( $name );
+unless ( $schema ) {
+ Jifty->web->redirect(
+ RT->config->get('WebPath')
+ . '/Admin/Global/StatusSchemas/index.html'
+ );
+}
+
+my @valid = $schema->valid;
+
+my @results;
+if ( $update ) {
+ my %tmp;
+ foreach my $status ( @valid ) {
+ my $v = $ARGS{ $status .'->' };
+ my @list = grep $schema->is_valid( $_ ), $v? ( ref $v? @{ $v }: ($v) ): ();
+ $tmp{ $status } = \@list;
+ }
+ my ($status, $msg) = $schema->set_transitions( %tmp );
+ push @results, $msg if $msg;
+}
+
+</%INIT>
+<%ARGS>
+$name => undef
+$update => undef
+</%ARGS>
Added: rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/index.html
==============================================================================
--- (empty file)
+++ rt/branches/3.999-DANGEROUS/share/html/Admin/Global/StatusSchemas/index.html Tue Oct 21 22:16:33 2008
@@ -0,0 +1,62 @@
+<&| /Admin/Elements/Header, title => $title &>
+
+<& /Admin/Elements/SystemTabs,
+ current_tab => 'Admin/Global/StatusSchemas/index.html',
+ current_subtab => 'Admin/Global/StatusSchemas/index.html',
+ title => $title,
+&>
+
+<& /Elements/ListActions, actions => \@results &>
+
+<ul>
+% foreach my $schema ( @list ) {
+<li><a href="<% RT->config->get('WebPath') %>/Admin/Global/StatusSchemas/Modify.html?<% $m->comp( '/Elements/QueryString', name => $schema ) %>"><% $schema %></a></li>
+% }
+</ul>
+
+<form action="<% RT->config->get('WebPath') %>/Admin/Global/StatusSchemas/index.html" method="post">
+
+Status schema name: <input name="name" value="" /><br />
+
+<& /Elements/Submit, caption => _('Create a new status schema'), label => _('Create'), name => 'create' &>
+</form>
+
+</&>
+
+<%INIT>
+my $title = _("Modify system status schemas");
+
+use RT::StatusSchema;
+my @list = RT::StatusSchema->new->list;
+
+my $subtabs = {
+ A => {
+ title => _('Select scrip'),
+ path => "Admin/Global/Scrips.html",
+ },
+ B => {
+ title => _('New scrip'),
+ path => "Admin/Global/Scrip.html?create=1&queue=0",
+ separator => 1,
+ }
+};
+
+my @results;
+if ( $create ) {
+ my $schema = new RT::StatusSchema;
+ my ($status, $msg) = $schema->create( name => $name );
+ push @results, $msg if $msg;
+ if ( $status ) {
+ Jifty->web->redirect(
+ RT->config->get('WebPath')
+ . '/Admin/Global/StatusSchemas/Modify.html?'
+ . $m->comp( '/Elements/QueryString', name => $schema->name )
+ );
+ }
+}
+
+</%INIT>
+<%ARGS>
+$name => undef
+$create => undef
+</%ARGS>
More information about the Rt-commit
mailing list