summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-09-30 22:49:38 -0700
committerMark Wells <mark@freeside.biz>2015-09-30 22:49:38 -0700
commitd07c72046444319e0811c6a00b504885da091992 (patch)
tree145b723189b757087d9984eafb96413ab994061c /httemplate/edit
parent21b519eb5313ebe09242a2d90e1e615c56c64739 (diff)
graphical selection of deployment zones and automatic block lookup, #30260
Diffstat (limited to 'httemplate/edit')
-rw-r--r--httemplate/edit/deploy_zone-fixed.html85
-rw-r--r--httemplate/edit/deploy_zone-mobile.html21
-rw-r--r--httemplate/edit/process/deploy_zone-fixed.html35
-rw-r--r--httemplate/edit/process/deploy_zone-mobile.html19
-rw-r--r--httemplate/edit/process/elements/process.html21
5 files changed, 125 insertions, 56 deletions
diff --git a/httemplate/edit/deploy_zone-fixed.html b/httemplate/edit/deploy_zone-fixed.html
index 90d1b6667..b8d9f8bbc 100644
--- a/httemplate/edit/deploy_zone-fixed.html
+++ b/httemplate/edit/deploy_zone-fixed.html
@@ -54,29 +54,36 @@
value => 'Contractually guaranteed speed (Mbps)' },
'cir_speed_down',
'cir_speed_up',
-
- { type => 'tablebreak-tr-title', value => 'Census blocks'},
- { field => 'file',
- type => 'file-upload',
- },
- { field => 'format',
- type => 'hidden',
- value => 'plain',
- },
- { field => 'censusyear',
- type => 'select',
- options => [ '', qw( 2013 2012 2011 ) ],
- },
-
- { type => 'tablebreak-tr-title', value => '', },
- { field => 'blocknum',
- type => 'deploy_zone_block',
- o2m_table => 'deploy_zone_block',
- m2_label => ' ',
- m2_error_callback => $m2_error_callback,
- },
+ { type => 'tablebreak-tr-title', value => 'Footprint'},
+ { field => 'vertices',
+ type => 'polygon',
+ curr_value_callback => sub {
+ my ($cgi, $object) = @_;
+ $cgi->param('vertices') || $object->vertices_json;
+ },
+ }
+#
+# { type => 'tablebreak-tr-title', value => 'Census blocks'},
+# { field => 'file',
+# type => 'file-upload',
+# },
+# { field => 'format',
+# type => 'hidden',
+# value => 'plain',
+# },
+# { field => 'censusyear',
+# type => 'hidden',
+# options => [ '', qw( 2013 2012 2011 ) ],
+# },
+#
+# { type => 'tablebreak-tr-title', value => '', },
+# { field => 'blocknum',
+# type => 'deploy_zone_block',
+# o2m_table => 'deploy_zone_block',
+# m2_label => ' ',
+# m2_error_callback => $m2_error_callback,
+# },
],
-
&>
<%init>
my $curuser = $FS::CurrentUser::CurrentUser;
@@ -90,22 +97,22 @@ my $technology_labels = FS::part_pkg_fcc_option->technology_labels;
my $media_types = FS::part_pkg_fcc_option->media_types;
delete $media_types->{'Mobile Wireless'}; # cause this is the fixed zone page
-my $m2_error_callback = sub {
- my ($cgi, $deploy_zone) = @_;
- my @blocknums = grep {
- /^blocknum\d+/ and length($cgi->param($_.'_censusblock'))
- } $cgi->param;
-
- sort { $a->censusblock <=> $b->censusblock }
- map {
- my $k = $_;
- FS::deploy_zone_block->new({
- blocknum => scalar($cgi->param($k)),
- zonenum => $deploy_zone->zonenum,
- censusblock => scalar($cgi->param($k.'_censusblock')),
- censusyear => scalar($cgi->param($k.'_censusyear')),
- })
- } @blocknums;
-};
+#my $m2_error_callback = sub {
+# my ($cgi, $deploy_zone) = @_;
+# my @blocknums = grep {
+# /^blocknum\d+/ and length($cgi->param($_.'_censusblock'))
+# } $cgi->param;
+#
+# sort { $a->censusblock <=> $b->censusblock }
+# map {
+# my $k = $_;
+# FS::deploy_zone_block->new({
+# blocknum => scalar($cgi->param($k)),
+# zonenum => $deploy_zone->zonenum,
+# censusblock => scalar($cgi->param($k.'_censusblock')),
+# censusyear => scalar($cgi->param($k.'_censusyear')),
+# })
+# } @blocknums;
+#};
</%init>
diff --git a/httemplate/edit/deploy_zone-mobile.html b/httemplate/edit/deploy_zone-mobile.html
index d049cb018..8cec298bf 100644
--- a/httemplate/edit/deploy_zone-mobile.html
+++ b/httemplate/edit/deploy_zone-mobile.html
@@ -49,14 +49,21 @@
'adv_speed_down',
'adv_speed_up',
{ type => 'tablebreak-tr-title', value => 'Footprint'},
- { field => 'vertexnum',
- type => 'deploy_zone_vertex',
- o2m_table => 'deploy_zone_vertex',
- m2_label => ' ',
- m2_error_callback => $m2_error_callback,
- },
- ],
+ { field => 'vertices',
+ type => 'polygon',
+ curr_value_callback => sub {
+ my ($cgi, $object) = @_;
+ $cgi->param('vertices') || $object->vertices_json;
+ },
+ }
+# { field => 'vertexnum',
+# type => 'deploy_zone_vertex',
+# o2m_table => 'deploy_zone_vertex',
+# m2_label => ' ',
+# m2_error_callback => $m2_error_callback,
+# },
+ ],
&>
<%init>
my $curuser = $FS::CurrentUser::CurrentUser;
diff --git a/httemplate/edit/process/deploy_zone-fixed.html b/httemplate/edit/process/deploy_zone-fixed.html
index eae3a746d..0033bbe52 100644
--- a/httemplate/edit/process/deploy_zone-fixed.html
+++ b/httemplate/edit/process/deploy_zone-fixed.html
@@ -3,12 +3,31 @@
error_redirect => popurl(2).'deploy_zone-fixed.html',
table => 'deploy_zone',
viewall_dir => 'browse',
- process_o2m => {
- 'table' => 'deploy_zone_block',
- 'fields' => [qw( censusblock censusyear )]
- },
- process_upload => {
- 'process' => 'misc/process/deploy_zone-import.html',
- 'fields' => [qw( censusyear format )],
- },
+ precheck_callback => $precheck_callback,
+ process_o2m =>
+ { 'table' => 'deploy_zone_vertex',
+ 'fields' => [qw( latitude longitude )]
+ },
+ progress_init => [
+ 'PostForm',
+ [ 'zonenum' ],
+ $fsurl.'misc/process/deploy_zone-block_lookup.cgi',
+ $fsurl.'browse/deploy_zone.html',
+ ],
&>
+<%init>
+my $precheck_callback = sub {
+ # convert the vertex list into a process_o2m-style parameter list
+ if ( $cgi->param('vertices') ) {
+ my $vertices = decode_json($cgi->param('vertices'));
+ my $i = 0;
+ foreach (@$vertices) {
+ $cgi->param("vertexnum${i}", '');
+ $cgi->param("vertexnum${i}_latitude", $_->[0]);
+ $cgi->param("vertexnum${i}_longitude", $_->[1]);
+ $i++;
+ }
+ }
+ '';
+};
+</%init>
diff --git a/httemplate/edit/process/deploy_zone-mobile.html b/httemplate/edit/process/deploy_zone-mobile.html
index 7b8f911ec..d36d5d448 100644
--- a/httemplate/edit/process/deploy_zone-mobile.html
+++ b/httemplate/edit/process/deploy_zone-mobile.html
@@ -2,8 +2,25 @@
error_redirect => popurl(2).'deploy_zone-mobile.html',
table => 'deploy_zone',
viewall_dir => 'browse',
- process_o2m =>
+ precheck_callback => $precheck_callback,
+ process_o2m =>
{ 'table' => 'deploy_zone_vertex',
'fields' => [qw( latitude longitude )]
},
&>
+<%init>
+my $precheck_callback = sub {
+ # convert the vertex list into a process_o2m-style parameter list
+ if ( $cgi->param('vertices') ) {
+ my $vertices = decode_json($cgi->param('vertices'));
+ my $i = 0;
+ foreach (@$vertices) {
+ $cgi->param("vertexnum${i}", '');
+ $cgi->param("vertexnum${i}_latitude", $_->[0]);
+ $cgi->param("vertexnum${i}_longitude", $_->[1]);
+ $i++;
+ }
+ }
+ '';
+};
+</%init>
diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html
index 69bd605f6..a76f4befb 100644
--- a/httemplate/edit/process/elements/process.html
+++ b/httemplate/edit/process/elements/process.html
@@ -160,7 +160,26 @@ process();
</script>
<& /elements/footer.html &>
-%} elsif ( $opt{'popup_reload'} ) {
+% } elsif ( $opt{'progress_init'} ) {
+% # some false laziness with the above
+% my ($form_name, $job_fields) = @{ $opt{'progress_init'} };
+<form name="<% $form_name %>">
+% foreach my $field (@$job_fields) {
+ <input type="hidden" name="<% $field %>" value="<% $cgi->param($field) |h %>">
+% }
+<& /elements/progress-init.html,
+ @{ $opt{'progress_init'} }
+&>
+<input type="submit" style="display:none">
+</form>
+<script>
+<&| /elements/onload.js &>
+process();
+</&>
+</script>
+<& /elements/footer.html &>
+
+% } elsif ( $opt{'popup_reload'} ) {
<% include('/elements/header-popup.html', $opt{'popup_reload'} ) %>