diff --git a/packages/check-in-place-select/README.md b/packages/check-in-place-select/README.md index b1ba6574f8ad04b37749fb6fbe130f4739351e53..65a933009e8ed49e7121176889163fe76fe57e3e 100644 --- a/packages/check-in-place-select/README.md +++ b/packages/check-in-place-select/README.md @@ -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>` - `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>` +- `auth` object: you need to set that object property for the auth token + - example auth property: `{token: "THE_BEARER_TOKEN"}` ## Local development diff --git a/packages/check-in-place-select/assets/index.html b/packages/check-in-place-select/assets/index.html index 14fc87c6d938c0aac5104613ed126a3222d6d0d4..7aff3df6307822a46d91b174106dc17864408c22 100644 --- a/packages/check-in-place-select/assets/index.html +++ b/packages/check-in-place-select/assets/index.html @@ -8,6 +8,6 @@ <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> </html> diff --git a/packages/check-in-place-select/src/check-in-place-select.js b/packages/check-in-place-select/src/check-in-place-select.js index 27a84b80a001a0142b1c9196ad1b9aa7fd6ed0f2..9cff78324e49102ebf1ac993e86432cfe2e77bc8 100644 --- a/packages/check-in-place-select/src/check-in-place-select.js +++ b/packages/check-in-place-select/src/check-in-place-select.js @@ -39,6 +39,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) { this.showReloadButton = false; this.reloadButtonTitle = ''; this.showCapacity = false; + this.auth = {}; this._onDocumentClicked = this._onDocumentClicked.bind(this); } @@ -67,6 +68,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) { showReloadButton: { type: Boolean, attribute: 'show-reload-button' }, reloadButtonTitle: { type: String, attribute: 'reload-button-title' }, showCapacity: { type: Boolean, attribute: 'show-capacity' }, + auth: { type: Object }, }; } @@ -163,7 +165,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) { url: apiUrl, contentType: "application/ld+json", beforeSend: function (jqXHR) { - jqXHR.setRequestHeader('Authorization', 'Bearer ' + window.DBPAuthToken); + jqXHR.setRequestHeader('Authorization', 'Bearer ' + that.auth.token); that.isSearching = true; }, data: function (params) { @@ -235,7 +237,7 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(AdapterLitElement) { fetch(apiUrl, { headers: { 'Content-Type': 'application/ld+json', - 'Authorization': 'Bearer ' + window.DBPAuthToken, + 'Authorization': 'Bearer ' + this.auth.token, }, }) .then(result => { diff --git a/packages/check-in-place-select/src/dbp-check-in-place-select-demo.js b/packages/check-in-place-select/src/dbp-check-in-place-select-demo.js index 46002a3f6cd807e1bcb8805baa03465b65dc3df7..f4e58324a25fd3e16c5f34519dbccc0d44baa3e3 100644 --- a/packages/check-in-place-select/src/dbp-check-in-place-select-demo.js +++ b/packages/check-in-place-select/src/dbp-check-in-place-select-demo.js @@ -75,13 +75,13 @@ export class CheckInPlaceSelectDemo extends ScopedElementsMixin(DBPLitElement) { <div class="field"> <label class="label">Check-In-Place 1</label> <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 class="field"> <label class="label">Check-In-Place 2</label> <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> </form>