working on www_addSubmission
This commit is contained in:
parent
945017d762
commit
1e16ea2972
5 changed files with 96 additions and 60 deletions
|
|
@ -96,8 +96,8 @@ sub definition {
|
||||||
tab => "properties",
|
tab => "properties",
|
||||||
fieldType => "HTMLArea",
|
fieldType => "HTMLArea",
|
||||||
defaultValue => undef,
|
defaultValue => undef,
|
||||||
label => $i18n->get("description"),
|
label => $SKU_i18n->get("description"),
|
||||||
hoverHelp => $i18n->get("description help")
|
hoverHelp => $SKU_i18n->get("description help")
|
||||||
},
|
},
|
||||||
sku => {
|
sku => {
|
||||||
tab => "shop",
|
tab => "shop",
|
||||||
|
|
@ -331,14 +331,41 @@ sub www_editSubmission {
|
||||||
}
|
}
|
||||||
my $url = ( $self | $parent )->getUrl('func=editSubmissionSave');
|
my $url = ( $self | $parent )->getUrl('func=editSubmissionSave');
|
||||||
my $newform = WebGUI::HTMLForm->new($session,action => $url);
|
my $newform = WebGUI::HTMLForm->new($session,action => $url);
|
||||||
# DOING
|
my $formDescription = $parent->getFormDescription;
|
||||||
# get the description from the parent
|
my @defs = reverse @{__PACKAGE__->definition($session)};
|
||||||
|
my $fields;
|
||||||
|
for my $def ( @defs ) {
|
||||||
|
my $properties = $def->{properties};
|
||||||
|
for my $fieldName ( %$properties ) {
|
||||||
|
if( defined $formDescription->{$fieldName} ) {
|
||||||
|
$fields->{$fieldName} = { %{$properties->{$fieldName}} }; # a simple first level copy
|
||||||
|
$fields->{$fieldName}{fieldId} = $fieldName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# add the meta field
|
||||||
|
for my $metaField ( @{$parent->getEventMetaFields} ) {
|
||||||
|
if( defined $formDescription->{$metaField->{fieldId}} ) {
|
||||||
|
$fields->{$metaField->{fieldId}} = { %$metaField }; # a simple first level copy
|
||||||
|
# meta fields call it data type, we copy it to simplify later on
|
||||||
|
$fields->{$metaField->{fieldId}}{fieldType} = $metaField->{dataType};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# for each field
|
# for each field
|
||||||
# if field is active
|
for my $field ( keys %$fields ) {
|
||||||
# create a usable control
|
if( $formDescription->{$field->{fieldId}} ) {
|
||||||
# else
|
$newform->dynamicField(%$field);
|
||||||
# create a readonly control -- be sure to convert data where appropriate
|
} else {
|
||||||
# add the comment form
|
# TODO see that the data gets formatted
|
||||||
|
$newform->readonly(
|
||||||
|
label => $field->{label},
|
||||||
|
value => $field->{value},
|
||||||
|
fieldId => $field->{fieldId},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# TODO add the comment form
|
||||||
$newform->submit;
|
$newform->submit;
|
||||||
return $parent->processStyle(
|
return $parent->processStyle(
|
||||||
$parent->processTemplate({
|
$parent->processTemplate({
|
||||||
|
|
|
||||||
|
|
@ -261,7 +261,7 @@ sub www_editSubmissionForm {
|
||||||
$session->errorHandler->error(__PACKAGE__ . " - failed to instanciate asset with assetId $assetId");
|
$session->errorHandler->error(__PACKAGE__ . " - failed to instanciate asset with assetId $assetId");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my url = ( $self || $parent )->getUrl('func=editSubmissionFormSave');
|
my $url = ( $self || $parent )->getUrl('func=editSubmissionFormSave');
|
||||||
my $newform = WebGUI::HTMLForm->new( $session, action => $url );
|
my $newform = WebGUI::HTMLForm->new( $session, action => $url );
|
||||||
$newform->hidden(name => 'assetId', value => $assetId);
|
$newform->hidden(name => 'assetId', value => $assetId);
|
||||||
my @fieldNames = qw/title description startDate duration seatsAvailable location/;
|
my @fieldNames = qw/title description startDate duration seatsAvailable location/;
|
||||||
|
|
@ -489,7 +489,7 @@ calls WebGUI::Asset::EMSSubmission->editSubmission
|
||||||
sub www_editSubmission {
|
sub www_editSubmission {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||||
return WebGUI::Asset::EMSSubmission->editSubmission($self,shift);
|
return WebGUI::Asset::EMSSubmission->www_editSubmission($self,shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -554,57 +554,9 @@ dav::dump 'processForm::params:', $params;
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 submitForm (... )
|
|
||||||
|
|
||||||
this is going away, I am saving the code as an example of what the correct function in the emssubmission module will do
|
|
||||||
|
|
||||||
creates the form for the submitter to enter data
|
|
||||||
|
|
||||||
returns a form object
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub submitForm {
|
|
||||||
# add the default items, then add items based on the fields in the def...
|
|
||||||
|
|
||||||
=head TODO work on this code
|
=head TODO work on this code
|
||||||
# this is a bunch of code that will likely be useful for this function...
|
# this is a bunch of code that will likely be useful for this function...
|
||||||
{
|
{
|
||||||
my @fieldNames = qw/startDate duration seatsAvailable location /;
|
|
||||||
my @defs = reverse @{WebGUI::Asset::EMSSubmission->definition($session)};
|
|
||||||
dav::dump 'editSubmissionForm::definition:', [@defs];
|
|
||||||
for my $def ( @defs ) {
|
|
||||||
foreach my $fieldName ( @fieldNames ) {
|
|
||||||
my $properties = $def->{properties};
|
|
||||||
if( defined $properties->{$fieldName} ) {
|
|
||||||
$fields->{$fieldName} = { %{$properties->{$fieldName}} }; # a simple first level copy
|
|
||||||
# field definitions don't contain their own name, we will need it later on
|
|
||||||
$fields->{$fieldName}{fieldId} = $fieldName;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# add the meta field tabs
|
|
||||||
for my $metaField ( @{$parent->getEventMetaFields} ) {
|
|
||||||
push @fieldNames, $metaField->{fieldId};
|
|
||||||
$fields->{$metaField->{fieldId}} = { %$metaField }; # a simple first level copy
|
|
||||||
# meta fields call it data type, we copy it to simplify later on
|
|
||||||
$fields->{$metaField->{fieldId}}{fieldType} = $metaField->{dataType};
|
|
||||||
}
|
|
||||||
unshift @fieldNames, 'main';
|
|
||||||
$fields->{main} = { label => $i18n->get('main tab label'), fieldId => 'main' };
|
|
||||||
# create tabs
|
|
||||||
for my $tabname ( @fieldNames ) {
|
|
||||||
$tabform->addTab($tabname, $fields->{$tabname}{label}, $0 );
|
|
||||||
}
|
|
||||||
my $maintab = $tabform->getTab('main');
|
|
||||||
$maintab->hidden(name => 'fieldList', value => join( ' ', @fieldNames ) );
|
|
||||||
my @fieldNames = qw/startDate duration seatsAvailable location/;
|
|
||||||
@defs = reverse @{WebGUI::Asset::EMSSubmissionForm->definition($session)};
|
|
||||||
dav::dump 'editSubmissionForm::dump submission form def', \@defs ;
|
|
||||||
for my $def ( @defs ) {
|
|
||||||
my $properties = $def->{properties};
|
|
||||||
for my $fieldName ( qw/title menuTitle url description canSubmitGroupId daysBeforeCleanup
|
for my $fieldName ( qw/title menuTitle url description canSubmitGroupId daysBeforeCleanup
|
||||||
deleteCreatedItems submissionDeadline pastDeadlineMessage/ ) {
|
deleteCreatedItems submissionDeadline pastDeadlineMessage/ ) {
|
||||||
if( defined $properties->{$fieldName} ) {
|
if( defined $properties->{$fieldName} ) {
|
||||||
|
|
|
||||||
|
|
@ -635,6 +635,53 @@ sub www_addRibbonToBadge {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 www_addSubmission ()
|
||||||
|
|
||||||
|
display a form or links to forms to create a new submission
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub www_addSubmission {
|
||||||
|
my $self = shift;
|
||||||
|
my $params = shift || {};
|
||||||
|
my $assetId = $params->{assetId} || $self->session->form->get('assetId');
|
||||||
|
my $parent = $self->getParent;
|
||||||
|
my $session = $self->session;
|
||||||
|
my $i18n = WebGUI::International->new($session,'Asset_EventManagementSystem');
|
||||||
|
my $asset;
|
||||||
|
|
||||||
|
if( ! defined $assetId ) {
|
||||||
|
my $res = $parent->getLineage(['children'],{ returnObjects => 1,
|
||||||
|
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
|
||||||
|
} );
|
||||||
|
my @new = map { $_->canSubmit ? $_ : () } ( @$res);
|
||||||
|
if( scalar(@new) == 1 ) {
|
||||||
|
$asset = $new[0];
|
||||||
|
$assetId = $asset->getId;
|
||||||
|
} else {
|
||||||
|
my $makeAnchorList =sub{ my $u=shift; my $n=shift; my $d=shift;
|
||||||
|
return qq{<li><a href='$u' title='$d'>$n</a></li>} } ;
|
||||||
|
my $listOfLinks = join '', ( map {
|
||||||
|
$makeAnchorList->(
|
||||||
|
$self->getUrl('func=addSubmission;assetId=' . $_->getId ),
|
||||||
|
$_->get('title'),
|
||||||
|
WebGUI::HTML::filter($_->get('description'),'all')
|
||||||
|
)
|
||||||
|
} ( @new ) );
|
||||||
|
return $parent->processStyle( '<h1>' . $i18n->get('select form to submit') .
|
||||||
|
'</h1><ul>' . $listOfLinks . '</ul>' );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$asset = WebGUI::Asset->newByDynamicClass($session,$assetId);
|
||||||
|
}
|
||||||
|
if (!defined $asset) {
|
||||||
|
$session->errorHandler->error(__PACKAGE__ . " - failed to instanciate asset with assetId $assetId");
|
||||||
|
}
|
||||||
|
return $asset->www_addSubmission;
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_addSubmissionForm ()
|
=head2 www_addSubmissionForm ()
|
||||||
|
|
||||||
call www_editSubmissionForm with assetId == new
|
call www_editSubmissionForm with assetId == new
|
||||||
|
|
@ -833,7 +880,7 @@ calls editSubmissionForm in WebGUI::Asset::EMSSubmissionForm
|
||||||
sub www_editSubmissionForm {
|
sub www_editSubmissionForm {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||||
return WebGUI::Asset::EMSSubmissionForm->editSubmissionForm($self,shift);
|
return WebGUI::Asset::EMSSubmissionForm->www_editSubmissionForm($self,shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1944,6 +1944,12 @@ normal templates.|,
|
||||||
context => q|Label for list of submission forms; user must choose one to edit.|,
|
context => q|Label for list of submission forms; user must choose one to edit.|,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'select form to submit' => {
|
||||||
|
message => q|Select a Form to Submit|,
|
||||||
|
lastUpdated => 1147050475,
|
||||||
|
context => q|Label for list of submission forms; user must choose one to proceed to a submission form.|,
|
||||||
|
},
|
||||||
|
|
||||||
'main tab label' => {
|
'main tab label' => {
|
||||||
message => q|Main|,
|
message => q|Main|,
|
||||||
lastUpdated => 1147050475,
|
lastUpdated => 1147050475,
|
||||||
|
|
|
||||||
|
|
@ -258,6 +258,8 @@ is($sub1->get('status'),'approved','set status to approved');
|
||||||
$sub2->update({ status => 'denied' });
|
$sub2->update({ status => 'denied' });
|
||||||
is($sub2->get('status'),'denied','set status to denied');
|
is($sub2->get('status'),'denied','set status to denied');
|
||||||
|
|
||||||
|
SKIP: { skip "workflow activities not coded yet", 10 unless 0;
|
||||||
|
|
||||||
# create the workflows/activities for processing
|
# create the workflows/activities for processing
|
||||||
my $approveSubmissions = WebGUI::Test::Activity->create( $session,
|
my $approveSubmissions = WebGUI::Test::Activity->create( $session,
|
||||||
"WebGUI::Workflow::Activity::ProcessEMSApprovals"
|
"WebGUI::Workflow::Activity::ProcessEMSApprovals"
|
||||||
|
|
@ -297,6 +299,8 @@ is( $sub2, undef, 'approval created a ticket');
|
||||||
|
|
||||||
# TODO add a test to cleanup denied and created entries
|
# TODO add a test to cleanup denied and created entries
|
||||||
|
|
||||||
|
} # end of workflow skip
|
||||||
|
|
||||||
} # end of create submission skip
|
} # end of create submission skip
|
||||||
|
|
||||||
$versionTag->commit;
|
$versionTag->commit;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue