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
This commit is contained in:
Scott Walters 2011-09-07 15:43:23 -04:00
parent d65fd7e646
commit 2628263384
4 changed files with 62 additions and 1 deletions

View file

@ -2927,6 +2927,7 @@ sub www_add {
url=>scalar($self->session->form->param("url")),
);
$properties{isHidden} = 1 unless $self->session->config->get("assets/".$class."/isContainer");
$class->extra_www_add_properties($self->session, $self, \%properties );
my $newAsset = WebGUI::Asset->newByPropertyHashRef($self->session,\%properties);
$newAsset->{_parent} = $self;
return $newAsset->www_edit();
@ -2934,6 +2935,24 @@ sub www_add {
#-------------------------------------------------------------------
=head2 extra_www_add_properties ( $session, $parentAsset, \%properties )
Called from C<www_add> by the parent asset on the class of the new asset being constructed.
The asset class has the chance to modify or augment C<$properties> before the new asset
is presented for edit.
This base version does nothing. It should be overridden as needed.
=cut
sub extra_www_add_properties {
my $self = shift;
my $session = shift;
my $parentAsset = shift;
my $properties = shift;
}
#-------------------------------------------------------------------
=head2 www_ajaxInlineView ( )
Returns the view() method of the asset object if the requestor canView.

View file

@ -514,5 +514,24 @@ sub www_view {
return $self->SUPER::www_view;
}
#-------------------------------------------------------------------
=head2 extra_www_add_properties ()
Inherit C<mobileStyleTemplateId> and C<mobileTemplateId> from the parent asset if it is an instance of
L<WebGUI::Asset::Wobject::Layout>.
=cut
sub extra_www_add_properties {
my $self = shift;
my $session = shift;
my $parentAsset = shift;
my $properties = shift;
return unless $parentAsset->isa('WebGUI::Asset::Wobject::Layout');
$properties->{ mobileStyleTemplateId } = $parentAsset->get("mobileStyleTemplateId");
$properties->{ mobileTemplateId } = $parentAsset->get("mobileTemplateId");
}
1;