feature: removing the widget extension

This commit is contained in:
Jean-Baptiste Pasquier 2021-02-18 12:55:25 +01:00
parent c8dc654fc7
commit 64b6744dfc
3 changed files with 2 additions and 73 deletions

View File

@ -1,68 +0,0 @@
function applyAdapt(prefix, sibDisplay, user) {
//- Allow to bind-user on selected attribute
if (sibDisplay.getAttribute(prefix + "-user-id")) {
sibDisplay.setAttribute(
sibDisplay.getAttribute(prefix + "-user-id"),
user["@id"]
);
}
//- Allow to set data-src to a children solid-form
if (sibDisplay.getAttribute(prefix + "-bind-resources")) {
let form = sibDisplay.querySelector(
sibDisplay.getAttribute(prefix + "-bind-resources") + " solid-form"
);
if (form) {
form.setAttribute(
"data-src",
sibDisplay.component.resourceId.replace("members/", "")
);
}
}
//- Allow to put user on a targetted search field
if (sibDisplay.getAttribute(prefix + "-bind-user2input")) {
let qS = sibDisplay.querySelector(
sibDisplay.getAttribute(prefix + "-bind-user2input")
);
if(qS) qS.value = user["@id"];
}
}
//- This function is a workaround for the currently unworking populate
//- Feel free to see examples on page-circles-
function recursiveAdaptWidgets(prefix, element, user) {
element.addEventListener("populate", () => {
element.querySelectorAll("[" + prefix + "-user-id]").forEach(el => {
el.setAttribute(el.getAttribute(prefix + "-user-id"), user["@id"]);
});
applyAdapt(prefix, element, user);
document.querySelectorAll('solid-display, solid-form').forEach(sibDisplay => {
applyAdapt(prefix, sibDisplay, user);
});
});
}
document.addEventListener("DOMContentLoaded", function () {
document
.querySelector("sib-auth")
.getUser()
.then(user => {
if (user !== null) {
document.querySelectorAll('solid-display, solid-form').forEach(element => {
// Set current user id on set-user-id of solid-display
recursiveAdaptWidgets("hubl-inherit", element, user);
});
for (leaveBtn of document.querySelectorAll(
"admin-circle-leave > solid-ac-checker:not([hidden])"
)) {
// Hide Join button
leaveBtn.parentNode.parentNode.parentNode.nextElementSibling.setAttribute(
"style",
"display:none !important"
);
}
}
});
});

View File

@ -80,9 +80,8 @@ solid-router(default-route='circle-profile', hidden)
widget-relation='hubl-circle-leave-button' widget-relation='hubl-circle-leave-button'
search-fields='user' search-fields='user'
search-widget-user='solid-form-hidden' search-widget-user='solid-form-hidden'
search-value-user="" search-value-user="store://user.@id"
empty-widget='hubl-circle-join-button' empty-widget='hubl-circle-join-button'
hubl-inherit-user-id="search-value-user"
) )
solid-ac-checker.segment.margin-left-small(permission='acl:Delete', bind-resources) solid-ac-checker.segment.margin-left-small(permission='acl:Delete', bind-resources)
solid-delete( solid-delete(

View File

@ -80,9 +80,7 @@ solid-router(default-route='project-profile', hidden)
search-fields='user' search-fields='user'
search-widget-user='solid-form-hidden' search-widget-user='solid-form-hidden'
search-value-user="" search-value-user="store://user.@id"
hubl-inherit-user-id="search-value-user"
) )
h3.text-color-heading.text-bold.text-letter-spacing-large(data-trans='project.profile.captain') h3.text-color-heading.text-bold.text-letter-spacing-large(data-trans='project.profile.captain')