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

Add context attribute to organization select

parent e4b0c78c
No related branches found
No related tags found
No related merge requests found
Pipeline #18227 passed
......@@ -22,6 +22,10 @@ npm i @dbp-toolkit/organization-select
- `value` (optional): api path of organization to preload the selector with
- example `<dbp-organization-select value="/people/testuser"></dbp-organization-select>`
- the `value` will also be set automatically when an organization is chosen in the selector
- `context` (optional): the context of the returned organizations
- example `<dbp-organization-select context="libray-manager"></dbp-organization-select>` returns all organizations
where the current user is library manager
- if no `context` is set all organizations are returned that are in a relation with the current user
- `data-object` (read-only): when an organization is selected the organization object will be set as json string
- example `<dbp-organization-select data-object="{"@id":"/organizations/1190-F2050","@type":"http://schema.org/Organization","identifier":"1190-F2050","name":"Institut für Stahlbau","url":"https://online.tugraz.at/tug_online/wborg.display?pOrgNr=1190","alternateName":"F2050"}"></dbp-organization-select>`
- `auth` object: you need to set that object property for the auth token
......
......@@ -81,7 +81,7 @@ export class OrganizationSelectDemo extends ScopedElementsMixin(DBPLitElement) {
<div class="field">
<label class="label">Organization 2</label>
<div class="control">
<dbp-organization-select subscribe="auth" lang="${this.lang}" entry-point-url="${this.entryPointUrl}"></dbp-organization-select>
<dbp-organization-select subscribe="auth" lang="${this.lang}" entry-point-url="${this.entryPointUrl}" context="test"></dbp-organization-select>
</div>
</div>
</form>
......
......@@ -24,6 +24,7 @@ export class OrganizationSelect extends AdapterLitElement {
this.selectId = 'select-organization-' + commonUtils.makeId(24);
this.cache = {};
this.value = '';
this.context = '';
}
static get properties() {
......@@ -32,6 +33,7 @@ export class OrganizationSelect extends AdapterLitElement {
lang: {type: String},
entryPointUrl: { type: String, attribute: 'entry-point-url' },
value: {type: String, reflect: true},
context: {type: String},
auth: { type: Object },
};
}
......@@ -186,6 +188,11 @@ export class OrganizationSelect extends AdapterLitElement {
this.fireEvent();
break;
}
case "context": {
delete this.cache[this.lang];
this.updateSelect2();
break;
}
case "entryPointUrl":
JSONLD.initialize(this.entryPointUrl, (jsonld) => {
this.jsonld = jsonld;
......@@ -227,7 +234,7 @@ export class OrganizationSelect extends AdapterLitElement {
let orgUrl = this.entryPointUrl + '/people/' +
encodeURIComponent(this.auth.person.identifier) +
'/organizations' +
'?context=' + encodeURIComponent('library-manager') +
'?context=' + encodeURIComponent(this.context) +
'&lang=' + encodeURIComponent(this.lang);
let response = await fetch(orgUrl, {
......
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