projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
search for missing/outdated census tract, RT#86245
[freeside.git]
/
httemplate
/
elements
/
select-country.html
diff --git
a/httemplate/elements/select-country.html
b/httemplate/elements/select-country.html
index
c4368c2
..
2868267
100644
(file)
--- a/
httemplate/elements/select-country.html
+++ b/
httemplate/elements/select-country.html
@@
-2,7
+2,7
@@
Example:
Example:
-
include( '/elements/select-country.html'
,
+
<& /elements/select-country.html
,
#recommended
country => $current_country,
#recommended
country => $current_country,
@@
-13,10
+13,16
@@
Example:
disable_empty => 1, #defaults to 1, disable the empty option
empty_label => 'all', #label for empty option
disable_stateupdate => 0, #bool - disabled update of the select-state.html
disable_empty => 1, #defaults to 1, disable the empty option
empty_label => 'all', #label for empty option
disable_stateupdate => 0, #bool - disabled update of the select-state.html
-
- );
+ style => [ 'attribute:value', 'another:value' ],
+
+ state_disable_empty => 1, #defaults to 1, disable the state empty option
+ state_empty_label => 'all', #label for state empty option
+ &>
</%doc>
</%doc>
+% #maybe this makes more sense in select-state.html?
+% # (county update is in select-county... and we wouldn't have to pass "state_"
+% # options)
% unless ( $opt{'disable_stateupdate'} ) {
<% include('/elements/xmlhttp.html',
% unless ( $opt{'disable_stateupdate'} ) {
<% include('/elements/xmlhttp.html',
@@
-34,6
+40,8
@@
Example:
}
function <% $pre %>country_changed(what, callback) {
}
function <% $pre %>country_changed(what, callback) {
+
+ what.form.<% $pre %>state.disabled = 'disabled';
country = what.options[what.selectedIndex].value;
country = what.options[what.selectedIndex].value;
@@
-45,16
+53,25
@@
Example:
// add the new states
var statesArray = eval('(' + states + ')' );
// add the new states
var statesArray = eval('(' + states + ')' );
+% unless ( $opt{'disable_empty'} ) {
+ statesArray.unshift('', '');
+% }
+
for ( var s = 0; s < statesArray.length; s=s+2 ) {
var stateLabel = statesArray[s+1];
if ( stateLabel == "" )
for ( var s = 0; s < statesArray.length; s=s+2 ) {
var stateLabel = statesArray[s+1];
if ( stateLabel == "" )
- stateLabel =
'(n/a)'
;
+ stateLabel =
<% $opt{state_empty_label} || '(n/a)' |js_string %>
;
opt(what.form.<% $pre %>state, statesArray[s], stateLabel);
}
opt(what.form.<% $pre %>state, statesArray[s], stateLabel);
}
+
+ what.form.<% $pre %>state.disabled = '';
//run the callback
//run the callback
- if ( callback != null )
+ if ( callback != null )
{
callback();
callback();
+ } else {
+ <% $pre %>state_changed(what.form.<% $pre %>state);
+ }
}
// go get the new states
}
// go get the new states
@@
-70,18
+87,17
@@
Example:
ID = "<% $pre %>country"
onChange = "<% $onchange %>"
<% $opt{'disabled'} %>
ID = "<% $pre %>country"
onChange = "<% $onchange %>"
<% $opt{'disabled'} %>
+ <% $style %>
>
% unless ( $opt{'disable_empty'} ) {
>
% unless ( $opt{'disable_empty'} ) {
- <OPTION VALUE=""><% $opt{'empty_label'} || '(all)' %>
+ <OPTION VALUE=""><% $opt{'empty_label'} || '(all)' %>
</OPTION>
% }
% foreach my $country ( @all_countries ) {
% }
% foreach my $country ( @all_countries ) {
-
- <OPTION VALUE="<% $country |h %>"
- <% $country eq $opt{'country'} ? ' SELECTED' : '' %>
- ><% code2country($country). " ($country)" %>
-
+ <OPTION VALUE="<% $country |h %>"<% $country eq $opt{'country'} ? ' SELECTED' : '' %>>
+ <% FS::geocode_Mixin->code2country($country). " ($country)" |h %>
+ </OPTION>
% }
</SELECT>
% }
</SELECT>
@@
-101,12
+117,18
@@
my $onchange =
( $opt{'disable_stateupdate'} ? '' : $pre.'country_changed(this); ' ).
$opt{'onchange'};
( $opt{'disable_stateupdate'} ? '' : $pre.'country_changed(this); ' ).
$opt{'onchange'};
+$opt{'style'} ||= [];
+my $style =
+ scalar(@{$opt{style}})
+ ? 'STYLE="'. join(';', @{$opt{style}}). '"'
+ : '';
+
my $conf = new FS::Conf;
my $default = $conf->config('countrydefault') || 'US';
my @all_countries = (
sort { ($b eq $default) <=> ($a eq $default)
my $conf = new FS::Conf;
my $default = $conf->config('countrydefault') || 'US';
my @all_countries = (
sort { ($b eq $default) <=> ($a eq $default)
- or
code2country($a) cmp
code2country($b)
+ or
FS::geocode_Mixin->code2country($a) cmp FS::geocode_Mixin->
code2country($b)
}
map { $_->country }
qsearch({
}
map { $_->country }
qsearch({