0

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:

Entry Template monovalued Property Control

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.

5
  • Running 3.0.3. i was unable to get the dialog you print-screened; Using P8 i created a document class, property and added a choicelist with groups/items. Then i created an entrytemplate; instead of the popup i get a drop-down where only the values are rendered, and not the groups. Either my reproduction is wrong, or an upgrade to 3.0.3 might be your solution?
    – Ivo Jonker
    Commented Jul 20, 2018 at 7:27
  • Thanks. Did you set the property as mono-valued ?
    – Amessihel
    Commented Jul 20, 2018 at 21:37
  • I've just checked the version (back to work), we run also ICN 3.0.3.
    – Amessihel
    Commented Jul 24, 2018 at 9:09
  • I indeed did set the property as single value in P8. Any remarks on the reproduction i qouted?
    – Ivo Jonker
    Commented Aug 22, 2018 at 11:46
  • I followed the steps of the reproduction you quoted, I got the same issue. The editor sent me an aswer I'll quote below.
    – Amessihel
    Commented Aug 28, 2018 at 16:52

1 Answer 1

0

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;
             }
         }
     }
    // [...]
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.