Directory suggestion widget in user edit layout won't show label

Hello community,

I overrode the default user schema to add new columns, one of them is a custom vocabulary. It saves and edits no problem, however, whenever one opens the edit dialog, the label for the selected vocabulary is missing, only showing the numerical id of the item, i.e: The selected item is missing the label

That only happens the first time, as after editing the item, it will correctly show the label, or unless the page is reloaded. How do I solve this?

This is the xml contribution that adds the vocabulary:

<?xml version="1.0"?>
<component name="mx.gob.ssa.directory.vocabularies">
    <extension target="org.nuxeo.ecm.directory.GenericDirectory" point="directories">
        <directory name="VOC_honorifico" extends="template-xvocabulary">
            <autoincrementIdField>false</autoincrementIdField>
            <createTablePolicy>on_missing_columns</createTablePolicy>
            <table>ssa_VOC_honorifico</table>
            <dataFile>vocabularies/VOC_honorifico.csv</dataFile>
            <cacheEntryName>vocab-VOC_honorifico-cache</cacheEntryName>
            <cacheEntryWithoutReferencesName>vocab-VOC_honorifico-cache-without-references</cacheEntryWithoutReferencesName>
        </directory>
    </extension>
    <extension target="org.nuxeo.ecm.core.cache.CacheService" point="caches">
        <cache name="vocab-VOC_honorifico-cache">
            <option name="maxSize">1000</option>
            <option name="concurrencyLevel">500</option>
            <ttl>60</ttl>
        </cache>
        <cache name="vocab-VOC_honorifico-cache-without-references">
            <option name="maxSize">1000</option>
            <option name="concurrencyLevel">500</option>
            <ttl>60</ttl>
        </cache>
    </extension>
</component>

The custom vocabulary is loaded to storage using a csv file that has the fields : “id”,“label”,“obsolete”,“ordering”.

This is the user schema extension that overrides the default user schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.nuxeo.org/ecm/schemas/user"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:nxs="http://www.nuxeo.org/ecm/schemas/user"
           xmlns:ref="http://www.nuxeo.org/ecm/schemas/core/external-references/">

<xs:include schemaLocation="base.xsd" />

<xs:element name="username" type="xs:string" />
<xs:element name="password" type="xs:string" />
<xs:element name="firstName" type="xs:string" />
<xs:element name="lastName" type="xs:string" />
<xs:element name="company" type="xs:string" />

<!-- the new field for the custom vocabulary -->
<xs:element name="honorifico">
    <xs:simpleType>
        <xs:restriction base="xs:string" ref:resolver="directoryResolver" ref:directory="VOC_honorifico"/>
    </xs:simpleType>
</xs:element>

<xs:element name="email">
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <!-- the same pattern is used in userinfo.xsd -->
            <xs:pattern value="[^@]+@[^\.]+\..+" />
        </xs:restriction>
    </xs:simpleType>
</xs:element>

<!-- inverse reference -->
<xs:element name="groups" type="nxs:stringList" />

<!-- tenant id for the user -->
<xs:element name="tenantId" type="xs:string" />

</xs:schema>

And finally, this is the widget used at the edit user layout:

<nuxeo-directory-suggestion
      role="widget"
      value="{{user.honorifico}}"
      label="Título"
      directory-name="VOC_honorifico"
      operation="Directory.SuggestEntries"
      min-chars="0">
</nuxeo-directory-suggestion>
0 votes

1 answers

1257 views

ANSWER



After some research, I found out that the requests use enrichers to get additonal information. Since the only user enricher available is the userProfile, I wrote a custom enricher that finds the custom vocabulary object by id; also I had to customize the user management views to add this custom enricher to the user request (), handle the value changes and the submition of the user form.

0 votes