[Bps-public-commit] rt-extension-lifecycleui branch, master, updated. 288769402d55fb404e8ef6f27bdd88f7e0ad4934

Shawn Moore shawn at bestpractical.com
Wed Aug 16 14:12:50 EDT 2017


The branch, master has been updated
       via  288769402d55fb404e8ef6f27bdd88f7e0ad4934 (commit)
       via  788e96ccb43e3c05cc3ae5691b022825bafa3628 (commit)
       via  bc27b00e78b7c710f611d397efd4d9d7cf908d4d (commit)
       via  1153289fa6fdf71c3d0e51918e52dca131fc1313 (commit)
       via  f1163985aba7fcec3eafe33c0f07d2e7cd27d9ca (commit)
       via  c2d8d2a77f51c1262fe495237cd5318c1fa2399b (commit)
       via  8e18b71d1907f2d98d5d02e1c0f0ed52308069c7 (commit)
       via  3f22e693ee0bed1379295a05a21e15e5f03e1e3b (commit)
       via  8b82505ac236e85ff938c356de727f1df275a4db (commit)
      from  735412878e6fcc2a319804615b858d12874ed7b6 (commit)

Summary of changes:
 META.yml                                           |  2 +
 html/Admin/Lifecycles/Create.html                  | 69 ++++++++++++++++++++++
 html/Admin/Lifecycles/Modify.html                  | 35 +++++++++++
 html/Admin/Lifecycles/index.html                   | 31 ++++++++++
 .../Elements/Tabs/Privileged                       | 46 +++++++++++++++
 lib/RT/Extension/LifecycleUI.pm                    |  2 +
 static/css/lifecycleui.css                         |  4 ++
 7 files changed, 189 insertions(+)
 create mode 100644 html/Admin/Lifecycles/Create.html
 create mode 100644 html/Admin/Lifecycles/Modify.html
 create mode 100644 html/Admin/Lifecycles/index.html
 create mode 100644 html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged
 create mode 100644 static/css/lifecycleui.css

- Log -----------------------------------------------------------------
commit 8b82505ac236e85ff938c356de727f1df275a4db
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed Aug 16 16:32:56 2017 +0000

    Page that lists all lifecycles

diff --git a/META.yml b/META.yml
index 968d3d2..b681509 100644
--- a/META.yml
+++ b/META.yml
@@ -16,6 +16,7 @@ meta-spec:
 name: RT-Extension-LifecycleUI
 no_index:
   directory:
+    - html
     - inc
 requires:
   RT::Extension::ConfigInDatabase: 0
diff --git a/html/Admin/Lifecycles/index.html b/html/Admin/Lifecycles/index.html
new file mode 100644
index 0000000..6abef74
--- /dev/null
+++ b/html/Admin/Lifecycles/index.html
@@ -0,0 +1,31 @@
+<& /Admin/Elements/Header, Title => loc("Admin Lifecycles") &>
+<& /Elements/Tabs &>
+
+% for my $type (@types) {
+% my @lifecycles = @{ $lifecycles{$type} };
+<h2><&|/l, $type&>"[_1]" lifecycles</&></h2>
+% if (@lifecycles) {
+<ul>
+% for my $lifecycle (@lifecycles) {
+<li><a href=""><% $lifecycle %></a></li>
+% }
+</ul>
+% } else {
+<p><&|/l&>No lifecycles.</&></p>
+% }
+% }
+<%INIT>
+my @types = List::MoreUtils::uniq(
+    'ticket',
+    'asset',
+    sort keys %RT::Lifecycle::LIFECYCLES_TYPES,
+);
+
+my %lifecycles;
+
+for my $type (@types) {
+    @{ $lifecycles{$type} } = sort { loc($a) cmp loc($b) }
+                              grep { $_ ne 'approvals' }
+                              RT::Lifecycle->ListAll($type);
+}
+</%INIT>

commit 3f22e693ee0bed1379295a05a21e15e5f03e1e3b
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed Aug 16 16:33:09 2017 +0000

    CSS to visually separate the lifecycle types

diff --git a/META.yml b/META.yml
index b681509..194472a 100644
--- a/META.yml
+++ b/META.yml
@@ -18,6 +18,7 @@ no_index:
   directory:
     - html
     - inc
+    - static
 requires:
   RT::Extension::ConfigInDatabase: 0
   perl: 5.10.1
diff --git a/lib/RT/Extension/LifecycleUI.pm b/lib/RT/Extension/LifecycleUI.pm
index 094c426..dff33dd 100644
--- a/lib/RT/Extension/LifecycleUI.pm
+++ b/lib/RT/Extension/LifecycleUI.pm
@@ -4,6 +4,8 @@ use warnings;
 
 our $VERSION = '0.01';
 
+RT->AddStyleSheets("lifecycleui.css");
+
 =head1 NAME
 
 RT-Extension-LifecycleUI - manage lifecycles via admin UI
diff --git a/static/css/lifecycleui.css b/static/css/lifecycleui.css
new file mode 100644
index 0000000..84bf832
--- /dev/null
+++ b/static/css/lifecycleui.css
@@ -0,0 +1,4 @@
+body#comp-Admin-Lifecycles ul + h2 {
+    margin-top: 2em;
+}
+

commit 8e18b71d1907f2d98d5d02e1c0f0ed52308069c7
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed Aug 16 16:33:46 2017 +0000

    Add lifecycle select/create menu between scrips and global

diff --git a/html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged b/html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged
new file mode 100644
index 0000000..ef3eb84
--- /dev/null
+++ b/html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged
@@ -0,0 +1,20 @@
+<%INIT>
+return unless $session{'CurrentUser'}->HasRight( Object=> RT->System, Right => 'SuperUser');
+
+my $scrips = Menu->child('admin')->child('scrips');;
+
+my $lifecycles = $scrips->add_after( lifecycles =>
+    title => loc('Lifecycles'),
+    path  => '/Admin/Lifecycles/',
+);
+
+$lifecycles->child( select =>
+    title => loc('Select'),
+    path  => '/Admin/Lifecycles/',
+);
+
+$lifecycles->child( create =>
+    title => loc('Create'),
+    path  => '/Admin/Lifecycles/',
+);
+</%INIT>

commit c2d8d2a77f51c1262fe495237cd5318c1fa2399b
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed Aug 16 17:12:00 2017 +0000

    Skeleton of a clone/new lifecycle page

diff --git a/html/Admin/Lifecycles/Create.html b/html/Admin/Lifecycles/Create.html
new file mode 100644
index 0000000..0178c27
--- /dev/null
+++ b/html/Admin/Lifecycles/Create.html
@@ -0,0 +1,46 @@
+<& /Admin/Elements/Header, Title => loc("Admin Lifecycles") &>
+<& /Elements/Tabs &>
+
+<form action="<%RT->Config->Get('WebPath')%>/Admin/Lifecycles/Create.html" name="CreateLifecycle" method="post" enctype="multipart/form-data">
+
+% for my $type (@types) {
+% my @lifecycles = @{ $lifecycles{$type} };
+<h2><&|/l, $type&>"[_1]" lifecycles</&></h2>
+% for my $lifecycle (@lifecycles) {
+<button type="submit" name="Clone" value="<% $type %>--<% $lifecycle %>"><&|/l, $lifecycle&>Clone "[_1]" lifecycle</&></button><br>
+% }
+<br>
+<button type="submit" name="Blank" value="<% $type %>"><&|/l, $type&>Blank "[_1]" lifecycle</&></button><br>
+% }
+</form>
+
+<%INIT>
+my @types = List::MoreUtils::uniq(
+    'ticket',
+    'asset',
+    sort keys %RT::Lifecycle::LIFECYCLES_TYPES,
+);
+
+my %lifecycles;
+
+for my $type (@types) {
+    @{ $lifecycles{$type} } = sort { loc($a) cmp loc($b) }
+                              grep { $_ ne 'approvals' }
+                              RT::Lifecycle->ListAll($type);
+}
+
+if (defined($Clone)) {
+    my ($type, $source_name) = split '--', $Clone;
+    Abort("Invalid $type lifecycle $source_name")
+        unless grep { $_ eq $source_name} RT::Lifecycle->ListAll($type);
+}
+elsif (defined($Blank)) {
+    my $type = $Blank;
+    Abort("Invalid lifecycle type $type")
+        unless $RT::Lifecycle::LIFECYCLES_TYPES{$type};
+}
+</%INIT>
+<%ARGS>
+$Clone => undef
+$Blank => undef
+</%ARGS>
diff --git a/html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged b/html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged
index ef3eb84..8ff74ae 100644
--- a/html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged
+++ b/html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged
@@ -15,6 +15,6 @@ $lifecycles->child( select =>
 
 $lifecycles->child( create =>
     title => loc('Create'),
-    path  => '/Admin/Lifecycles/',
+    path  => '/Admin/Lifecycles/Create.html',
 );
 </%INIT>

commit f1163985aba7fcec3eafe33c0f07d2e7cd27d9ca
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed Aug 16 17:33:37 2017 +0000

    Take a lifecycle name and redirect to Modify.html

diff --git a/html/Admin/Lifecycles/Create.html b/html/Admin/Lifecycles/Create.html
index 0178c27..a1b1ad1 100644
--- a/html/Admin/Lifecycles/Create.html
+++ b/html/Admin/Lifecycles/Create.html
@@ -3,6 +3,9 @@
 
 <form action="<%RT->Config->Get('WebPath')%>/Admin/Lifecycles/Create.html" name="CreateLifecycle" method="post" enctype="multipart/form-data">
 
+<&|/l&>New lifecycle name</&>: <input name="Name" value="" />
+<hr />
+
 % for my $type (@types) {
 % my @lifecycles = @{ $lifecycles{$type} };
 <h2><&|/l, $type&>"[_1]" lifecycles</&></h2>
@@ -29,18 +32,38 @@ for my $type (@types) {
                               RT::Lifecycle->ListAll($type);
 }
 
-if (defined($Clone)) {
-    my ($type, $source_name) = split '--', $Clone;
-    Abort("Invalid $type lifecycle $source_name")
-        unless grep { $_ eq $source_name} RT::Lifecycle->ListAll($type);
-}
-elsif (defined($Blank)) {
-    my $type = $Blank;
-    Abort("Invalid lifecycle type $type")
-        unless $RT::Lifecycle::LIFECYCLES_TYPES{$type};
+if (defined($Clone) || defined($Blank)) {
+    my ($type, $clone_of);
+
+    Abort("New lifecycle name required")
+        unless defined $Name;
+
+    if (defined($Clone)) {
+        ($type, $clone_of) = split '--', $Clone;
+        Abort("Invalid $type lifecycle $clone_of")
+            unless grep { $_ eq $clone_of } RT::Lifecycle->ListAll($type);
+    }
+    else {
+        $type = $Blank;
+        Abort("Invalid lifecycle type $type")
+            unless $RT::Lifecycle::LIFECYCLES_TYPES{$type};
+    }
+
+    Abort("$type lifecycle $Name already exists")
+        if grep { $_ eq $Name } RT::Lifecycle->ListAll($type);
+
+    # XXX create blank or clone
+
+    my $type_uri = $type;
+    my $Name_uri = $Name;
+    RT::Interface::Web::EscapeURI(\$type_uri);
+    RT::Interface::Web::EscapeURI(\$Name_uri);
+
+    RT::Interface::Web::Redirect( RT->Config->Get('WebURL') ."Admin/Lifecycles/Modify.html?Type=". $type_uri."&Name=".$Name_uri);
 }
 </%INIT>
 <%ARGS>
 $Clone => undef
 $Blank => undef
+$Name => undef
 </%ARGS>

commit 1153289fa6fdf71c3d0e51918e52dca131fc1313
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed Aug 16 17:35:49 2017 +0000

    Links from index to Modify.html

diff --git a/html/Admin/Lifecycles/index.html b/html/Admin/Lifecycles/index.html
index 6abef74..6c5f84f 100644
--- a/html/Admin/Lifecycles/index.html
+++ b/html/Admin/Lifecycles/index.html
@@ -7,7 +7,7 @@
 % if (@lifecycles) {
 <ul>
 % for my $lifecycle (@lifecycles) {
-<li><a href=""><% $lifecycle %></a></li>
+<li><a href="<% RT->Config->Get('WebURL') %>Admin/Lifecycles/Modify.html?Type=<% $type |u %>&Name=<% $lifecycle |u %>"><% $lifecycle %></a></li>
 % }
 </ul>
 % } else {

commit bc27b00e78b7c710f611d397efd4d9d7cf908d4d
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed Aug 16 17:49:18 2017 +0000

    Modify page that just validates the lifecycle

diff --git a/html/Admin/Lifecycles/Modify.html b/html/Admin/Lifecycles/Modify.html
new file mode 100644
index 0000000..5cf0bfc
--- /dev/null
+++ b/html/Admin/Lifecycles/Modify.html
@@ -0,0 +1,35 @@
+<& /Admin/Elements/Header, Title => $title &>
+<& /Elements/Tabs &>
+<& /Elements/ListActions, actions => \@results &>
+
+
+<form action="<%RT->Config->Get('WebPath')%>/Admin/Lifecycles/Modify.html" name="ModifyLifecycle" method="post" enctype="multipart/form-data">
+<input type="hidden" class="hidden" name="Name" value="<% $LifecycleObj->Name %>" />
+<input type="hidden" class="hidden" name="Type" value="<% $LifecycleObj->Type %>" />
+
+<& /Elements/Submit, Label => loc('Save Changes') &>
+
+</form>
+
+
+
+<%INIT>
+my ($title, @results);
+my $LifecycleObj = RT::Lifecycle->new();
+$LifecycleObj->Load(Name => $Name, Type => $Type);
+
+Abort("Invalid lifecycle") unless $LifecycleObj->Name
+                               && $LifecycleObj->{data}{type} eq $Type;
+
+$title = loc("Modify lifecycle [_1]", $LifecycleObj->Name);
+
+# This code does automatic redirection if any updates happen.
+MaybeRedirectForResults(
+    Actions   => \@results,
+    Arguments => { Name => $LifecycleObj->Name, Type => $LifecycleObj->Type },
+);
+</%INIT>
+<%ARGS>
+$Name => undef
+$Type => undef
+</%ARGS>

commit 788e96ccb43e3c05cc3ae5691b022825bafa3628
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed Aug 16 17:56:54 2017 +0000

    Add Modify pagemenu

diff --git a/html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged b/html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged
index 8ff74ae..e8fea9a 100644
--- a/html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged
+++ b/html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged
@@ -1,3 +1,6 @@
+<%ARGS>
+$Path
+</%ARGS>
 <%INIT>
 return unless $session{'CurrentUser'}->HasRight( Object=> RT->System, Right => 'SuperUser');
 
@@ -17,4 +20,21 @@ $lifecycles->child( create =>
     title => loc('Create'),
     path  => '/Admin/Lifecycles/Create.html',
 );
+
+if ( $Path =~ m{^/Admin/Lifecycles} ) {
+    if (defined($DECODED_ARGS->{'Name'}) && defined($DECODED_ARGS->{'Type'}) ) {
+        my $LifecycleObj = RT::Lifecycle->new();
+        $LifecycleObj->Load(Name => $DECODED_ARGS->{'Name'}, Type => $DECODED_ARGS->{'Type'});
+
+        if ($LifecycleObj->Name && $LifecycleObj->{data}{type} eq $DECODED_ARGS->{'Type'}) {
+            my $Name_uri = $LifecycleObj->Name;
+            my $Type_uri = $LifecycleObj->Type;
+            RT::Interface::Web::EscapeURI(\$Name_uri);
+            RT::Interface::Web::EscapeURI(\$Type_uri);
+
+            my $menu = PageMenu();
+            $menu->child( basics => title => loc('Modify'),  path => "/Admin/Lifecycles/Modify.html?Type=" . $Type_uri . "&Name=" . $Name_uri );
+        }
+    }
+}
 </%INIT>

commit 288769402d55fb404e8ef6f27bdd88f7e0ad4934
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed Aug 16 17:57:01 2017 +0000

    Add select/create pagemenu

diff --git a/html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged b/html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged
index e8fea9a..f2388ac 100644
--- a/html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged
+++ b/html/Callbacks/RT-Extension-LifecycleUI/Elements/Tabs/Privileged
@@ -36,5 +36,11 @@ if ( $Path =~ m{^/Admin/Lifecycles} ) {
             $menu->child( basics => title => loc('Modify'),  path => "/Admin/Lifecycles/Modify.html?Type=" . $Type_uri . "&Name=" . $Name_uri );
         }
     }
+    else {
+        my $tabs = PageMenu();
+
+        $tabs->child( select => title => loc('Select'), path => "/Admin/Lifecycles/" );
+        $tabs->child( create => title => loc('Create'), path => "/Admin/Lifecycles/Create.html" );
+    }
 }
 </%INIT>

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list