Skip to content
Snippets Groups Projects
Commit e6352489 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

Disable the selector in case the user isn't logged in

parent b9c6b1ce
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@
"mocha": "^6.2.0",
"node-sass": "^4.12.0",
"puppeteer": "^1.15.0",
"rollup": "^1.11.3",
"rollup": "^1.20.0",
"rollup-plugin-commonjs": "^10.0.2",
"rollup-plugin-copy": "^3.1.0",
"rollup-plugin-json": "^4.0.0",
......@@ -28,7 +28,7 @@
"dependencies": {
"jquery": "^3.4.1",
"lit-element": "^2.1.0",
"select2": "^4.0.7"
"select2": "^4.0.9"
},
"scripts": {
"clean": "rm dist/*",
......
{
"person-select": {
"placeholder": "Bitte wählen Sie eine Person aus",
"error-summary": "Ein Fehler ist aufgetreten"
"error-summary": "Ein Fehler ist aufgetreten",
"login-required": "Anmeldung erforderlich"
}
}
{
"person-select": {
"placeholder": "Please select a person",
"error-summary": "An error occurred"
"error-summary": "An error occurred",
"login-required": "Login required"
}
}
......@@ -34,7 +34,7 @@ class PersonSelectDemo extends LitElement {
<h1 class="title">Person-Select-Demo</h1>
</div>
<div class="container">
<vpu-auth lang="${this.lang}" client-id="${commonUtils.setting('keyCloakClientId')}" load-person force-login></vpu-auth>
<vpu-auth lang="${this.lang}" client-id="${commonUtils.setting('keyCloakClientId')}" load-person></vpu-auth>
</div>
<div class="container">
<form>
......
......@@ -21,6 +21,7 @@ class PersonSelect extends VPULitElementJQuery {
this.entryPointUrl = commonUtils.getAPiUrl();
this.jsonld = null;
this.$select = null;
this.active = false;
// For some reason using the same ID on the whole page twice breaks select2 (regardless if they are in different custom elements)
this.selectId = 'person-select-' + commonUtils.makeId(24);
}
......@@ -28,6 +29,7 @@ class PersonSelect extends VPULitElementJQuery {
static get properties() {
return {
lang: { type: String },
active: { type: Boolean, attribute: false },
entryPointUrl: { type: String, attribute: 'entry-point-url' },
};
}
......@@ -156,6 +158,7 @@ class PersonSelect extends VPULitElementJQuery {
JSONLD.initialize(this.entryPointUrl, function (jsonld) {
that.jsonld = jsonld;
that.active = true;
that.$select = that.initSelect2();
});
break;
......@@ -178,7 +181,7 @@ class PersonSelect extends VPULitElementJQuery {
</style>
<!-- https://select2.org-->
<select id="${this.selectId}" name="person" class="select"></select>
<select id="${this.selectId}" name="person" class="select" ?disabled=${!this.active}>${!this.active ? html`<option value="" disabled selected>${ i18n.t('person-select.login-required')}</option>` : ''}</select>
<div id="person-select-dropdown"></div>
`;
}
......
auth @ 31a528fe
Subproject commit 15f24eeb6873fa016b24cc2913073d613c3c4349
Subproject commit 31a528fe1a36c08c1f16d4998d193b5f5cb623b3
common @ 47aeef81
Subproject commit 8a80921c5f8ea2b0d1a0a548741d2ca1716a5139
Subproject commit 47aeef8162129cb7beab9ec1d1e1bf7bb9b2e578
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment