[Bps-public-commit] rt-extension-assetsql branch, master, updated. 10383f4948d03493f225bf068008a2389e4bc407
Shawn Moore
shawn at bestpractical.com
Wed Jun 15 15:50:17 EDT 2016
The branch, master has been updated
via 10383f4948d03493f225bf068008a2389e4bc407 (commit)
via b93af28bcc8fb162b988537cef5202c785b3aebc (commit)
via 240abdbc89dfbf8b98874bd508f913ba2278718c (commit)
from 6ab3b20f89046c974ca776878108fa64fe73cb62 (commit)
Summary of changes:
html/Asset/Search/Build.html | 14 +-
html/Asset/Search/Edit.html | 2 +-
html/Asset/Search/Elements/ConditionRow | 52 ----
html/Asset/Search/Elements/DisplayOptions | 2 +-
html/Asset/Search/Elements/EditFormat | 84 ------
html/Asset/Search/Elements/EditQuery | 196 --------------
html/Asset/Search/Elements/EditSearches | 282 ---------------------
html/Asset/Search/Elements/NewListActions | 19 --
html/Asset/Search/Elements/PickBasics | 11 +-
html/Asset/Search/Elements/PickCriteria | 2 +-
html/Asset/Search/Elements/SearchPrivacy | 14 -
html/Asset/Search/Elements/SelectAndOr | 6 -
html/Asset/Search/Elements/SelectSearchObject | 17 --
.../Asset/Search/Elements/SelectSearchesForObjects | 21 --
patches/assetsql.patch | 4 +-
patches/rt-4.4.0-4.4.1.patch | 23 ++
16 files changed, 42 insertions(+), 707 deletions(-)
delete mode 100644 html/Asset/Search/Elements/ConditionRow
delete mode 100644 html/Asset/Search/Elements/EditFormat
delete mode 100644 html/Asset/Search/Elements/EditQuery
delete mode 100644 html/Asset/Search/Elements/EditSearches
delete mode 100644 html/Asset/Search/Elements/NewListActions
delete mode 100644 html/Asset/Search/Elements/SearchPrivacy
delete mode 100644 html/Asset/Search/Elements/SelectAndOr
delete mode 100644 html/Asset/Search/Elements/SelectSearchObject
delete mode 100644 html/Asset/Search/Elements/SelectSearchesForObjects
- Log -----------------------------------------------------------------
commit 240abdbc89dfbf8b98874bd508f913ba2278718c
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Wed Jun 15 19:03:00 2016 +0000
Regenerate assetsql.patch
4.4/dashboard-sorting changed ShowSearch; this fixes compatibility
with that change.
diff --git a/patches/assetsql.patch b/patches/assetsql.patch
index c841849..7346229 100644
--- a/patches/assetsql.patch
+++ b/patches/assetsql.patch
@@ -21,8 +21,8 @@ index 15b7b75..4234387 100644
titleright => $customize ? loc('Edit') : '',
titleright_href => $customize,
hideable => $hideable &>
--<& $query_display_component, hideable => $hideable, %$ProcessedSearchArg, ShowNavigation => 0, Class => 'RT::Tickets', HasResults => $HasResults &>
-+<& $query_display_component, hideable => $hideable, %$ProcessedSearchArg, ShowNavigation => 0, Class => $SearchArg && $SearchArg->{SearchType} eq 'Asset' ? 'RT::Assets' : 'RT::Tickets', HasResults => $HasResults &>
+-<& $query_display_component, hideable => $hideable, %$ProcessedSearchArg, ShowNavigation => 0, Class => 'RT::Tickets', HasResults => $HasResults, PreferOrderBy => 1 &>
++<& $query_display_component, hideable => $hideable, %$ProcessedSearchArg, ShowNavigation => 0, Class => $SearchArg && $SearchArg->{SearchType} eq 'Asset' ? 'RT::Assets' : 'RT::Tickets', HasResults => $HasResults, PreferOrderBy => 1 &>
</&>
<%init>
my $search;
commit b93af28bcc8fb162b988537cef5202c785b3aebc
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Wed Jun 15 19:14:33 2016 +0000
Reuse core EditFormat, with $IncludeTicketLinks => 0
This gets us AJAX refresh
diff --git a/html/Asset/Search/Elements/DisplayOptions b/html/Asset/Search/Elements/DisplayOptions
index 6847aeb..fc673c9 100644
--- a/html/Asset/Search/Elements/DisplayOptions
+++ b/html/Asset/Search/Elements/DisplayOptions
@@ -2,5 +2,5 @@
<& EditSort, %ARGS &>
</&>
<&| /Widgets/TitleBox, title => loc("Display Columns"), id => 'columns' &>
-<& EditFormat, %ARGS &>
+<& /Search/Elements/EditFormat, IncludeTicketLinks => 0, %ARGS &>
</&>
diff --git a/html/Asset/Search/Elements/EditFormat b/html/Asset/Search/Elements/EditFormat
deleted file mode 100644
index bd649ac..0000000
--- a/html/Asset/Search/Elements/EditFormat
+++ /dev/null
@@ -1,84 +0,0 @@
-<table class="edit-columns">
-
-<tr>
-<th><&|/l&>Add Columns</&>:</th>
-<th><&|/l&>Format</&>:</th>
-<th></th>
-<th><&|/l&>Show Columns</&>:</th>
-</tr>
-
-<tr>
-
-<td valign="top"><select size="15" name="SelectDisplayColumns" multiple="multiple">
-% my %seen;
-% foreach my $field ( grep !$seen{lc $_}++, @$AvailableColumns) {
-<option value="<% $field %>" <% $selected{$field} ? 'selected="selected"' : '' |n%>>\
-<% $field =~ /^(?:CustomField|CF)\./ ? $field : loc($field) %></option>
-% }
-</select></td>
-<td>
-<div class="row">
-<span class="label"><&|/l&>Link</&>:</span>
-<span class="value">
-<select name="Link">
-<option value="None">-</option>
-<option value="Display"><&|/l&>Display</&></option>
-</select>
-</span>
-</div>
-<div class="row">
-<span class="label"><&|/l&>Title</&>:</span>
-<span class="value"><input name="Title" size="10" /></span>
-</div>
-<div class="row">
-<span class="label"><&|/l&>Size</&>:</span>
-<span class="value"><select name="Size">
-<option value="">-</option>
-<option value="Small"><&|/l&>Small</&></option>
-<option value="Large"><&|/l&>Large</&></option>
-</select>
-</span>
-</div>
-<div class="row">
-<span class="label"><&|/l&>Style</&>:</span>
-<span class="value"><select name="Face">
-<option value="">-</option>
-<option value="Bold"><&|/l&>Bold</&></option>
-<option value="Italic"><&|/l&>Italic</&></option>
-</select>
-</span>
-</div>
-</td>
-
-<td><input type="submit" class="button" name="AddCol" value=" → " /></td>
-
-<td valign="top">
-<select size="15" name="CurrentDisplayColumns">
-% my $i=0;
-% my $current = $ARGS{CurrentDisplayColumns} || ''; $current =~ s/^\d+>//;
-% foreach my $field ( @$CurrentFormat ) {
-<option value="<% $i++ %>><% $field->{Column} %>" <% $field->{Column} eq $current ? 'selected="selected"' : '' |n%>>\
-<% $field->{Column} =~ /^(?:CustomField|CF)\./ ? $field->{Column} : loc( $field->{Column} ) %></option>
-% }
-</select>
-<br />
-<center>
-<input type="submit" class="button" name="ColUp" value=" ↑ " />
-<input type="submit" class="button" name="ColDown" value=" ↓ " />
-<input type="submit" class="button" name="RemoveCol" value="<%loc('Delete')%>" />
-</center>
-</td>
-
-</tr>
-</table>
-
-<%init>
-my $selected = $ARGS{SelectDisplayColumns};
-$selected = [ $selected ] unless ref $selected;
-my %selected;
-$selected{$_}++ for grep {defined} @{ $selected };
-</%init>
-<%ARGS>
-$CurrentFormat => undef
-$AvailableColumns => undef
-</%ARGS>
diff --git a/patches/rt-4.4.0-4.4.1.patch b/patches/rt-4.4.0-4.4.1.patch
index abc33ee..0830779 100644
--- a/patches/rt-4.4.0-4.4.1.patch
+++ b/patches/rt-4.4.0-4.4.1.patch
@@ -169,3 +169,26 @@ index f4ac8a9..e672e3b 100644
};
+diff --git a/share/html/Search/Elements/EditFormat b/share/html/Search/Elements/EditFormat
+index 4e2bfd8..4c305d2 100644
+--- a/share/html/Search/Elements/EditFormat
++++ b/share/html/Search/Elements/EditFormat
+@@ -97,10 +97,12 @@ jQuery( function() {
+ <select name="Link">
+ <option value="None">-</option>
+ <option value="Display"><&|/l&>Display</&></option>
++% if ($IncludeTicketLinks) {
+ <option value="Take"><&|/l&>Take</&></option>
+ <option value="Respond"><&|/l&>Respond</&></option>
+ <option value="Comment"><&|/l&>Comment</&></option>
+ <option value="Resolve"><&|/l&>Resolve</&></option>
++% }
+ </select>
+ </span>
+ </div>
+@@ -159,4 +161,5 @@ $selected{$_}++ for grep {defined} @{ $selected };
+ <%ARGS>
+ $CurrentFormat => undef
+ $AvailableColumns => undef
++$IncludeTicketLinks => 1
+ </%ARGS>
commit 10383f4948d03493f225bf068008a2389e4bc407
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Wed Jun 15 19:06:15 2016 +0000
Remove unchanged (or mostly unchanged) copies of core search components
diff --git a/html/Asset/Search/Build.html b/html/Asset/Search/Build.html
index 20b0403..86744d7 100644
--- a/html/Asset/Search/Build.html
+++ b/html/Asset/Search/Build.html
@@ -37,7 +37,7 @@
<div id="editquery">
-<& Elements/EditQuery,
+<& /Search/Elements/EditQuery,
%ARGS,
actions => \@actions,
optionlist => $optionlist,
@@ -45,7 +45,7 @@
&>
</div>
<div id="editsearches">
- <& Elements/EditSearches, %saved_search, CurrentSearch => \%query &>
+ <& /Search/Elements/EditSearches, %saved_search, Type => 'Asset', CurrentSearch => \%query &>
</div>
<span id="display-options">
@@ -64,13 +64,13 @@ use RT::Interface::Web::QueryBuilder::Tree;
my $title = loc("Asset Query Builder");
-my %query;
+my %query = (Type => 'Asset');
for( qw(Query Format OrderBy Order RowsPerPage) ) {
$query{$_} = $ARGS{$_};
}
-my %saved_search;
-my @actions = $m->comp( 'Elements/EditSearches:Init', %ARGS, Query => \%query, SavedSearch => \%saved_search);
+my %saved_search = (Type => 'Asset');
+my @actions = $m->comp( '/Search/Elements/EditSearches:Init', %ARGS, Type => 'Asset', Query => \%query, SavedSearch => \%saved_search);
if ( $NewQuery ) {
@@ -208,7 +208,7 @@ foreach my $arg ( keys %ARGS ) {
}
-push @actions, $m->comp('Elements/EditQuery:Process',
+push @actions, $m->comp('/Search/Elements/EditQuery:Process',
%ARGS,
Tree => $tree,
Selected => \@current_values,
@@ -238,7 +238,7 @@ my ( $AvailableColumns, $CurrentFormat );
# if we're asked to save the current search, save it
-push @actions, $m->comp( 'Elements/EditSearches:Save', %ARGS, Query => \%query, SavedSearch => \%saved_search);
+push @actions, $m->comp( '/Search/Elements/EditSearches:Save', %ARGS, Type => 'Asset', Query => \%query, SavedSearch => \%saved_search);
# Populate the "query" context with saved search data
diff --git a/html/Asset/Search/Edit.html b/html/Asset/Search/Edit.html
index cc255bc..8c1f7ff 100644
--- a/html/Asset/Search/Edit.html
+++ b/html/Asset/Search/Edit.html
@@ -1,7 +1,7 @@
<& /Elements/Header, Title => $title&>
<& /Elements/Tabs &>
-<& Elements/NewListActions, actions => \@actions &>
+<& /Search/Elements/NewListActions, actions => \@actions &>
<form method="post" action="Build.html" id="BuildQueryAdvanced" name="BuildQueryAdvanced">
<input type="hidden" class="hidden" name="SavedSearchId" value="<% $SavedSearchId %>" />
diff --git a/html/Asset/Search/Elements/ConditionRow b/html/Asset/Search/Elements/ConditionRow
deleted file mode 100644
index 8dd6328..0000000
--- a/html/Asset/Search/Elements/ConditionRow
+++ /dev/null
@@ -1,52 +0,0 @@
-<tr>
-<td class="label"><% $handle_block->( $Condition->{'Field'}, $Condition->{'Name'} .'Field' ) |n %></td>
-<td class="operator"><% $handle_block->( $Condition->{'Op'}, $Condition->{'Name'} .'Op') |n %></td>
-<td class="value"><% $handle_block->( $Condition->{'Value'}, 'ValueOf'. $Condition->{'Name'} ) |n %></td>
-</tr>
-<%INIT>
-return unless $Condition && $Condition->{'Name'};
-
-$m->callback( Condition => \$Condition );
-return unless $Condition;
-
-my $handle_block;
-$handle_block = sub {
- my $box = shift;
- return $box unless ref $box;
-
- my $name = shift;
- if ( UNIVERSAL::isa($box, 'ARRAY') ) {
- my $res = '';
- $res .= $handle_block->( $_, $name ) foreach @$box;
- return $res;
- }
-
- return undef unless UNIVERSAL::isa($box, 'HASH');
- if ( $box->{'Type'} eq 'component' ) {
- $box->{'Arguments'} ||= {},
- return $m->scomp( $box->{'Path'}, %{ $box->{'Arguments'} }, Name => $name );
- }
- if ( $box->{'Type'} eq 'text' ) {
- $box->{id} ||= $box->{name} ||= $name;
- $box->{value} ||= delete($box->{Default}) || '';
- return "<input ".join(" ", map{$m->interp->apply_escapes(lc($_),'h')
- .q{="}.$m->interp->apply_escapes($box->{$_},'h').q{"}}
- sort keys %$box)." />";
- }
- if ( $box->{'Type'} eq 'select' ) {
- my $res = '';
- $res .= qq{<select id="$name" name="$name">};
- my @options = @{ $box->{'Options'} };
- while( my $k = shift @options ) {
- my $v = shift @options;
- $res .= qq{<option value="$k">$v</option>};
- }
- $res .= qq{</select>};
- return $res;
- }
-};
-
-</%INIT>
-<%ARGS>
-$Condition => {}
-</%ARGS>
diff --git a/html/Asset/Search/Elements/EditQuery b/html/Asset/Search/Elements/EditQuery
deleted file mode 100644
index d019cc3..0000000
--- a/html/Asset/Search/Elements/EditQuery
+++ /dev/null
@@ -1,196 +0,0 @@
-<& NewListActions, actions => $actions &>
-<&|/Widgets/TitleBox, title => join(': ', grep defined, loc("Current search"), $Description) &>
-
-<select size="10" name="clauses" style="width: 100%" multiple="multiple">
-% $m->out($optionlist);
-</select>
-
-<p align="center">
-<input type="submit" class="button" name="Up" value=" ↑ " />
-<input type="submit" class="button" name="Down" value=" ↓ " />
-<input type="submit" class="button" name="Left" value=" ← " />
-<input type="submit" class="button" name="Right" value=" → " />
-<input type="submit" class="button" name="Toggle" value="<&|/l&>And/Or</&>" />
-<input type="submit" class="button" name="DeleteClause" value="<&|/l&>Delete</&>" />
-%#<input type="submit" class="button" name="EditQuery" value="Advanced" />
-</p>
-
-</&>
-<%ARGS>
-$Description => undef
-$optionlist => ''
-$actions => []
-</%ARGS>
-
-<%METHOD Process>
-<%ARGS>
-$Tree
-$Selected
- at New => ()
-</%ARGS>
-<%INIT>
-
-my @NewSelection = ();
-
-my @results;
-if ( $ARGS{'Up'} || $ARGS{'Down'} ) {
- if (@$Selected) {
- foreach my $value (@$Selected) {
- my $parent = $value->getParent;
- my $index = $value->getIndex;
- my $newindex = $index;
- $newindex++ if $ARGS{'Down'};
- $newindex-- if $ARGS{'Up'};
- if ( $newindex < 0 || $newindex >= $parent->getChildCount ) {
- push( @results, [ loc("error: can't move up"), -1 ] ) if $ARGS{'Up'};
- push( @results, [ loc("error: can't move down"), -1 ] ) if $ARGS{'Down'};
- next;
- }
-
- $parent->removeChild( $index );
- $parent->insertChild( $newindex, $value );
- }
- }
- else {
- push( @results, [ loc("error: nothing to move"), -1 ] );
- }
-}
-elsif ( $ARGS{"Left"} ) {
- if (@$Selected) {
- foreach my $value (@$Selected) {
- my $parent = $value->getParent;
- if( $value->isRoot || $parent->isRoot ) {
- push( @results, [ loc("error: can't move left"), -1 ] );
- next;
- }
-
- my $grandparent = $parent->getParent;
- if( $grandparent->isRoot ) {
- push( @results, [ loc("error: can't move left"), -1 ] );
- next;
- }
-
- my $index = $parent->getIndex;
- $parent->removeChild($value);
- $grandparent->insertChild( $index, $value );
- if ( $parent->isLeaf ) {
- $grandparent->removeChild($parent);
- }
- }
- }
- else {
- push( @results, [ loc("error: nothing to move"), -1 ] );
- }
-}
-elsif ( $ARGS{"Right"} ) {
- if (@$Selected) {
- foreach my $value (@$Selected) {
- my $parent = $value->getParent;
- my $index = $value->getIndex;
-
- my $newparent;
- if ( $index > 0 ) {
- my $sibling = $parent->getChild( $index - 1 );
- $newparent = $sibling unless $sibling->isLeaf;
- }
- $newparent ||= RT::Interface::Web::QueryBuilder::Tree->new( $ARGS{'AndOr'} || 'AND', $parent );
-
- $parent->removeChild($value);
- $newparent->addChild($value);
- }
- }
- else {
- push( @results, [ loc("error: nothing to move"), -1 ] );
- }
-}
-elsif ( $ARGS{"DeleteClause"} ) {
- if (@$Selected) {
- my (@top);
- my %Selected = map { $_ => 1 } @$Selected;
- foreach my $node ( @$Selected ) {
- my $tmp = $node->getParent;
- while ( !$Selected{ $tmp } && !$tmp->isRoot ) {
- $tmp = $tmp->getParent;
- }
- next if $Selected{ $tmp };
- push @top, $node;
- }
-
- my %seen;
- my @non_siblings_top = grep !$seen{ $_->getParent }++, @top;
-
- foreach ( @New ) {
- my $add = $_->clone;
- foreach my $selected( @non_siblings_top ) {
- my $newindex = $selected->getIndex + 1;
- $selected->insertSibling( $newindex, $add );
- }
- $add->getParent->setNodeValue( $ARGS{'AndOr'} );
- push @NewSelection, $add;
- }
- @New = ();
-
- while( my $node = shift @top ) {
- my $parent = $node->getParent;
- $parent->removeChild($node);
- $node->DESTROY;
- }
- @$Selected = ();
- }
- else {
- push( @results, [ loc("error: nothing to delete"), -1 ] );
- }
-}
-elsif ( $ARGS{"Toggle"} ) {
- if (@$Selected) {
- my %seen;
- my @unique_nodes = grep !$seen{ $_ + 0 }++,
- map ref $_->getNodeValue? $_->getParent: $_,
- @$Selected;
-
- foreach my $node ( @unique_nodes ) {
- if ( $node->getNodeValue eq 'AND' ) {
- $node->setNodeValue('OR');
- }
- else {
- $node->setNodeValue('AND');
- }
- }
- }
- else {
- push( @results, [ loc("error: nothing to toggle"), -1 ] );
- }
-}
-
-if ( @New && @$Selected ) {
- my %seen;
- my @non_siblings_selected = grep !$seen{ $_->getParent }++, @$Selected;
-
- foreach ( @New ) {
- my $add = $_->clone;
- foreach my $selected( @non_siblings_selected ) {
- my $newindex = $selected->getIndex + 1;
- $selected->insertSibling( $newindex, $add );
- }
- $add->getParent->setNodeValue( $ARGS{'AndOr'} );
- push @NewSelection, $add;
- }
- @$Selected = ();
-}
-elsif ( @New ) {
- foreach ( @New ) {
- my $add = $_->clone;
- $Tree->addChild( $add );
- push @NewSelection, $add;
- }
- $Tree->setNodeValue( $ARGS{'AndOr'} );
-}
-$_->DESTROY foreach @New;
-
-push @$Selected, @NewSelection;
-
-$Tree->PruneChildlessAggregators;
-
-return @results;
-</%INIT>
-</%METHOD>
diff --git a/html/Asset/Search/Elements/EditSearches b/html/Asset/Search/Elements/EditSearches
deleted file mode 100644
index f1db3f3..0000000
--- a/html/Asset/Search/Elements/EditSearches
+++ /dev/null
@@ -1,282 +0,0 @@
-<div class="edit-saved-searches">
-<&| /Widgets/TitleBox, title => loc($Title)&>
-
-%# Hide all the save functionality if the user shouldn't see it.
-% if ( $can_modify ) {
-<span class="label"><&|/l&>Privacy</&>:</span>
-<& SelectSearchObject, Name => 'SavedSearchOwner', Objects => \@Objects, Object => ( $Object && $Object->id ) ? $Object->Object : '' &>
-<br />
-<span class="label"><&|/l&>Description</&>:</span>
-<input size="25" name="SavedSearchDescription" value="<% $Description || '' %>" />
-
-% if ($Id ne 'new') {
-<nobr>
-% if ( $Dirty ) {
-<input type="submit" class="button" name="SavedSearchRevert" value="<%loc('Revert')%>" />
-% }
-<input type="submit" class="button" name="SavedSearchDelete" value="<%loc('Delete')%>" />
-% if ( $AllowCopy ) {
-<input type="submit" class="button" name="SavedSearchCopy" value="<%loc('Save as New')%>" />
-% }
-</nobr>
-% }
-% if ( $Object && $Object->Id ) {
-<input type="submit" class="button" id="SavedSearchSave" name="SavedSearchSave" value="<%loc('Update')%>" />
-% } else {
-<input type="submit" class="button" id="SavedSearchSave" name="SavedSearchSave" value="<%loc('Save')%>" />
-%}
-% }
-<br />
-<hr />
-<span class="label"><&|/l&>Load saved search</&>:</span>
-<& SelectSearchesForObjects, Name => 'SavedSearchLoad', Objects => \@Objects, SearchType => $Type &>
-<input type="submit" value="<% loc('Load') %>" id="SavedSearchLoadSubmit" name="SavedSearchLoadSubmit" class="button" />
-
-</&>
-</div>
-<%INIT>
-return unless $session{'CurrentUser'}->HasRight(
- Right => 'LoadSavedSearch',
- Object => $RT::System,
-);
-
-my $can_modify = $session{'CurrentUser'}->HasRight(
- Right => 'CreateSavedSearch',
- Object => $RT::System,
-);
-
-use RT::SavedSearch;
-my @Objects = RT::SavedSearch->new($session{CurrentUser})->_PrivacyObjects;
-push @Objects, RT::System->new( $session{'CurrentUser'} )
- if $session{'CurrentUser'}->HasRight( Object=> $RT::System,
- Right => 'SuperUser' );
-
-my $is_dirty = sub {
- my %arg = (
- Query => {},
- SavedSearch => {},
- SearchFields => [qw(Query Format OrderBy Order RowsPerPage)],
- @_
- );
-
- my $obj = $arg{'SavedSearch'}->{'Object'};
- return 0 unless $obj && $obj->id;
-
- foreach( @{ $arg{'SearchFields'} } ) {
- return 1 if $obj->SubValue( $_ ) ne $arg{'Query'}->{$_};
- }
-
- return 0;
-};
-
-# If we're modifying an old query, check if it's been changed
-my $Dirty = $is_dirty->(
- Query => $CurrentSearch,
- SavedSearch => { Id => $Id, Object => $Object, Description => $Description },
- SearchFields => \@SearchFields,
-);
-
-</%INIT>
-
-<%ARGS>
-$Id => 'new'
-$Object => undef
-$Type => 'Asset'
-$Description => ''
-$CurrentSearch => {}
- at SearchFields => ()
-$AllowCopy => 1
-$Title => loc('Saved searches')
-</%ARGS>
-
-<%METHOD Init>
-<%ARGS>
-$Query => {}
-$SavedSearch => {}
- at SearchFields => qw(Query Format OrderBy Order RowsPerPage)
-</%ARGS>
-<%INIT>
-
-$SavedSearch->{'Id'} = $ARGS{'SavedSearchId'} || 'new';
-$SavedSearch->{'Type'} = 'Asset';
-$SavedSearch->{'Description'} = $ARGS{'SavedSearchDescription'} || '';
-$SavedSearch->{'Privacy'} = $ARGS{'SavedSearchOwner'} || undef;
-
-my @results;
-
-if ( $ARGS{'SavedSearchRevert'} ) {
- $ARGS{'SavedSearchLoad'} = $SavedSearch->{'Id'};
-}
-
-if ( $ARGS{'SavedSearchLoad'} ) {
- my ($container, $id ) = _parse_saved_search ($ARGS{'SavedSearchLoad'});
- if ( $container ) {
- my $search = RT::Attribute->new( $session{'CurrentUser'} );
- $search->Load( $id );
- $SavedSearch->{'Id'} = $ARGS{'SavedSearchLoad'};
- $SavedSearch->{'Object'} = $search;
- $SavedSearch->{'Description'} = $search->Description;
- $Query->{$_} = $search->SubValue($_) foreach @SearchFields;
-
- if ( $ARGS{'SavedSearchRevert'} ) {
- push @results, loc('Loaded original "[_1]" saved search', $SavedSearch->{'Description'} );
- } else {
- push @results, loc('Loaded saved search "[_1]"', $SavedSearch->{'Description'} );
- }
- }
- else {
- push @results, loc( 'Can not load saved search "[_1]"',
- $ARGS{'SavedSearchLoad'} );
- return @results;
- }
-}
-elsif ( $ARGS{'SavedSearchDelete'} ) {
- # We set $SearchId to 'new' above already, so peek into the %ARGS
- my ($container, $id) = _parse_saved_search( $SavedSearch->{'Id'} );
- if ( $container && $container->id ) {
- # We have the object the entry is an attribute on; delete the entry...
- my ($val, $msg) = $container->Attributes->DeleteEntry( Name => 'SavedSearch', id => $id );
- unless ( $val ) {
- push @results, $msg;
- return @results;
- }
- }
- $SavedSearch->{'Id'} = 'new';
- $SavedSearch->{'Object'} = undef;
- $SavedSearch->{'Description'} = undef;
- push @results, loc("Deleted saved search");
-}
-elsif ( $ARGS{'SavedSearchCopy'} ) {
- my ($container, $id ) = _parse_saved_search( $ARGS{'SavedSearchId'} );
- $SavedSearch->{'Object'} = RT::Attribute->new( $session{'CurrentUser'} );
- $SavedSearch->{'Object'}->Load( $id );
- if ( $ARGS{'SavedSearchDescription'} && $ARGS{'SavedSearchDescription'} ne $SavedSearch->{'Object'}->Description ) {
- $SavedSearch->{'Description'} = $ARGS{'SavedSearchDescription'};
- } else {
- $SavedSearch->{'Description'} = loc( "[_1] copy", $SavedSearch->{'Object'}->Description );
- }
- $SavedSearch->{'Id'} = 'new';
- $SavedSearch->{'Object'} = undef;
-}
-
-if ( $SavedSearch->{'Id'} && $SavedSearch->{'Id'} ne 'new'
- && !$SavedSearch->{'Object'} )
-{
- my ($container, $id ) = _parse_saved_search( $ARGS{'SavedSearchId'} );
- $SavedSearch->{'Object'} = RT::Attribute->new( $session{'CurrentUser'} );
- $SavedSearch->{'Object'}->Load( $id );
- $SavedSearch->{'Description'} ||= $SavedSearch->{'Object'}->Description;
-}
-
-return @results;
-
-</%INIT>
-</%METHOD>
-
-<%METHOD Save>
-<%ARGS>
-$Query => {}
-$SavedSearch => {}
- at SearchFields => qw(Query Format OrderBy Order RowsPerPage)
-</%ARGS>
-<%INIT>
-
-return unless $ARGS{'SavedSearchSave'} || $ARGS{'SavedSearchCopy'};
-
-my @results;
-my $obj = $SavedSearch->{'Object'};
-my $id = $SavedSearch->{'Id'};
-my $desc = $SavedSearch->{'Description'};
-my $privacy = $SavedSearch->{'Privacy'};
-
-my %params = map { $_ => $Query->{$_} } @SearchFields;
-my ($new_obj_type, $new_obj_id) = split(/\-/, ($privacy || ''));
-
-if ( $obj && $obj->id ) {
- # permission check
- if ($obj->Object->isa('RT::System')) {
- unless ($session{'CurrentUser'}->HasRight( Object=> $RT::System, Right => 'SuperUser')) {
- push @results, loc("No permission to save system-wide searches");
- return @results;
- }
- }
-
- $obj->SetSubValues( %params );
- $obj->SetDescription( $desc );
-
- my $obj_type = ref($obj->Object);
- # We need to get current obj_id now, because when we change obj_type to
- # RT::System, $obj->Object->Id returns 1, not the old one :(
- my $obj_id = $obj->Object->Id;
-
- if ( $new_obj_type && $new_obj_id ) {
- my ($val, $msg);
-
- # we need to check right before we change any of ObjectType and ObjectId,
- # or it will fail the 2nd change if we use SetObjectType and
- # SetObjectId sequentially
-
- if ( $obj->CurrentUserHasRight('update') ) {
- if ( $new_obj_type ne $obj_type ) {
- ( $val, $msg ) = $obj->__Set(
- Field => 'ObjectType',
- Value => $new_obj_type,
- );
- push @results, loc( 'Unable to set privacy object: [_1]', $msg )
- unless ($val);
- }
- if ( $new_obj_id != $obj_id ) {
- ( $val, $msg ) = $obj->__Set(
- Field => 'ObjectId',
- Value => $new_obj_id,
- );
- push @results, loc( 'Unable to set privacy id: [_1]', $msg )
- unless ($val);
- }
- }
- else {
- # two loc are just for convenience so we don't need to
- # write an extra i18n translation item
- push @results,
- loc( 'Unable to set privacy object or id: [_1]',
- loc('Permission Denied') )
- }
- } else {
- push @results, loc('Unable to determine object type or id');
- }
- push @results, loc('Updated saved search "[_1]"', $desc);
-}
-elsif ( $id eq 'new' and defined $desc and length $desc ) {
- my $saved_search = RT::SavedSearch->new( $session{'CurrentUser'} );
- my ($status, $msg) = $saved_search->Save(
- Privacy => $privacy,
- Name => $desc,
- Type => $SavedSearch->{'Type'},
- SearchParams => \%params,
- );
-
- if ( $status ) {
- $SavedSearch->{'Object'} = RT::Attribute->new( $session{'CurrentUser'} );
- $SavedSearch->{'Object'}->Load( $saved_search->Id );
- # Build new SearchId
- $SavedSearch->{'Id'} =
- ref( $session{'CurrentUser'}->UserObj ) . '-'
- . $session{'CurrentUser'}->UserObj->Id
- . '-SavedSearch-'
- . $SavedSearch->{'Object'}->Id;
- }
- else {
- push @results, loc("Can't find a saved search to work with").': '.loc($msg);
- }
-}
-elsif ( $id eq 'new' ) {
- push @results, loc("Can't save a search without a Description");
-}
-else {
- push @results, loc("Can't save this search");
-}
-
-return @results;
-
-</%INIT>
-</%METHOD>
diff --git a/html/Asset/Search/Elements/NewListActions b/html/Asset/Search/Elements/NewListActions
deleted file mode 100644
index 4424405..0000000
--- a/html/Asset/Search/Elements/NewListActions
+++ /dev/null
@@ -1,19 +0,0 @@
-<b><%loc('Results')%></b><br />
-% foreach my $action (@actions) {
-% my @item = @$action;
-% if ($item[1] < 0) {
-<font color="red">
-% }
- <%$item[0]%><br />
-% if ($item[1] < 0) {
-</font>
-% }
-% }
-<br />
-<%init>
- at actions = map ref $_? $_: [$_, 0], grep defined && length, @actions;
-return unless @actions;
-</%init>
-<%ARGS>
- at actions => undef
-</%ARGS>
diff --git a/html/Asset/Search/Elements/PickBasics b/html/Asset/Search/Elements/PickBasics
index 6d6b242..7f903ee 100644
--- a/html/Asset/Search/Elements/PickBasics
+++ b/html/Asset/Search/Elements/PickBasics
@@ -1,5 +1,5 @@
% foreach( @lines ) {
-<& ConditionRow, Condition => $_ &>
+<& /Search/Elements/ConditionRow, Condition => $_ &>
% }
<%INIT>
@@ -63,7 +63,7 @@ my @lines = (
Name => 'Watcher',
Field => {
Type => 'component',
- Path => 'SelectPersonType',
+ Path => '/Asset/Search/Elements/SelectPersonType',
Arguments => { Default => 'Owner' },
},
Op => {
@@ -76,7 +76,7 @@ my @lines = (
Name => 'WatcherGroup',
Field => {
Type => 'component',
- Path => 'SelectPersonType',
+ Path => '/Asset/Search/Elements/SelectPersonType',
Arguments => { Default => 'Owner', Suffix => 'Group' },
},
Op => {
@@ -103,7 +103,10 @@ my @lines = (
},
{
Name => 'Links',
- Field => { Type => 'component', Path => 'SelectLinks' },
+ Field => {
+ Type => 'component',
+ Path => '/Asset/Search/Elements/SelectLinks',
+ },
Op => {
Type => 'component',
Path => '/Elements/SelectBoolean',
diff --git a/html/Asset/Search/Elements/PickCriteria b/html/Asset/Search/Elements/PickCriteria
index 94920d9..6a3cc34 100644
--- a/html/Asset/Search/Elements/PickCriteria
+++ b/html/Asset/Search/Elements/PickCriteria
@@ -11,7 +11,7 @@
<tr class="separator"><td colspan="3"><hr /></td></tr>
<tr>
<td class="label"><&|/l&>Aggregator</&></td>
-<td class="operator" colspan="2"><& SelectAndOr, Name => "AndOr" &></td>
+<td class="operator" colspan="2"><& /Search/Elements/SelectAndOr, Name => "AndOr" &></td>
</tr>
diff --git a/html/Asset/Search/Elements/SearchPrivacy b/html/Asset/Search/Elements/SearchPrivacy
deleted file mode 100644
index 2008cdd..0000000
--- a/html/Asset/Search/Elements/SearchPrivacy
+++ /dev/null
@@ -1,14 +0,0 @@
-<%args>
-$Object => undef
-</%args>
-<%init>
-my $label;
-if (ref($Object) eq 'RT::User') {
- $label = $Object->id == $session{'CurrentUser'}->Id
- ? loc("My saved searches")
- : loc("[_1]'s saved searches", $Object->Format);
-} else {
- $label = loc("[_1]'s saved searches", $Object->Name);
-}
-</%init>
-<% $label %>\
diff --git a/html/Asset/Search/Elements/SelectAndOr b/html/Asset/Search/Elements/SelectAndOr
deleted file mode 100644
index 5002360..0000000
--- a/html/Asset/Search/Elements/SelectAndOr
+++ /dev/null
@@ -1,6 +0,0 @@
-<label><input type="radio" class="radio" name="<%$Name%>" checked="checked" value="AND" /><&|/l&>AND</&></label>
-<label><input type="radio" class="radio" name="<%$Name%>" value="OR" /><&|/l&>OR</&></label>
-
-<%ARGS>
-$Name => "Operator"
-</%ARGS>
diff --git a/html/Asset/Search/Elements/SelectSearchObject b/html/Asset/Search/Elements/SelectSearchObject
deleted file mode 100644
index fd1d75e..0000000
--- a/html/Asset/Search/Elements/SelectSearchObject
+++ /dev/null
@@ -1,17 +0,0 @@
-<%args>
- at Objects => undef
-$Name => undef
-$Object => undef
-</%args>
-<%init>
-my $default_privacy = '';
-if ( $Object && $Object->Id ) {
- $default_privacy = ref($Object).'-'.$Object->Id;
-}
-</%init>
-<select id="<%$Name%>" name="<%$Name%>">
-% foreach my $object (@Objects) {
-% my $privacy = ref($object).'-'.$object->id;
-<option value="<%$privacy%>" <% ( $privacy eq $default_privacy ) ? "selected='selected'" : '' |n %>><& SearchPrivacy, Object => $object &></option>
-% }
-</select>
diff --git a/html/Asset/Search/Elements/SelectSearchesForObjects b/html/Asset/Search/Elements/SelectSearchesForObjects
deleted file mode 100644
index d2f3068..0000000
--- a/html/Asset/Search/Elements/SelectSearchesForObjects
+++ /dev/null
@@ -1,21 +0,0 @@
-<%args>
- at Objects => undef
-$Name => undef
-$SearchType => 'Asset',
-</%args>
-<select id="<%$Name%>" name="<%$Name%>">
-<option value="">-</option>
-% foreach my $object (@Objects) {
-% my @searches = $object->Attributes->Named('SavedSearch');
-% if ( @searches ) {
-<optgroup label="<& SearchPrivacy, Object => $object &>">
-% foreach my $search (@searches) {
-% # Skip it if it is not of search type we want.
-% next if ($search->SubValue('SearchType')
-% && $search->SubValue('SearchType') ne $SearchType);
-<option value="<%ref($object)%>-<%$object->id%>-SavedSearch-<%$search->Id%>"><%$search->Description||loc('Unnamed search')%></option>
-% }
-</optgroup>
-% }
-% }
-</select>
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list