[Bps-public-commit] rt-extension-assetsql branch, asset-sql-custom-roles, repushed

Craig Kaiser craig at bestpractical.com
Thu Nov 9 16:30:53 EST 2017


The branch asset-sql-custom-roles was deleted and repushed:
       was 5d1360ecc244c9f664518af10a9aa4e1758ebdc6
       now 29fdb98587311303bab57801c440bed762b776fe

1:  5d1360e ! 1:  29fdb98 Add support for CustomRoles in Asset Search Builder
    @@ -1,8 +1,14 @@
     Author: craig <craig at bestpractical.com>
     
    -    Add support for CustomRole Query with Asset Search Builder.
    +    Add support for CustomRoles in Asset Search Builder
         
    -    Referencing commit: 'b77e1d2dbef3adaebf16f252c36c842c3098f01a'
    +    b77e1d2db search assets based on Custom Roles.
    +    Allows user to search CRs based on which catalog
    +    is chosen.
    +    
    +    If a catalog is chosen CustomRoles available for
    +    the selected catalog can now be selected as part
    +    of the query as well as the 'display columns' options.
     
     diff --git a/html/Asset/Search/Build.html b/html/Asset/Search/Build.html
     --- a/html/Asset/Search/Build.html
    @@ -72,11 +78,9 @@
      $Format => RT->Config->Get('AssetSearchFormat')
      
     @@
    -     NBSP
      ); # loc_qw
      
    --my $CustomFields = RT::CustomFields->new( $session{'CurrentUser'});
    -+
    + my $CustomFields = RT::CustomFields->new( $session{'CurrentUser'});
     +my %ranges = %{ RT->Config->Get('CustomDateRanges')->{'RT::Asset'} || {} };
     +push @fields, sort keys %ranges;
     +
    @@ -84,26 +88,26 @@
      foreach my $id (keys %catalogs) {
          # Gotta load up the $catalog object, since catalogs get stored by name now.
          my $catalog = RT::Catalog->new($session{'CurrentUser'});
    -     $catalog->Load($id);
    +@@
          next unless $catalog->Id;
    --    $CustomFields->LimitToCatalog($catalog->Id);
    --    $CustomFields->SetContextObject( $catalog ) if keys %catalogs == 1;
    +     $CustomFields->LimitToCatalog($catalog->Id);
    +     $CustomFields->SetContextObject( $catalog ) if keys %catalogs == 1;
     +    $CustomRoles->LimitToObjectId($catalog->Id);
      }
    --$CustomFields->LimitToCatalog(0);
    + $CustomFields->LimitToCatalog(0);
    + 
    + while ( my $CustomField = $CustomFields->Next ) {
    +     push @fields, "CustomField.{" . $CustomField->Name . "}";
    + }
     -
    --while ( my $CustomField = $CustomFields->Next ) {
    --    push @fields, "CustomField.{" . $CustomField->Name . "}";
    +-my %ranges = %{ RT->Config->Get('CustomDateRanges')->{'RT::Asset'} || {} };
    +-push @fields, sort keys %ranges;
     +while ( my $Role = $CustomRoles->Next ) {
     +    push @fields, "CustomRole.{" . $Role->Name . "}";
    - }
    - 
    --my %ranges = %{ RT->Config->Get('CustomDateRanges')->{'RT::Asset'} || {} };
    --push @fields, sort keys %ranges;
    --
    ++}
    + 
      $m->callback( Fields => \@fields, ARGSRef => \%ARGS );
      
    - my ( @seen);
     
     diff --git a/html/Asset/Search/Elements/EditSort b/html/Asset/Search/Elements/EditSort
     --- a/html/Asset/Search/Elements/EditSort
    @@ -172,18 +176,15 @@
     +   @types = qw(Cc AdminCc);
     +}
     +elsif ($Suffix eq 'Group') {
    -+   @types = qw(Owner Requestor Cc AdminCc Watcher);
    ++   @types = qw(Owner HeldBy Contact Watcher);
     +}
     +else {
    -+   @types = qw(Requestor Cc AdminCc Watcher Owner CatalogCc CatalogAdminCc CatalogWatcher);
    ++   @types = qw( Watcher Owner CatalogWatcher HeldBy contact );
     +}
     +
      my @subtypes = @{ $RT::Assets::SEARCHABLE_SUBFIELDS{'User'} };
      
    --$m->callback(Types => \@types, Subtypes => \@subtypes);
    - </%INIT>
    - <%ARGS>
    - $AllowNull => 1
    + $m->callback(Types => \@types, Subtypes => \@subtypes);
     @@
      $Default =>undef
      $Scope => 'asset'
    @@ -194,23 +195,6 @@
     diff --git a/lib/RT/Extension/AssetSQL/Assets.pm b/lib/RT/Extension/AssetSQL/Assets.pm
     --- a/lib/RT/Extension/AssetSQL/Assets.pm
     +++ b/lib/RT/Extension/AssetSQL/Assets.pm
    -@@
    - use strict;
    - use warnings;
    - use 5.010;
    -+# use RT::CustomRoles;
    - 
    - package RT::Assets;
    - 
    -@@
    -     my $self = shift;
    -     my $window = shift;
    - 
    --    my @old = ($self->_ItemsCounter, $self->RowsPerPage, $self->FirstRow+1);
    -+    my @old = ($self->_ItemsCounter, $self->RowsPerPage, $self->FirstRow1);
    - 
    -     $self->RowsPerPage( $window );
    -     $self->FirstRow(1);
     @@
          Contact         => [ 'WATCHERFIELD' => 'Contact', ], #loc_left_pair
          ContactGroup    => [ 'MEMBERSHIPFIELD' => 'Contact', ], #loc_left_pair
    @@ -250,24 +234,9 @@
              VALUE     => $value,
              SUBCLAUSE => "assetsql",
     @@
    -         if ( $cf ) {
    -             $cf = undef if $cfs->Next;
    + 
    +             $cf = $cfs->First unless $cfs->Count > 1;
              }
    --        else {
    --            # find the cf without ACL
    --            # this is because current _CustomFieldJoinByName has a bug that
    --            # can't search correctly with negative cf ops :/
    --            my $cfs = RT::CustomFields->new( RT->SystemUser );
    --            $cfs->Limit( FIELD => 'Name', VALUE => $field, CASESENSITIVE => 0 );
    --            $cfs->LimitToLookupType( $lookuptype );
    --
    --            if ( $applied_to ) {
    --                $cfs->SetContextObject( $applied_to );
    --                $cfs->LimitToObjectId( $applied_to->id );
    --            }
    --
    --            $cf = $cfs->First unless $cfs->Count > 1;
    --        }
     -
          }
          else {



More information about the Bps-public-commit mailing list