@yuuvis/client-shell-core
v3.26.0
Published
This library is the core layer for building yuuvis® MOMENTUM shell clients using [`@yuuvis/client-shell`](https://www.npmjs.com/package/@yuuvis/client-shell).
Readme
@yuuvis/client-shell-core
This library is the core layer for building yuuvis® MOMENTUM shell clients using @yuuvis/client-shell.
Object open handlers
Lets one part of the client open an object owned by another app without knowing that app's routes. The owning app registers a handler with ShellService; requesting code just asks the shell to open the object by appId.
Registering a handler (owning app)
An app registers a handler — typically in its ClientShellExtension.init() — keyed by its appId. The handler decides what "open" means (route change, overlay, popout, dialog) using its own routes and services. Registering the same appId again overwrites the previous entry.
this.#shell.registerObjectOpenHandler({
appId: APP_ID,
// receives the object's raw field data (DmsObject.data) and the resolved flavor
open: (data) => {
const id = data[BaseObjectTypeField.OBJECT_ID] as string;
const isFolder = data[BaseObjectTypeField.BASE_TYPE_ID] === SystemType.FOLDER;
this.#router.navigate([this.#shell.appBaseRoutes[APP_ID], isFolder ? 'files' : 'object', id]);
}
});The open callback receives the resolved ObjectFlavor as a second argument, so apps that expose several flavors can branch to the right view.
Opening an object (requesting side)
// gate UI (e.g. an "open" button) — true only when an app registered a handler for appId
this.#shell.canOpenObjectFor(appId);
// open from already-loaded field data (synchronous); returns false when no app can open it
this.#shell.openObject(appId, data, flavor?);
// open by id — resolves the object via DmsService (and its flavor if none given),
// then delegates to openObject; emits false when no app can open it (object not fetched)
this.#shell.openObjectById(appId, id, flavor?).subscribe();Typical consumer — opening a task's attached document in the app it originated from:
canOpen(): boolean {
return !!this.attachmentId && this.#shell.canOpenObjectFor(this.task().app?.id);
}
openAttachment() {
const appId = this.task().app?.id;
if (appId && this.attachmentId) this.#shell.openObjectById(appId, this.attachmentId).subscribe();
}Command palette
An overlay that runs any registered command by label. It opens when the user taps Ctrl twice within 300ms — there is no public open method — and closes again as soon as a command is picked.
Apps register their commands with CommandPaletteService, usually in ngOnInit or in their ClientShellExtension.init():
this.#cmdService
.registerCommand({ id: 'drive.upload', label: 'Upload file', description: 'Adds a document to the current folder' })
.pipe(takeUntilDestroyed())
.subscribe(() => this.upload());The returned observable emits whenever that command is triggered; a callback on the command works as well. updateCommands(cmds) re-labels registered commands by id — the hook for language changes — and addDisabledCause({ id, message }) makes the palette explain why it is unavailable instead of listing commands.
Typing # (the configurable searchModeIndicator) as first character turns the palette into a dms search: the rest of the term is used as CMIS fulltext term, scoped to the object flavors registered with ShellService. Hits are rendered from the object config of their type, and picking one opens it in the app that owns the type — a hit claimed by several apps offers a chip per app so the user can choose. Picks are emitted on searchResult$ together with the chosen app.
Full documentation: src/lib/services/command-palette/README.md.
