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

Integrate auth property into dbp-check-in-place-select

parent d542bb16
No related branches found
No related tags found
No related merge requests found
Pipeline #16446 passed
...@@ -32,6 +32,8 @@ npm i @dbp-toolkit/check-in-place-select ...@@ -32,6 +32,8 @@ npm i @dbp-toolkit/check-in-place-select
- example `<dbp-check-in-place-select show-reload-button></dbp-check-in-place-select>` - example `<dbp-check-in-place-select show-reload-button></dbp-check-in-place-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-check-in-place-select show-reload-button reload-button-text="Reload result list"></dbp-check-in-place-select>` - example `<dbp-check-in-place-select show-reload-button reload-button-text="Reload result list"></dbp-check-in-place-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
......
...@@ -8,6 +8,6 @@ ...@@ -8,6 +8,6 @@
<body> <body>
<dbp-check-in-place-select-demo lang="de" entry-point-url="http://127.0.0.1:8000"></dbp-check-in-place-select-demo> <dbp-check-in-place-select-demo lang="de" entry-point-url="http://127.0.0.1:8000" auth></dbp-check-in-place-select-demo>
</body> </body>
</html> </html>
...@@ -39,6 +39,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) { ...@@ -39,6 +39,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) {
this.showReloadButton = false; this.showReloadButton = false;
this.reloadButtonTitle = ''; this.reloadButtonTitle = '';
this.showCapacity = false; this.showCapacity = false;
this.auth = {};
this._onDocumentClicked = this._onDocumentClicked.bind(this); this._onDocumentClicked = this._onDocumentClicked.bind(this);
} }
...@@ -67,6 +68,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) { ...@@ -67,6 +68,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) {
showReloadButton: { type: Boolean, attribute: 'show-reload-button' }, showReloadButton: { type: Boolean, attribute: 'show-reload-button' },
reloadButtonTitle: { type: String, attribute: 'reload-button-title' }, reloadButtonTitle: { type: String, attribute: 'reload-button-title' },
showCapacity: { type: Boolean, attribute: 'show-capacity' }, showCapacity: { type: Boolean, attribute: 'show-capacity' },
auth: { type: Object },
}; };
} }
...@@ -163,7 +165,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) { ...@@ -163,7 +165,7 @@ export class CheckInPlaceSelect 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) {
...@@ -235,7 +237,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) { ...@@ -235,7 +237,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) {
fetch(apiUrl, { fetch(apiUrl, {
headers: { headers: {
'Content-Type': 'application/ld+json', 'Content-Type': 'application/ld+json',
'Authorization': 'Bearer ' + window.DBPAuthToken, 'Authorization': 'Bearer ' + this.auth.token,
}, },
}) })
.then(result => { .then(result => {
......
...@@ -75,13 +75,13 @@ export class CheckInPlaceSelectDemo extends ScopedElementsMixin(DBPLitElement) { ...@@ -75,13 +75,13 @@ export class CheckInPlaceSelectDemo extends ScopedElementsMixin(DBPLitElement) {
<div class="field"> <div class="field">
<label class="label">Check-In-Place 1</label> <label class="label">Check-In-Place 1</label>
<div class="control"> <div class="control">
<dbp-check-in-place-select lang="${this.lang}" entry-point-url="${this.entryPointUrl}"></dbp-check-in-place-select> <dbp-check-in-place-select lang="${this.lang}" entry-point-url="${this.entryPointUrl}" subscribe="auth:auth"></dbp-check-in-place-select>
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<label class="label">Check-In-Place 2</label> <label class="label">Check-In-Place 2</label>
<div class="control"> <div class="control">
<dbp-check-in-place-select lang="${this.lang}" entry-point-url="${this.entryPointUrl}" show-reload-button reload-button-title="Click me"></dbp-check-in-place-select> <dbp-check-in-place-select lang="${this.lang}" entry-point-url="${this.entryPointUrl}" subscribe="auth:auth" show-reload-button reload-button-title="Click me"></dbp-check-in-place-select>
</div> </div>
</div> </div>
</form> </form>
......
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