fix: recursiveAdaptWidgets
This commit is contained in:
parent
e1bce61124
commit
8042b179c6
@ -1,50 +1,47 @@
|
|||||||
function recursiveAdaptWidgets(prefix, element, user) {
|
function applyAdapt(prefix, sibDisplay, user) {
|
||||||
//- This function is a workaround for the currently unworking populate
|
|
||||||
//- Feel free to see examples on page-circles-
|
|
||||||
|
|
||||||
element.querySelectorAll("[" + prefix + "-user-id]").forEach(el => {
|
|
||||||
el.setAttribute(el.getAttribute(prefix + "-user-id"), user["@id"]);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (element != document) {
|
|
||||||
//- Allow to bind-user on selected attribute
|
//- Allow to bind-user on selected attribute
|
||||||
if (element.getAttribute(prefix + "-user-id")) {
|
if (sibDisplay.getAttribute(prefix + "-user-id")) {
|
||||||
element.setAttribute(
|
sibDisplay.setAttribute(
|
||||||
element.getAttribute(prefix + "-user-id"),
|
sibDisplay.getAttribute(prefix + "-user-id"),
|
||||||
user["@id"]
|
user["@id"]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Allow to set data-src to a children sib-form
|
//- Allow to set data-src to a children sib-form
|
||||||
if (element.getAttribute(prefix + "-bind-resources")) {
|
if (sibDisplay.getAttribute(prefix + "-bind-resources")) {
|
||||||
let form = element.querySelector(
|
let form = sibDisplay.querySelector(
|
||||||
element.getAttribute(prefix + "-bind-resources") + " sib-form"
|
sibDisplay.getAttribute(prefix + "-bind-resources") + " sib-form"
|
||||||
);
|
);
|
||||||
if (form) {
|
if (form) {
|
||||||
form.setAttribute(
|
form.setAttribute(
|
||||||
"data-src",
|
"data-src",
|
||||||
element.component.resourceId.replace("members/", "")
|
sibDisplay.component.resourceId.replace("members/", "")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Allow to put user on a targetted search field
|
//- Allow to put user on a targetted search field
|
||||||
if (element.getAttribute(prefix + "-bind-user2input")) {
|
if (sibDisplay.getAttribute(prefix + "-bind-user2input")) {
|
||||||
element.querySelector(
|
sibDisplay.querySelector(
|
||||||
element.getAttribute(prefix + "-bind-user2input")
|
sibDisplay.getAttribute(prefix + "-bind-user2input")
|
||||||
).value = user["@id"];
|
).value = user["@id"];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//- In case your sib-display use a multiple, you have to target sub-sib-display auto-generated
|
function recursiveAdaptWidgets(prefix, element, user) {
|
||||||
element.querySelectorAll("sib-display, sib-form, div > sib-display, div > sib-form").forEach(el => {
|
|
||||||
el.setAttribute(prefix + "-widgets", "");
|
element.addEventListener("populate", () => {
|
||||||
|
|
||||||
|
//- This function is a workaround for the currently unworking populate
|
||||||
|
//- Feel free to see examples on page-circles-
|
||||||
|
element.querySelectorAll("[" + prefix + "-user-id]").forEach(el => {
|
||||||
|
el.setAttribute(el.getAttribute(prefix + "-user-id"), user["@id"]);
|
||||||
});
|
});
|
||||||
}
|
applyAdapt(prefix, element, user);
|
||||||
|
|
||||||
//- This function is hooked every time a sib-something with prefix+"-widgets" is populated
|
document.querySelectorAll('sib-display, sib-form').forEach(sibDisplay => {
|
||||||
element.querySelectorAll("[" + prefix + "-widgets]").forEach(elementChild => {
|
applyAdapt(prefix, sibDisplay, user);
|
||||||
elementChild.addEventListener("populate", () => {
|
|
||||||
recursiveAdaptWidgets(prefix, elementChild, user);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -219,8 +216,10 @@ document.addEventListener("DOMContentLoaded", function(event) {
|
|||||||
document
|
document
|
||||||
.querySelector('button[role="log in"]')
|
.querySelector('button[role="log in"]')
|
||||||
.setAttribute("style", "display:none !important");
|
.setAttribute("style", "display:none !important");
|
||||||
|
document.querySelectorAll('sib-display, sib-form').forEach(element => {
|
||||||
// Set current user id on set-user-id of sib-display
|
// Set current user id on set-user-id of sib-display
|
||||||
recursiveAdaptWidgets("hd-inherit", document, user);
|
recursiveAdaptWidgets("hd-inherit", element, user);
|
||||||
|
});
|
||||||
for (leaveBtn of document.querySelectorAll(
|
for (leaveBtn of document.querySelectorAll(
|
||||||
"admin-circle-leave > sib-ac-checker:not([hidden])"
|
"admin-circle-leave > sib-ac-checker:not([hidden])"
|
||||||
)) {
|
)) {
|
||||||
|
@ -94,7 +94,6 @@
|
|||||||
|
|
||||||
class-members='w33 cell border cell-with-buttons'
|
class-members='w33 cell border cell-with-buttons'
|
||||||
widget-members="admin-circle-join-button"
|
widget-members="admin-circle-join-button"
|
||||||
hd-inherit-bind-user2input="input[name='user.@id']"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +68,6 @@
|
|||||||
search-widget-user='sib-form-hidden'
|
search-widget-user='sib-form-hidden'
|
||||||
search-value-user="-"
|
search-value-user="-"
|
||||||
hd-inherit-user-id="search-value-user"
|
hd-inherit-user-id="search-value-user"
|
||||||
hd-inherit-widgets
|
|
||||||
)
|
)
|
||||||
|
|
||||||
sib-display(
|
sib-display(
|
||||||
@ -84,8 +83,6 @@
|
|||||||
|
|
||||||
widget-buttons="admin-project-buttons"
|
widget-buttons="admin-project-buttons"
|
||||||
action-buttons="buttons"
|
action-buttons="buttons"
|
||||||
hd-inherit-widgets
|
|
||||||
hd-inherit-widgets-multiple
|
|
||||||
|
|
||||||
widget-captain='project-captain'
|
widget-captain='project-captain'
|
||||||
widget-members='project-admins'
|
widget-members='project-admins'
|
||||||
|
@ -60,7 +60,6 @@ sib-router(default-route='circle-profile', hidden)
|
|||||||
widget-user.@id='sib-form-hidden'
|
widget-user.@id='sib-form-hidden'
|
||||||
|
|
||||||
hd-inherit-bind-user2input="input[name='user.@id']"
|
hd-inherit-bind-user2input="input[name='user.@id']"
|
||||||
hd-inherit-widgets
|
|
||||||
|
|
||||||
submit-button='Join Circle'
|
submit-button='Join Circle'
|
||||||
)
|
)
|
||||||
@ -77,7 +76,6 @@ sib-router(default-route='circle-profile', hidden)
|
|||||||
empty-widget='circle-join-button'
|
empty-widget='circle-join-button'
|
||||||
hd-inherit-bind-resources='circle-join-button'
|
hd-inherit-bind-resources='circle-join-button'
|
||||||
hd-inherit-user-id="search-value-user"
|
hd-inherit-user-id="search-value-user"
|
||||||
hd-inherit-widgets
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,7 +94,6 @@ sib-router(default-route='project-profile', hidden)
|
|||||||
search-value-user=""
|
search-value-user=""
|
||||||
|
|
||||||
hd-inherit-user-id="search-value-user"
|
hd-inherit-user-id="search-value-user"
|
||||||
hd-inherit-widgets
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user