Skip to content
Snippets Groups Projects
Commit b5f5dbcd authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire: Committed by Reiter, Christoph
Browse files

Add entry-point-url attribute support

parent f152c82f
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,8 @@
- `lang` (optional, default: `de`): set to `de` or `en` for German or English
- example `<vpu-person-select lang="de"></vpu-person-select>`
- `entry-point-url` (optional, default is the TU Graz entry point url): entry point url to access the api
- example `<vpu-person-select entry-point-url="http://127.0.0.1:8000"></vpu-person-select>`
## Local development
......
......@@ -41,7 +41,7 @@ class PersonSelectDemo extends LitElement {
<div class="field">
<label class="label">Person</label>
<div class="control">
<vpu-person-select lang="${this.lang}"></vpu-person-select>
<vpu-person-select lang="${this.lang}" entry-point-url="${utils.getAPiUrl()}"></vpu-person-select>
</div>
</div>
</form>
......
......@@ -5,7 +5,7 @@ import select2LangDe from './i18n/de/select2'
import select2LangEn from './i18n/en/select2'
import JSONLD from 'vpu-common/jsonld';
import {html} from 'lit-element';
import {i18n, dateTimeFormat, numberFormat} from './i18n.js';
import {i18n} from './i18n.js';
import VPULitElementJQuery from 'vpu-common/vpu-lit-element-jquery';
select2(window, $);
......@@ -15,12 +15,14 @@ class PersonSelect extends VPULitElementJQuery {
constructor() {
super();
this.lang = 'de';
this.entryPointUrl = utils.getAPiUrl();
this.jsonld = null;
}
static get properties() {
return {
lang: { type: String },
entryPointUrl: { type: String, attribute: 'entry-point-url' },
};
}
......@@ -29,7 +31,7 @@ class PersonSelect extends VPULitElementJQuery {
const that = this;
this.updateComplete.then(()=>{
JSONLD.initialize(utils.getAPiUrl(), function (jsonld) {
JSONLD.initialize(this.entryPointUrl, function (jsonld) {
that.jsonld = jsonld;
const $select = that.initSelect2();
......@@ -63,6 +65,10 @@ class PersonSelect extends VPULitElementJQuery {
const $select = this.$('#person-select');
if ($select.hasClass('select2-hidden-accessible')) {
$select.select2('destroy');
}
$select.select2({
width: '100%',
language: this.lang === "de" ? select2LangDe() : select2LangEn(),
......@@ -126,7 +132,6 @@ class PersonSelect extends VPULitElementJQuery {
if ($select.length > 0) {
// no other way to set an other language at runtime did work
$select.select2('destroy');
this.initSelect2();
}
}
......
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