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,50 +14,31 @@
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. div(
Like: id=`${component.route}-events`
{ hidden
"type": "circles", data-view=`${component.route}-events`
... no-render
"extensions": [ )
{ include partials/circle/page-circle-events.pug
"type": "events", if extension.type == 'resources'
"endpoints": {...}, div(
... id=`${component.route}-resources`
} hidden
] data-view=`${component.route}-resources`
} no-render
- )
let extensions = new Set(); include partials/circle/page-circle-resources.pug
if(component.extensions) { if extension.type == 'polls'
extensions = new Set(component.extensions.map(c=>c.type)); div(
} id=`${component.route}-polls`
if extensions.has('events') hidden
div( data-view=`${component.route}-polls`
id=`${component.route}-events` no-render
hidden )
data-view=`${component.route}-events` include partials/circle/page-circle-polls.pug
no-render
)
include partials/circle/page-circle-events.pug
if extensions.has('resources')
div(
id=`${component.route}-resources`
hidden
data-view=`${component.route}-resources`
no-render
)
include partials/circle/page-circle-resources.pug
if extensions.has('polls')
div(
id=`${component.route}-polls`
hidden
data-view=`${component.route}-polls`
no-render
)
include partials/circle/page-circle-polls.pug
nav.jsRightMenu.text-disable-selection.sidebar.whitespace-normal(role='navigation') nav.jsRightMenu.text-disable-selection.sidebar.whitespace-normal(role='navigation')
solid-router.segment.whitespace-normal.text-color-heading.text-bold(default-route=`${component.route}-chat`) solid-router.segment.whitespace-normal.text-color-heading.text-bold(default-route=`${component.route}-chat`)
@ -75,18 +56,19 @@ 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
solid-route.segment.full(name=`${component.route}-resources` use-id) if extension.type == 'resources'
li.segment.full.padding-medium solid-route.segment.full(name=`${component.route}-resources` use-id)
span.icon.ci-file.icon-xlarge.margin-right-medium li.segment.full.padding-medium
a(data-trans='circle.menuRight.resources') span.icon.ci-file.icon-xlarge.margin-right-medium
if extensions.has('events') a(data-trans='circle.menuRight.resources')
solid-route.segment.full(name=`${component.route}-events` use-id) if extension.type == 'events'
li.segment.full.padding-medium solid-route.segment.full(name=`${component.route}-events` use-id)
span.icon.ci-appointment.icon-xlarge.margin-right-medium li.segment.full.padding-medium
a(data-trans='circle.menuRight.events') span.icon.ci-appointment.icon-xlarge.margin-right-medium
if extensions.has('polls') a(data-trans='circle.menuRight.events')
solid-route.segment.full(name=`${component.route}-polls` use-id) if extension.type == 'polls'
li.segment.full.padding-medium solid-route.segment.full(name=`${component.route}-polls` use-id)
span.icon.ci-list.icon-xlarge.margin-right-medium li.segment.full.padding-medium
a(data-trans='circle.menuRight.polls') span.icon.ci-list.icon-xlarge.margin-right-medium
a(data-trans='circle.menuRight.polls')

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
) )