Open ebruchez opened 9 years ago
Exact same case with the email field, which should also show the "Character Counter" appearance. Current rules:
xf|input:xxf-type('xf:email')
xf|input[appearance ~= character-counter]
The question is whether we can generally enable this. Does xf|input[appearance ~= character-counter]
mean that this is supported for any datatype? I think so. If it is only supported for some datatypes, then the rule should be stricter, e.g. xf|input:xxf-type('xs:string')[appearance ~= character-counter]
.
Quickly check if it is an easy fix. If so, do for 4.10, otherwise postpone.
Some more:
[x] possibleAppearancesWithBindings
needs to be changed. Currently, if there is any mapping found with a datatype, we only keep bindings with a datatype. This is incorrect and should be done per appearance.
For example, if we have xf|input:xxf-type('xf:email')
, then xf|input[appearance ~= character-counter]
is removed, but we should keep it.
OTOH if we have xf|input:xxf-type('xf:email')
and xf|input
, we do need to remove xf|input
.
xf:character-counter
never makes sense and should be removed. BUT we need to be careful because the CSS depends on the class xbl-fr-character-counter
being present, and if we remove the direct binding the class is not placed.xf:character-counter
need to be more specific. It makes sense to have the character counter for xf:string
, xf:email
, but not xs:date
. So: xf|input:xxf-type('xs:string')[appearance ~= character-counter], xf|input:xxf-type('xf:email')[appearance ~= character-counter], ...
newElementName
must be fixed. With the above, it generates directly a fr:character-counter
, but that must never be generated.It's a bit more complicated than I thought. The idea, when handling datatypes at design time, is to introduce a substitution. For example, we substitute `fr:number
for xf|input:xxf-type('xs:decimal')
.
In the case of character-counter
, say we match on:
xf|input:xxf-type('xs:string')[appearance ~= character-counter]
The current code substitutes the direct binding fr|character-counter
, which is clearly wrong and even causes a stack overflow at runtime. Clearly, another substitution is needed. But the runtime currently ignores all selectors containing datatypes. So we cannot simply NOT substitute because:
<xf:input appearance="character-counter">
will not match anything. And we cannot simply add the selector:
xf|input[appearance ~= character-counter]
because then the character-counter
appearance would show in Form Builder for types like xs:date
, etc.
Question: should there be a difference between cases like xf|input:xxf-type('xf:email')
and xf|textarea[appearance ~= 'xxf:autosize']
where support is implemented natively, vs. cases where support is implemented with XBL components?
Issue: autosize textarea should only apply to xs:string
type, so that it doesn't apply to the rich text area.
Current status: on local branch 2015-07-16-2298-2300-htmlfragment-etc
there is some work, including the change to possibleAppearancesWithBindings
. But we cannot push that change because otherwise the character-counter
appearance shows for too many controls, like date controls, etc.
And we cannot push the change to the selectors for fr|character-counter
, because we don't yet have a solution for the substitution.
Following discussion with @avernet today, it appears okay to have the XBL engine just erase the datatypes. If so:
<xf:input appearance="character-counter">
xf|input:xxf-type('xs:string')[appearance ~= character-counter]
selector in this caseThere can be problems, for example if we have, say, two bindings with selectors such as:
fr|foo
→ xf|input:xxf-type('xs:string')[appearance ~= gaga]
fr|bar
→ xf|input:xxf-type('xs:date')[appearance ~= gaga]
The erased selectors would be the same, so the runtime would just pick one.
We can issue a warning in such cases, and avoid writing selectors that conflict in this way until dynamic bindings are supported.
<xf:textarea>
Based on the last comment, it seems that this is close from being done, depending on how hard fixing "character counter appearance on rich text produces an <xf:textarea>
" is.
I think I am hitting an issue where adding xf|input:xxf-type('xf:email')[appearance ~= character-counter]
to fr|character-counter
shows the option in Form Builder, but setting it causes an error (which doesn't show in the logs for some reason).
Scenario:
fr:tinymce
fr|tinymce, xf|textarea:xxf-type('xf:HTMLFragment')
<bind type="xf:HTMLFragment"/>
I would like to see the "Character Counter" checkbox here.