Open ebruchez opened 1 month ago
number.xbl
uses this to compute the formatted value:
string-join(
(
fr:component-param-value('prefix'),
NumberSupport:getDisplayValueJava(
xxf:binding('fr-number'),
fr:component-param-value('decimal-separator'),
fr:component-param-value('grouping-separator'),
fr:component-param-value('prefix'),
fr:component-param-value('digits-after-decimal'),
string(fr:component-param-value('round-when-formatting')) = 'true',
string(fr:component-param-value('round-when-storing')) = 'true'
),
fr:component-param-value('suffix')
),
' '
)
Ideally, the Summary page/export should obtain the field's format information as well, but we don't have a function to do this yet.
We could easily reuse componentParamValue()
, but this would require having a PartAnalysis
available. On the Summary page, this is not the case. The static state of the form should/could be in the static state cache, but we don't have a way to know or obtain this information right now!
Could we:
new
/edit
static stateNow the above is not even that great, because the format of the value is known by the component at runtime, and it could ue xxbl:format
but not necessarily.
Other solutions:
xxf:dynamic
with concrete instances of the fields, and ask them for their formats. This could be costly.fr:time
does it better: the configured format is on the control as output-format="[h01]:[m] [PN,2-2]"
. While for fr:number
, each component is individually set on the control, as round-when-formatting="true" grouping-separator="'"
, etc.
The idea for fr:time
was that we didn't think that overriding individual components made sense, so they are all together.
If the component or Form Builder also output an output-format
, or just switched to it, the Summary page's job would be easier. We could standardize on output-format
. This should include:
decimal-separator
grouping-separator
prefix
digits-after-decimal
round-when-formatting
(might not be encodable)suffix
Reaching the conclusion that creating an xxf:dynamic
might be the cleanest and most versatile solution for the Summary page! This would also avoid special-casing controls in the Summary page as we do now.
However, for the Excel export, we are not running a form, so we wouldn't be able to do that. The Summary page could pass the formats, if it can somehow extract them from the running form. However, if we were to ever want to publicly expose a separate Summary Page Excel Export API endpoint, we wouldn't be able to automatically determine the formats.
Tasks:
Following #6323.
Right now, they are just output as is.