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 @@ ...@@ -12,7 +12,7 @@
"mocha": "^6.2.0", "mocha": "^6.2.0",
"node-sass": "^4.12.0", "node-sass": "^4.12.0",
"puppeteer": "^1.15.0", "puppeteer": "^1.15.0",
"rollup": "^1.11.3", "rollup": "^1.20.0",
"rollup-plugin-commonjs": "^10.0.2", "rollup-plugin-commonjs": "^10.0.2",
"rollup-plugin-copy": "^3.1.0", "rollup-plugin-copy": "^3.1.0",
"rollup-plugin-json": "^4.0.0", "rollup-plugin-json": "^4.0.0",
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
"dependencies": { "dependencies": {
"jquery": "^3.4.1", "jquery": "^3.4.1",
"lit-element": "^2.1.0", "lit-element": "^2.1.0",
"select2": "^4.0.7" "select2": "^4.0.9"
}, },
"scripts": { "scripts": {
"clean": "rm dist/*", "clean": "rm dist/*",
......
{ {
"person-select": { "person-select": {
"placeholder": "Bitte wählen Sie eine Person aus", "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": { "person-select": {
"placeholder": "Please select a person", "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 { ...@@ -34,7 +34,7 @@ class PersonSelectDemo extends LitElement {
<h1 class="title">Person-Select-Demo</h1> <h1 class="title">Person-Select-Demo</h1>
</div> </div>
<div class="container"> <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>
<div class="container"> <div class="container">
<form> <form>
......
...@@ -21,6 +21,7 @@ class PersonSelect extends VPULitElementJQuery { ...@@ -21,6 +21,7 @@ class PersonSelect extends VPULitElementJQuery {
this.entryPointUrl = commonUtils.getAPiUrl(); this.entryPointUrl = commonUtils.getAPiUrl();
this.jsonld = null; this.jsonld = null;
this.$select = 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) // 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); this.selectId = 'person-select-' + commonUtils.makeId(24);
} }
...@@ -28,6 +29,7 @@ class PersonSelect extends VPULitElementJQuery { ...@@ -28,6 +29,7 @@ class PersonSelect extends VPULitElementJQuery {
static get properties() { static get properties() {
return { return {
lang: { type: String }, lang: { type: String },
active: { type: Boolean, attribute: false },
entryPointUrl: { type: String, attribute: 'entry-point-url' }, entryPointUrl: { type: String, attribute: 'entry-point-url' },
}; };
} }
...@@ -156,6 +158,7 @@ class PersonSelect extends VPULitElementJQuery { ...@@ -156,6 +158,7 @@ class PersonSelect extends VPULitElementJQuery {
JSONLD.initialize(this.entryPointUrl, function (jsonld) { JSONLD.initialize(this.entryPointUrl, function (jsonld) {
that.jsonld = jsonld; that.jsonld = jsonld;
that.active = true;
that.$select = that.initSelect2(); that.$select = that.initSelect2();
}); });
break; break;
...@@ -178,7 +181,7 @@ class PersonSelect extends VPULitElementJQuery { ...@@ -178,7 +181,7 @@ class PersonSelect extends VPULitElementJQuery {
</style> </style>
<!-- https://select2.org--> <!-- 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> <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.
Finish editing this message first!
Please register or to comment