[freeside-commits] freeside/httemplate/config config-view.cgi, 1.28, 1.29 config-delete.cgi, 1.1, 1.2 config-process.cgi, 1.17, 1.18

Ivan,,, ivan at wavetail.420.am
Fri May 1 17:01:32 PDT 2009


Update of /home/cvs/cvsroot/freeside/httemplate/config
In directory wavetail.420.am:/tmp/cvs-serv30278/config

Modified Files:
	config-view.cgi config-delete.cgi config-process.cgi 
Log Message:
finish up useful agent stuff on the config editor: adding, deleting overrides too.  also add a confirmation to override deletion from the agent browse page.  RT#5218

Index: config-process.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/config/config-process.cgi,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- config-process.cgi	1 May 2009 01:07:45 -0000	1.17
+++ config-process.cgi	2 May 2009 00:01:30 -0000	1.18
@@ -66,6 +66,9 @@
 %   my $n = 0;
 %   foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
     var configCell = window.top.document.getElementById('<% $agentnum. $i->key. $n %>');
+    if ( ! configCell ) {
+      window.top.location.reload();
+    }
     //alert('found cell ' + configCell);
 %     if (    $type eq 'textarea'
 %          || $type eq 'editlist'

Index: config-delete.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/config/config-delete.cgi,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- config-delete.cgi	18 Jul 2007 18:07:38 -0000	1.1
+++ config-delete.cgi	2 May 2009 00:01:30 -0000	1.2
@@ -2,14 +2,19 @@
 die "access denied\n"
   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
 
-die "No configuration item specified (bad URL)!" unless $cgi->keywords;
-my ($query) = $cgi->keywords;
-$query =~ /^(\d+)$/;
+$cgi->param('confnum') =~ /^(\d+)$/ or die "illegal or missing confnum";
 my $confnum = $1;
 
 my $conf = qsearchs('conf', {'confnum' => $confnum});
 die "Configuration not found!" unless $conf;
 $conf->delete;
 
+my $redirect = popurl(2);
+if ( $cgi->param('redirect') eq 'config_view' ) {
+  $redirect .= 'config/config-view.cgi?showagent=1#'. $conf->name;
+} else {
+  $redirect .= 'browse/agent.cgi';
+}
+
 </%init>
-<% $cgi->redirect(popurl(2) . "browse/agent.cgi") %>
+<% $cgi->redirect($redirect) %>

Index: config-view.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/config/config-view.cgi,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- config-view.cgi	1 May 2009 02:43:24 -0000	1.28
+++ config-view.cgi	2 May 2009 00:01:30 -0000	1.29
@@ -58,7 +58,22 @@
 %     #$height = 
 %   }
 %
-%   my @agents = $page_agent ? ( $page_agent ) : ( '', @all_agents );
+%   my @agents = ();
+%   my @add_agents = ();
+%   if ( $page_agent ) {
+%     @agents = ( $page_agent );
+%   } else {
+%     @agents = ( '' );
+%     if ( $i->per_agent ) {
+%       foreach my $agent (@all_agents) {
+%         if ( defined(_config_agentonly($conf, $i->key, $agent->agentnum)) ) {
+%           push @agents, $agent;
+%         } else {
+%           push @add_agents, $agent;
+%         }
+%       }
+%     }
+%   }
 %
 %   foreach my $agent ( @agents ) {
 %     my $agentnum = $agent ? $agent->agentnum : '';
@@ -81,6 +96,10 @@
                                                  # if $cgi->param('showagent')?
                     )
           %>: <% $i->description %>
+%       if ( $agent && $cgi->param('showagent') ) {
+          (<A HREF="javascript:areyousure('delete this agent override', 'config-delete.cgi?confnum=<% _config_agentonly($conf, $i->key, $agent->agentnum)->confnum %>;redirect=config_view')">delete agent override</A>)
+%       }
+
       </td>
       <td><table border=0>
 
@@ -190,25 +209,81 @@
 
 % } # foreach my $agentnum
 
+% if ( @add_agents ) {
+
+  <tr>
+    <td>
+      <FORM>
+      Add <b><% $i->key %></b> override for
+        <% include('/elements/select-agent.html',
+                     'agents'      => \@add_agents,
+                     'empty_label' => 'Select agent',
+                     'onchange'    => "agent_changed",
+                     'id'          => 'agent_'. $i->key,
+                  )
+        %>
+      agent
+
+%     my $agent_el = "document.getElementById('agent_". $i->key. "')";
+      <INPUT TYPE    = "button"
+             VALUE   = "Add"
+             ID      = "add_<% $i->key %>"
+             DISABLED
+             onClick = "<%
+               include('/elements/popup_link_onclick.html',
+                         'action'      =>
+                           'config.cgi?key='.      $i->key.
+                           ";agentnum=' + ".
+                             "$agent_el.options[$agent_el.selectedIndex].value".
+                             " + '",
+                         'width'       => $width,
+                         'height'      => $height,
+                         'actionlabel' => 'Enter configuration value',
+                      )
+             %>"
+      >
+      </FORM>
+    </td>
+  </tr>
+
+% } #if @add_agents
+
 % } # foreach my $i
 
   </table><br><br>
 
 % } # foreach my $nav_section
 
+<SCRIPT TYPE="text/javascript">
+
+  function agent_changed(what) {
+    var key = what.id.substring(6); // trim agent_
+    var button = document.getElementById('add_'+key);
+    if ( what.selectedIndex > 0 ) {
+      button.disabled = false;
+    } else {
+      button.disabled = true;
+    }
+  }
+
+  function areyousure(what, href) {
+    if ( confirm("Are you sure you want to " + what + "?") == true )
+      window.location.href = href;
+  }
+
+</SCRIPT>
+
 </body></html>
 <%once>
 
 #should probably be a Conf method.  what else would need to use it?
-#not even us, apparantly...
-#  defined( _config_agentonly($conf, $i->key, $_->agentnum) )
-#sub _config_agentonly {
-#  my($self,$name,$agentnum)=@_;
-#  my $hashref = { 'name' => $name };
-#  $hashref->{agentnum} = $agentnum;
-#  local $FS::Record::conf = undef;  # XXX evil hack prevents recursion
-#  FS::Record::qsearchs('conf', $hashref);
-#}
+sub _config_agentonly {
+  my($self,$name,$agentnum)=@_;
+  my $hashref = { 'name' => $name };
+  $hashref->{agentnum} = $agentnum;
+  local $FS::Record::conf = undef;  # XXX evil hack prevents recursion
+  FS::Record::qsearchs('conf', $hashref);
+}
 
 </%once>
 <%init>



More information about the freeside-commits mailing list