[Rt-commit] rt branch, 5.0-trunk, updated. rt-5.0.0alpha1-221-g1a3be80f96

? sunnavy sunnavy at bestpractical.com
Mon May 4 14:05:04 EDT 2020


The branch, 5.0-trunk has been updated
       via  1a3be80f960b17b954ad5f0a44aa43c7622a8db8 (commit)
       via  ad74962bd7c20cdaec370f02f51c7428bd99b22b (commit)
       via  879148e95db80543098301c9fc625970b3961753 (commit)
       via  0cd51462a39bae1cbee37da2cb49be9bc19e38d6 (commit)
      from  5cd71e843cad617c7043e2917f6f5d2f5eb8e22c (commit)

Summary of changes:
 share/html/Group/Elements/AssetList            | 53 ++++++++++++++++++++-----
 share/html/Group/Elements/Portlets/GroupAssets |  2 +-
 share/html/SelfService/Asset/index.html        |  2 +-
 share/html/User/Elements/AssetList             | 54 +++++++++++++++++++++-----
 share/html/User/Elements/Portlets/UserAssets   |  2 +-
 5 files changed, 90 insertions(+), 23 deletions(-)

- Log -----------------------------------------------------------------
commit 0cd51462a39bae1cbee37da2cb49be9bc19e38d6
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri May 1 14:43:14 2020 -0400

    Convert summary page asset searches to use AssetSQL

diff --git a/share/html/Group/Elements/AssetList b/share/html/Group/Elements/AssetList
index e88443bf58..dd820653a1 100644
--- a/share/html/Group/Elements/AssetList
+++ b/share/html/Group/Elements/AssetList
@@ -61,8 +61,43 @@ my $Format = q[
     Description,
 ];
 $m->callback( CallbackName => 'ModifyFormat', %ARGS, Format => \$Format );
+
+my %QueryProperties = (
+    Query      => join(' OR ', map { "$_.id = ".$Group->PrincipalId } ('HeldBy', 'Contact', 'Owner') ),
+    OrderBy    => 'id',
+    Order      => 'ASC',
+);
+
+$m->callback( CallbackName => 'ModifyQueryProperties',
+    %ARGS,
+    QueryProperties => \%QueryProperties,
+);
+
+my $query_string = $m->comp('/Elements/QueryString',
+    Class       => 'RT::Assets',
+    Query       => $QueryProperties{Query},
+    OrderBy     => $QueryProperties{OrderBy},
+    Order       => $QueryProperties{Order},
+);
+
+my $search_url  =
+    RT->Config->Get('WebPath') .
+    '/Search/Results.html?' .
+    $query_string;
+
+my $bulk_update_url  =
+    RT->Config->Get('WebPath') .
+    '/Asset/Search/Bulk.html?' .
+    $query_string;
+
 </%INIT>
-<&| /Widgets/TitleBox, title => $Title, class => "group asset-list" &>
+<&| /Widgets/TitleBox,
+    title => $Title,
+    title_href => $search_url,
+    titleright => loc('Bulk Update'),
+    titleright_href => $bulk_update_url,
+    class => "group asset-list",
+&>
     <& /Elements/CollectionList,
         Collection      => $assets,
         OrderBy         => 'id',
diff --git a/share/html/User/Elements/AssetList b/share/html/User/Elements/AssetList
index 154737fd29..1944f73e81 100644
--- a/share/html/User/Elements/AssetList
+++ b/share/html/User/Elements/AssetList
@@ -61,8 +61,43 @@ my $Format = q[
     Description,
 ];
 $m->callback( CallbackName => 'ModifyFormat', %ARGS, Format => \$Format );
+
+my %QueryProperties = (
+    Query      => join(' OR ', map { "$_.id = ".$User->Id } ('HeldBy', 'Contact', 'Owner') ),
+    OrderBy    => 'id',
+    Order      => 'ASC',
+);
+
+$m->callback( CallbackName => 'ModifyQueryProperties',
+    %ARGS,
+    QueryProperties => \%QueryProperties,
+);
+
+my $query_string = $m->comp('/Elements/QueryString',
+    Class       => 'RT::Assets',
+    Query       => $QueryProperties{Query},
+    OrderBy     => $QueryProperties{OrderBy},
+    Order       => $QueryProperties{Order},
+);
+
+my $search_url  =
+    RT->Config->Get('WebPath') .
+    '/Search/Results.html?' .
+    $query_string;
+
+my $bulk_update_url  =
+    RT->Config->Get('WebPath') .
+    '/Asset/Search/Bulk.html?' .
+    $query_string;
+
 </%init>
-<&| /Widgets/TitleBox, title => $Title, class => "user asset-list" &>
+<&| /Widgets/TitleBox,
+    title => $Title,
+    title_href => $search_url,
+    titleright => loc('Bulk Update'),
+    titleright_href => $bulk_update_url,
+    class => "user asset-list",
+&>
     <& /Elements/CollectionList,
         Collection      => $assets,
         OrderBy         => 'id',

commit 879148e95db80543098301c9fc625970b3961753
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon May 4 11:41:19 2020 -0400

    Convert asset lists to FromSQL searches
    
    Also use the Roles arg to define the query rather than the
    hard-coded list previously. Roles can now be modified via
    callback.

diff --git a/share/html/Group/Elements/AssetList b/share/html/Group/Elements/AssetList
index dd820653a1..32e0f824ab 100644
--- a/share/html/Group/Elements/AssetList
+++ b/share/html/Group/Elements/AssetList
@@ -47,14 +47,7 @@
 %# END BPS TAGGED BLOCK }}}
 <%INIT>
 my $assets = RT::Assets->new($session{CurrentUser});
-$m->callback( CallbackName => 'ModifyAssetSearch', %ARGS, Assets => $assets, Roles => \@Roles );
-for my $role (@Roles) {
-    $assets->RoleLimit(
-        TYPE        => $role,
-        VALUE       => $Group->PrincipalId,
-        SUBCLAUSE   => "Role$role",
-    );
-}
+
 my $Format = q[
     '<b><a href="__WebHomePath__/Asset/Display.html?id=__id__">__id__</a></b>/TITLE:#',
     '<b><a href="__WebHomePath__/Asset/Display.html?id=__id__">__Name__</a></b>/TITLE:Name',
@@ -63,16 +56,21 @@ my $Format = q[
 $m->callback( CallbackName => 'ModifyFormat', %ARGS, Format => \$Format );
 
 my %QueryProperties = (
-    Query      => join(' OR ', map { "$_.id = ".$Group->PrincipalId } ('HeldBy', 'Contact', 'Owner') ),
+    Query      => join(' OR ', map { "$_.id = ".$Group->PrincipalId } @Roles ),
     OrderBy    => 'id',
     Order      => 'ASC',
 );
-
 $m->callback( CallbackName => 'ModifyQueryProperties',
     %ARGS,
     QueryProperties => \%QueryProperties,
+    Roles => \@Roles,
 );
 
+my ($ok, $msg) = $assets->FromSQL($QueryProperties{Query});
+RT->Logger->error('Unable to parse asset query ' . $QueryProperties{Query} . ' : $msg')
+    unless $ok;
+$m->callback( CallbackName => 'ModifyAssetSearch', %ARGS, Assets => $assets, Roles => \@Roles );
+
 my $query_string = $m->comp('/Elements/QueryString',
     Class       => 'RT::Assets',
     Query       => $QueryProperties{Query},
@@ -110,6 +108,6 @@ my $bulk_update_url  =
 <%ARGS>
 $Group
 $Title
- at Roles
+ at Roles => ('HeldBy', 'Contact', 'Owner')
 $HasResults => undef
 </%ARGS>
diff --git a/share/html/Group/Elements/Portlets/GroupAssets b/share/html/Group/Elements/Portlets/GroupAssets
index 88aa7a2ee2..e4a4b563e7 100644
--- a/share/html/Group/Elements/Portlets/GroupAssets
+++ b/share/html/Group/Elements/Portlets/GroupAssets
@@ -46,7 +46,7 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 %# Roles => [''] triggers the magical RoleLimit behavior that matches any role
-<& /Group/Elements/AssetList, Group => $Group, Roles => [''], Title => loc('Assigned Assets') &>
+<& /Group/Elements/AssetList, Group => $Group, Title => loc('Assigned Assets') &>
 <%ARGS>
 $Group
 </%ARGS>
diff --git a/share/html/User/Elements/AssetList b/share/html/User/Elements/AssetList
index 1944f73e81..b980d58040 100644
--- a/share/html/User/Elements/AssetList
+++ b/share/html/User/Elements/AssetList
@@ -47,14 +47,7 @@
 %# END BPS TAGGED BLOCK }}}
 <%init>
 my $assets = RT::Assets->new($session{CurrentUser});
-$m->callback( CallbackName => 'ModifyAssetSearch', %ARGS, Assets => $assets, Roles => \@Roles );
-for my $role (@Roles) {
-    $assets->RoleLimit(
-        TYPE        => $role,
-        VALUE       => $User->PrincipalId,
-        SUBCLAUSE   => "Role$role",
-    );
-}
+
 my $Format = q[
     '<b><a href="__WebHomePath__/Asset/Display.html?id=__id__">__id__</a></b>/TITLE:#',
     '<b><a href="__WebHomePath__/Asset/Display.html?id=__id__">__Name__</a></b>/TITLE:Name',
@@ -63,7 +56,7 @@ my $Format = q[
 $m->callback( CallbackName => 'ModifyFormat', %ARGS, Format => \$Format );
 
 my %QueryProperties = (
-    Query      => join(' OR ', map { "$_.id = ".$User->Id } ('HeldBy', 'Contact', 'Owner') ),
+    Query      => join(' OR ', map { "$_.id = ".$User->Id } @Roles ),
     OrderBy    => 'id',
     Order      => 'ASC',
 );
@@ -71,8 +64,14 @@ my %QueryProperties = (
 $m->callback( CallbackName => 'ModifyQueryProperties',
     %ARGS,
     QueryProperties => \%QueryProperties,
+    Roles => \@Roles,
 );
 
+my ($ok, $msg) = $assets->FromSQL($QueryProperties{Query});
+RT->Logger->error('Unable to parse asset query ' . $QueryProperties{Query} . ' : $msg')
+    unless $ok;
+$m->callback( CallbackName => 'ModifyAssetSearch', %ARGS, Assets => $assets, Roles => \@Roles );
+
 my $query_string = $m->comp('/Elements/QueryString',
     Class       => 'RT::Assets',
     Query       => $QueryProperties{Query},
@@ -110,6 +109,6 @@ my $bulk_update_url  =
 <%args>
 $User
 $Title
- at Roles
+ at Roles => ('HeldBy', 'Contact', 'Owner')
 $HasResults => undef
 </%args>
diff --git a/share/html/User/Elements/Portlets/UserAssets b/share/html/User/Elements/Portlets/UserAssets
index e998fa01f0..54a03852ad 100644
--- a/share/html/User/Elements/Portlets/UserAssets
+++ b/share/html/User/Elements/Portlets/UserAssets
@@ -46,7 +46,7 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 %# Roles => [''] triggers the magical RoleLimit behavior that matches any role
-<& /User/Elements/AssetList, User => $User, Roles => [''], Title => loc('Assigned Assets') &>
+<& /User/Elements/AssetList, User => $User, Title => loc('Assigned Assets') &>
 <%ARGS>
 $User
 </%ARGS>

commit ad74962bd7c20cdaec370f02f51c7428bd99b22b
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon May 4 11:46:16 2020 -0400

    Show HeldBy assets in self service view
    
    This is consistent with MyAsset for privileged users.

diff --git a/share/html/SelfService/Asset/index.html b/share/html/SelfService/Asset/index.html
index 9fd526f0e8..1bd1901087 100644
--- a/share/html/SelfService/Asset/index.html
+++ b/share/html/SelfService/Asset/index.html
@@ -46,4 +46,4 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <& /SelfService/Elements/Header, Title => loc("My Assets") &>
-<& /User/Elements/AssetList, User => $session{'CurrentUser'}->UserObj, Roles => [''], Title => loc('My Assets') &>
+<& /User/Elements/AssetList, User => $session{'CurrentUser'}->UserObj, Roles => [qw(HeldBy)], Title => loc('My Assets') &>

commit 1a3be80f960b17b954ad5f0a44aa43c7622a8db8
Merge: 5cd71e843c ad74962bd7
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue May 5 01:53:32 2020 +0800

    Merge branch '5.0/user-summary-assets' into 5.0-trunk


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


More information about the rt-commit mailing list