diff --git a/models/card/src/index.ts b/models/card/src/index.ts index d46e1fbd961..9a589b6573c 100644 --- a/models/card/src/index.ts +++ b/models/card/src/index.ts @@ -447,15 +447,24 @@ export function createModel (builder: Builder): void { position: 'top' } ], - spaces: [ + spaces: [], + groups: [ { - id: 'spaces', - label: core.string.Spaces, - spaceClass: card.class.CardSpace, - addSpaceLabel: core.string.Space, - icon: card.icon.Space, - // intentionally left empty in order to make space presenter working - specials: [] + id: 'types', + label: card.string.MasterTags, + groupByClass: card.class.MasterTag, + icon: card.icon.MasterTags, + component: card.component.TypesNavigator, + specials: [ + { + id: 'type', + label: card.string.Cards, + component: card.component.Main, + componentProps: { + defaultViewletDescriptor: card.viewlet.CardFeedDescriptor + } + } + ] } ] }, @@ -658,7 +667,7 @@ export function createModel (builder: Builder): void { ) builder.mixin(card.class.Card, core.class.Class, view.mixin.ClassFilters, { - filters: [], + filters: ['space'], ignoreKeys: ['parent'] }) diff --git a/plugins/card-resources/src/components/CardFeedView.svelte b/plugins/card-resources/src/components/CardFeedView.svelte index 8bad60c4354..e292e3add9b 100644 --- a/plugins/card-resources/src/components/CardFeedView.svelte +++ b/plugins/card-resources/src/components/CardFeedView.svelte @@ -63,6 +63,7 @@ } } ) + $: cardSpace = space ?? getSpaceFromFilter(resultQuery) $: hasNextPage = total > cards.length @@ -76,6 +77,16 @@ } } + function getSpaceFromFilter (_query: DocumentQuery): Ref | undefined { + if (_query.space != null) { + if (typeof _query.space === 'object' && '$in' in _query.space && Array.isArray(_query.space.$in)) { + return _query.space.$in[0] as Ref + } + return _query.space as Ref + } + return undefined + } + function getFormatDateId (timestamp: number): string { const now = new Date() const date = new Date(timestamp) @@ -110,7 +121,7 @@
- +
{#each cards as card, index} {@const previousCard = cards[index - 1]} diff --git a/plugins/card-resources/src/components/Main.svelte b/plugins/card-resources/src/components/Main.svelte index c06841ae68a..340fc0850e5 100644 --- a/plugins/card-resources/src/components/Main.svelte +++ b/plugins/card-resources/src/components/Main.svelte @@ -14,7 +14,7 @@ --> + +
+ + { + selectType(e.detail) + }} + /> + +
diff --git a/plugins/card-resources/src/index.ts b/plugins/card-resources/src/index.ts index c2f622b0414..be1d2809504 100644 --- a/plugins/card-resources/src/index.ts +++ b/plugins/card-resources/src/index.ts @@ -53,6 +53,7 @@ import CreateCardButton from './components/CreateCardButton.svelte' import CardArrayEditor from './components/CardArrayEditor.svelte' import NewCardHeader from './components/navigator/NewCardHeader.svelte' import SpacePresenter from './components/navigator/SpacePresenter.svelte' +import TypesNavigator from './components/navigator/TypesNavigator.svelte' import LabelsPresenter from './components/LabelsPresenter.svelte' import RolesSection from './components/settings/RolesSection.svelte' import EditRole from './components/settings/EditRole.svelte' @@ -111,6 +112,7 @@ export default async (): Promise => ({ CardArrayEditor, NewCardHeader, SpacePresenter, + TypesNavigator, LabelsPresenter, RolesSection, EditRole, diff --git a/plugins/card-resources/src/plugin.ts b/plugins/card-resources/src/plugin.ts index 51f19dda86a..0c1a677e948 100644 --- a/plugins/card-resources/src/plugin.ts +++ b/plugins/card-resources/src/plugin.ts @@ -46,6 +46,7 @@ export default mergeIds(cardId, card, { CreateCardButton: '' as AnyComponent, NewCardHeader: '' as AnyComponent, SpacePresenter: '' as AnyComponent, + TypesNavigator: '' as AnyComponent, RolesSection: '' as AnyComponent, EditRole: '' as AnyComponent, CardWidget: '' as AnyComponent, diff --git a/plugins/card-resources/src/utils.ts b/plugins/card-resources/src/utils.ts index 142967acfb0..eefae66a7da 100644 --- a/plugins/card-resources/src/utils.ts +++ b/plugins/card-resources/src/utils.ts @@ -98,7 +98,8 @@ export async function resolveLocation (loc: Location): Promise s._id === currentSpace)} /> {/each} + + {#if model.groups && model.groups.length > 0} +
+ {#each model.groups as group (group.id)} + {#if group.component} + + {/if} + {/each} + {/if} {/if} diff --git a/plugins/workbench-resources/src/components/Workbench.svelte b/plugins/workbench-resources/src/components/Workbench.svelte index 41254cb769c..bd423d4e547 100644 --- a/plugins/workbench-resources/src/components/Workbench.svelte +++ b/plugins/workbench-resources/src/components/Workbench.svelte @@ -642,6 +642,12 @@ return sp } } + for (const g of navigatorModel?.groups ?? []) { + const sp = g.specials?.find((x) => x.id === id) + if (sp !== undefined) { + return sp + } + } } let cover: HTMLElement diff --git a/plugins/workbench/src/types.ts b/plugins/workbench/src/types.ts index e2ff83790f0..0370bb35b0f 100644 --- a/plugins/workbench/src/types.ts +++ b/plugins/workbench/src/types.ts @@ -114,6 +114,7 @@ export interface ApplicationNavModel extends Doc { spaces?: SpacesNavModel[] specials?: SpecialNavModel[] + groups?: GroupsNavModel[] } /** @public */ @@ -136,10 +137,25 @@ export interface SpacesNavModel { visibleIf?: Resource<(space: Space) => Promise> } +/** @public */ +export interface GroupsNavModel { + id: string // Id could be used for extending of navigation model + label?: IntlString + groupByClass: Ref> // Any class to group by (MasterTag, Project, etc.) + icon?: Asset + component?: AnyComponent // Component to render the group navigation (e.g., TypesNavigator) + + // Child special items. + specials?: SpecialNavModel[] + + visibleIf?: Resource<(docs: Doc[]) => Promise> +} + /** @public */ export interface NavigatorModel { spaces: SpacesNavModel[] specials?: SpecialNavModel[] + groups?: GroupsNavModel[] } /** @public */