From 2170509c0f6334203752035019409b72cf4f649b Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Wed, 16 Feb 2011 15:53:51 -0600 Subject: [PATCH] allow TaxDriver getEditForm to use FormBuilder There would be far too much rewriting in order to change the EU driver to use FormBuilder. We can revisit that later. --- docs/migration.txt | 5 +++++ lib/WebGUI/Shop/Tax.pm | 7 ++++++- lib/WebGUI/Shop/TaxDriver.pm | 6 +++--- lib/WebGUI/Shop/TaxDriver/EU.pm | 26 +++++++++++++------------- lib/WebGUI/Shop/TaxDriver/Generic.pm | 4 ++-- 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/docs/migration.txt b/docs/migration.txt index cd3ce1f50..867d802a9 100644 --- a/docs/migration.txt +++ b/docs/migration.txt @@ -76,6 +76,11 @@ WebGUI::Shop::ShipDriver getEditForm now returns a WebGUI::FormBuilder object +WebGUI::Shop::TaxDriver +======================= + +getConfigurationScreen is now called getEditForm and should return a WebGUI::FormBuilder object + WebGUI::Utility =============== This module has been removed. It had many functions that weren't used, and others have better replacements. diff --git a/lib/WebGUI/Shop/Tax.pm b/lib/WebGUI/Shop/Tax.pm index 29cd7778c..2763547e4 100644 --- a/lib/WebGUI/Shop/Tax.pm +++ b/lib/WebGUI/Shop/Tax.pm @@ -244,10 +244,15 @@ sub www_manage { # } my $taxDriver = $self->getDriver; + my $editForm = $taxDriver->getEditForm; + my $editFormHtml = ''; + if ( blessed $editForm and $editForm->isa( 'WebGUI::FormBuilder' ) ) { + $editFormHtml = $editForm->toHtml; + } my $output = $pluginSwitcher . '
Plugin configuration' - . $taxDriver->getConfigurationScreen + . $editFormHtml . '
' ; diff --git a/lib/WebGUI/Shop/TaxDriver.pm b/lib/WebGUI/Shop/TaxDriver.pm index adc4ad841..b5db14584 100644 --- a/lib/WebGUI/Shop/TaxDriver.pm +++ b/lib/WebGUI/Shop/TaxDriver.pm @@ -177,13 +177,13 @@ sub className { #----------------------------------------------------------- -=head2 getConfigurationScreen ( ) +=head2 getEditForm ( ) -Returns the configuration screen that contains the configuration options for this plugin in the admin console. +Returns the edit form that contains the configuration options for this plugin in the admin console. =cut -sub getConfigurationScreen { +sub getEditForm { return 'This plugin has no configuration options'; } diff --git a/lib/WebGUI/Shop/TaxDriver/EU.pm b/lib/WebGUI/Shop/TaxDriver/EU.pm index af616be98..f7096853b 100644 --- a/lib/WebGUI/Shop/TaxDriver/EU.pm +++ b/lib/WebGUI/Shop/TaxDriver/EU.pm @@ -291,13 +291,13 @@ sub deleteVATNumber { #----------------------------------------------------------- -=head2 getConfigurationScreen ( ) +=head2 getEditForm ( ) Returns the form that contains the configuration options for this plugin in the admin console. =cut -sub getConfigurationScreen { +sub getEditForm { my $self = shift; my $session = $self->session; my $i18n = WebGUI::International->new( $session, 'TaxDriver_EU' ); @@ -310,48 +310,48 @@ sub getConfigurationScreen { ); # General setting form - my $f = WebGUI::HTMLForm->new( $session ); - $f->hidden( + my $f = WebGUI::FormBuilder->new( $session ); + $f->addField( "hidden", name => 'shop', value => 'tax', ); - $f->hidden( + $f->addField( "hidden", name => 'method', value => 'do', ); - $f->hidden( + $f->addField( "hidden", name => 'do', value => 'saveConfiguration', ); - $f->selectBox( + $f->addField( "selectBox", name => 'shopCountry', value => $self->get( 'shopCountry' ), label => $i18n->get('shop country'), hoverHelp => $i18n->get('shop country help'), options => \%countryOptions, ); - $f->template( + $f->addField( "template", name => 'userTemplateId', value => $self->get('userTemplateId'), label => $i18n->get('user template'), hoverHelp => $i18n->get('user template help'), namespace => 'TaxDriver/EU/User', ); - $f->yesNo( + $f->addField( "yesNo", name => 'automaticViesApproval', value => $self->get('automaticViesApproval'), label => $i18n->get('auto vies approval'), hoverHelp => $i18n->get('auto vies approval help'), ); - $f->yesNo( + $f->addField( "yesNo", name => 'acceptOnViesUnavailable', value => $self->get('acceptOnViesUnavailable'), label => $i18n->get('accept when vies unavailable'), hoverHelp => $i18n->get('accept when vies unavailable help'), ); - $f->submit; - my $general = $f->print; + $f->addField( "submit", name => "submit" ); + my $general = $f->toHtml; # VAT groups manager my $vatGroups = @@ -365,7 +365,7 @@ sub getConfigurationScreen { . $i18n->get('rate') . WebGUI::Form::float( $session, { name => 'rate' } ) . '%' - . WebGUI::Form::submit( $session, { value => 'Add' } ) + . WebGUI::Form::submit( $session, { name => 'submit', value => 'Add' } ) . WebGUI::Form::formFooter( $session ); # Wrap output in a YUI Tab widget. diff --git a/lib/WebGUI/Shop/TaxDriver/Generic.pm b/lib/WebGUI/Shop/TaxDriver/Generic.pm index 15f48a4ac..ffc45b574 100644 --- a/lib/WebGUI/Shop/TaxDriver/Generic.pm +++ b/lib/WebGUI/Shop/TaxDriver/Generic.pm @@ -528,13 +528,13 @@ sub www_importTax { #----------------------------------------------------------- -=head2 getConfigurationScreen ( ) +=head2 getEditForm ( ) Returns the form that contains the configuration options for this plugin in the admin console. =cut -sub getConfigurationScreen { +sub getEditForm { my $self = shift; my $session = $self->session; my $status_message = $session->stow->get( 'tax_message' );