Event converted to Moose.
This commit is contained in:
parent
4f8ff01659
commit
98c18bb04f
1 changed files with 59 additions and 71 deletions
|
|
@ -35,66 +35,113 @@ aspect tableName => 'Event';
|
||||||
property description => (
|
property description => (
|
||||||
label => ['description', 'Asset_Event'],
|
label => ['description', 'Asset_Event'],
|
||||||
fieldType => "HTMLArea",
|
fieldType => "HTMLArea",
|
||||||
defaultValue => "",
|
default => "",
|
||||||
);
|
);
|
||||||
property startDate => (
|
property startDate => (
|
||||||
label => ['start date', 'Asset_Event'],
|
label => ['start date', 'Asset_Event'],
|
||||||
fieldType => "Date",
|
fieldType => "Date",
|
||||||
defaultValue => $dt->toMysqlDate,
|
builder => '_defaultMysqlDate',
|
||||||
);
|
);
|
||||||
property endDate => (
|
property endDate => (
|
||||||
label => ['end date', 'Asset_Event'],
|
label => ['end date', 'Asset_Event'],
|
||||||
fieldType => "Date",
|
fieldType => "Date",
|
||||||
defaultValue => $dt->toMysqlDate,
|
builder => '_defaultMysqlDate',
|
||||||
);
|
);
|
||||||
|
sub _defaultMysqlDate {
|
||||||
|
my $self = shift;
|
||||||
|
my $dt = WebGUI::DateTime->new($self->session, time);
|
||||||
|
return $dt->toMysqlDate;
|
||||||
|
}
|
||||||
property startTime => (
|
property startTime => (
|
||||||
|
label => ['start', 'Asset_Event'],
|
||||||
fieldType => "TimeField",
|
fieldType => "TimeField",
|
||||||
defaultValue => undef,
|
default => undef,
|
||||||
format => 'mysql',
|
format => 'mysql',
|
||||||
|
|
||||||
);
|
);
|
||||||
property endTime => (
|
property endTime => (
|
||||||
|
label => ['end', 'Asset_Event'],
|
||||||
fieldType => "TimeField",
|
fieldType => "TimeField",
|
||||||
defaultValue => undef,
|
default => undef,
|
||||||
format => 'mysql',
|
format => 'mysql',
|
||||||
);
|
);
|
||||||
|
|
||||||
property recurId => (
|
property recurId => (
|
||||||
|
label => ['recurrence', 'Asset_Event'],
|
||||||
fieldType => "Text",
|
fieldType => "Text",
|
||||||
defaultValue => undef,
|
default => undef,
|
||||||
);
|
);
|
||||||
|
|
||||||
property location => (
|
property location => (
|
||||||
|
label => ['location', 'Asset_Event'],
|
||||||
fieldType => "Text",
|
fieldType => "Text",
|
||||||
defaultValue => undef,
|
default => undef,
|
||||||
);
|
);
|
||||||
property feedId => (
|
property feedId => (
|
||||||
|
noFormPost => 1,
|
||||||
fieldType => "Text",
|
fieldType => "Text",
|
||||||
defaultValue => undef,
|
default => undef,
|
||||||
);
|
);
|
||||||
property storageId => (
|
property storageId => (
|
||||||
|
label => ['attachments for event', 'Asset_Event'],
|
||||||
fieldType => "Image",
|
fieldType => "Image",
|
||||||
defaultValue => '',
|
default => '',
|
||||||
maxAttachments => 1,
|
maxAttachments => 1,
|
||||||
);
|
);
|
||||||
property feedUid => (
|
property feedUid => (
|
||||||
|
noFormPost => 1,
|
||||||
fieldType => "Text",
|
fieldType => "Text",
|
||||||
defaultValue => undef,
|
default => undef,
|
||||||
);
|
);
|
||||||
property timeZone => (
|
property timeZone => (
|
||||||
|
label => ['time zone', 'DateTime'],
|
||||||
fieldType => 'TimeZone',
|
fieldType => 'TimeZone',
|
||||||
);
|
);
|
||||||
property sequenceNumber => (
|
property sequenceNumber => (
|
||||||
|
noFormPost => 1,
|
||||||
fieldType => 'hidden',
|
fieldType => 'hidden',
|
||||||
);
|
);
|
||||||
property iCalSequenceNumber => (
|
property iCalSequenceNumber => (
|
||||||
|
noFormPost => 1,
|
||||||
fieldType => 'hidden',
|
fieldType => 'hidden',
|
||||||
);
|
);
|
||||||
|
property userDefined1 => (
|
||||||
|
label => 'userDefined1',
|
||||||
|
fieldType => 'text',
|
||||||
|
default => '',
|
||||||
|
);
|
||||||
|
property userDefined2 => (
|
||||||
|
label => 'userDefined2',
|
||||||
|
fieldType => 'text',
|
||||||
|
default => '',
|
||||||
|
);
|
||||||
|
property userDefined3 => (
|
||||||
|
label => 'userDefined3',
|
||||||
|
fieldType => 'text',
|
||||||
|
default => '',
|
||||||
|
);
|
||||||
|
property userDefined4 => (
|
||||||
|
label => 'userDefined4',
|
||||||
|
fieldType => 'text',
|
||||||
|
default => '',
|
||||||
|
);
|
||||||
|
property userDefined5 => (
|
||||||
|
label => 'userDefined5',
|
||||||
|
fieldType => 'text',
|
||||||
|
default => '',
|
||||||
|
);
|
||||||
|
|
||||||
|
around is_hidden => sub {
|
||||||
|
my $orig = shift;
|
||||||
|
my $self = shift;
|
||||||
|
if (@_ > 0) {
|
||||||
|
$_[0] = 1;
|
||||||
|
}
|
||||||
|
$self->$orig(@_);
|
||||||
|
};
|
||||||
|
|
||||||
use WebGUI::DateTime;
|
use WebGUI::DateTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
WebGUI::Asset::Event
|
WebGUI::Asset::Event
|
||||||
|
|
@ -135,50 +182,6 @@ sub addRevision {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
####################################################################
|
|
||||||
|
|
||||||
sub definition {
|
|
||||||
my $class = shift;
|
|
||||||
my $session = shift;
|
|
||||||
my $definition = shift;
|
|
||||||
|
|
||||||
my $i18n = WebGUI::International->new($session, 'Asset_Event');
|
|
||||||
my $dt = WebGUI::DateTime->new($session, time);
|
|
||||||
|
|
||||||
### Set up list options ###
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Build properties hash ###
|
|
||||||
my %properties;
|
|
||||||
tie %properties, 'Tie::IxHash';
|
|
||||||
%properties = (
|
|
||||||
|
|
||||||
##### DEFAULTS #####
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
### Add user defined fields
|
|
||||||
for my $num (1..5) {
|
|
||||||
$properties{"userDefined".$num} = {
|
|
||||||
fieldType => "text",
|
|
||||||
defaultValue => "",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
push(@{$definition}, {
|
|
||||||
className => 'WebGUI::Asset::Event',
|
|
||||||
properties => \%properties
|
|
||||||
});
|
|
||||||
|
|
||||||
return $class->SUPER::definition($session, $definition);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 canAdd ( session )
|
=head2 canAdd ( session )
|
||||||
|
|
@ -1901,21 +1904,6 @@ sub setRelatedLinks {
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
####################################################################
|
|
||||||
|
|
||||||
=head2 update
|
|
||||||
|
|
||||||
Wrap update so that isHidden is always set to be a 1.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub update {
|
|
||||||
my $self = shift;
|
|
||||||
my $properties = shift;
|
|
||||||
return $self->SUPER::update({%$properties, isHidden => 1});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 validParent
|
=head2 validParent
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue