Rough conversion of Comments and Installable to Moose.
This commit is contained in:
parent
a37b1c725b
commit
2b39e16cc8
2 changed files with 20 additions and 41 deletions
|
|
@ -1,4 +1,4 @@
|
|||
package WebGUI::AssetAspect::Comments;
|
||||
package WebGUI::Role::Asset::Comments;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
|
|
@ -14,10 +14,21 @@ package WebGUI::AssetAspect::Comments;
|
|||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use Class::C3;
|
||||
use Moose::Role;
|
||||
use WebGUI::Definition::Asset;
|
||||
define tableName => 'assetAspectComments';
|
||||
property comments => (
|
||||
noFormPost => 1,
|
||||
fieldType => "hidden",
|
||||
default => '[]',
|
||||
);
|
||||
property averageCommentRating => (
|
||||
noFormPost => 1,
|
||||
fieldType => "hidden",
|
||||
default => 0,
|
||||
);
|
||||
|
||||
use JSON;
|
||||
use Tie::IxHash;
|
||||
use WebGUI::Exception;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::HTML;
|
||||
|
|
@ -25,7 +36,7 @@ use WebGUI::Utility;
|
|||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetAspect::Comments
|
||||
Package WebGUI::Role::Asset::Comments
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
|
|
@ -33,11 +44,8 @@ This is an aspect which makes adding comments to existing assets trivial.
|
|||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use Class::C3;
|
||||
use base qw(WebGUI::AssetAspect::Comments WebGUI::Asset);
|
||||
with 'WebGUI::Role::Asset::Comments';
|
||||
|
||||
And then where-ever you would call $self->SUPER::someMethodName call $self->next::method instead.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
|
@ -128,33 +136,6 @@ Extends the definition to add the comments and averageCommentRating fields.
|
|||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my %properties;
|
||||
tie %properties, 'Tie::IxHash';
|
||||
%properties = (
|
||||
comments => {
|
||||
noFormPost => 1,
|
||||
fieldType => "hidden",
|
||||
defaultValue => [],
|
||||
},
|
||||
averageCommentRating => {
|
||||
noFormPost => 1,
|
||||
fieldType => "hidden",
|
||||
defaultValue => 0,
|
||||
},
|
||||
);
|
||||
push(@{$definition}, {
|
||||
autoGenerateForms => 1,
|
||||
tableName => 'assetAspectComments',
|
||||
className => 'WebGUI::Asset::Sku::BazaarItem',
|
||||
properties => \%properties
|
||||
});
|
||||
return $class->next::method($session, $definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 deleteComment ( id )
|
||||
|
|
@ -1,19 +1,17 @@
|
|||
package WebGUI::AssetAspect::Installable;
|
||||
package WebGUI::Role::Asset::Installable;
|
||||
|
||||
use strict;
|
||||
use Class::C3;
|
||||
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Form::DynamicField;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WebGUI::AssetAspect::Installable -- Make your asset installable
|
||||
WebGUI::Role::Asset::Installable -- Make your asset installable
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
package WebGUI::Asset::MyAsset;
|
||||
use base ( 'WebGUI::AssetAspect::Installable', 'WebGUI::Asset' );
|
||||
with 'WebGUI::Role::Asset::Installable';
|
||||
|
||||
# Override the install method to install collateral tables
|
||||
sub install {
|
||||
Loading…
Add table
Add a link
Reference in a new issue