fix: js recursive parent selector for admin
This commit is contained in:
parent
5adbd98f51
commit
c50e05530e
@ -1,3 +1,13 @@
|
|||||||
|
function querySelectorParentChild(el, selector) {
|
||||||
|
while(el !== document.body) {
|
||||||
|
if(el.querySelector(selector)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
el = el.parentNode;
|
||||||
|
}
|
||||||
|
return el.querySelector(selector);
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function (event) {
|
document.addEventListener('DOMContentLoaded', function (event) {
|
||||||
const menuWrappers = Array.from(document.querySelectorAll('.menu-wrapper'));
|
const menuWrappers = Array.from(document.querySelectorAll('.menu-wrapper'));
|
||||||
const rightMenus = Array.from(document.querySelectorAll('nav.jsRightMenu'));
|
const rightMenus = Array.from(document.querySelectorAll('nav.jsRightMenu'));
|
||||||
@ -46,11 +56,10 @@ document.addEventListener('DOMContentLoaded', function (event) {
|
|||||||
|
|
||||||
for(sibForm of document.querySelectorAll('[set-user-id-select]')) {
|
for(sibForm of document.querySelectorAll('[set-user-id-select]')) {
|
||||||
sibForm.addEventListener('populate', () => {
|
sibForm.addEventListener('populate', () => {
|
||||||
document.querySelectorAll('sib-form[submit-button^="Join"]').forEach(el=>el.style.display = 'none');
|
|
||||||
if(document.querySelectorAll('sib-ac-checker:not([hidden]) > sib-delete[data-label^="Leave"]').length == 0) {
|
|
||||||
document.querySelectorAll('sib-form[submit-button^="Join"]').forEach(el=>el.style.display = 'inline-block');
|
|
||||||
}
|
|
||||||
// BUG: Populate event trigger before the view is fully loaded! - https://git.happy-dev.fr/startinblox/framework/sib-core/issues/521
|
// BUG: Populate event trigger before the view is fully loaded! - https://git.happy-dev.fr/startinblox/framework/sib-core/issues/521
|
||||||
|
document.querySelectorAll('sib-ac-checker:not([hidden]) > sib-delete[data-label^="Leave"]').forEach((el)=>{
|
||||||
|
querySelectorParentChild(el, 'sib-form[submit-button^="Join"]').style.display = "none";
|
||||||
|
});
|
||||||
for(select of sibForm.querySelectorAll('select[name="'+sibForm.getAttribute('set-user-id-select')+'"]')) {
|
for(select of sibForm.querySelectorAll('select[name="'+sibForm.getAttribute('set-user-id-select')+'"]')) {
|
||||||
for(option of select.options) {
|
for(option of select.options) {
|
||||||
option.selected = (option.getAttribute('value') == '{"@id": "'+user['@id']+'"}');
|
option.selected = (option.getAttribute('value') == '{"@id": "'+user['@id']+'"}');
|
||||||
|
Loading…
Reference in New Issue
Block a user