Update Carousel for Moose.
This commit is contained in:
parent
6287ebdd46
commit
e5d471567e
1 changed files with 31 additions and 94 deletions
|
|
@ -15,78 +15,33 @@ $VERSION = "1.0.0";
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use JSON;
|
use JSON;
|
||||||
use Tie::IxHash;
|
|
||||||
use WebGUI::International;
|
use WebGUI::International;
|
||||||
use WebGUI::Utility;
|
use WebGUI::Utility;
|
||||||
use base 'WebGUI::Asset::Wobject';
|
use WebGUI::Definition::Asset;
|
||||||
|
extends 'WebGUI::Asset::Wobject';
|
||||||
#-------------------------------------------------------------------
|
aspect assetName => [ 'assetName', 'Asset_Carousel' ];
|
||||||
|
aspect icon => 'Carousel.png';
|
||||||
=head2 definition ( )
|
aspect tableName => 'Carousel';
|
||||||
|
property templateId => (
|
||||||
defines wobject properties for New Wobject instances. You absolutely need
|
fieldType => "template",
|
||||||
this method in your new Wobjects. If you choose to "autoGenerateForms", the
|
default => 'CarouselTmpl0000000001',
|
||||||
getEditForm method is unnecessary/redundant/useless.
|
tab => "display",
|
||||||
|
noFormPost => 0,
|
||||||
=cut
|
namespace => "Carousel",
|
||||||
|
hoverHelp => [ 'carousel template description', 'Asset_Carousel' ],
|
||||||
sub definition {
|
label => [ 'carousel template label', 'Asset_Carousel' ],
|
||||||
my $class = shift;
|
);
|
||||||
my $session = shift;
|
property slideWidth => (
|
||||||
my $definition = shift;
|
fieldType => "integer",
|
||||||
my $i18n = WebGUI::International->new($session, 'Asset_Carousel');
|
default => 0,
|
||||||
my %properties;
|
tab => "display",
|
||||||
tie %properties, 'Tie::IxHash';
|
hoverHelp => [ 'carousel slideWidth description', 'Asset_Carousel' ],
|
||||||
%properties = (
|
label => [ 'carousel slideWidth label', 'Asset_Carousel' ],
|
||||||
templateId =>{
|
);
|
||||||
fieldType =>"template",
|
property items => (
|
||||||
defaultValue =>'CarouselTmpl0000000001',
|
noFormPost => 1,
|
||||||
tab =>"display",
|
fieldType => 'text',
|
||||||
noFormPost =>0,
|
);
|
||||||
namespace =>"Carousel",
|
|
||||||
hoverHelp =>$i18n->get('carousel template description'),
|
|
||||||
label =>$i18n->get('carousel template label'),
|
|
||||||
},
|
|
||||||
slideWidth =>{
|
|
||||||
fieldType => "integer",
|
|
||||||
defaultValue => 0,
|
|
||||||
tab => "display",
|
|
||||||
hoverHelp => $i18n->get('carousel slideWidth description'),
|
|
||||||
label => $i18n->get('carousel slideWidth label'),
|
|
||||||
},
|
|
||||||
items =>{
|
|
||||||
noFormPost =>1,
|
|
||||||
fieldType =>'text',
|
|
||||||
autoGenerate =>0,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
push(@{$definition}, {
|
|
||||||
assetName=>$i18n->get('assetName'),
|
|
||||||
icon=>'Carousel.png',
|
|
||||||
autoGenerateForms=>1,
|
|
||||||
tableName=>'Carousel',
|
|
||||||
className=>'WebGUI::Asset::Wobject::Carousel',
|
|
||||||
properties=>\%properties
|
|
||||||
});
|
|
||||||
return $class->SUPER::definition($session, $definition);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 duplicate ( )
|
|
||||||
|
|
||||||
duplicates a New Wobject. This method is unnecessary, but if you have
|
|
||||||
auxiliary, ancillary, or "collateral" data or files related to your
|
|
||||||
wobject instances, you will need to duplicate them here.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub duplicate {
|
|
||||||
my $self = shift;
|
|
||||||
my $newAsset = $self->SUPER::duplicate(@_);
|
|
||||||
return $newAsset;
|
|
||||||
}
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -119,8 +74,8 @@ sub getEditForm {
|
||||||
|
|
||||||
$tabform->getTab("properties")->raw($tableRowStart);
|
$tabform->getTab("properties")->raw($tableRowStart);
|
||||||
|
|
||||||
if($self->getValue('items')){
|
if($self->items){
|
||||||
my @items = @{JSON->new->decode($self->getValue('items'))->{items}};
|
my @items = @{JSON->new->decode($self->items)->{items}};
|
||||||
|
|
||||||
foreach my $item (@items){
|
foreach my $item (@items){
|
||||||
my $itemNr = $item->{sequenceNumber};
|
my $itemNr = $item->{sequenceNumber};
|
||||||
|
|
@ -184,11 +139,11 @@ See WebGUI::Asset::prepareView() for details.
|
||||||
sub prepareView {
|
sub prepareView {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->SUPER::prepareView();
|
$self->SUPER::prepareView();
|
||||||
my $template = WebGUI::Asset::Template->new($self->session, $self->get("templateId"));
|
my $template = WebGUI::Asset::Template->new($self->session, $self->templateId);
|
||||||
if (!$template) {
|
if (!$template) {
|
||||||
WebGUI::Error::ObjectNotFound::Template->throw(
|
WebGUI::Error::ObjectNotFound::Template->throw(
|
||||||
error => qq{Template not found},
|
error => qq{Template not found},
|
||||||
templateId => $self->get("templateId"),
|
templateId => $self->templateId,
|
||||||
assetId => $self->getId,
|
assetId => $self->getId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -238,24 +193,6 @@ sub processPropertiesFromFormPost {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 purge ( )
|
|
||||||
|
|
||||||
removes collateral data associated with a Carousel when the system
|
|
||||||
purges it's data. This method is unnecessary, but if you have
|
|
||||||
auxiliary, ancillary, or "collateral" data or files related to your
|
|
||||||
wobject instances, you will need to purge them here.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub purge {
|
|
||||||
my $self = shift;
|
|
||||||
#purge your wobject-specific data here. This does not include fields
|
|
||||||
# you create for your Carousel asset/wobject table.
|
|
||||||
return $self->SUPER::purge;
|
|
||||||
}
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 view ( )
|
=head2 view ( )
|
||||||
|
|
||||||
method called by the www_view method. Returns a processed template
|
method called by the www_view method. Returns a processed template
|
||||||
|
|
@ -271,8 +208,8 @@ sub view {
|
||||||
#This automatically creates template variables for all of your wobject's properties.
|
#This automatically creates template variables for all of your wobject's properties.
|
||||||
my $var = $self->get;
|
my $var = $self->get;
|
||||||
|
|
||||||
if($self->getValue('items')){
|
if($self->items){
|
||||||
$var->{item_loop} = JSON->new->decode($self->getValue('items'))->{items};
|
$var->{item_loop} = JSON->new->decode($self->items)->{items};
|
||||||
}
|
}
|
||||||
|
|
||||||
#This is an example of debugging code to help you diagnose problems.
|
#This is an example of debugging code to help you diagnose problems.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue