improve performance of package add/edit (don't pull up pricing info in add-on/supplem...
authorIvan Kohler <ivan@freeside.biz>
Tue, 25 Mar 2014 23:33:26 +0000 (16:33 -0700)
committerIvan Kohler <ivan@freeside.biz>
Tue, 25 Mar 2014 23:33:26 +0000 (16:33 -0700)
FS/FS/part_pkg.pm
httemplate/edit/elements/edit.html
httemplate/edit/part_pkg.cgi
httemplate/elements/select-part_pkg.html

index d1ec0fb..198c362 100644 (file)
@@ -772,6 +772,16 @@ sub pkg_comment {
   $pre. $self->pkg. ( $custom_comment ? " - $custom_comment" : '' );
 }
 
+#without price info (so without hitting the DB again)
+sub pkg_comment_only {
+  my $self = shift;
+  my %opt = @_;
+
+  my $pre = $opt{nopkgpart} ? '' : $self->pkgpart. ': ';
+  my $comment = $self->comment;
+  $pre. $self->pkg. ( $comment ? " - $comment" : '' );
+}
+
 sub price_info { # safety, in case a part_pkg hasn't defined price_info
     '';
 }
@@ -1205,6 +1215,8 @@ will be suppressed.
 
 sub option {
   my( $self, $opt, $ornull ) = @_;
+  cluck "$self -> option: searching for $opt"
+    if $DEBUG;
   my $part_pkg_option =
     qsearchs('part_pkg_option', {
       pkgpart    => $self->pkgpart,
index 938d3a5..c644425 100644 (file)
@@ -317,6 +317,9 @@ Example:
 %     'disabled'      => $f->{'disabled'},
 %     'fixed'         => $f->{'fixed'},
 %
+%     #umm.  for select-agent_types at least
+%     'label_callback'=> $f->{'label_callback'},
+%
 %     #any?
 %     'colspan'       => $f->{'colspan'},
 %     'required'      => $f->{'required'},
index d1fbdf2..829bf83 100755 (executable)
                                                      ? "AND pkgpart != $pkgpart"
                                                      : ''
                                                   },
++                             'label_callback' => sub { shift->pkg_comment_only },
                               'm2_label'   => 'Include line item(s) from package',
                               'm2m_method' => 'bill_part_pkg_link',
                               'm2m_dstcol' => 'dst_pkgpart',
                                                      ? "AND pkgpart != $pkgpart"
                                                      : ''
                                                   },
++                             'label_callback' => sub { shift->pkg_comment_only },
                               'm2_label'   => 'Include services of package: ',
                               'm2m_method' => 'svc_part_pkg_link',
                               'm2m_dstcol' => 'dst_pkgpart',
                             },
                             { 'field'       => 'supp_dst_pkgpart',
                               'type'        => 'select-part_pkg',
++                             'label_callback' => sub { shift->pkg_comment_only },
                               'm2_label'    => 'When ordering package, also order',
                               'm2m_method'  => 'supp_part_pkg_link',
                               'm2m_dstcol'  => 'dst_pkgpart',
index 9d41b07..bf58191 100644 (file)
@@ -15,17 +15,16 @@ Example:
 
 </%doc>
 
-<% include( '/elements/select-table.html',
-              'table'          => 'part_pkg',
-              'agent_virt'     => 1,
-              'agent_null'     => 1,
-              'name_col'       => 'pkg',
-              'empty_label'    => 'Select package', #should this be the default?
-              'label_callback' => sub { shift->pkg_comment },
-              'hashref'        => \%hash,
-              %opt,
-          )
-%>
+<& /elements/select-table.html,
+     'table'          => 'part_pkg',
+     'agent_virt'     => 1,
+     'agent_null'     => 1,
+     'name_col'       => 'pkg',
+     'empty_label'    => 'Select package', #should this be the default?
+     'label_callback' => $opt{'label_callback'} || sub { shift->pkg_comment },
+     'hashref'        => \%hash,
+     %opt,
+&>
 <%init>
  
 my( %opt ) = @_;