From 7dd236d5fa01ca24f903b8b5c6e4bbfbe64c678a Mon Sep 17 00:00:00 2001
From: Patrizio Bekerle <patrizio.bekerle@tugraz.at>
Date: Tue, 30 Jul 2019 09:21:29 +0200
Subject: [PATCH] Add language support to the api request

---
 .../index.html                                    |  2 +-
 .../vpu-kb-wpe-view-demo.js                       | 15 ++++++++++-----
 .../vpu-kb-wpe-view.js                            |  3 ++-
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/packages/knowledge-base-web-page-element-view/index.html b/packages/knowledge-base-web-page-element-view/index.html
index e34fadd6..ec599a39 100644
--- a/packages/knowledge-base-web-page-element-view/index.html
+++ b/packages/knowledge-base-web-page-element-view/index.html
@@ -8,7 +8,7 @@
 
 <body>
 
-<vpu-knowledge-base-web-page-element-view-demo lang="de"></vpu-knowledge-base-web-page-element-view-demo>
+<vpu-knowledge-base-web-page-element-view-demo></vpu-knowledge-base-web-page-element-view-demo>
 
 </body>
 </html>
diff --git a/packages/knowledge-base-web-page-element-view/vpu-kb-wpe-view-demo.js b/packages/knowledge-base-web-page-element-view/vpu-kb-wpe-view-demo.js
index cc83b461..f1544a55 100644
--- a/packages/knowledge-base-web-page-element-view/vpu-kb-wpe-view-demo.js
+++ b/packages/knowledge-base-web-page-element-view/vpu-kb-wpe-view-demo.js
@@ -29,14 +29,19 @@ class KnowledgeBaseWebPageElementViewDemo extends LitElement {
             <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.5/css/bulma.min.css">
 
             <section class="section">
-                <div class="container">
+                <div class="content">
                     <h1 class="title">KnowledgeBaseWebPageElementView-Demo</h1>
                 </div>
-                <div class="container">
-                    <vpu-auth lang="${this.lang}" client-id="${utils.setting('keyCloakClientId')}" load-person force-login></vpu-auth>
+                <div class="content">
+                    <vpu-auth lang="de" client-id="${utils.setting('keyCloakClientId')}" load-person force-login></vpu-auth>
                 </div>
-                <div class="container">
-                    <vpu-knowledge-base-web-page-element-view lang="${this.lang}" value="bedienstete/bibliothek/buch-ausleihen"></vpu-knowledge-base-web-page-element-view>
+                <div class="content">
+                    <h2 class="subtitle">Deutsch</h2>
+                    <vpu-knowledge-base-web-page-element-view lang="de" value="bedienstete/bibliothek/buch-ausleihen"></vpu-knowledge-base-web-page-element-view>
+                </div>
+                <div class="content">
+                    <h2 class="subtitle">Englisch</h2>
+                    <vpu-knowledge-base-web-page-element-view lang="en" value="bedienstete/bibliothek/buch-ausleihen"></vpu-knowledge-base-web-page-element-view>
                 </div>
             </section>
         `;
diff --git a/packages/knowledge-base-web-page-element-view/vpu-kb-wpe-view.js b/packages/knowledge-base-web-page-element-view/vpu-kb-wpe-view.js
index 6e7bfda7..7f4bccc1 100644
--- a/packages/knowledge-base-web-page-element-view/vpu-kb-wpe-view.js
+++ b/packages/knowledge-base-web-page-element-view/vpu-kb-wpe-view.js
@@ -39,7 +39,8 @@ class VPUKnowledgeBaseWebPageElementView extends VPULitElement {
 
         // sadly there there is no entity url without "collectionOperations" in entity KnowledgeBaseWebPageElement!
         const apiUrl = utils.getAPiUrl("/web_page_elements/knowledge_base_web_page_elements/") +
-            encodeURIComponent(commonUtils.base64EncodeUnicode(encodeURIComponent(that.value)));
+            encodeURIComponent(commonUtils.base64EncodeUnicode(encodeURIComponent(that.value))) +
+            "?lang=" + encodeURIComponent(that.lang);
 
         window.addEventListener("vpu-auth-init", function(e)
         {
-- 
GitLab