tests and such

This commit is contained in:
Doug Bell 2010-05-11 16:05:02 -05:00
parent 5c2581850f
commit e891410075
7 changed files with 254 additions and 3 deletions

View file

@ -142,6 +142,7 @@ property ticketId => (
with 'WebGUI::Role::Asset::Comments';
use Tie::IxHash;
use base qw(WebGUI::Asset);
use WebGUI::Utility;
use WebGUI::Inbox;

View file

@ -0,0 +1,106 @@
package WebGUI::Form::ButtonGroup;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2009 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Form::Control';
use WebGUI::International;
use WebGUI::Pluggable;
=head1 NAME
Package WebGUI::Form::ButtonGroup
=head1 DESCRIPTION
Creates a series of buttons
=head1 SEE ALSO
This is a subclass of WebGUI::Form::Control.
=head1 METHODS
The following methods are specifically available from this class. Check the superclass for additional methods.
=cut
#-------------------------------------------------------------------
=head2 definition ( [ additionalTerms ] )
See the super class for additional details.
=head3 additionalTerms
The following additional parameters have been added via this sub class.
=head4 buttons
The buttons in this button group
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift || [];
push @{$definition}, {
buttons => {
defaultValue=>[],
},
};
return $class->SUPER::definition($session, $definition);
}
#-------------------------------------------------------------------
=head2 addButton ( type, params )
Add a new button to the button group.
=cut
sub addButton {
my ( $self, $type, $params ) = @_;
my $buttons = $self->get('buttons');
my $button = WebGUI::Pluggable::instanciate("WebGUI::Form::".ucfirst($type), "new", [$self->session, $params]);
push @{$buttons}, $button;
$self->set('buttons', $buttons);
return $button;
}
#-------------------------------------------------------------------
=head2 toHtml ( )
Renders a button group
=cut
sub toHtml {
my $self = shift;
my $html = '';
for my $button ( @{ $self->get('buttons') } ) {
$html .= $button->toHtml; # Inline as toHtml
}
return $html;
}
1;
#vim:ft=perl

View file

@ -235,9 +235,15 @@ sub load {
croak $moduleError{$module};
}
# Check if we already have it
# Try to load the module
my $modulePath = $module . ".pm";
$modulePath =~ s{::|'}{/}g;
if ( $INC{$modulePath} ) {
return 1;
}
if (eval { require $modulePath; 1 }) {
return 1;
}

View file

@ -253,6 +253,7 @@ if ($self->session->user->isRegistered || $self->session->setting->get("preventP
# TODO: Figure out if user is still in the admin console
$var{'head.tags'} .= '<script type="text/javascript">';
if ( $session->asset ) {
my $assetDef = {
assetId => $session->asset->getId,
@ -261,13 +262,12 @@ if ($self->session->user->isRegistered || $self->session->setting->get("preventP
icon => $session->asset->getIcon(1),
};
$var{'head.tags'} .= sprintf <<'ADMINJS', JSON->new->encode( $assetDef );
<script type="text/javascript">
if ( window.parent && window.parent.admin ) {
window.parent.admin.navigate( %s );
}
</script>
ADMINJS
}
$var{'head.tags'} .= '</script>';
# Removing the newlines will probably annoy people.
# Perhaps turn it off under debug mode?