Skip to content
Snippets Groups Projects
Commit 98e9b2b0 authored by florian's avatar florian
Browse files

DOC: Add explanation on customizing the resolving of references

parent 9756f8ba
No related branches found
No related tags found
2 merge requests!47Release v0.4.0,!41Document reference resolver and move person resolving to separate example
Pipeline #13516 passed
...@@ -26,3 +26,4 @@ xerr.log ...@@ -26,3 +26,4 @@ xerr.log
conf/ext conf/ext
test/ext test/ext
src/ext src/ext
*~
Customizing the display of referenced entities
=============================================
CaosDB WebUI supports the customized display of referenced entities
using the :doc:`ext_references <../api/module-resolve_references>`
module. The ``BUILD_MODULE_EXT_RESOLVE_REFERENCES`` build variable has
to be set to ``ENABLED`` (see :doc:`/getting_started`) in order to use
this module.
You may then define your own JavaScript module to define how
references to specific Records should be resolved. The module has to
be located at a directory which is known to CaosDB WebUI; we recommend
``caosdb-webui/src/ext/js``. Set the value of the
``BUILD_EXT_REFERENCES_CUSTOM_RESOLVER`` build variable to the name of
this module. The module has to have a ``resolve`` function which takes
an entity id as its only parameter and returns a ``reference_info``
object with the resolved custom reference as a ``text`` property. So
the basic structure of the module should look like
.. code-block:: javascript
var my_reference_resolver = new function () {
// Has to be called ``resolve`` and has to take exactly one
// string parameter: the id of the referenced entity.
this.resolve = async function (id) {
/*
* find the string that the reference should be resolved to,
* e.g., from the value of the entity's properties.
*/
return {"text": new_reference_text}
}
}
An example is located in
``caosdb-webui/src/ext/js/person_reference_resolver.js``. It resolves
any reference to a ``Person`` Record to the value of its ``firstname``
and ``lastname`` properties separated by a space and is active by
default.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment