started adding functionality, somethings look OK still long ways to go for base functionality
This commit is contained in:
parent
ccc9e36e25
commit
03a0279040
8 changed files with 443 additions and 60 deletions
|
|
@ -85,6 +85,7 @@ sub definition {
|
|||
my $definition = shift;
|
||||
my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmission" );
|
||||
my $EMS_i18n = WebGUI::International->new($session, "Asset_EventManagementSystem");
|
||||
my $SKU_i18n = WebGUI::International->new($session, "Asset_Sku");
|
||||
tie my %properties, 'Tie::IxHash', (
|
||||
submissionId => {
|
||||
noFormPost => 1,
|
||||
|
|
@ -102,29 +103,29 @@ sub definition {
|
|||
tab => "shop",
|
||||
fieldType => "text",
|
||||
defaultValue => $session->id->generate,
|
||||
label => $i18n->get("sku"),
|
||||
hoverHelp => $i18n->get("sku help")
|
||||
label => $SKU_i18n->get("sku"),
|
||||
hoverHelp => $SKU_i18n->get("sku help")
|
||||
},
|
||||
displayTitle => {
|
||||
tab => "display",
|
||||
fieldType => "yesNo",
|
||||
defaultValue => 1,
|
||||
label => $i18n->get("display title"),
|
||||
hoverHelp => $i18n->get("display title help")
|
||||
label => $SKU_i18n->get("display title"),
|
||||
hoverHelp => $SKU_i18n->get("display title help")
|
||||
},
|
||||
vendorId => {
|
||||
tab => "shop",
|
||||
fieldType => "vendor",
|
||||
defaultValue => 'defaultvendor000000000',
|
||||
label => $i18n->get("vendor"),
|
||||
hoverHelp => $i18n->get("vendor help")
|
||||
label => $SKU_i18n->get("vendor"),
|
||||
hoverHelp => $SKU_i18n->get("vendor help")
|
||||
},
|
||||
shipsSeparately => {
|
||||
tab => 'shop',
|
||||
fieldType => 'yesNo',
|
||||
defaultValue => 0,
|
||||
label => $i18n->get('shipsSeparately'),
|
||||
hoverHelp => $i18n->get('shipsSeparately help'),
|
||||
label => $SKU_i18n->get('shipsSeparately'),
|
||||
hoverHelp => $SKU_i18n->get('shipsSeparately help'),
|
||||
},
|
||||
|
||||
price => {
|
||||
|
|
@ -185,8 +186,8 @@ sub definition {
|
|||
},
|
||||
sendEmailOnChange => {
|
||||
tab => "properties",
|
||||
fieldType => "text",
|
||||
defaultValue => undef,
|
||||
fieldType => "yesNo",
|
||||
defaultValue => 1,
|
||||
label => $i18n->get("send email label"),
|
||||
hoverHelp => $i18n->get("send email label help")
|
||||
},
|
||||
|
|
@ -209,6 +210,71 @@ sub definition {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 drawLocationField ()
|
||||
|
||||
Draws the field for the location property.
|
||||
|
||||
TODO: check form params for additional options
|
||||
|
||||
=cut
|
||||
|
||||
sub drawLocationField {
|
||||
my ($self, $params) = @_;
|
||||
my $options = $self->session->db->buildHashRef("select distinct(location) from EMSTicket left join asset using (assetId)
|
||||
where parentId=? order by location",[$self->get('parentId')]);
|
||||
return WebGUI::Form::combo($self->session, {
|
||||
name => 'location',
|
||||
value => $self->get('location'),
|
||||
options => $options,
|
||||
});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 drawRelatedBadgeGroupsField ()
|
||||
|
||||
Draws the field for the relatedBadgeGroups property.
|
||||
|
||||
TODO: check form params for additional options
|
||||
|
||||
=cut
|
||||
|
||||
sub drawRelatedBadgeGroupsField {
|
||||
my ($self, $params) = @_;
|
||||
return WebGUI::Form::checkList($self->session, {
|
||||
name => $params->{name},
|
||||
value => $self->get($params->{name}),
|
||||
vertical => 1,
|
||||
options => $self->getParent->getBadgeGroups,
|
||||
});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 drawRelatedRibbonsField ()
|
||||
|
||||
Draws the field for the relatedRibbons property.
|
||||
|
||||
TODO: check form params for additional options
|
||||
|
||||
=cut
|
||||
|
||||
sub drawRelatedRibbonsField {
|
||||
my ($self, $params) = @_;
|
||||
my %ribbons = ();
|
||||
foreach my $ribbon (@{$self->getParent->getRibbons}) {
|
||||
$ribbons{$ribbon->getId} = $ribbon->getTitle;
|
||||
}
|
||||
return WebGUI::Form::checkList($self->session, {
|
||||
name => $params->{name},
|
||||
value => $self->get($params->{name}),
|
||||
vertical => 1,
|
||||
options => \%ribbons,
|
||||
});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 duplicate
|
||||
|
||||
This method exists for demonstration purposes only. The superclass
|
||||
|
|
@ -223,6 +289,49 @@ whenever a copy action is executed
|
|||
# return $newAsset;
|
||||
#}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getEditForm ( )
|
||||
|
||||
Extends the base class to add Tax information for the Sku, in a new tab.
|
||||
|
||||
=cut
|
||||
|
||||
sub getEditForm {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
|
||||
my $tabform = $self->SUPER::getEditForm;
|
||||
|
||||
my $comments = $tabform->getTab( 'comments' );
|
||||
|
||||
#add the comments...
|
||||
$comments->div({name => 'comments',
|
||||
contentCallback => sub { $self->getFormattedComments },
|
||||
});
|
||||
|
||||
return $tabform;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getEditTabs ( )
|
||||
|
||||
Not to be modified, just defines 2 new tabs.
|
||||
the shop tab is created here to mimic the function of the sku-created
|
||||
shop tab. this class holds data like Sku assets so that they can be assigned
|
||||
in the future when the sku asset is created from this data.
|
||||
|
||||
=cut
|
||||
|
||||
sub getEditTabs {
|
||||
my $self = shift;
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_EMSSubmission");
|
||||
my $sku_i18n = WebGUI::International->new($self->session,"Asset_Sku");
|
||||
return ($self->SUPER::getEditTabs(), ['shop', $sku_i18n->get('shop'), 9], ['comments', $i18n->get('comments'), 9]);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 indexContent ( )
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package WebGUI::Asset::EMSSubmissionForm;
|
|||
use strict;
|
||||
use Tie::IxHash;
|
||||
use base 'WebGUI::Asset';
|
||||
use JSON;
|
||||
use WebGUI::Utility;
|
||||
|
||||
# TODO:
|
||||
|
|
@ -55,21 +56,22 @@ These methods are available from this class:
|
|||
=head2 addSubmission
|
||||
|
||||
Creates an EMSSubmission object based on the params
|
||||
( called by www_saveSubmission )
|
||||
|
||||
=cut
|
||||
|
||||
sub addSubmission {
|
||||
my $self = shift;
|
||||
my $parent = $self->getParent;
|
||||
my $session = $self->session;
|
||||
my $params = shift || {};
|
||||
$self->validateSubmission($params);
|
||||
$parent->addChild({
|
||||
className => 'WebGUI::Asset::EMSSubmission',
|
||||
status => 'pending',
|
||||
title => $params->{title},
|
||||
# TODO add all the fields...
|
||||
});
|
||||
return undef if $self->canSubmit;
|
||||
return undef unless $self->validateSubmission($params);
|
||||
for my $param ( keys %{$self->getFormDefinition()} ) {
|
||||
|
||||
}
|
||||
$params->{className} = 'WebGUI::Asset::EMSSubmission';
|
||||
$params->{status} = 'pending';
|
||||
$self->addChild($params);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -89,6 +91,20 @@ handles revisions to NewAsset Assets.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 canSubmit
|
||||
|
||||
returns true if current user can submit using this form
|
||||
|
||||
=cut
|
||||
|
||||
sub canSubmit {
|
||||
my $self = shift;
|
||||
|
||||
return $session->user->isInGroup($self->get('canSubmitGroupId');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, definition )
|
||||
|
||||
defines asset properties for New Asset instances. You absolutely need
|
||||
|
|
@ -117,8 +133,8 @@ sub definition {
|
|||
},
|
||||
canSubmitGroupId => {
|
||||
tab => "security",
|
||||
fieldType => "groupid",
|
||||
defaultValue => undef,
|
||||
fieldType => "group",
|
||||
defaultValue => 2,
|
||||
label => $i18n->get("can submit group label"),
|
||||
hoverHelp => $i18n->get("can submit group label help")
|
||||
},
|
||||
|
|
@ -131,22 +147,29 @@ sub definition {
|
|||
},
|
||||
deleteCreatedItems => {
|
||||
tab => "properties",
|
||||
fieldType => "yesno",
|
||||
defaultValue => 'no',
|
||||
fieldType => "yesNo",
|
||||
defaultValue => undef,
|
||||
label => $i18n->get("delete created items label"),
|
||||
hoverHelp => $i18n->get("delete created items label help")
|
||||
},
|
||||
submissionDeadline => {
|
||||
tab => "properties",
|
||||
fieldType => "Date",
|
||||
defaultValue => undef,
|
||||
defaultValue => '677496912', # far in the future...
|
||||
label => $i18n->get("submission deadline label"),
|
||||
hoverHelp => $i18n->get("submission deadline label help")
|
||||
},
|
||||
pastDeadlineMessage => {
|
||||
tab => "properties",
|
||||
fieldType => "HTMLArea",
|
||||
defaultValue => $i18n->get('past deadline message'),
|
||||
label => $i18n->get("past deadline label"),
|
||||
hoverHelp => $i18n->get("past deadline label help")
|
||||
},
|
||||
formDescription => {
|
||||
tab => "properties",
|
||||
fieldType => "text",
|
||||
defaultValue => undef,
|
||||
fieldType => "textarea",
|
||||
defaultValue => '{ }',
|
||||
label => $i18n->get("form dscription label"),
|
||||
hoverHelp => $i18n->get("form dscription label help")
|
||||
},
|
||||
|
|
@ -158,7 +181,7 @@ sub definition {
|
|||
tableName => 'EMSSubmissionForm',
|
||||
className => 'WebGUI::Asset::EMSSubmissionForm',
|
||||
properties => \%properties,
|
||||
};
|
||||
};
|
||||
return $class->SUPER::definition( $session, $definition );
|
||||
} ## end sub definition
|
||||
|
||||
|
|
@ -180,17 +203,31 @@ whenever a copy action is executed
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getFormDefinition
|
||||
|
||||
returns a hash ref decoded from the JSON in the form description field
|
||||
|
||||
=cut
|
||||
|
||||
sub getFormDefinition {
|
||||
my $self = shift;
|
||||
return JSON->new->decode($self->get('formDescription'));
|
||||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 indexContent ( )
|
||||
|
||||
Making private. See WebGUI::Asset::indexContent() for additonal details.
|
||||
|
||||
=cut
|
||||
|
||||
sub indexContent {
|
||||
my $self = shift;
|
||||
my $indexer = $self->SUPER::indexContent;
|
||||
$indexer->setIsPublic(0);
|
||||
}
|
||||
#sub indexContent {
|
||||
# my $self = shift;
|
||||
# my $indexer = $self->SUPER::indexContent;
|
||||
# $indexer->setIsPublic(0);
|
||||
#}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,59 @@ use Tie::IxHash;
|
|||
use Data::Dumper;
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
=head2 addSubmissionForm
|
||||
|
||||
creates a child of class WG::Asset::EMSSubmissionForm
|
||||
|
||||
=head3 params
|
||||
|
||||
parameters that define the form
|
||||
|
||||
=head4 title
|
||||
|
||||
the title for the form
|
||||
|
||||
=head4 canSubmitGroupId ( optional )
|
||||
|
||||
group id for the users that are allowed to submit via this form
|
||||
defaults to 2 -- registered users
|
||||
|
||||
=head4 daysBeforeCleanup ( optional )
|
||||
|
||||
number fo days to leave denied/created status items in the database before deleting
|
||||
defaults t0 7
|
||||
|
||||
=head4 deleteCreatedItems ( optional )
|
||||
|
||||
1 indicates that items with status 'created' should be deleted as well as denied
|
||||
default: 0
|
||||
|
||||
=head4 formDescription
|
||||
|
||||
a JSON description of the form data fields
|
||||
|
||||
TODO: write a comprehensive doc for this field
|
||||
|
||||
=cut
|
||||
|
||||
sub addSubmissionForm {
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
$params{className} = 'WebGUI::Asset::EMSSubmissionForm';
|
||||
$params{canSubmitGroupId} ||= 2;
|
||||
$self->addGroupToSubmitList($params{canSubmitGroupId});
|
||||
# DOING -- add previous function and finish adding operations to this function
|
||||
# TODO re-edit the Badge view template and save it, see that it gets added after resets
|
||||
# TODO see how hard it would be to dump the whole template class to the file system
|
||||
# also how hard is it to sync it?
|
||||
# perhaps there is a way to write a module based on the test system that would be simple enough
|
||||
# to look for new versions of the templates and save it off to the file system -- also notice
|
||||
# when the file system is newer than the database ad load the file.
|
||||
#-- ultimate goal is to figure out what is failing in the test battery...
|
||||
# also add tests for Form_Div
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
=head2 canSubmit
|
||||
|
||||
|
|
@ -427,7 +480,12 @@ returns true if the EMS has subission forms attached
|
|||
=cut
|
||||
|
||||
sub hasForms {
|
||||
return 0;
|
||||
my $self = shift;
|
||||
# are there ~any~ forms attached to this ems?
|
||||
my $res = $self->getLineage(['children'],{ limit => 1,
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
|
||||
} );
|
||||
return scalar(@$res);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -438,7 +496,13 @@ returns true if the current user has submission forms in this EMS
|
|||
=cut
|
||||
|
||||
sub hasSubmissions {
|
||||
return 0;
|
||||
my $self = shift;
|
||||
return 0 if ! $self->canSubmit;
|
||||
my @res = $self->getLineage(['descendants'],{ limit => 1,
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
|
||||
whereClause => q{createdBy='} . $self->session->user->userId . q/'/,
|
||||
} );
|
||||
return scalar(@res);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -2157,5 +2221,28 @@ sub www_viewSchedule {
|
|||
|
||||
}
|
||||
|
||||
#---------------------------------------------
|
||||
=head2 www_viewSubmission
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewSubmission {
|
||||
|
||||
# fill the view submission template
|
||||
|
||||
}
|
||||
|
||||
#---------------------------------------------
|
||||
=head2 www_viewSubmissionQueue
|
||||
|
||||
=cut
|
||||
|
||||
sub www_viewSubmissionQueue {
|
||||
|
||||
# fill the view submission queue template
|
||||
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue