[freeside-commits] freeside/httemplate/elements tr-select-part_pkg.html, 1.1, 1.2 select-cust-part_pkg.html, 1.1, 1.2 select-part_pkg.html, NONE, 1.1 select-table.html, 1.10, 1.11

Ivan,,, ivan at wavetail.420.am
Sun Apr 13 13:35:12 PDT 2008


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

Modified Files:
	tr-select-part_pkg.html select-cust-part_pkg.html 
	select-table.html 
Added Files:
	select-part_pkg.html 
Log Message:
select-table and select-part_pkg updates so we can use select-part_pkg as an edit/elements/edit.html m2 type

Index: select-table.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-table.html,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- select-table.html	13 Apr 2008 03:03:00 -0000	1.10
+++ select-table.html	13 Apr 2008 20:35:10 -0000	1.11
@@ -100,6 +100,7 @@
     'table'     => $opt{'table'},
     'hashref'   => ( $opt{'hashref'} || {} ),
     'extra_sql' => ( $opt{'extra_sql'} || '' ),
+    'order_by'  => ( $opt{'order_by'} || "ORDER BY $name_col" ),
   });
 }
 

Index: tr-select-part_pkg.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/tr-select-part_pkg.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- tr-select-part_pkg.html	1 Aug 2007 22:25:10 -0000	1.1
+++ tr-select-part_pkg.html	13 Apr 2008 20:35:09 -0000	1.2
@@ -1,29 +1,39 @@
-% if ( scalar(@{ $opt{'part_pkg'} }) == 0 ) { 
+% if ( $opt{'part_pkg'} && scalar(@{ $opt{'part_pkg'} }) == 0 ) { 
+%   unless ( $opt{'js_only'} ) {
 
-  <INPUT TYPE="hidden" NAME="<% $opt{'field'} || 'pkgpart' %>" VALUE="">
+      <INPUT TYPE="hidden" NAME="<% $opt{'field'} || 'pkgpart' %>" VALUE="">
 
+%   }
+%
 % } else { 
+%
+%   unless ( $opt{'js_only'} ) {
 
-  <TR>
-    <TD ALIGN="right"><% $opt{'label'} || 'Package definition' %></TD>
-    <TD>
-      <% include( '/elements/select-table.html',
-                    'table'     => 'part_pkg',
-                    'name_col'  => 'pkg',
-                    'multiple'  => 1,
-                    #N/A 'empty_label' => '(none)',
-                    %opt,
-                )
-      %>
-    </TD>
-  </TR>
+      <% include('tr-td-label.html', %opt) %>
+        <TD <% $cell_style %>>
 
-% } 
+%   }
+%
+          <% include( '/elements/select-part_pkg.html', %opt ) %>
+%
+%   unless ( $opt{'js_only'} ) {
+
+        </TD>
+      </TR>
 
+%   }
+%
+% } 
 <%init>
 
 my( %opt ) = @_;
 
-$opt{'part_pkg'} ||= [ qsearch( 'part_pkg', {} ) ]; # { disabled=>'' } )
+my $cell_style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
+
+$opt{'label'} ||= 'Package definition';
+
+#taken care of (better) in select-part_pkg now (is there anything using this
+# that needs to override the disabed=>'' ??)
+#$opt{'part_pkg'} ||= [ qsearch( 'part_pkg', {} ) ]; # { disabled=>'' } )
 
 </%init>

--- NEW FILE: select-part_pkg.html ---
<%doc>

Example:

  include( '/elements/select-part_pkg.html',

    #strongly recommended (you want your forms to be "sticky" on errors, right?)
    'curr_value' => 'current_value',
  
    #opt
    'part_pkg'   => \@records,

    #select-table.html options
  )

</%doc>

<% include( '/elements/select-table.html',
              'table'          => 'part_pkg',
              'name_col'       => 'pkg',
              'empty_label'    => 'Select package', #should this be the default?
              'label_callback' => sub { shift->pkg_comment },
              'hashref'        => { 'disabled' => '' },
              %opt,
          )
%>
<%init>

my( %opt ) = @_;

$opt{'records'} = delete $opt{'part_pkg'}
  if $opt{'part_pkg'};

</%init>

Index: select-cust-part_pkg.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-cust-part_pkg.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- select-cust-part_pkg.html	2 Aug 2007 23:01:01 -0000	1.1
+++ select-cust-part_pkg.html	13 Apr 2008 20:35:09 -0000	1.2
@@ -18,14 +18,9 @@
 
 </%doc>
 
-<% include( '/elements/select-table.html',
-              'table'          => 'part_pkg',
-              'name_col'       => 'pkg',
-              'empty_label'    => 'Select package',
-              'label_callback' => sub { $_[0]->pkgpart. ': '.
-                                        $_[0]->pkg.     ' - '.
-                                        $_[0]->comment;
-                                      },
+<% include( '/elements/select-part_pkg.html',
+              'empty_label'    => 'Select package', #? need here in case removed
+                                                    #from select-part_pkg ??
               %opt,
           )
 %>
@@ -36,21 +31,9 @@
 my $cust_main = $opt{'cust_main'}
   or die "cust_main not specified";
 
-$opt{'records'} = delete $opt{'part_pkg'}
-  if $opt{'part_pkg'};
-
-my $extra_sql = $opt{'extra_sql'}.
+$opt{'extra_sql'} .=
   ' AND 0 < ( SELECT COUNT(*) FROM type_pkgs '.
   '             WHERE typenum = '. $cust_main->agent->typenum.
   '             AND type_pkgs.pkgpart = part_pkg.pkgpart )';
 
-$opt{'records'} ||= [ qsearch({ 
-                                'table'     => 'part_pkg',
-                                'hashref'   => { 'disabled' => '', },
-                                'extra_sql' => "$extra_sql ORDER BY pkg",
-                                #'extra_sql' => $extra_sql,
-                                #'order_by'  => 'ORDER BY pkg',
-                             })
-                    ];
-
 </%init>



More information about the freeside-commits mailing list