Skip to content
Snippets Groups Projects
Unverified Commit 874c73cf authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire:
Browse files

Integrate auth property into dbp-person-select

parent f32534b4
No related branches found
No related tags found
No related merge requests found
Pipeline #16458 passed
...@@ -33,6 +33,8 @@ npm i @dbp-toolkit/person-select ...@@ -33,6 +33,8 @@ npm i @dbp-toolkit/person-select
- example `<dbp-person-select show-reload-button></dbp-person-select>` - example `<dbp-person-select show-reload-button></dbp-person-select>`
- `reload-button-title` (optional): sets a title text on the reload button - `reload-button-title` (optional): sets a title text on the reload button
- example `<dbp-person-select show-reload-button reload-button-text="Reload result list"></dbp-person-select>` - example `<dbp-person-select show-reload-button reload-button-text="Reload result list"></dbp-person-select>`
- `auth` object: you need to set that object property for the auth token
- example auth property: `{token: "THE_BEARER_TOKEN"}`
## Local development ## Local development
......
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
<body> <body>
<dbp-person-select-demo lang="de" entry-point-url="http://127.0.0.1:8000"></dbp-person-select-demo> <dbp-person-select-demo auth lang="de" entry-point-url="http://127.0.0.1:8000"></dbp-person-select-demo>
</body> </body>
</html> </html>
...@@ -75,13 +75,13 @@ export class PersonSelectDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -75,13 +75,13 @@ export class PersonSelectDemo extends ScopedElementsMixin(DBPLitElement) {
<div class="field"> <div class="field">
<label class="label">Person 1</label> <label class="label">Person 1</label>
<div class="control"> <div class="control">
<dbp-person-select lang="${this.lang}" entry-point-url="${this.entryPointUrl}"></dbp-person-select> <dbp-person-select subscribe="auth:auth" lang="${this.lang}" entry-point-url="${this.entryPointUrl}"></dbp-person-select>
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<label class="label">Person 2</label> <label class="label">Person 2</label>
<div class="control"> <div class="control">
<dbp-person-select lang="${this.lang}" entry-point-url="${this.entryPointUrl}" show-reload-button reload-button-title="Click me"></dbp-person-select> <dbp-person-select subscribe="auth:auth" lang="${this.lang}" entry-point-url="${this.entryPointUrl}" show-reload-button reload-button-title="Click me"></dbp-person-select>
</div> </div>
</div> </div>
</form> </form>
......
...@@ -156,7 +156,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) { ...@@ -156,7 +156,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
url: apiUrl, url: apiUrl,
contentType: "application/ld+json", contentType: "application/ld+json",
beforeSend: function (jqXHR) { beforeSend: function (jqXHR) {
jqXHR.setRequestHeader('Authorization', 'Bearer ' + window.DBPAuthToken); jqXHR.setRequestHeader('Authorization', 'Bearer ' + that.auth.token);
that.isSearching = true; that.isSearching = true;
}, },
data: function (params) { data: function (params) {
...@@ -223,7 +223,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) { ...@@ -223,7 +223,7 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
fetch(apiUrl, { fetch(apiUrl, {
headers: { headers: {
'Content-Type': 'application/ld+json', 'Content-Type': 'application/ld+json',
'Authorization': 'Bearer ' + this.auth.token || window.DBPAuthToken, 'Authorization': 'Bearer ' + this.auth.token,
}, },
}) })
.then(result => { .then(result => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment