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
|
=head1 LEGAL
|
||||||
|
|
||||||
|
|
@ -14,10 +14,21 @@ package WebGUI::AssetAspect::Comments;
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
use strict;
|
use Moose::Role;
|
||||||
use Class::C3;
|
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 JSON;
|
||||||
use Tie::IxHash;
|
|
||||||
use WebGUI::Exception;
|
use WebGUI::Exception;
|
||||||
use WebGUI::Form;
|
use WebGUI::Form;
|
||||||
use WebGUI::HTML;
|
use WebGUI::HTML;
|
||||||
|
|
@ -25,7 +36,7 @@ use WebGUI::Utility;
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
Package WebGUI::AssetAspect::Comments
|
Package WebGUI::Role::Asset::Comments
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
|
@ -33,11 +44,8 @@ This is an aspect which makes adding comments to existing assets trivial.
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
use Class::C3;
|
with 'WebGUI::Role::Asset::Comments';
|
||||||
use base qw(WebGUI::AssetAspect::Comments WebGUI::Asset);
|
|
||||||
|
|
||||||
And then where-ever you would call $self->SUPER::someMethodName call $self->next::method instead.
|
|
||||||
|
|
||||||
=head1 METHODS
|
=head1 METHODS
|
||||||
|
|
||||||
These methods are available from this class:
|
These methods are available from this class:
|
||||||
|
|
@ -128,33 +136,6 @@ Extends the definition to add the comments and averageCommentRating fields.
|
||||||
|
|
||||||
=cut
|
=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 )
|
=head2 deleteComment ( id )
|
||||||
|
|
@ -1,19 +1,17 @@
|
||||||
package WebGUI::AssetAspect::Installable;
|
package WebGUI::Role::Asset::Installable;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Class::C3;
|
|
||||||
|
|
||||||
use WebGUI::Asset;
|
use WebGUI::Asset;
|
||||||
use WebGUI::Form::DynamicField;
|
use WebGUI::Form::DynamicField;
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
WebGUI::AssetAspect::Installable -- Make your asset installable
|
WebGUI::Role::Asset::Installable -- Make your asset installable
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
package WebGUI::Asset::MyAsset;
|
with 'WebGUI::Role::Asset::Installable';
|
||||||
use base ( 'WebGUI::AssetAspect::Installable', 'WebGUI::Asset' );
|
|
||||||
|
|
||||||
# Override the install method to install collateral tables
|
# Override the install method to install collateral tables
|
||||||
sub install {
|
sub install {
|
||||||
Loading…
Add table
Add a link
Reference in a new issue