Skip to content

Commit 2628263

Browse files
committedSep 7, 2011
Mobile template is not being inherited (#12246)
added extra_www_add_properties method to Asset.pm and subclassed it in as Layout.pm as properties fix-up hook in child for www_add
1 parent d65fd7e commit 2628263

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed
 

‎docs/changelog/7.x.x.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- fixed #12239: Still get cart error message after removing extra recurring items from the cart
88
- fixed #12240: Empty Extend Calendar Recurrance version tags
99
- fixed #12241: Account Shop
10+
- fixed #12246: added extra_www_add_properties as properties fix-up hook in child for www_add
1011

1112
7.10.22
1213
- rfe #12223: Add date type to content profiling (metadata)

‎lib/WebGUI/Asset.pm

+19
Original file line numberDiff line numberDiff line change
@@ -2927,13 +2927,32 @@ sub www_add {
29272927
url=>scalar($self->session->form->param("url")),
29282928
);
29292929
$properties{isHidden} = 1 unless $self->session->config->get("assets/".$class."/isContainer");
2930+
$class->extra_www_add_properties($self->session, $self, \%properties );
29302931
my $newAsset = WebGUI::Asset->newByPropertyHashRef($self->session,\%properties);
29312932
$newAsset->{_parent} = $self;
29322933
return $newAsset->www_edit();
29332934
}
29342935

29352936
#-------------------------------------------------------------------
29362937

2938+
=head2 extra_www_add_properties ( $session, $parentAsset, \%properties )
2939+
2940+
Called from C<www_add> by the parent asset on the class of the new asset being constructed.
2941+
The asset class has the chance to modify or augment C<$properties> before the new asset
2942+
is presented for edit.
2943+
This base version does nothing. It should be overridden as needed.
2944+
2945+
=cut
2946+
2947+
sub extra_www_add_properties {
2948+
my $self = shift;
2949+
my $session = shift;
2950+
my $parentAsset = shift;
2951+
my $properties = shift;
2952+
}
2953+
2954+
#-------------------------------------------------------------------
2955+
29372956
=head2 www_ajaxInlineView ( )
29382957
29392958
Returns the view() method of the asset object if the requestor canView.

‎lib/WebGUI/Asset/Wobject/Layout.pm

+19
Original file line numberDiff line numberDiff line change
@@ -514,5 +514,24 @@ sub www_view {
514514
return $self->SUPER::www_view;
515515
}
516516

517+
#-------------------------------------------------------------------
518+
519+
=head2 extra_www_add_properties ()
520+
521+
Inherit C<mobileStyleTemplateId> and C<mobileTemplateId> from the parent asset if it is an instance of
522+
L<WebGUI::Asset::Wobject::Layout>.
523+
524+
=cut
525+
526+
sub extra_www_add_properties {
527+
my $self = shift;
528+
my $session = shift;
529+
my $parentAsset = shift;
530+
my $properties = shift;
531+
return unless $parentAsset->isa('WebGUI::Asset::Wobject::Layout');
532+
$properties->{ mobileStyleTemplateId } = $parentAsset->get("mobileStyleTemplateId");
533+
$properties->{ mobileTemplateId } = $parentAsset->get("mobileTemplateId");
534+
}
535+
517536
1;
518537

‎t/Asset/Wobject/Layout.t

+23-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ use lib "$FindBin::Bin/../../lib";
1616
use Test::MockTime qw/:all/; ##Must be loaded before all other code
1717
use WebGUI::Test;
1818
use WebGUI::Session;
19-
use Test::More tests => 3; # increment this value for each test you create
19+
use Test::More tests => 5; # increment this value for each test you create
2020
use WebGUI::Asset::Wobject::Layout;
21+
use WebGUI::Asset::Template;
2122

2223
my $session = WebGUI::Test->session;
2324

@@ -64,4 +65,25 @@ set_relative_time(-100);
6465
$snip1 = $snip1->addRevision({ title => 'titular', }, 18);
6566
is $page->getContentLastModifiedBy, $revised_user1->userId, '... check that a new revision tracks';
6667

68+
# inheriting mobileStyleTemplateId and mobileTemplateId; from ``Mobile template is not being inherited (#12246)''
69+
70+
my $importNode = WebGUI::Asset::Template->getImportNode($session);
71+
my $template1 = $importNode->addChild({className=>"WebGUI::Asset::Template"});
72+
my $template2 = $importNode->addChild({className=>"WebGUI::Asset::Template"});
73+
WebGUI::Test->addToCleanup($template1, $template2);
74+
75+
my $mobileStyleTemplateId = $template1->getId;
76+
my $mobileTemplateId = $template2->getId;
77+
$page->update({ mobileStyleTemplateId => $mobileStyleTemplateId, mobileTemplateId => $mobileTemplateId });
78+
my $url = $page->get('url') . '/layout_child_test';
79+
my $html = WebGUI::Test->getPage($page, "www_add", {
80+
userId => 3,
81+
formParams => {
82+
class => 'WebGUI::Asset::Wobject::Layout',
83+
url => $page->get('url') . '/layout_child_test',
84+
},
85+
});
86+
87+
like $html, qr/name="mobileTemplateId" value="$mobileTemplateId"/, 'child PageLayout inherited parents mobileTempaleId';
88+
like $html, qr/name="mobileStyleTemplateId" value="$mobileStyleTemplateId"/, 'child PageLayout inherited parents mobileStyleTempaleId';
6789

0 commit comments

Comments
 (0)
Please sign in to comment.