perf: improve circle admin

This commit is contained in:
Jean-Baptiste Pasquier 2020-02-10 17:58:03 +01:00
parent 31bd34df98
commit e1bce61124
No known key found for this signature in database
GPG Key ID: F2702E6D22ED4D62
2 changed files with 34 additions and 42 deletions

View File

@ -36,12 +36,10 @@ function recursiveAdaptWidgets(prefix, element, user) {
}
//- In case your sib-display use a multiple, you have to target sub-sib-display auto-generated
if (element.getAttribute(prefix + "-widgets-multiple") !== null) {
element.querySelectorAll("div > sib-display").forEach(el => {
element.querySelectorAll("sib-display, sib-form, div > sib-display, div > sib-form").forEach(el => {
el.setAttribute(prefix + "-widgets", "");
});
}
}
//- This function is hooked every time a sib-something with prefix+"-widgets" is populated
element.querySelectorAll("[" + prefix + "-widgets]").forEach(elementChild => {
@ -125,6 +123,7 @@ async function refreshResource(event) {
if(resourceId.includes('circle') && user != null) {
let userId = user['@id'];
refreshSibDisplays(userId + "circles/");
refreshSibDisplays(resourceId.split('/').slice(0,4).join('/')+'/joinable/');
}
//clear cache on this resource

View File

@ -51,57 +51,50 @@
data-label='Leave circle'
)
sib-display(
class='table-body'
bind-user
nested-field='circles'
fields='circle.name, circle.owner, leaveButton'
class-circle.name='w33 cell border cell-with-name'
class-circle.owner='w33 cell border cell-with-id-card'
class-leaveButton='w33 cell border cell-with-buttons'
action-leaveButton="joinButton"
widget-leaveButton="admin-circle-leave-button"
widget-circle.owner='circle-owner'
)
sib-widget(name='admin-circle-join-button')
template
button.button.text-bold.text-uppercase.reversed.button-blue.bordered.with-icon.icon-arrow-right-circle.test
sib-form(
data-src=''
nested-field='members'
sib-form.button.text-bold.text-uppercase.reversed.button-blue.bordered.with-icon.icon-arrow-right-circle.test(
data-src='${value}'
fields='user.@id'
label-user.@id=''
value-user.@id=''
value-user.@id='self'
widget-user.@id='sib-form-hidden'
hd-inherit-bind-user2input="input[name='user.@id']"
hd-inherit-widgets
submit-button='Join Circle'
)
sib-widget(name="admin-circle-buttons")
template
sib-display(
data-src='${src}'
nested-field='members'
fields='relation'
action-relation='relation'
widget-relation='admin-circle-leave-button'
search-fields='user'
search-widget-user='sib-form-hidden'
search-value-user="-"
empty-widget='admin-circle-join-button'
hd-inherit-bind-resources='admin-circle-join-button'
hd-inherit-user-id="search-value-user"
hd-inherit-widgets
)
sib-display(
class='table-body'
data-src=`${endpoints.circles || endpoints.get.circles}`
fields='name, owner, buttons'
data-src=`${endpoints.circles || endpoints.get.circles}joinable/`
fields='name, owner, members'
class-name='w33 cell border cell-with-name'
class-owner='w33 cell border cell-with-id-card'
class-buttons='w33 cell border cell-with-buttons'
widget-buttons="admin-circle-buttons"
action-buttons="buttons"
hd-inherit-widgets
hd-inherit-widgets-multiple
widget-owner='circle-owner'
class-members='w33 cell border cell-with-buttons'
widget-members="admin-circle-join-button"
hd-inherit-bind-user2input="input[name='user.@id']"
)