Given a Document class, a mono-valued Property of the Entry Template is associated with a ChoiceList. This works well if the ChoiceList has no "sublevels" (Choice).
When a Group Choice is added and the user tries to fill the property, the dialog becomes ugly, as well as displayed below:
Is there a way to automatically unfold the tree view for the root Choices, and moreover to remove the "none" label ("Aucun" in french) as well as the symbolic name of the ChoiceList (blurred here)?
Do I have to write a Plugin to fix the issue?
Update. The purpose of "Aucun" here is to empty the field.
I contacted the support team, and in a few words, it's not possible "out of the box". But I found a workaround.
I wrote a ResponseFilter which catches the response of the request /p8/openContentClass
. Turns out its response contains the ChoiceList values:
{
"classes": [{
"parentClassId": "<PARENTCLASSID>",
"template_name": "<ENTRYTEMPLATE>",
/* [...] */
}
],
/* [...] */
"criterias": [/* [...] */, {
"settability": "readWrite",
"defaultOperator": "EQUAL",
"minValue": null,
"uniqueValues": true,
"orderable": false,
"choiceList": {
"choices": /* <----- here */,
"displayName": "CL_ToFilter"
},
/* [...] */
"name": "<propertyName>"
}
]
}
Reformatting "choices"
entry to get a one-level Choice List ensure a display on one level. Below the relevant code of the ResponseFilter
:
public class ChoiceListValuesResponseFilter extends PluginResponseFilter {
public String[] getFilteredServices() {
return new String[] { "/p8/openContentClass"/* "/p8/openItem"*/ };
}
public void filter(String serverType, PluginServiceCallbacks callbacks,
HttpServletRequest request, JSONObject jsonResponse) throws Exception {
// [...]
JSONArray jsonProperties =
(JSONArray) jsonResponse.get("criterias");
Iterator it = jsonProperties.iterator();
while (it.hasNext()) {
JSONObject jo = (JSONObject) it.next();
if ("<PROPERTYWITHFILTEREDCL>".equals(jo.get("name"))) {
JSONObject choiceListJo = (JSONObject) jo.get("choiceList");
// do the processing here
break;
}
}
}
// [...]
}