[Rt-commit] rt branch, 4.6/lifecycle-ui-dev, updated. rt-4.4.4-735-gc68ffb4d36
Craig Kaiser
craig at bestpractical.com
Thu Feb 6 10:35:45 EST 2020
The branch, 4.6/lifecycle-ui-dev has been updated
via c68ffb4d36e1c52fe1deebf1e19e9e4000700107 (commit)
via b7e4de1bd67c4c3b5c38998fddc2b11a3d93b31e (commit)
via c8d9e4aaf8da02c74ab6dfa1e774ae03e728d1c7 (commit)
via 8edf83e4f83bee258105d0d4b162cf9ff3465b8e (commit)
from 2cad9fdf1b0767ad2fd4fbeafc2a81a8a5795998 (commit)
Summary of changes:
lib/RT/Lifecycle.pm | 17 +++-
share/html/Admin/Lifecycles/Actions.html | 19 +++-
share/html/Admin/Lifecycles/Mappings.html | 4 +-
share/html/Admin/Lifecycles/Rights.html | 21 ++++-
share/html/Admin/Lifecycles/index.html | 138 ++++++++++++++++++++++++------
5 files changed, 165 insertions(+), 34 deletions(-)
- Log -----------------------------------------------------------------
commit 8edf83e4f83bee258105d0d4b162cf9ff3465b8e
Author: Craig Kaiser <craig at bestpractical.com>
Date: Wed Feb 5 10:49:05 2020 -0500
Increase column size on lifecycle mappings page
diff --git a/share/html/Admin/Lifecycles/Mappings.html b/share/html/Admin/Lifecycles/Mappings.html
index 27f8f90d0a..44238f3642 100644
--- a/share/html/Admin/Lifecycles/Mappings.html
+++ b/share/html/Admin/Lifecycles/Mappings.html
@@ -61,7 +61,7 @@
<&| /Widgets/TitleBox, title => "Support Mappings with ".$Other->Name &>
<div class="form-row">
- <div class="col-md-3">
+ <div class="col-md-4">
<h3><&|/l, $Other->Name, $LifecycleObj->Name &>Changing from [_1] to [_2]:</&></h3>
% for my $OtherStatus (@OtherStatuses) {
<div class="form-row">
@@ -73,7 +73,7 @@
% }
</div>
- <div class="col-md-3">
+ <div class="col-md-4">
<h3><&|/l, $LifecycleObj->Name, $Other->Name &>Changing from [_1] to [_2]:</&></h3>
% for my $MyStatus (@MyStatuses) {
<div class="form-row">
commit c8d9e4aaf8da02c74ab6dfa1e774ae03e728d1c7
Author: Craig Kaiser <craig at bestpractical.com>
Date: Thu Feb 6 09:42:49 2020 -0500
Allow for lifecycle to be set to disabled
diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 1ae7111600..7e964b65e3 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -204,7 +204,7 @@ sub ListAll {
my $self = shift;
my $for = shift || 'ticket';
- return sort grep {$LIFECYCLES_CACHE{$_}{type} eq $for}
+ return sort grep {$LIFECYCLES_CACHE{$_}{type} eq $for && !$LIFECYCLES_CACHE{$_}{disabled}}
grep $_ ne '__maps__', keys %LIFECYCLES_CACHE;
}
diff --git a/share/html/Admin/Lifecycles/index.html b/share/html/Admin/Lifecycles/index.html
index 33a19fea8d..35eb909a06 100644
--- a/share/html/Admin/Lifecycles/index.html
+++ b/share/html/Admin/Lifecycles/index.html
@@ -47,40 +47,122 @@
%# END BPS TAGGED BLOCK }}}
<& /Admin/Elements/Header, Title => loc("Admin Lifecycles") &>
<& /Elements/Tabs &>
+<& /Elements/ListActions, actions => \@results &>
-<h1><&|/l&>Lifecycles</&></h1>
+<form method="post" action="<% RT->Config->Get('WebPath') %>/Admin/Lifecycles/index.html">
+ <div class="form-row">
+ <div class="col-md-12">
+ <div class="custom-control custom-checkbox">
+ <input type="checkbox" class="custom-control-input checkbox" id="FindDisabledLifecycles" name="FindDisabledLifecycles" value="1" <% $FindDisabledLifecycles ? 'checked="checked"': '' |n%> />
+ <label class="custom-control-label" for="FindDisabledLifecycles"><&|/l&>Include disabled lifecycles in listing.</&></label>
+ </div>
+ </div>
+ </div>
-<table class="table collection collection-as-table" cellspacing="0">
- <tbody>
- <tr class="collection-as-table">
- <th class="collection-as-table">Name</th>
- <th class="collection-as-table">Type</th>
- </tr>
- </tbody>
- <tbody class="list-item">
+ <div class="form-row">
+ <div class="col-md-12">
+ <div align="left">
+ <input type="submit" name="Go" class="form-control btn btn-primary" value="<&|/l&>Go!</&>" />
+ </div>
+ </div>
+ </div>
+
+ <table class="table collection collection-as-table" cellspacing="0">
+ <tbody>
+ <tr class="collection-as-table">
+ <th class="collection-as-table">Name</th>
+ <th class="collection-as-table">Type</th>
+ <th class="collection-as-table">Enabled</th>
+ </tr>
% my $i = 0;
-% for my $lifecycle (@lifecycles) {
-% ++$i;
- <tr class="<% $i % 2 ? 'oddline' : 'evenline' %>">
- <td class="collection-as-table"><a href="<% RT->Config->Get('WebURL') %>Admin/Lifecycles/Modify.html?Type=<% $lifecycle->Type |u %>&Name=<% $lifecycle->Name |u %>"><% $lifecycle->Name %></a></td>
- <td class="collection-as-table"><% loc($lifecycle->Type) %></td>
- </tr>
+% for my $key ( sort keys %lifecycles ) {
+% next if grep { $key eq $_ } qw/approvals __maps__/;
+% next if $lifecycles{$key}{'disabled'} and !$FindDisabledLifecycles;
+
+ <tr class="<% $i % 2 ? 'oddline' : 'evenline' %>">
+ <td class="collection-as-table"><a href="<% RT->Config->Get('WebURL') %>Admin/Lifecycles/Modify.html?Type=<% $lifecycles{$key}{'type'} ? loc($lifecycles{$key}{'type'}) : loc('ticket') |u %>&Name=<% $key %>"><% $key %></a></td>
+ <td class="collection-as-table"><% $lifecycles{$key}{'type'} ? loc($lifecycles{$key}{'type'}) : loc('ticket') %></td>
+ <td class="collection-as-table">
+ <div class="custom-control custom-checkbox">
+ <input type="checkbox" class="custom-control-input checkbox" id="enable-lifecycle-<% $key %>" name="enable-lifecycle-<% $key %>" value="1" <% $lifecycles{$key}{'disabled'} ? '' : 'checked="checked"' %> />
+ <label class="custom-control-label" for="enable-lifecycle-<% $key %>"></label>
+ </div>
+ </td>
+ </tr>
+% ++$i;
% }
- </tbody>
-</table>
+ </tbody>
+ </table>
+
+ <div class="form-row">
+ <div class="col-md-12">
+ <div align="right">
+ <input type="submit" name="Submit" class="form-control btn btn-primary" value="<&|/l&>Update</&>" />
+ </div>
+ </div>
+ </div>
+
+</form>
<%INIT>
-my @types = List::MoreUtils::uniq(
- 'ticket',
- 'asset',
- sort keys %RT::Lifecycle::LIFECYCLES_TYPES,
-);
+my @results;
-my @lifecycles;
+my %lifecycles = ();
-for my $type (@types) {
- push @lifecycles, map { RT::Lifecycle->Load(Name => $_, Type => $type) }
- sort { loc($a) cmp loc($b) }
- grep { $_ ne 'approvals' }
- RT::Lifecycle->ListAll($type);
+my $setting = RT::Configuration->new($session{'CurrentUser'});
+$setting->Load('Lifecycles');
+if ( $setting->Id ) {
+ %lifecycles = %{$setting->_DeserializeContent( $setting->Content )};
}
+else {
+ %lifecycles = RT::Config->Get( "Lifecycles" );
+}
+if ( $Submit ) {
+ foreach my $lifecycle ( keys %lifecycles ) {
+ next if grep { $lifecycle eq $_ } qw/approvals __maps__/;
+ if ( $ARGS{"enable-lifecycle-$lifecycle"} ) {
+ if ( $lifecycles{$lifecycle}{'disabled'} && $lifecycles{$lifecycle}{'disabled'} eq 1 ) {
+ $lifecycles{$lifecycle}{'disabled'} = 0;
+ push @results, loc("Set lifecycle $lifecycle to enabled");
+ }
+ }
+ elsif ( !$lifecycles{$lifecycle}{'disabled'} ) {
+ $lifecycles{$lifecycle}{'disabled'} = 1;
+ push @results, loc("Set lifecycle $lifecycle to disabled");
+ }
+ }
+
+ if ( $setting->Id ) {
+ my ($ret, $msg) = $setting->SetContent( \%lifecycles );
+ if ( $ret ) {
+ RT::Logger->debug( "Updated lifecycle configuration content" );
+ RT::System->LifecycleCacheNeedsUpdate(1);
+ }
+ else {
+ RT::Logger->error( "Could not set lifeycle configuration content: $msg" );
+ }
+ }
+ else {
+ my ($ret, $msg) = $setting->Create(
+ Name => 'Lifecycles',
+ Content => \%lifecycles,
+ ContentType => 'perl',
+ );
+ if ( $ret ) {
+ RT::Logger->debug("Creating lifecycles configuration");
+ }
+ else {
+ RT::Logger->debug("Could not create lifecycles configuration: $msg" );
+ }
+ }
+}
+
+# This code does automatic redirection if any updates happen.
+MaybeRedirectForResults(
+ Actions => \@results,
+ Arguments => { FindDisabledLifecycles => $FindDisabledLifecycles },
+);
</%INIT>
+<%ARGS>
+$Submit => undef
+$FindDisabledLifecycles => undef
+</%ARGS>
commit b7e4de1bd67c4c3b5c38998fddc2b11a3d93b31e
Author: Craig Kaiser <craig at bestpractical.com>
Date: Thu Feb 6 10:12:48 2020 -0500
Add 'remove' checkbox for lifecycle rights and actions page"
diff --git a/share/html/Admin/Lifecycles/Actions.html b/share/html/Admin/Lifecycles/Actions.html
index 4ae408ed37..11561be982 100644
--- a/share/html/Admin/Lifecycles/Actions.html
+++ b/share/html/Admin/Lifecycles/Actions.html
@@ -60,6 +60,7 @@
<th class="collection-as-table">To Status</th>
<th class="collection-as-table">Label</th>
<th class="collection-as-table">Update</th>
+ <th class="collection-as-table"></th>
</tr>
</tbody>
<tbody class="list-item">
@@ -82,6 +83,12 @@
<option <% !$action->{'update'} ? qq[selected='selected'] : '' %> value="">None</option>
</select>
</td>
+ <td class="collection-as-table">
+ <div class="custom-control custom-checkbox">
+ <input type="checkbox" name="Delete-<% $i %>" id="Delete-<% $i %>" value="1" class="custom-control-input"/>
+ <label class="custom-control-label" for="Delete-<% $i %>">remove</label>
+ </div>
+ </td>
</tr>
% ++$i;
% }
@@ -120,10 +127,19 @@ push @statuses, '*';
my $actions = $LifecycleObj->{'data'}->{'actions'} || ();
if ($UpdateLifecycleActions) {
+ # Delete any keys checked for delete
+ my %delete_id = ();
+ foreach my $arg ( keys %ARGS ) {
+ if ( $arg =~ /Delete-(\d+)/ ){
+ $delete_id{$1} = 1;
+ }
+ }
+
my %new_actions;
foreach my $arg ( keys %ARGS ) {
my ($field, $count) = $arg =~ /Action-(\w+)-(\d+)/;
next unless $field and defined $count && $ARGS{$arg};
+ next if $delete_id{$count};
if ( $new_actions{$count} ) {
$new_actions{$count}->{lc $field} = $ARGS{$arg};
diff --git a/share/html/Admin/Lifecycles/Rights.html b/share/html/Admin/Lifecycles/Rights.html
index 6f9302a25d..9724a4dffb 100644
--- a/share/html/Admin/Lifecycles/Rights.html
+++ b/share/html/Admin/Lifecycles/Rights.html
@@ -59,6 +59,7 @@
<th class="collection-as-table">From Status</th>
<th class="collection-as-table">To Status</th>
<th class="collection-as-table">Right</th>
+ <th class="collection-as-table"></th>
</tr>
</tbody>
<tbody class="list-item">
@@ -74,6 +75,13 @@
<td class="collection-as-table">
<input type="text" value="<% $right->{'Name'} %>" class="form-control" Name="Right-Name-<%$i%>" />
</td>
+
+ <td class="collection-as-table">
+ <div class="custom-control custom-checkbox">
+ <input type="checkbox" name="Delete-<% $i %>" id="Delete-<% $i %>" value="1" class="custom-control-input"/>
+ <label class="custom-control-label" for="Delete-<% $i %>">remove</label>
+ </div>
+ </td>
</tr>
% ++$i;
% }
@@ -112,10 +120,19 @@ foreach my $key ( keys %{$rights} ) {
}
if ($UpdateLifecycleRights) {
+
+ # Delete any keys checked for delete
+ my %delete_id = ();
+ foreach my $arg ( keys %ARGS ) {
+ if ( $arg =~ /Delete-(\d+)/ ){
+ $delete_id{$1} = 1;
+ }
+ }
my %new_rights;
foreach my $arg ( keys %ARGS ) {
my ($field, $count) = $arg =~ /Right-(\w+)-(\d+)/;
next unless $field and defined $count && $ARGS{$arg};
+ next if $delete_id{$count};
if ( $new_rights{$count} ) {
$new_rights{$count}->{$field} = $ARGS{$arg};
commit c68ffb4d36e1c52fe1deebf1e19e9e4000700107
Author: Craig Kaiser <craig at bestpractical.com>
Date: Thu Feb 6 10:21:39 2020 -0500
If no lifecycles configuration exists we need to load lifecycles from RT::Config
diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 7e964b65e3..b98de492c1 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -170,6 +170,19 @@ sub Load {
return $self;
}
+sub Lifecycles {
+ my $self = shift;
+
+ my $setting = RT::Configuration->new( RT->SystemUser );
+ $setting->Load('Lifecycles');
+ if ( $setting->Id ) {
+ return $setting->_DeserializeContent( $setting->Content );
+ }
+ else {
+ return RT::Config->Get( "Lifecycles" );
+ }
+}
+
=head2 List
List available lifecycles. This list omits RT's default approvals
@@ -941,7 +954,7 @@ sub UpdateLifecycle {
);
if ( $args{'Configuration'} ) {
- my $config = RT::Configuration->new( RT->SystemUser );
+ my $config = RT::Configuration->new( $args{'CurrentUser'} );
if ( $config->Load( 'LifecycleConfiguration-'.$args{'LifecycleObj'}->Name ) ) {
my ($ret, $msg) = $config->SetContent( $args{'Configuration'} );
diff --git a/share/html/Admin/Lifecycles/Actions.html b/share/html/Admin/Lifecycles/Actions.html
index 11561be982..288ced3830 100644
--- a/share/html/Admin/Lifecycles/Actions.html
+++ b/share/html/Admin/Lifecycles/Actions.html
@@ -160,7 +160,7 @@ if ($UpdateLifecycleActions) {
};
}
- my $config = RT->Config->Get('Lifecycles')->{$LifecycleObj->Name};
+ my $config = RT::Lifecycle->Lifecycles->{$LifecycleObj->Name};
$config->{'actions'} = \@new_actions;
my ($ok, $msg) = RT::Lifecycle->UpdateLifecycle(
@@ -170,6 +170,7 @@ if ($UpdateLifecycleActions) {
);
if ( $ok ) {
push @results, "Lifecycle updated";
+ RT::System->LifecycleCacheNeedsUpdate(1);
}
else {
push @results, "An error occured when attempting to update lifecycle, see RT log for more info.";
diff --git a/share/html/Admin/Lifecycles/Rights.html b/share/html/Admin/Lifecycles/Rights.html
index 9724a4dffb..13eb698d56 100644
--- a/share/html/Admin/Lifecycles/Rights.html
+++ b/share/html/Admin/Lifecycles/Rights.html
@@ -147,7 +147,8 @@ if ($UpdateLifecycleRights) {
foreach my $right ( keys %new_rights ) {
$new_rights->{"$new_rights{$right}->{To} -> $new_rights{$right}->{From}"} = $new_rights{$right}->{Name};
}
- my $config = RT->Config->Get('Lifecycles')->{$LifecycleObj->Name};
+
+ my $config = RT::Lifecycle->Lifecycles->{$LifecycleObj->Name};
$config->{'rights'} = $new_rights;
my ($ok, $msg) = RT::Lifecycle->UpdateLifecycle(
@@ -157,6 +158,7 @@ if ($UpdateLifecycleRights) {
);
if ( $ok ) {
push @results, "Lifecycle updated";
+ RT::System->LifecycleCacheNeedsUpdate(1);
}
else {
push @results, "An error occured when attempting to update lifecycle, see RT log for more info.";
-----------------------------------------------------------------------
More information about the rt-commit
mailing list