Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Commit 3f29d23

Browse files
committed
use workspace create
1 parent 7a48f9c commit 3f29d23

File tree

2 files changed

+41
-34
lines changed

2 files changed

+41
-34
lines changed

src/packages/block/block-grid/components/block-grid-area-config-entry/workspace/block-grid-area-type-workspace.context.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { UmbArrayState, UmbObjectState, appendToFrozenArray } from '@umbraco-cms
1414
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
1515
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
1616
import type { ManifestWorkspace, PropertyEditorSettingsProperty } from '@umbraco-cms/backoffice/extension-registry';
17+
import { UmbId } from '@umbraco-cms/backoffice/id';
1718

1819
export class UmbBlockGridAreaTypeWorkspaceContext
1920
extends UmbSubmittableWorkspaceContextBase<UmbBlockGridTypeAreaType>
@@ -43,12 +44,20 @@ export class UmbBlockGridAreaTypeWorkspaceContext
4344
{
4445
path: 'edit/:id',
4546
component: () => import('./block-grid-area-type-workspace-editor.element.js'),
46-
setup: (_component, info) => {
47+
setup: (component, info) => {
4748
const id = info.match.params.id;
48-
(_component as any).workspaceAlias = manifest.alias;
49+
(component as any).workspaceAlias = manifest.alias;
4950
this.load(id);
5051
},
5152
},
53+
{
54+
path: 'create',
55+
component: () => import('./block-grid-area-type-workspace-editor.element.js'),
56+
setup: (component) => {
57+
(component as any).workspaceAlias = manifest.alias;
58+
this.create();
59+
},
60+
},
5261
]);
5362
}
5463

@@ -78,17 +87,24 @@ export class UmbBlockGridAreaTypeWorkspaceContext
7887
}
7988

8089
async create() {
81-
throw new Error('Method not implemented.');
82-
/*
83-
//Only set groupKey property if it exists
84-
const data: UmbBlockGridTypeAreaType = {
85-
90+
this.resetState();
91+
let data: UmbBlockGridTypeAreaType = {
92+
key: UmbId.new(),
93+
alias: '',
94+
columnSpan: 12,
95+
rowSpan: 1,
96+
minAllowed: 0,
97+
maxAllowed: undefined,
98+
specifiedAllowance: [],
99+
};
100+
101+
// If we have a modal context, we blend in the modal preset data: [NL]
102+
if (this.modalContext) {
103+
data = { ...data, ...this.modalContext.data.preset };
86104
}
87105

88106
this.setIsNew(true);
89107
this.#data.setValue(data);
90-
return { data };
91-
*/
92108
}
93109

94110
getData() {

src/packages/block/block-grid/property-editors/block-grid-areas-config/property-editor-ui-block-grid-areas-config.element.ts

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,17 @@ export class UmbPropertyEditorUIBlockGridAreasConfigElement
6161
new UmbModalRouteRegistrationController(this, UMB_BLOCK_GRID_AREA_TYPE_WORKSPACE_MODAL)
6262
.addAdditionalPath('block-grid-area-type')
6363
.onSetup(() => {
64-
return { data: { entityType: 'block-grid-area-type', preset: {} }, modal: { size: 'large' } };
64+
if (!this._areaGridColumns) return false;
65+
const halfGridColumns = this._areaGridColumns * 0.5;
66+
const columnSpan = halfGridColumns === Math.round(halfGridColumns) ? halfGridColumns : this._areaGridColumns;
67+
68+
return {
69+
data: {
70+
entityType: 'block-grid-area-type',
71+
preset: { columnSpan, alias: this.#generateUniqueAreaAlias('area') },
72+
},
73+
modal: { size: 'large' },
74+
};
6575
})
6676
.observeRouteBuilder((routeBuilder) => {
6777
this._workspacePath = routeBuilder({});
@@ -104,29 +114,6 @@ export class UmbPropertyEditorUIBlockGridAreasConfigElement
104114
return alias;
105115
}
106116

107-
#addNewArea() {
108-
if (!this._areaGridColumns) return;
109-
const halfGridColumns = this._areaGridColumns * 0.5;
110-
const columnSpan = halfGridColumns === Math.round(halfGridColumns) ? halfGridColumns : this._areaGridColumns;
111-
112-
this._value = [
113-
...this._value,
114-
{
115-
key: UmbId.new(),
116-
alias: this.#generateUniqueAreaAlias('area'),
117-
columnSpan: columnSpan,
118-
rowSpan: 1,
119-
minAllowed: 0,
120-
maxAllowed: undefined,
121-
specifiedAllowance: [],
122-
},
123-
];
124-
this.requestUpdate('_value');
125-
this.dispatchEvent(new UmbPropertyValueChangeEvent());
126-
127-
//TODO: open area edit workspace
128-
}
129-
130117
override render() {
131118
return this._areaGridColumns
132119
? html`${this._styleElement}
@@ -144,7 +131,11 @@ export class UmbPropertyEditorUIBlockGridAreasConfigElement
144131
.key=${area.key}></umb-block-area-config-entry>`,
145132
)}
146133
</div>
147-
<uui-button id="add-button" look="placeholder" label=${'Add area'} @click=${this.#addNewArea}></uui-button>`
134+
<uui-button
135+
id="add-button"
136+
look="placeholder"
137+
label=${'Add area'}
138+
href=${this._workspacePath + 'create'}></uui-button>`
148139
: '';
149140
}
150141
}

0 commit comments

Comments
 (0)