@digital-blueprint/sublibrary-app
Version:
[GitHub Repository](https://github.com/digital-blueprint/sublibrary-app) | [npmjs package](https://www.npmjs.com/package/@digital-blueprint/sublibrary-app) | [Unpkg CDN](https://unpkg.com/browse/@digital-blueprint/sublibrary-app/) | [Sublibrary Bundle](ht
30 lines (24 loc) • 868 B
JavaScript
import {PersonSelect} from "@dbp-toolkit/person-select";
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
export class CustomPersonSelect extends ScopedElementsMixin(PersonSelect) {
// Search for persons by name requesting local data attribute 'email'
buildUrlData(select, params) {
let term = params.term.trim();
let data = {};
data['includeLocal'] = 'email';
data['search'] = term;
return data;
}
// Includes the persons 'email' attribute if available
formatPerson(select, person) {
let text = person['givenName'] ?? '';
if (person['familyName']) {
text += ` ${person['familyName']}`;
}
let email = person.localData.email;
if (email !== null && email.length) {
text += ` (${email})`;
}
return text;
}
}