fix: circle extensions loading

This commit is contained in:
Jean-Baptiste Pasquier 2021-04-15 13:29:03 +02:00
parent 127afe287d
commit e6ae9d036c
5 changed files with 79 additions and 77 deletions

View File

@ -53,6 +53,22 @@ for component of components
routes.add(route); routes.add(route);
component.route = route; component.route = route;
} }
if(component.extensions)
for extension of component.extensions
-
if(typeof extension.route === 'undefined') {
extension.route = extension.type;
}
if(extension.route) {
extension.uniq = Math.random().toString(16).slice(2);
let route = extension.route;
if (routes.has(extension.route)) {
route += "-" + extension.uniq;
}
routes.add(route);
extension.route = route;
}
- -
const defaultComponent = components.filter(e=>e.defaultRoute != undefined); const defaultComponent = components.filter(e=>e.defaultRoute != undefined);
let defaultRoute = "dashboard"; let defaultRoute = "dashboard";

View File

@ -14,27 +14,8 @@
no-render no-render
) )
include partials/circle/page-circle-profile.pug include partials/circle/page-circle-profile.pug
//- Note: for extension of component.extensions
Instead of using flat events/resources or polls components, you if extension.type == 'events'
may you to expend the way circle work to handle events & cie.
Like:
{
"type": "circles",
...
"extensions": [
{
"type": "events",
"endpoints": {...},
...
}
]
}
-
let extensions = new Set();
if(component.extensions) {
extensions = new Set(component.extensions.map(c=>c.type));
}
if extensions.has('events')
div( div(
id=`${component.route}-events` id=`${component.route}-events`
hidden hidden
@ -42,7 +23,7 @@
no-render no-render
) )
include partials/circle/page-circle-events.pug include partials/circle/page-circle-events.pug
if extensions.has('resources') if extension.type == 'resources'
div( div(
id=`${component.route}-resources` id=`${component.route}-resources`
hidden hidden
@ -50,7 +31,7 @@
no-render no-render
) )
include partials/circle/page-circle-resources.pug include partials/circle/page-circle-resources.pug
if extensions.has('polls') if extension.type == 'polls'
div( div(
id=`${component.route}-polls` id=`${component.route}-polls`
hidden hidden
@ -75,17 +56,18 @@ nav.jsRightMenu.text-disable-selection.sidebar.whitespace-normal(role='navigatio
li.segment.full.padding-medium li.segment.full.padding-medium
span.icon.ci-information.icon-xlarge.margin-right-medium span.icon.ci-information.icon-xlarge.margin-right-medium
a(data-trans='circle.menuRight.information') a(data-trans='circle.menuRight.information')
if extensions.has('resources') for extension of component.extensions
if extension.type == 'resources'
solid-route.segment.full(name=`${component.route}-resources` use-id) solid-route.segment.full(name=`${component.route}-resources` use-id)
li.segment.full.padding-medium li.segment.full.padding-medium
span.icon.ci-file.icon-xlarge.margin-right-medium span.icon.ci-file.icon-xlarge.margin-right-medium
a(data-trans='circle.menuRight.resources') a(data-trans='circle.menuRight.resources')
if extensions.has('events') if extension.type == 'events'
solid-route.segment.full(name=`${component.route}-events` use-id) solid-route.segment.full(name=`${component.route}-events` use-id)
li.segment.full.padding-medium li.segment.full.padding-medium
span.icon.ci-appointment.icon-xlarge.margin-right-medium span.icon.ci-appointment.icon-xlarge.margin-right-medium
a(data-trans='circle.menuRight.events') a(data-trans='circle.menuRight.events')
if extensions.has('polls') if extension.type == 'polls'
solid-route.segment.full(name=`${component.route}-polls` use-id) solid-route.segment.full(name=`${component.route}-polls` use-id)
li.segment.full.padding-medium li.segment.full.padding-medium
span.icon.ci-list.icon-xlarge.margin-right-medium span.icon.ci-list.icon-xlarge.margin-right-medium

View File

@ -1,10 +1,9 @@
solid-event( solid-event(
class='w700'
bind-resources bind-resources
nested-field="events" nested-field="events"
range-event-type=`${component.extensions.find(c => c.type=='events').endpoints.typeevents}` range-event-type=`${extension.endpoints.typeevents}`
range-event-circle=`${component.endpoints.get}/` range-event-circle=`${getComponent('circles').endpoints.get}/`
upload-dir=`${component.extensions.find(c => c.type=='events').endpoints.uploads}` upload-dir=`${extension.endpoints.uploads}`
id-prefix=`${component.route}` id-prefix='default'
uniq=component.uniq uniq=extension.uniq
) )

View File

@ -1,9 +1,9 @@
solid-poll( solid-poll(
class='w700'
id-prefix='circles'
bind-resources bind-resources
nested-field="polls" nested-field="polls"
range-base-polls=`${component.get('polls').endpoints.pollRangeBase}` data-dest=extension.endpoints.post
upload-dir=`${component.get('polls').endpoints.uploads}` range-tags=extension.endpoints.pollRangeTags
uniq=component.uniq range-circles=extension.endpoints.pollRangeCircles
upload-dir=extension.endpoints.uploads
uniq=extension.uniq
) )

View File

@ -1,10 +1,15 @@
solid-resource( solid-resource(
class='w700'
bind-resources bind-resources
nested-field="resources" nested-field="resources"
range-resource-type=`${component.extensions.find(c => c.type=='resources').endpoints.resourcestypes}` post-data-src=`${extension.endpoints.post}`
range-resource-keyword=`${component.extensions.find(c => c.type=='resources').endpoints.resourceskeywords}` range-resource-type=`${extension.endpoints.types}`
range-resource-circle=`${component.endpoints.get}/` post-data-type-src=`${extension.endpoints.postTypes}`
upload-dir=`${component.extensions.find(c => c.type=='resources').endpoints.uploads}` range-resource-keyword=`${extension.endpoints.keywords}`
id-prefix='circles' post-data-keyword-src=`${extension.endpoints.postKeywords}`
range-resource-circle=`${getComponent('circles').endpoints.get}/`
associated-circle-label=""
data-trans=`associated-circle-label=${extension.parameters && extension.parameters.associatedName ? extension.parameters.associatedName : 'circle.extensions.associated'}`
upload-dir=`${extension.endpoints.uploads}`
id-prefix='default'
uniq=extension.uniq
) )