Skip to content

Commit cd2dea0

Browse files
committed
add workspace for document blueprint folders
1 parent 24d7c03 commit cd2dea0

File tree

8 files changed

+134
-0
lines changed

8 files changed

+134
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './repository/index.js';
2+
export * from './workspace/index.js';

src/packages/documents/document-blueprints/tree/folder/manifests.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { UMB_DOCUMENT_BLUEPRINT_FOLDER_ENTITY_TYPE } from '../../entity.js';
22
import { UMB_DOCUMENT_BLUEPRINT_FOLDER_REPOSITORY_ALIAS } from './repository/index.js';
33
import { manifests as repositoryManifests } from './repository/manifests.js';
4+
import { manifests as workspaceManifests } from './workspace/manifests.js';
45

56
export const manifests: Array<UmbExtensionManifest> = [
67
{
@@ -24,4 +25,5 @@ export const manifests: Array<UmbExtensionManifest> = [
2425
},
2526
},
2627
...repositoryManifests,
28+
...workspaceManifests,
2729
];
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const UMB_DOCUMENT_BLUEPRINT_FOLDER_WORKSPACE_ALIAS = 'Umb.Workspace.DocumentBlueprint.Folder';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { UMB_DOCUMENT_BLUEPRINT_FOLDER_WORKSPACE_ALIAS } from './constants.js';
2+
import { UMB_DOCUMENT_BLUEPRINT_FOLDER_WORKSPACE_CONTEXT } from './document-blueprint-folder.workspace.context-token.js';
3+
import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
4+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
5+
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
6+
7+
const elementName = 'umb-data-type-folder-workspace-editor';
8+
@customElement(elementName)
9+
export class UmbDocumentBlueprintFolderWorkspaceEditorElement extends UmbLitElement {
10+
@state()
11+
private _name = '';
12+
13+
#workspaceContext?: typeof UMB_DOCUMENT_BLUEPRINT_FOLDER_WORKSPACE_CONTEXT.TYPE;
14+
15+
constructor() {
16+
super();
17+
18+
this.consumeContext(UMB_DOCUMENT_BLUEPRINT_FOLDER_WORKSPACE_CONTEXT, (workspaceContext) => {
19+
this.#workspaceContext = workspaceContext;
20+
this.#observeName();
21+
});
22+
}
23+
24+
#observeName() {
25+
if (!this.#workspaceContext) return;
26+
this.observe(this.#workspaceContext.name, (name) => {
27+
if (name !== this._name) {
28+
this._name = name ?? '';
29+
}
30+
});
31+
}
32+
33+
override render() {
34+
return html`<umb-workspace-editor headline=${this._name} alias=${UMB_DOCUMENT_BLUEPRINT_FOLDER_WORKSPACE_ALIAS}>
35+
</umb-workspace-editor>`;
36+
}
37+
38+
static override styles = [UmbTextStyles, css``];
39+
}
40+
41+
export { UmbDocumentBlueprintFolderWorkspaceEditorElement as element };
42+
43+
declare global {
44+
interface HTMLElementTagNameMap {
45+
[elementName]: UmbDocumentBlueprintFolderWorkspaceEditorElement;
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { UMB_DOCUMENT_BLUEPRINT_FOLDER_ENTITY_TYPE } from '../../../entity.js';
2+
import {
3+
UMB_DOCUMENT_BLUEPRINT_FOLDER_REPOSITORY_ALIAS,
4+
type UmbDocumentBlueprintFolderRepository,
5+
} from '../repository/index.js';
6+
import { UMB_DOCUMENT_BLUEPRINT_FOLDER_WORKSPACE_ALIAS } from './constants.js';
7+
import { UmbDocumentBlueprintFolderWorkspaceEditorElement } from './document-blueprint-folder-editor.element.js';
8+
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
9+
import {
10+
UmbEntityDetailWorkspaceContextBase,
11+
type UmbRoutableWorkspaceContext,
12+
type UmbSubmittableWorkspaceContext,
13+
} from '@umbraco-cms/backoffice/workspace';
14+
import type { IRoutingInfo, PageComponent } from '@umbraco-cms/backoffice/router';
15+
import type { UmbFolderModel } from '@umbraco-cms/backoffice/tree';
16+
17+
export class UmbDocumentBlueprintFolderWorkspaceContext
18+
extends UmbEntityDetailWorkspaceContextBase<UmbFolderModel, UmbDocumentBlueprintFolderRepository>
19+
implements UmbSubmittableWorkspaceContext, UmbRoutableWorkspaceContext
20+
{
21+
public readonly name = this._data.createObservablePartOfCurrent((data) => data?.name);
22+
23+
constructor(host: UmbControllerHost) {
24+
super(host, {
25+
workspaceAlias: UMB_DOCUMENT_BLUEPRINT_FOLDER_WORKSPACE_ALIAS,
26+
entityType: UMB_DOCUMENT_BLUEPRINT_FOLDER_ENTITY_TYPE,
27+
detailRepositoryAlias: UMB_DOCUMENT_BLUEPRINT_FOLDER_REPOSITORY_ALIAS,
28+
});
29+
30+
this.routes.setRoutes([
31+
{
32+
path: 'edit/:unique',
33+
component: UmbDocumentBlueprintFolderWorkspaceEditorElement,
34+
setup: (component: PageComponent, info: IRoutingInfo) => {
35+
const unique = info.match.params.unique;
36+
this.load(unique);
37+
},
38+
},
39+
]);
40+
}
41+
42+
/**
43+
* @description Set the name of the script
44+
* @param {string} value
45+
* @memberof UmbScriptWorkspaceContext
46+
*/
47+
public setName(value: string) {
48+
this._data.updateCurrent({ name: value });
49+
}
50+
}
51+
52+
export { UmbDocumentBlueprintFolderWorkspaceContext as api };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { UMB_DOCUMENT_BLUEPRINT_FOLDER_ENTITY_TYPE } from '../../../entity.js';
2+
import type { UmbDocumentBlueprintFolderWorkspaceContext } from './document-blueprint-folder-workspace.context.js';
3+
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
4+
import type { UmbWorkspaceContext } from '@umbraco-cms/backoffice/workspace';
5+
6+
export const UMB_DOCUMENT_BLUEPRINT_FOLDER_WORKSPACE_CONTEXT = new UmbContextToken<
7+
UmbWorkspaceContext,
8+
UmbDocumentBlueprintFolderWorkspaceContext
9+
>(
10+
'UmbWorkspaceContext',
11+
undefined,
12+
(context): context is UmbDocumentBlueprintFolderWorkspaceContext =>
13+
context.getEntityType?.() === UMB_DOCUMENT_BLUEPRINT_FOLDER_ENTITY_TYPE,
14+
);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './constants.js';
2+
export * from './document-blueprint-folder.workspace.context-token.js';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { UMB_DOCUMENT_BLUEPRINT_FOLDER_ENTITY_TYPE } from '../../../entity.js';
2+
import { UMB_DOCUMENT_BLUEPRINT_FOLDER_WORKSPACE_ALIAS } from './constants.js';
3+
4+
export const manifests: Array<UmbExtensionManifest> = [
5+
{
6+
type: 'workspace',
7+
kind: 'routable',
8+
alias: UMB_DOCUMENT_BLUEPRINT_FOLDER_WORKSPACE_ALIAS,
9+
name: 'Document Blueprint Folder Workspace',
10+
api: () => import('./document-blueprint-folder-workspace.context.js'),
11+
meta: {
12+
entityType: UMB_DOCUMENT_BLUEPRINT_FOLDER_ENTITY_TYPE,
13+
},
14+
},
15+
];

0 commit comments

Comments
 (0)