Skip to content

Commit 53bbdf4

Browse files
authored
Merge pull request #2392 from umbraco/v15/bugfix/template-master-state
Bug: re-implement master template state
2 parents 239df08 + 12aab32 commit 53bbdf4

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/packages/templating/templates/workspace/template-workspace.context.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { UmbRoutableWorkspaceContext, UmbSubmittableWorkspaceContext } from
88
import {
99
UmbEntityDetailWorkspaceContextBase,
1010
UmbWorkspaceIsNewRedirectController,
11+
UmbWorkspaceIsNewRedirectControllerAlias,
1112
} from '@umbraco-cms/backoffice/workspace';
1213
import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';
1314
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
@@ -43,7 +44,7 @@ export class UmbTemplateWorkspaceContext
4344
setup: (component: PageComponent, info: IRoutingInfo) => {
4445
const parentEntityType = info.match.params.entityType;
4546
const parentUnique = info.match.params.parentUnique === 'null' ? null : info.match.params.parentUnique;
46-
this.createScaffold({ parent: { entityType: parentEntityType, unique: parentUnique } });
47+
this.create({ entityType: parentEntityType, unique: parentUnique });
4748

4849
new UmbWorkspaceIsNewRedirectController(
4950
this,
@@ -56,13 +57,32 @@ export class UmbTemplateWorkspaceContext
5657
path: 'edit/:unique',
5758
component: UmbTemplateWorkspaceEditorElement,
5859
setup: (component: PageComponent, info: IRoutingInfo): void => {
60+
this.removeUmbControllerByAlias(UmbWorkspaceIsNewRedirectControllerAlias);
5961
const unique = info.match.params.unique;
6062
this.load(unique);
6163
},
6264
},
6365
]);
6466
}
6567

68+
override async load(unique: string) {
69+
const response = await super.load(unique);
70+
if (response.data) {
71+
this.setMasterTemplate(response.data.masterTemplate?.unique ?? null);
72+
}
73+
return response;
74+
}
75+
76+
async create(parent: any) {
77+
const data = await this.createScaffold({ parent });
78+
79+
if (data) {
80+
if (!parent) return;
81+
await this.setMasterTemplate(parent.unique);
82+
}
83+
return data;
84+
}
85+
6686
setName(value: string) {
6787
this._data.updateCurrent({ name: value });
6888
}

0 commit comments

Comments
 (0)