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

Commit 54dcc62

Browse files
authored
Merge pull request #2160 from umbraco/v14/bugfix/block-area-config-use-workspace-create
V14/bugfix/block area config use workspace create
2 parents c7652f3 + 7de4f79 commit 54dcc62

File tree

3 files changed

+42
-40
lines changed

3 files changed

+42
-40
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: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
66
import { html, customElement, property, state, repeat } from '@umbraco-cms/backoffice/external/lit';
77
import type { UmbPropertyEditorUiElement } from '@umbraco-cms/backoffice/extension-registry';
88
import { UMB_PROPERTY_DATASET_CONTEXT } from '@umbraco-cms/backoffice/property';
9-
import {
10-
UmbPropertyValueChangeEvent,
11-
type UmbPropertyEditorConfigCollection,
12-
} from '@umbraco-cms/backoffice/property-editor';
13-
import { UmbId } from '@umbraco-cms/backoffice/id';
9+
import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor';
1410
import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router';
1511
import { incrementString } from '@umbraco-cms/backoffice/utils';
1612

@@ -61,7 +57,17 @@ export class UmbPropertyEditorUIBlockGridAreasConfigElement
6157
new UmbModalRouteRegistrationController(this, UMB_BLOCK_GRID_AREA_TYPE_WORKSPACE_MODAL)
6258
.addAdditionalPath('block-grid-area-type')
6359
.onSetup(() => {
64-
return { data: { entityType: 'block-grid-area-type', preset: {} }, modal: { size: 'large' } };
60+
if (!this._areaGridColumns) return false;
61+
const halfGridColumns = this._areaGridColumns * 0.5;
62+
const columnSpan = halfGridColumns === Math.round(halfGridColumns) ? halfGridColumns : this._areaGridColumns;
63+
64+
return {
65+
data: {
66+
entityType: 'block-grid-area-type',
67+
preset: { columnSpan, alias: this.#generateUniqueAreaAlias('area') },
68+
},
69+
modal: { size: 'large' },
70+
};
6571
})
6672
.observeRouteBuilder((routeBuilder) => {
6773
this._workspacePath = routeBuilder({});
@@ -104,29 +110,6 @@ export class UmbPropertyEditorUIBlockGridAreasConfigElement
104110
return alias;
105111
}
106112

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-
130113
override render() {
131114
return this._areaGridColumns
132115
? html`${this._styleElement}
@@ -144,7 +127,11 @@ export class UmbPropertyEditorUIBlockGridAreasConfigElement
144127
.key=${area.key}></umb-block-area-config-entry>`,
145128
)}
146129
</div>
147-
<uui-button id="add-button" look="placeholder" label=${'Add area'} @click=${this.#addNewArea}></uui-button>`
130+
<uui-button
131+
id="add-button"
132+
look="placeholder"
133+
label=${'Add area'}
134+
href=${this._workspacePath + 'create'}></uui-button>`
148135
: '';
149136
}
150137
}

src/packages/block/block-type/workspace/block-type-workspace.context.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ export class UmbBlockTypeWorkspaceContext<BlockTypeData extends UmbBlockTypeWith
112112

113113
this.setIsNew(true);
114114
this.#data.setValue(data);
115-
return { data };
116115
}
117116

118117
getData() {

0 commit comments

Comments
 (0)