Skip to content

Commit 475b300

Browse files
committed
register folder workspace
1 parent 983d8e0 commit 475b300

File tree

8 files changed

+130
-0
lines changed

8 files changed

+130
-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/templating/partial-views/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_PARTIAL_VIEW_FOLDER_ENTITY_TYPE } from '../../entity.js';
22
import { UMB_PARTIAL_VIEW_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 UMB_DELETE_PARTIAL_VIEW_FOLDER_ENTITY_ACTION_ALIAS = 'Umb.EntityAction.PartialView.Folder.Delete';
67

@@ -16,4 +17,5 @@ export const manifests: Array<UmbExtensionManifest> = [
1617
},
1718
},
1819
...repositoryManifests,
20+
...workspaceManifests,
1921
];
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const UMB_PARTIAL_VIEW_FOLDER_WORKSPACE_ALIAS = 'Umb.Workspace.PartialView.Folder';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './constants.js';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE } from '../../../entity.js';
2+
import { UMB_PARTIAL_VIEW_FOLDER_WORKSPACE_ALIAS } from './constants.js';
3+
4+
export const manifests: Array<UmbExtensionManifest> = [
5+
{
6+
type: 'workspace',
7+
kind: 'routable',
8+
alias: UMB_PARTIAL_VIEW_FOLDER_WORKSPACE_ALIAS,
9+
name: 'Partial View Folder Workspace',
10+
api: () => import('./partial-view-folder-workspace.context.js'),
11+
meta: {
12+
entityType: UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE,
13+
},
14+
},
15+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { UMB_PARTIAL_VIEW_FOLDER_WORKSPACE_ALIAS } from './constants.js';
2+
import { UMB_PARTIAL_VIEW_FOLDER_WORKSPACE_CONTEXT } from './partial-view-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-partial-view-folder-workspace-editor';
8+
@customElement(elementName)
9+
export class UmbPartialViewFolderWorkspaceEditorElement extends UmbLitElement {
10+
@state()
11+
private _name = '';
12+
13+
#workspaceContext?: typeof UMB_PARTIAL_VIEW_FOLDER_WORKSPACE_CONTEXT.TYPE;
14+
15+
constructor() {
16+
super();
17+
18+
this.consumeContext(UMB_PARTIAL_VIEW_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_PARTIAL_VIEW_FOLDER_WORKSPACE_ALIAS}>
35+
</umb-workspace-editor>`;
36+
}
37+
38+
static override styles = [UmbTextStyles, css``];
39+
}
40+
41+
export { UmbPartialViewFolderWorkspaceEditorElement as element };
42+
43+
declare global {
44+
interface HTMLElementTagNameMap {
45+
[elementName]: UmbPartialViewFolderWorkspaceEditorElement;
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE } from '../../../entity.js';
2+
import type { UmbPartialViewFolderWorkspaceContext } from './partial-view-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_PARTIAL_VIEW_FOLDER_WORKSPACE_CONTEXT = new UmbContextToken<
7+
UmbWorkspaceContext,
8+
UmbPartialViewFolderWorkspaceContext
9+
>(
10+
'UmbWorkspaceContext',
11+
undefined,
12+
(context): context is UmbPartialViewFolderWorkspaceContext =>
13+
context.getEntityType?.() === UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE,
14+
);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { UMB_PARTIAL_VIEW_FOLDER_REPOSITORY_ALIAS, type UmbPartialViewFolderRepository } from '../repository/index.js';
2+
import { UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE } from '../../../entity.js';
3+
import { UMB_PARTIAL_VIEW_FOLDER_WORKSPACE_ALIAS } from './constants.js';
4+
import { UmbPartialViewFolderWorkspaceEditorElement } from './partial-view-folder-workspace-editor.element.js';
5+
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
6+
import {
7+
UmbEntityDetailWorkspaceContextBase,
8+
type UmbRoutableWorkspaceContext,
9+
type UmbSubmittableWorkspaceContext,
10+
} from '@umbraco-cms/backoffice/workspace';
11+
import type { IRoutingInfo, PageComponent } from '@umbraco-cms/backoffice/router';
12+
import type { UmbFolderModel } from '@umbraco-cms/backoffice/tree';
13+
14+
export class UmbPartialViewFolderWorkspaceContext
15+
extends UmbEntityDetailWorkspaceContextBase<UmbFolderModel, UmbPartialViewFolderRepository>
16+
implements UmbSubmittableWorkspaceContext, UmbRoutableWorkspaceContext
17+
{
18+
public readonly name = this._data.createObservablePartOfCurrent((data) => data?.name);
19+
20+
constructor(host: UmbControllerHost) {
21+
super(host, {
22+
workspaceAlias: UMB_PARTIAL_VIEW_FOLDER_WORKSPACE_ALIAS,
23+
entityType: UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE,
24+
detailRepositoryAlias: UMB_PARTIAL_VIEW_FOLDER_REPOSITORY_ALIAS,
25+
});
26+
27+
this.routes.setRoutes([
28+
{
29+
path: 'edit/:unique',
30+
component: UmbPartialViewFolderWorkspaceEditorElement,
31+
setup: (component: PageComponent, info: IRoutingInfo) => {
32+
const unique = info.match.params.unique;
33+
this.load(unique);
34+
},
35+
},
36+
]);
37+
}
38+
39+
/**
40+
* @description Set the name of the script
41+
* @param {string} value
42+
* @memberof UmbScriptWorkspaceContext
43+
*/
44+
public setName(value: string) {
45+
this._data.updateCurrent({ name: value });
46+
}
47+
}
48+
49+
export { UmbPartialViewFolderWorkspaceContext as api };

0 commit comments

Comments
 (0)