diff options
Diffstat (limited to 'httemplate/elements')
-rw-r--r-- | httemplate/elements/select-part_svc.html | 18 | ||||
-rw-r--r-- | httemplate/elements/select-table.html | 11 | ||||
-rw-r--r-- | httemplate/elements/tr-select-part_svc.html | 7 |
3 files changed, 29 insertions, 7 deletions
diff --git a/httemplate/elements/select-part_svc.html b/httemplate/elements/select-part_svc.html new file mode 100644 index 000000000..72ab7f6b0 --- /dev/null +++ b/httemplate/elements/select-part_svc.html @@ -0,0 +1,18 @@ +<% include( '/elements/select-table.html', + 'table' => 'part_svc', + 'name_col' => 'svc', + 'label_showkey' => 1, + #N/A 'empty_label' => '(none)', + %opt, + ) +%> +<%init> + +my( %opt ) = @_; + +$opt{'records'} = delete $opt{'part_svc'} + if $opt{'part_svc'}; + +$opt{'records'} ||= [ qsearch( 'part_svc', {} ) ]; # { disabled=>'' } ) + +</%init> diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html index 1a440f07e..10a8b2741 100644 --- a/httemplate/elements/select-table.html +++ b/httemplate/elements/select-table.html @@ -34,6 +34,7 @@ Example: 'empty_label' => '', #better specify it though, the default might change 'multiple' => 0, # bool 'disable_empty' => 0, # bool (implied by multiple) + 'label_showkey' => 0, # bool 'label_callback' => sub { my $record = shift; return "label"; }, #more params controlling HTML stuff about the <SELECT> @@ -77,13 +78,19 @@ Example: <OPTION VALUE=""><% $opt{'empty_label'} || 'all' %> % } -% foreach my $record ( sort { $a->$name_col() cmp $b->$name_col() } @records ) { +% foreach my $record ( sort { $a->$name_col() cmp $b->$name_col() +% || $a->$key() <=> $b->$key() +% } +% @records +% ) +% { % my $recvalue = $record->$key(); <OPTION VALUE="<% $recvalue %>" <% ref($value) && $value->{$recvalue} || $value == $recvalue ? ' SELECTED' : '' %> - ><% $opt{'label_callback'} + ><% $opt{'label_showkey'} ? "$recvalue: " : '' %> + <% $opt{'label_callback'} ? &{ $opt{'label_callback'} }( $record ) : $record->$name_col() %> diff --git a/httemplate/elements/tr-select-part_svc.html b/httemplate/elements/tr-select-part_svc.html index 0274ef12a..af5148749 100644 --- a/httemplate/elements/tr-select-part_svc.html +++ b/httemplate/elements/tr-select-part_svc.html @@ -7,11 +7,8 @@ <TR> <TD ALIGN="right"><% $opt{'label'} || 'Package definition' %></TD> <TD> - <% include( '/elements/select-table.html', - 'table' => 'part_svc', - 'name_col' => 'svc', - 'multiple' => 1, - #N/A 'empty_label' => '(none)', + <% include( '/elements/select-part_svc.html', + 'multiple' => 1, %opt, ) %> |