Add 40% to POD coverage in DataForm.

This commit is contained in:
Colin Kuskie 2009-07-06 03:54:26 +00:00
parent 7b343074ef
commit 2e28a9870a

View file

@ -115,22 +115,58 @@ sub _createTabInit {
#-------------------------------------------------------------------
=head2 defaultViewForm
Returns true if defaultView is set to 0.
=cut
sub defaultViewForm {
my $self = shift;
return ($self->get("defaultView") == 0);
}
#-------------------------------------------------------------------
=head2 defaultView
Returns the kind of default view. If defaultView == 0, it returns 'form'. Otherwise,
it returns 'list'.
=cut
sub defaultView {
my $self = shift;
return ($self->get("defaultView") == 0 ? 'form' : 'list');
}
#-------------------------------------------------------------------
=head2 currentView
By priority, returns that the current view is. First, it checks in internally
cached mode, then it checks for a C<mode> form parameter, then it resorts to defaultView.
=cut
sub currentView {
my $self = shift;
my $view = $self->{_mode} || $self->session->form->param('mode') || $self->defaultView;
return $view;
}
#-------------------------------------------------------------------
=head2 deleteField ($fieldName)
Removes a field from the DataForm.
=head3 $fieldName
The name of a field to delete.
=cut
sub deleteField {
my $self = shift;
my $fieldName = shift;
@ -146,6 +182,18 @@ sub deleteField {
return 1;
}
#-------------------------------------------------------------------
=head2 deleteTab ( $tabId )
Deletes a tab from the tabs in this DataForm.
=head3 $tabId
The GUID of a tab to delete.
=cut
sub deleteTab {
my $self = shift;
my $tabId = shift;
@ -164,6 +212,15 @@ sub deleteTab {
return 1;
}
#-------------------------------------------------------------------
=head2 getContentLastModified
Extends the base method to modify caching. If the currentView is in list mode, or
an entry is being viewed, bypass caching altogether.
=cut
sub getContentLastModified {
my $self = shift;
if ($self->currentView eq 'list' || $self->session->form->process('entryId')) {
@ -172,6 +229,22 @@ sub getContentLastModified {
return $self->SUPER::getContentLastModified;
}
#-------------------------------------------------------------------
=head2 renameField ($oldName, $newName)
Renames a field by name
=head3 $oldName
The old name of the field.
=head3 $newName
The new name of the field.
=cut
sub renameField {
my $self = shift;
my $oldName = shift;
@ -188,6 +261,8 @@ sub renameField {
return $self->getFieldConfig->{$newName}{name} = $newName;
}
#-------------------------------------------------------------------
sub _saveFieldConfig {
my $self = shift;
my @config = map {
@ -197,6 +272,8 @@ sub _saveFieldConfig {
$self->update({fieldConfiguration => $data});
}
#-------------------------------------------------------------------
sub _saveTabConfig {
my $self = shift;
my @config = map {
@ -402,6 +479,8 @@ sub definition {
return $class->SUPER::definition($session, $definition);
}
#-------------------------------------------------------------------
sub _cacheFieldConfig {
my $self = shift;
if (!$self->{_fieldConfig}) {
@ -425,6 +504,8 @@ sub _cacheFieldConfig {
return 1;
}
#-------------------------------------------------------------------
sub _cacheTabConfig {
my $self = shift;
if (!$self->{_tabConfig}) {
@ -447,6 +528,19 @@ sub _cacheTabConfig {
return 1;
}
#-------------------------------------------------------------------
=head2 getFieldConfig ($field)
Returns the configuration for 1 field.
=head3 $field
The GUID of the field to return. If left blank, it will return configurations for
all fields in this DataForm.
=cut
sub getFieldConfig {
my $self = shift;
my $field = shift;
@ -459,12 +553,33 @@ sub getFieldConfig {
}
}
#-------------------------------------------------------------------
=head2 getFieldOrder
Returns the internally cached field order, an array reference.
=cut
sub getFieldOrder {
my $self = shift;
$self->_cacheFieldConfig;
return $self->{_fieldOrder};
}
#-------------------------------------------------------------------
=head2 getTabConfig ( $tabId )
Returns the configuration for 1 tab.
=head3 $tabId
The GUID of the tab to return a configuration for. If no tabId is passed, then
it returns the configurations for all of them.
=cut
sub getTabConfig {
my $self = shift;
my $tabId = shift;
@ -477,6 +592,14 @@ sub getTabConfig {
}
}
#-------------------------------------------------------------------
=head2 getTabOrder
Returns the order of the tabs, an array reference.
=cut
sub getTabOrder {
my $self = shift;
$self->_cacheTabConfig;
@ -485,6 +608,13 @@ sub getTabOrder {
#-------------------------------------------------------------------
=head2 deleteAttachedFiles
Deletes all files attached to this DataForm, or to any fields or entries in the DataForm.
=cut
sub deleteAttachedFiles {
my $self = shift;
my %params = @_;
@ -523,6 +653,16 @@ sub deleteAttachedFiles {
}
#-------------------------------------------------------------------
=head2 getAttachedFiles ( $entryData )
Return an array reference to every file in every storage location in every field for
one set of entryData.
=head3 $entryData
=cut
sub getAttachedFiles {
my $self = shift;
my $entryData = shift;
@ -541,6 +681,17 @@ sub getAttachedFiles {
}
#-------------------------------------------------------------------
=head2 getListTemplateVars ( $var )
Appends template variables for list mode.
=head3 $var
A hash reference. New template variables will be appended to it.
=cut
sub getListTemplateVars {
my $self = shift;
my $var = shift;
@ -593,6 +744,16 @@ sub getListTemplateVars {
#-------------------------------------------------------------------
=head2 getFormUrl ($params)
Returns a URL to this DataForm in form mode.
=head3 $params
URL parameters to append to the form URL.
=cut
sub getFormUrl {
my $self = shift;
my $params = shift;
@ -634,7 +795,20 @@ sub getListUrl {
}
#-------------------------------------------------------------------
# Template variables for normal form view and email message
=head2 getRecordTemplateVars ($var, $entry)
Template variables for normal form view and email message
=head3 $var
A hash reference. Template variables will be appended to it.
=head3 $entry
The data entered by the user, as a WebGUI::AssetCollateral::DataForm::Entry object.
=cut
sub getRecordTemplateVars {
my $self = shift;
@ -756,11 +930,15 @@ sub getRecordTemplateVars {
#----------------------------------------------------------------------------
=head2 getTemplateVars ( )
=head2 getTemplateVars ( $var )
Gets the default template vars for the asset. Includes the asset properties
as well as shared template vars.
=head3 $var
A hash reference. Template variables are appended to it.
=cut
sub getTemplateVars {
@ -808,7 +986,7 @@ sub hasEntries {
=head2 prepareView ( )
See WebGUI::Asset::prepareView() for details.
Extends the base class to handle form and list mode.
=cut
@ -825,6 +1003,14 @@ sub prepareView {
}
#-------------------------------------------------------------------
=head2 purge
Extends the base method to handle deleting attached files and purging the
entry collateral.
=cut
sub purge {
my $self = shift;
$self->deleteAttachedFiles;
@ -833,6 +1019,22 @@ sub purge {
}
#-------------------------------------------------------------------
=head2 sendEmail ($var, $entry)
Sends an email with information about the data entered by the user. The email
is templated, and macros in the template will be expanded.
=head3 $var
A hash reference of template variables
=head3 $entry
The data entered by the user, as a WebGUI::AssetCollateral::DataForm::Entry object.
=cut
sub sendEmail {
my $self = shift;
my $var = shift;
@ -921,6 +1123,13 @@ sub useCaptcha {
}
#-------------------------------------------------------------------
=head2 view
Based on the view mode, renders either the form or the list.
=cut
sub view {
my $self = shift;
my $view = $self->currentView;
@ -933,6 +1142,14 @@ sub view {
}
#-------------------------------------------------------------------
=head2 canView
Extends the base method to include users who can edit the DataForm in list mode,
or are part of the groupToViewEntries.
=cut
sub canView {
my $self = shift;
return 0
@ -1433,6 +1650,8 @@ sub www_moveFieldDown {
return $newSelf->www_view;
}
#-------------------------------------------------------------------
sub moveFieldDown {
my $self = shift;
my $fieldName = shift;
@ -1467,6 +1686,8 @@ sub www_moveFieldUp {
return $newSelf->www_view;
}
#-------------------------------------------------------------------
sub moveFieldUp {
my $self = shift;
my $fieldName = shift;
@ -1503,6 +1724,8 @@ sub www_moveTabRight {
}
#-------------------------------------------------------------------
sub moveTabRight {
my $self = shift;
my $tabId = shift;
@ -1532,7 +1755,7 @@ sub www_moveTabLeft {
return $newSelf->www_view;
}
#-------------------------------------------------------------------
sub moveTabLeft {
my $self = shift;
my $tabId = shift;