Index: openacs-4/packages/acs-templating/tcl/list-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/list-procs.tcl,v diff -u -r1.81 -r1.82 --- openacs-4/packages/acs-templating/tcl/list-procs.tcl 1 May 2018 09:34:09 -0000 1.81 +++ openacs-4/packages/acs-templating/tcl/list-procs.tcl 8 May 2018 11:21:49 -0000 1.82 @@ -54,6 +54,7 @@ {-formats ""} {-filter_form 0} {-bulk_action_click_function "acs_ListBulkActionClick"} + {-aggregation_format ""} } { Defines a list to be displayed in a template. The list works in conjunction with a multirow, which contains the data for the list. The list is output using the <listtemplate> and <listfilters> templating tags, with the help of <listelement> and <listrow>. @@ -235,6 +236,8 @@ @param filter_form Whether or not we create the form data structure for the listfilters-form tag to dynamically generate a form to specify filter criteria. Default 0 will not generate form. Set to 1 to generate form to use listfilters-form tag. @param bulk_action_click_functon JavaScript function name to call when bulk action buttons are clicked. + @param aggregation_format An option to format the result (number) of an aggregation operation. Default is empty string (result is not formatted). See the Tcl built-in command format for details on the different formatting options. + @see template::list::element::create @see template::list::filter::create @see template::list::orderby::create @@ -271,6 +274,7 @@ # These are defaults for internally maintained properties array set list_properties { aggregates_p 0 + aggregation_format {} bulk_action_export_chunk {} display_elements {} dynamic_cols_p 0 @@ -306,6 +310,7 @@ # Set properties from the parameters passed foreach elm { actions + aggregation_format bulk_action_click_function bulk_action_export_vars bulk_action_method @@ -1292,6 +1297,9 @@ set __agg_sum($__element_properties(name)) \ [expr {$__agg_sum($__element_properties(name)) + ([set $__element_properties(name)] ne "" ? [set $__element_properties(name)] : 0)} ] + if {$__list_properties(aggregation_format) ne ""} { + set __agg_sum($__element_properties(name)) [format $__list_properties(aggregation_format) $__agg_sum($__element_properties(name))] + } } # Check if the value of the groupby column has changed @@ -1306,6 +1314,9 @@ set __agg_group_sum($__element_properties(name)) \ [expr {$__agg_group_sum($__element_properties(name)) + ([string is double [set $__element_properties(name)]] ? [set $__element_properties(name)] : 0)}] + if {$__list_properties(aggregation_format) ne ""} { + set __agg_group_sum($__element_properties(name)) [format $__list_properties(aggregation_format) $__agg_group_sum($__element_properties(name))] + } } switch -- $__element_properties(aggregate) {