From 7bf5d4c504cf8e80cd26628cc85c657f5e0dff54 Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle <patrizio@bekerle.com> Date: Tue, 22 Jun 2021 10:44:46 +0200 Subject: [PATCH] Allow globally overriding slots in the light dom of components and use it to override the auth-info slot in the Nextcloud file picker --- assets/dbp-signature.html.ejs | 37 +++++++++++++++-------------------- vendor/toolkit | 2 +- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/assets/dbp-signature.html.ejs b/assets/dbp-signature.html.ejs index bcae50d..70d8a53 100644 --- a/assets/dbp-signature.html.ejs +++ b/assets/dbp-signature.html.ejs @@ -92,10 +92,10 @@ nextcloud-web-app-password-url="<%= nextcloudWebAppPasswordURL %>" nextcloud-webdav-url="<%= nextcloudWebDavURL %>" nextcloud-name="<%= nextcloudName %>" - nextcloud-auth-info="" nextcloud-file-url="<%= nextcloudFileURL %>" initial-file-handling-state clipboard-files + html-overrides="global-override" auth requested-login-status analytics-event src="<%= getUrl(name + '.topic.metadata.json') %>" base-path="<%= getUrl('') %>" @@ -137,28 +137,23 @@ </template> </<%= name %>> +<template id="global-override"> + <template id="dbp-nextcloud-file-picker"> + <div slot="auth-info"> + <dbp-translated subscribe="lang"> + <div slot="de"> + <%= nextcloudAuthInfoDE %> + </div> + <div slot="en"> + <%= nextcloudAuthInfoEN %> + </div> + </dbp-translated> + </div> + </template> +</template> + <!-- Error handling for too old browsers --> <script src="<%= getPrivateUrl('browser-check.js') %>" defer></script> <noscript>Diese Applikation benötigt Javascript / This application requires Javascript</noscript> -<script> - const langTexts = { - "de": { - "nextcloud-auth-info": "<%= nextcloudAuthInfoDE %>", - }, - "en": { - "nextcloud-auth-info": "<%= nextcloudAuthInfoEN %>", - }, - } - - window.addEventListener('dbp-lang', function (e) { - const lang = e.detail; - if (!lang) { - return; - } - - const app = document.getElementById("app"); - app.setAttribute("nextcloud-auth-info", langTexts[lang]["nextcloud-auth-info"]); - }); -</script> </body> </html> \ No newline at end of file diff --git a/vendor/toolkit b/vendor/toolkit index 1c81f7e..e3594e1 160000 --- a/vendor/toolkit +++ b/vendor/toolkit @@ -1 +1 @@ -Subproject commit 1c81f7e344a4fdd5a3aec0612f5ba325b64fbad9 +Subproject commit e3594e1de8d3ed44c88b2d7afa5316a91933a001 -- GitLab