Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • advertisement
  • automagic
  • dbp-translation-component
  • demo
  • demo-file-handling
  • favorites-and-recent-files
  • icon-set-mapping
  • lit2
  • main
  • person-select-custom
  • port-i18next-parser
  • publish
  • remove-sentry
  • renovate/lock-file-maintenance
  • revert-6c632dc6
  • wc-part
  • wip-cleanup
17 results

Target

Select target project
  • 987FCF504483CBC8/toolkit
1 result
Select Git revision
  • advertisement
  • automagic
  • dbp-translation-component
  • demo
  • demo-file-handling
  • favorites-and-recent-files
  • icon-set-mapping
  • lit2
  • main
  • person-select-custom
  • port-i18next-parser
  • publish
  • remove-sentry
  • renovate/lock-file-maintenance
  • revert-6c632dc6
  • wc-part
  • wip-cleanup
17 results
Show changes
Commits on Source (10)
...@@ -73,7 +73,7 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -73,7 +73,7 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
this.boundCloseMenuHandler = this.hideMenu.bind(this); this.boundCloseMenuHandler = this.hideMenu.bind(this);
this.initateOpenMenu = false; this.initateOpenMenu = false;
this.auth = {}; this.auth = null;
this.langDir = ''; this.langDir = '';
} }
...@@ -332,6 +332,11 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -332,6 +332,11 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
break; break;
case 'auth': case 'auth':
{ {
// kill event if auth gets default
if (this.auth === null) {
break;
}
if (this.auth.person) { if (this.auth.person) {
this._roles = this.auth.person['roles']; this._roles = this.auth.person['roles'];
} else { } else {
...@@ -340,11 +345,14 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -340,11 +345,14 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
this._updateVisibleRoutes(); this._updateVisibleRoutes();
const loginStatus = this.auth['login-status']; const loginStatus = this.auth['login-status'];
if (loginStatus !== this._loginStatus) { if (loginStatus !== this._loginStatus) {
console.log('Login status: ' + loginStatus); console.log('Login status: ' + loginStatus);
} }
this._loginStatus = loginStatus; if (loginStatus !== undefined) {
this._loginStatus = loginStatus;
}
// Clear the session storage when the user logs out // Clear the session storage when the user logs out
if (this._loginStatus === 'logging-out') { if (this._loginStatus === 'logging-out') {
...@@ -943,13 +951,9 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) { ...@@ -943,13 +951,9 @@ export class AppShell extends ScopedElementsMixin(DBPLitElement) {
// if app is loaded correctly, remove spinner // if app is loaded correctly, remove spinner
this.updateComplete.then(() => { this.updateComplete.then(() => {
const slot = this.shadowRoot.querySelector('slot:not([name])'); const slot = this.shadowRoot.querySelector('slot:not([name])');
if (slot) slot.style.display = 'none';
}); // remove for safari 12 support. safari 13+ supports display: none on slots.
} else { if (slot) slot.remove();
// if app is not loaded correctly, show spinner
this.updateComplete.then(() => {
const slot = this.shadowRoot.querySelector('slot:not([name])');
if (slot) slot.style.display = '';
}); });
} }
......
...@@ -44,6 +44,13 @@ Or directly via CDN: ...@@ -44,6 +44,13 @@ Or directly via CDN:
- example auth property: `{token: "THE_BEARER_TOKEN"}` - example auth property: `{token: "THE_BEARER_TOKEN"}`
- note: most often this should be an attribute that is not set directly, but subscribed at a provider - note: most often this should be an attribute that is not set directly, but subscribed at a provider
## Override Properties
- `buildUrlData` - A function which gets passed the select and the current search context and
should return the query parameters used for searching.
- `formatPerson` - A function which takes the select and a person object and should
return the text representation displayed to the user.
## Local development ## Local development
```bash ```bash
......
<html>
<body>
<script>
parent.postMessage(location.href, location.origin)
</script>
</body>
</html>
\ No newline at end of file
...@@ -48,6 +48,7 @@ export default (async () => { ...@@ -48,6 +48,7 @@ export default (async () => {
build !== 'local' && build !== 'test' ? terser() : false, build !== 'local' && build !== 'test' ? terser() : false,
copy({ copy({
targets: [ targets: [
{src: 'assets/silent-check-sso.html', dest: 'dist'},
{src: 'assets/index.html', dest: 'dist'}, {src: 'assets/index.html', dest: 'dist'},
{ {
src: await getPackagePath('@dbp-toolkit/common', 'assets/icons/*.svg'), src: await getPackagePath('@dbp-toolkit/common', 'assets/icons/*.svg'),
......
...@@ -67,7 +67,7 @@ export class PersonSelectDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -67,7 +67,7 @@ export class PersonSelectDemo extends ScopedElementsMixin(DBPLitElement) {
subscribe="requested-login-status" subscribe="requested-login-status"
lang="${this.lang}" lang="${this.lang}"
entry-point-url="${this.entryPointUrl}" entry-point-url="${this.entryPointUrl}"
silent-check-sso-redirect-uri="/dist/silent-check-sso.html" silent-check-sso-redirect-uri="/silent-check-sso.html"
url="https://auth-dev.tugraz.at/auth" url="https://auth-dev.tugraz.at/auth"
realm="tugraz-vpu" realm="tugraz-vpu"
client-id="auth-dev-mw-frontend-local" client-id="auth-dev-mw-frontend-local"
......
...@@ -14,15 +14,6 @@ import select2CSSPath from 'select2/dist/css/select2.min.css'; ...@@ -14,15 +14,6 @@ import select2CSSPath from 'select2/dist/css/select2.min.css';
import * as errorUtils from '@dbp-toolkit/common/error'; import * as errorUtils from '@dbp-toolkit/common/error';
import {AdapterLitElement} from '@dbp-toolkit/common'; import {AdapterLitElement} from '@dbp-toolkit/common';
const personContext = {
'@id': '@id',
givenName: 'http://schema.org/givenName',
familyName: 'http://schema.org/familyName',
email: 'http://schema.org/email',
};
select2(window, $);
export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) { export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
constructor() { constructor() {
super(); super();
...@@ -46,6 +37,8 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) { ...@@ -46,6 +37,8 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
this.showDetails = false; this.showDetails = false;
this._onDocumentClicked = this._onDocumentClicked.bind(this); this._onDocumentClicked = this._onDocumentClicked.bind(this);
select2(window, $);
} }
static get scopedElements() { static get scopedElements() {
...@@ -178,21 +171,19 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) { ...@@ -178,21 +171,19 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
jqXHR.setRequestHeader('Authorization', 'Bearer ' + that.auth.token); jqXHR.setRequestHeader('Authorization', 'Bearer ' + that.auth.token);
that.isSearching = true; that.isSearching = true;
}, },
data: function (params) { data: (params) => {
return { return this.buildUrlData(this, params);
search: params.term.trim(),
};
}, },
processResults: function (data) { processResults: function (data) {
that.$('#person-select-dropdown').addClass('select2-bug'); that.$('#person-select-dropdown').addClass('select2-bug');
that.lastResult = data; that.lastResult = data;
let transformed = that.jsonld.transformMembers(data, personContext); let members = data['hydra:member'];
const results = []; const results = [];
transformed.forEach((person) => { members.forEach((person) => {
results.push({ results.push({
id: person['@id'], id: person['@id'],
text: that.generateOptionText(person), text: that.formatPerson(that, person),
}); });
}); });
...@@ -260,14 +251,10 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) { ...@@ -260,14 +251,10 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
}) })
.then((person) => { .then((person) => {
that.object = person; that.object = person;
const transformed = that.jsonld.compactMember( const identifier = person['@id'];
that.jsonld.expandMember(person),
personContext
);
const identifier = transformed['@id'];
const option = new Option( const option = new Option(
that.generateOptionText(transformed), that.formatPerson(this, person),
identifier, identifier,
true, true,
true true
...@@ -295,7 +282,29 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) { ...@@ -295,7 +282,29 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
return true; return true;
} }
generateOptionText(person) { /**
* Gets passed the select2 params (https://select2.org/data-sources/ajax#jquery-ajax-options)
* and should return an object containing the query parameters send to the server.
*
* @param {object} select
* @param {object} params
* @returns {object}
*/
buildUrlData(select, params) {
return {
search: params.term.trim(),
};
}
/**
* Gets passed a person object and should return a string representation that will
* will be shown to the user.
*
* @param {object} select
* @param {object} person
* @returns {string}
*/
formatPerson(select, person) {
let text = person['givenName'] ?? ''; let text = person['givenName'] ?? '';
if (person['familyName']) { if (person['familyName']) {
text += ` ${person['familyName']}`; text += ` ${person['familyName']}`;
......
...@@ -4184,9 +4184,9 @@ escape-string-regexp@^1.0.5: ...@@ -4184,9 +4184,9 @@ escape-string-regexp@^1.0.5:
integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==
eslint-plugin-jsdoc@^39.0.0: eslint-plugin-jsdoc@^39.0.0:
version "39.7.0" version "39.7.4"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-39.7.0.tgz#887c8996fcad5c9d2ac7835018f81278706464e5" resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-39.7.4.tgz#fec1b5a3cfcbb706980e98e0dbb60ae1f31777d7"
integrity sha512-4gWAJABzWzfu/LBNLo5cdZph8Ce8QY/Og3FvzU2TsBz50hDB3gBlMJulrmFvPHFXnSxmB6mzMf3dpi4yxdFKfQ== integrity sha512-2eJcWGKRyNQFa37UIpGcAdOp3wtES8vV3mlnFmEmJCuBNyFhK6cMhbZgMkLoLjKnipoxsN9GbfZZ+8nPY8ETZQ==
dependencies: dependencies:
"@es-joy/jsdoccomment" "~0.36.1" "@es-joy/jsdoccomment" "~0.36.1"
comment-parser "1.3.1" comment-parser "1.3.1"
......