RT#39115: View SNMP info on svc_broadband service [fix to default value handling]
[freeside.git] / httemplate / edit / elements / part_export / broadband_snmp.html
index 8df0b8e..63b61e2 100644 (file)
@@ -11,7 +11,7 @@
 <& /elements/tr-input-text.html,
   label   => 'Community',
   field   => 'community',
-  curr_value  => $part_export->option('community'),
+  curr_value  => $curr_value->{'community'},
 &>
 <& /elements/tr-checkbox.html,
   label   => 'Send IP address changes to new address',
@@ -29,8 +29,8 @@
 function open_select_mib(obj) {
   nd(1); // if there's already one open, close it
   var rownum = obj.rownum;
-  var curr_oid = obj.value || '';
-  var url = '<%$fsurl%>/elements/select-mib-popup.html?' +
+  var curr_oid = obj.form.elements['oid' + rownum].value || '';
+  var url = '<%$fsurl%>misc/select-mib-popup.html?' +
             'callback=receive_mib;' +
             'arg=' + rownum +
             ';curr_value=' + curr_oid;
@@ -45,8 +45,10 @@ function open_select_mib(obj) {
 function receive_mib(obj, rownum) {
   //console.log(JSON.stringify(obj));
   // we don't really need the numeric OID or any of the other properties
-  document.getElementById('oid'+rownum).value = obj.fullname;
-  document.getElementById('datatype'+rownum).innerHTML = obj.type;
+  var oidfield =   document.getElementById('oid'+rownum);
+  oidfield.value = obj.fullname;
+  document.getElementById('datatype'+rownum).value = obj.type;
+  oidfield.onchange(); //should be same as datatype, only need to run one
 }
 </script>
 
@@ -66,10 +68,11 @@ function receive_mib(obj, rownum) {
     </SELECT>
   </TD>
   <TD>
-    <INPUT NAME="oid" ID="oid" SIZE="60" onclick="open_select_mib(this)">
+    <INPUT NAME="oid" ID="oid" SIZE="54">
+    <INPUT TYPE="button" VALUE="..." ID="openselector" onclick="open_select_mib(this)">
   </TD>
   <TD>
-    <SPAN ID="datatype"></SPAN>
+    <INPUT TYPE="text" NAME="datatype" ID="datatype">
   </TD>
   <TD>
     <INPUT NAME="value" ID="value">
@@ -77,22 +80,27 @@ function receive_mib(obj, rownum) {
 </TR>
 <& /elements/auto-table.html,
   template_row  => 'mytemplate',
-  fieldorder    => ['action', 'oid', 'value'],
+  fieldorder    => ['action', 'oid', 'datatype', 'value'],
   data          => \@data,
 &>
-<INPUT TYPE="hidden" NAME="multi_options" VALUE="action,oid,value">
+<INPUT TYPE="hidden" NAME="multi_options" VALUE="action,oid,datatype,value">
 <& foot.html, %opt &>
 <%init>
 my %opt = @_;
 my $part_export = $opt{part_export} || FS::part_export->new;
+my $curr_value = {};
+$curr_value->{'community'} = ($opt{'part_export'} && $opt{'part_export'}->exportnum)
+                           ? $part_export->option('community') 
+                           : $opt{'export_info'}->{'options'}->{'community'}->{'default'};
 
 my @actions = split("\n", $part_export->option('action'));
 my @oids    = split("\n", $part_export->option('oid'));
+my @types   = split("\n", $part_export->option('datatype'));
 my @values  = split("\n", $part_export->option('value'));
 
 my @data;
 while (@actions or @oids or @values) {
-  my @thisrow = (shift(@actions), shift(@oids), shift(@values));
+  my @thisrow = (shift(@actions), shift(@oids), shift(@types), shift(@values));
   push @data, \@thisrow if grep length($_), @thisrow;
 }