rfe #12123: Layouts related for export purposes
This commit is contained in:
parent
3e161b3ead
commit
f1538824f7
3 changed files with 32 additions and 14 deletions
|
|
@ -1,5 +1,6 @@
|
|||
7.10.16
|
||||
- fixed #12121: typ-o Asset_Map.templateIdEditPoint
|
||||
- rfe #2123: Layouts related for export purposes
|
||||
|
||||
7.10.15
|
||||
- fixed #12117: Thingy - www_searchViaAjax broken
|
||||
|
|
|
|||
|
|
@ -522,9 +522,13 @@ sub exportGetAssetIds {
|
|||
my $session = $self->session;
|
||||
my $ids = $self->exportGetDescendants( undef, $options->{depth} );
|
||||
return $ids unless $options->{exportRelated};
|
||||
# We want the ids in a descendant order, but we don't want to repeat
|
||||
# assetIds, so we're using Tie::IxHash to get an ordered set.
|
||||
tie my %set, 'Tie::IxHash';
|
||||
|
||||
# We don't particularly care about the order of the assetIds. The only
|
||||
# thing that might care is the ProgressTree page, and it computes the tree
|
||||
# by looking at asset lineage anyway. We do want to follow chains of
|
||||
# related assets though, so we'll use $ids as a queue and push related
|
||||
# assets onto the end (unless, of course, they're already in the set).
|
||||
my %set;
|
||||
while (my $id = shift @$ids) {
|
||||
my $asset = WebGUI::Asset->new($session, $id);
|
||||
undef $set{$id};
|
||||
|
|
@ -623,21 +627,25 @@ sub exportGetDescendants {
|
|||
|
||||
=head2 exportGetRelatedAssetIds
|
||||
|
||||
Normally all an asset's shorcuts, but override if exporting your asset would
|
||||
invalidate other exported assets. If exportRelated is checked, this will be
|
||||
called and any assetIds it returns will be exported when your asset is
|
||||
exported.
|
||||
Normally all an asset's shorcuts and its container (via $asset->getContainer),
|
||||
but override if exporting your asset would invalidate other exported assets.
|
||||
If exportRelated is checked, this will be called and any assetIds it returns
|
||||
will be exported when your asset is exported.
|
||||
|
||||
Note: You should NOT include parents as related assets simply because they're
|
||||
your parents. If the user wants to export your parent, he can do that. This is
|
||||
for assets that aren't necessarily in your ancestry. If parents were always
|
||||
related, exporting anything would export everything.
|
||||
This method returns an arrayref, and IS ALLOWED to contain the same assetId
|
||||
more than once. Anyone calling this function should check for duplicates. No
|
||||
particular order should be assumed.
|
||||
|
||||
=cut
|
||||
|
||||
sub exportGetRelatedAssetIds {
|
||||
my $self = shift;
|
||||
WebGUI::Asset::Shortcut->getShortcutsForAssetId($self->session, $self->getId);
|
||||
my $related = WebGUI::Asset::Shortcut->getShortcutsForAssetId(
|
||||
$self->session,
|
||||
$self->getId
|
||||
);
|
||||
push @$related, $self->getContainer->getId;
|
||||
return $related;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -647,9 +647,18 @@ subtest exportRelated => sub {
|
|||
});
|
||||
$tag->commit();
|
||||
my $cleanup = guard { $tag->rollback; if ($old) { $old->setWorking(); } };
|
||||
cmp_deeply(
|
||||
|
||||
# This will include some folders, because of the way Archive works
|
||||
my $expected = $archive->getLineage(['self', 'descendants']);
|
||||
push @$expected, $topic->getId;
|
||||
|
||||
# getContainer should be included; since parent is a Layout, the
|
||||
# upward-recursion will stop there.
|
||||
push @$expected, $topic->getContainer->getId;
|
||||
|
||||
cmp_bag(
|
||||
$archive->exportGetAssetIds({ depth => 99, exportRelated => 1}),
|
||||
superbagof(map { $_->getId } ($topic, $archive, $story)),
|
||||
$expected,
|
||||
'exporting archive includes topic with exportRelated'
|
||||
);
|
||||
is(0, scalar grep { $_ eq $topic->getId }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue