Skip to content
Snippets Groups Projects
Commit 99f7674e authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

MAINT: Rename default person reference resolver

parent b00d01f5
Branches
Tags
1 merge request!69MAINT: Rename default person reference resolver
Pipeline #21010 passed
...@@ -59,7 +59,7 @@ BUILD_MODULE_USER_MANAGEMENT=ENABLED ...@@ -59,7 +59,7 @@ BUILD_MODULE_USER_MANAGEMENT=ENABLED
BUILD_MODULE_USER_MANAGEMENT_CHANGE_OWN_PASSWORD_REALM=CaosDB BUILD_MODULE_USER_MANAGEMENT_CHANGE_OWN_PASSWORD_REALM=CaosDB
BUILD_MODULE_EXT_RESOLVE_REFERENCES=ENABLED BUILD_MODULE_EXT_RESOLVE_REFERENCES=ENABLED
BUILD_EXT_REFERENCES_CUSTOM_RESOLVER=person_reference BUILD_EXT_REFERENCES_CUSTOM_RESOLVER=caosdb_default_person_reference
BUILD_MODULE_EXT_EDITMODE_WYSIWYG_TEXT=DISABLED BUILD_MODULE_EXT_EDITMODE_WYSIWYG_TEXT=DISABLED
......
...@@ -311,8 +311,8 @@ var resolve_references = new function () { ...@@ -311,8 +311,8 @@ var resolve_references = new function () {
* resolved as a string and returns a `reference_info` object with * resolved as a string and returns a `reference_info` object with
* the resolved custom reference as a `text` property. * the resolved custom reference as a `text` property.
* *
* See caosdb-webui/src/ext/js/person_reference_resolver.js for an * See caosdb-webui/src/ext/js/caosdb_default_person_reference_resolver.js
* example. * for an example.
* *
* TODO refactor to be configurable. @async @param {string} id - the id of * TODO refactor to be configurable. @async @param {string} id - the id of
* the entity which is to be resolved. @return {reference_info} * the entity which is to be resolved. @return {reference_info}
......
...@@ -32,7 +32,6 @@ the basic structure of the module should look like ...@@ -32,7 +32,6 @@ the basic structure of the module should look like
} }
An example is located in An example is located in
``caosdb-webui/src/ext/js/person_reference_resolver.js``. It resolves ``caosdb-webui/src/ext/js/caosdb_default_person_reference_resolver.js``. It
any reference to a ``Person`` Record to the value of its ``firstname`` resolves any reference to a ``Person`` Record to the value of its ``firstname``
and ``lastname`` properties separated by a space and is active by and ``lastname`` properties separated by a space and is active by default.
default.
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
/** /**
* @module person_reference * @module caosdb_default_person_reference
* *
* Replace the reference to a Person Record by the values of that * Replace the reference to a Person Record by the values of that
* Record's firstname and lastname properties. * Record's firstname and lastname properties.
...@@ -30,9 +30,9 @@ ...@@ -30,9 +30,9 @@
* TODO: Make name(s) of person RecordType(s) and names of firstname * TODO: Make name(s) of person RecordType(s) and names of firstname
* and lastname properties configurable. * and lastname properties configurable.
*/ */
var person_reference = new function () { var caosdb_default_person_reference = new function () {
var logger = log.getLogger("person_reference"); var logger = log.getLogger("caosdb_default_person_reference");
const lastname_prop_name = "lastname" const lastname_prop_name = "lastname"
const firstname_prop_name = "firstname" const firstname_prop_name = "firstname"
...@@ -42,24 +42,26 @@ var person_reference = new function () { ...@@ -42,24 +42,26 @@ var person_reference = new function () {
* Return the name of a person as firstname + lastname * Return the name of a person as firstname + lastname
*/ */
this.get_person_str = function (el) { this.get_person_str = function (el) {
var valpr = getProperties(el); var valpr = getProperties(el);
if (valpr == undefined) { if (valpr == undefined) {
return; return;
} }
return valpr.filter(valprel => return valpr.filter(valprel =>
valprel.name.toLowerCase().trim() == valprel.name.toLowerCase().trim() ==
firstname_prop_name.toLowerCase())[0].value + firstname_prop_name.toLowerCase())[0].value +
" " + " " +
valpr.filter(valprel => valprel.name.toLowerCase().trim() == valpr.filter(valprel => valprel.name.toLowerCase().trim() ==
lastname_prop_name.toLowerCase())[0].value; lastname_prop_name.toLowerCase())[0].value;
} }
this.resolve = async function (id) { this.resolve = async function (id) {
const entity = (await resolve_references.retrieve(id))[0]; const entity = (await resolve_references.retrieve(id))[0];
if (resolve_references.is_child(entity, person_rt_name)) { if (resolve_references.is_child(entity, person_rt_name)) {
return {"text": person_reference.get_person_str(entity)}; return {
} "text": caosdb_default_person_reference.get_person_str(entity)
};
}
} }
} }
...@@ -104,7 +104,7 @@ QUnit.test("is_child", function(assert){ ...@@ -104,7 +104,7 @@ QUnit.test("is_child", function(assert){
}); });
QUnit.test("get_person_str", function(assert){ QUnit.test("get_person_str", function(assert){
assert.ok(person_reference.get_person_str); assert.ok(caosdb_default_person_reference.get_person_str);
}); });
QUnit.test("update_visible_references_without_summary", async function(assert){ QUnit.test("update_visible_references_without_summary", async function(assert){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment