update: Cleanup circle information

This commit is contained in:
Jean-Baptiste Pasquier
2019-10-25 15:35:14 +02:00
parent 8e7547d06b
commit d4279b0c7a
10 changed files with 250 additions and 158 deletions

View File

@ -43,7 +43,24 @@ document.addEventListener('DOMContentLoaded', function (event) {
for(sibDisplay of document.querySelectorAll('sib-display[set-user-id]')) {
sibDisplay.setAttribute(sibDisplay.getAttribute('set-user-id'), user['@id']);
}
for(sibForm of document.querySelectorAll('[set-user-id-select]')) {
sibForm.addEventListener('populate', () => {
document.querySelector('sib-form[submit-button="Join Circle"]').style.display = 'none';
if(document.querySelectorAll('sib-ac-checker:not([hidden]) > sib-delete[data-label="Leave circle"]').length == 0) {
document.querySelector('sib-form[submit-button="Join Circle"]').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
for(select of sibForm.querySelectorAll('select[name="'+sibForm.getAttribute('set-user-id-select')+'"]')) {
for(option of select.options) {
option.selected = (option.getAttribute('value') == '{"@id": "'+user['@id']+'"}');
}
}
});
}
}
}).catch(error => console.log(error));
});