Refactor out the Wobject level www_edit code that switches between Add Wobject and
Edit Wobject into an Asset level method. Convert Wobject.pm and Snippet.pm to use it. Build a very bare bones test method for it.
This commit is contained in:
parent
abf5a15749
commit
7018d38f15
4 changed files with 37 additions and 14 deletions
|
|
@ -57,6 +57,22 @@ These methods are available from this class:
|
|||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 addEditLabel ( )
|
||||
|
||||
Generate an internationalized label for the add/edit screens that says
|
||||
whether you're adding or editing an Asset, for clarity.
|
||||
|
||||
=cut
|
||||
|
||||
sub addEditLabel {
|
||||
my $self = shift;
|
||||
my $i18n = WebGUI::International->new($self->session,'Asset_Wobject');
|
||||
my $addEdit = ($self->session->form->process("func") eq 'add') ? $i18n->get('add') : $i18n->get('edit');
|
||||
return $addEdit.' '.$self->getName;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 addMissing ( url )
|
||||
|
|
@ -2065,7 +2081,7 @@ The asset url you'd like to check for.
|
|||
|
||||
head3 options
|
||||
|
||||
A hash reference of optional parameters.
|
||||
A hash reference of optional parameters that can be passed to refine the search.
|
||||
|
||||
head4 assetId
|
||||
|
||||
|
|
|
|||
|
|
@ -178,9 +178,7 @@ sub www_edit {
|
|||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
$self->getAdminConsole->setHelp("snippet add/edit","Asset_Snippet");
|
||||
my $i18n = WebGUI::International->new($self->session,'Asset_Wobject');
|
||||
my $addEdit = ($self->session->form->process("func") eq 'add') ? $i18n->get('add') : $i18n->get('edit');
|
||||
return $self->getAdminConsole->render($self->getEditForm->print,$addEdit.' '.$self->getName);
|
||||
return $self->getAdminConsole->render($self->getEditForm->print,$self->addEditLabel);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -493,9 +493,7 @@ sub www_edit {
|
|||
$tag =~ s/([a-z])([A-Z])/$1 $2/g; #Separate studly caps
|
||||
$tag =~ s/([A-Z]+(?![a-z]))/$1 /g; #Separate acronyms
|
||||
$self->getAdminConsole->setHelp(lc($tag)." add/edit", "Asset_".$tag2);
|
||||
my $i18n = WebGUI::International->new($self->session,'Asset_Wobject');
|
||||
my $addEdit = ($self->session->form->process("func") eq 'add') ? $i18n->get('add') : $i18n->get('edit');
|
||||
return $self->getAdminConsole->render($self->getEditForm->print,$addEdit.' '.$self->getName);
|
||||
return $self->getAdminConsole->render($self->getEditForm->print,$self->addEditLabel);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue