From 0b94e40c533288be69a4fe60da36a385d31eff7f Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 12 Oct 2009 01:45:12 +0000 Subject: UI for per-city taxes (setup and assigning to customers/package locations), RT#5852 --- httemplate/elements/city.html | 142 +++++++++++++++++++++++ httemplate/elements/location.html | 14 +-- httemplate/elements/select-county.html | 32 ++--- httemplate/elements/tr-select-cust_location.html | 5 +- 4 files changed, 166 insertions(+), 27 deletions(-) create mode 100644 httemplate/elements/city.html (limited to 'httemplate/elements') diff --git a/httemplate/elements/city.html b/httemplate/elements/city.html new file mode 100644 index 000000000..1659ebf47 --- /dev/null +++ b/httemplate/elements/city.html @@ -0,0 +1,142 @@ +<%doc> + +Example: + + include( '/elements/city.html', + #recommended + country => $current_country, + state => $current_state, + county => $current_county, + city => $current_city, + + #optional + prefix => $optional_unique_prefix, + onchange => $javascript, + disabled => 0, #bool +# disable_empty => 1, #defaults to 1, disable the empty option +# empty_label => 'all', #label for empty option + style => [ 'attribute:value', 'another:value' ], + ); + + + +<% include('/elements/xmlhttp.html', + 'url' => $p.'misc/cities.cgi', + 'subs' => [ $pre. 'get_cities' ], + ) +%> + + + + + <% $text_style %> +> + + + +%# VALUE = "<% $curr_value |h %>" +<%init> + +my %opt = @_; + +my $pre = $opt{'prefix'}; + +my $text_style = $opt{'style'} ? [ @{ $opt{'style'} } ] : []; +my $select_style = $opt{'style'} ? [ @{ $opt{'style'} } ] : []; + +my @cities = cities( $opt{'county'}, $opt{'state'}, $opt{'country'} ); +if ( scalar(@cities) > 1 || $cities[0] ) { + push @$text_style, 'display:none'; +} else { + push @$select_style, 'display:none'; +} + +$text_style = + scalar(@$text_style) + ? 'STYLE="'. join(';', @$text_style). '"' + : ''; + +$select_style = + scalar(@$select_style) + ? 'STYLE="'. join(';', @$select_style). '"' + : ''; + + diff --git a/httemplate/elements/location.html b/httemplate/elements/location.html index 07aaa69f0..5478e1e1e 100644 --- a/httemplate/elements/location.html +++ b/httemplate/elements/location.html @@ -49,16 +49,7 @@ Example: <%$r%>City - - - <% $style %> - > - + <% include('/elements/city.html', %select_hash) %> ><%$r%>County <% include('/elements/select-county.html', %select_hash ) %> <%$r%>State @@ -123,7 +114,7 @@ $object->set($pre.'state', $statedefault ) || $object->get($pre.'country') ne $countrydefault; my @style = (); -push @style, 'background-color: #dddddd"' if $disabled; +push @style, 'background-color: #dddddd' if $disabled; my @address2_label_style = (); push @address2_label_style, 'visibility:hidden' @@ -152,6 +143,7 @@ my $county_style = : ''; my %select_hash = ( + 'city' => $object->get($pre.'city'), 'county' => $object->get($pre.'county'), 'state' => $object->get($pre.'state'), 'country' => $object->get($pre.'country'), diff --git a/httemplate/elements/select-county.html b/httemplate/elements/select-county.html index aa88abe96..aa9f453fd 100644 --- a/httemplate/elements/select-county.html +++ b/httemplate/elements/select-county.html @@ -67,8 +67,11 @@ Example: } //run the callback - if ( callback != null ) + if ( callback != null ) { callback(); + } else { + <% $pre %>county_changed(what.form.<% $pre %>county); + } } // go get the new counties @@ -80,7 +83,7 @@ Example: