I guess that would be your 2 options if you don't want to modify the core.
Glad to help :)
Le 18/01/2024 à 10:33, Ernest Hocking a écrit :
Good afternoon Florian
Many thanks for the quick response and cl;arification - it's good to know
rather than trying things in the hope that it might work . I'll check out
the references.
As the comparative cash flow report is part of the core accounting
application (rather than a plug in) I didn't want to make too many changes
I guess the two options are
1. a plugin with freemarker templates,
2. just replace the 4 grids in the core accounting application with
freemarker and migrate the change during upgrades.
thanks and kind regards
Ernest
On Thu, Jan 18, 2024 at 4:17 PM Florian Motteau <[email protected]>
wrote:
Hello Ernest,
Happy new year to you !
Currently "title-area-style" attribute on field element cannot be set
dynamically in XML through a groovy snippet or a simple expression. You
can compare its implementation with the "disabled" attribute in
ModelFormFieldBuilder, which involves a FlexibleStringExpander :
https://github.com/apache/ofbiz-framework/blob/d17d06fd7c654621446320a98b45b3ebb859c648/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormFieldBuilder.java#L108
vs
https://github.com/apache/ofbiz-framework/blob/d17d06fd7c654621446320a98b45b3ebb859c648/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormFieldBuilder.java#L119
IMHO it would be a great improvement to switch widget-style,
widget-area-style, tooltip-style, title-style and title-area-style (from
a front-end developer perspective at least :), this kind of conditionnal
HTML rendering should be a given), but we may have to consider a
potential performance impact.
"red-when" has a specific behavior : it checks a condition on the
thruDate field value (the field would be red if now < entity.thruDate,
or the other way around).
You can check https://github.com/apache/ofbiz-framework/pull/548 for an
implementation example.
Le 18/01/2024 à 09:47, Ernest Hocking a écrit :
Happy New Year everyone
a question: "is it possible to conditionally colour a field in a form"
Based on the grid ComparativeCashFlowBalanceTotals in
ReportFinancialSummaryForms.xml
I tried the following groovy
<field name="balance1" title="Period1" title-area-style="${groovy: if
(balance < 0 ) red ?: green }" widget-area-style="green"
widget-style="tabletextright"><display type="currency"
currency="${currencyUomId}"/></field>
but get the error:
The value of attribute "title-area-style" associated with an element type
"field" must not contain the '<' character.org.xml.sax.SAXParseException;
I tried using alternatives such as
if (Maths.signum(balance1).equals(-1) )
etc but had no success to date. Is there a number equivalent of
"red-when"
that is available for date fields.
Any suggestions on how this could be implemented would be appreciated
I suspect I've overlooked something very obvious
thanks and kind regards
Ernest