Skip to content

Commit d2444f5

Browse files
committed
binding corrections
1 parent 3b4df2e commit d2444f5

File tree

9 files changed

+45
-40
lines changed

9 files changed

+45
-40
lines changed

src/packages/core/content-type/structure/content-type-property-structure-helper.class.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,6 @@ export class UmbContentTypePropertyStructureHelper<T extends UmbContentTypeModel
181181
// TODO: consider moving this to another class, to separate 'viewer' from 'manipulator':
182182
/** Manipulate methods: */
183183

184-
/*
185-
Only used by legacy implementation:
186-
@deprecated
187-
*/
188-
/*
189-
async addProperty(containerId?: string, sortOrder?: number) {
190-
await this.#init;
191-
if (!this.#structure) return;
192-
193-
return await this.#structure.createProperty(null, containerId, sortOrder);
194-
}
195-
*/
196-
197184
async insertProperty(property: UmbPropertyTypeModel, sortOrder?: number) {
198185
await this.#init;
199186
if (!this.#structure) return false;

src/packages/core/content-type/workspace/views/design/content-type-design-editor-properties.element.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ import { type UmbSorterConfig, UmbSorterController } from '@umbraco-cms/backoffi
1919
import { type UmbModalRouteBuilder, UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router';
2020

2121
import './content-type-design-editor-property.element.js';
22-
import { UMB_WORKSPACE_MODAL } from '@umbraco-cms/backoffice/modal';
23-
import { UMB_PROPERTY_TYPE_WORKSPACE_MODAL } from '@umbraco-cms/backoffice/property-type';
22+
import {
23+
UMB_CREATE_PROPERTY_TYPE_WORKSPACE_PATH_PATTERN,
24+
UMB_EDIT_PROPERTY_TYPE_WORKSPACE_PATH_PATTERN,
25+
UMB_PROPERTY_TYPE_WORKSPACE_MODAL,
26+
} from '@umbraco-cms/backoffice/property-type';
2427

2528
const SORTER_CONFIG: UmbSorterConfig<UmbPropertyTypeModel, UmbContentTypeDesignEditorPropertyElement> = {
2629
getUniqueOfElement: (element) => {
@@ -99,12 +102,13 @@ export class UmbContentTypeDesignEditorPropertiesElement extends UmbLitElement {
99102
const oldValue = this._containerId;
100103
if (value === oldValue) return;
101104
this._containerId = value;
105+
this.createAddPropertyRoute();
102106
this.#propertyStructureHelper.setContainerId(value);
103-
this.#addPropertyModal.setUniquePathValue('container-id', value === null ? 'root' : value);
107+
this.#addPropertyModal?.setUniquePathValue('container-id', value === null ? 'root' : value);
104108
this.requestUpdate('containerId', oldValue);
105109
}
106110

107-
#addPropertyModal: UmbModalRouteRegistrationController;
111+
#addPropertyModal?: UmbModalRouteRegistrationController;
108112

109113
#propertyStructureHelper = new UmbContentTypePropertyStructureHelper<UmbContentTypeModel>(this);
110114

@@ -118,7 +122,7 @@ export class UmbContentTypeDesignEditorPropertiesElement extends UmbLitElement {
118122
private _ownerContentType?: UmbContentTypeModel;
119123

120124
@state()
121-
private _modalRouteBuilderNewProperty?: UmbModalRouteBuilder;
125+
private _newPropertyPath?: string;
122126

123127
@state()
124128
private _sortModeActive?: boolean;
@@ -158,11 +162,14 @@ export class UmbContentTypeDesignEditorPropertiesElement extends UmbLitElement {
158162
this._propertyStructure = propertyStructure;
159163
this.#sorter.setModel(this._propertyStructure);
160164
});
165+
}
161166

167+
createAddPropertyRoute() {
162168
// Note: Route for adding a new property
169+
this.#addPropertyModal?.destroy();
163170
this.#addPropertyModal = new UmbModalRouteRegistrationController(this, UMB_PROPERTY_TYPE_WORKSPACE_MODAL)
164171
.addUniquePaths(['container-id'])
165-
.addAdditionalPath('add-property/:sortOrder')
172+
.addAdditionalPath('add-property')
166173
.onSetup(async (params) => {
167174
// TODO: Make a onInit promise, that can be awaited here.
168175
if (!this._ownerContentType || this._containerId === undefined) return false;
@@ -179,7 +186,9 @@ export class UmbContentTypeDesignEditorPropertiesElement extends UmbLitElement {
179186
return { data: { contentTypeUnique: this._ownerContentType.unique, preset } };
180187
})
181188
.observeRouteBuilder((routeBuilder) => {
182-
this._modalRouteBuilderNewProperty = routeBuilder;
189+
this._newPropertyPath =
190+
routeBuilder({}) +
191+
UMB_CREATE_PROPERTY_TYPE_WORKSPACE_PATH_PATTERN.generateLocal({ containerUnique: this._containerId! });
183192
});
184193
}
185194

@@ -209,7 +218,7 @@ export class UmbContentTypeDesignEditorPropertiesElement extends UmbLitElement {
209218
() => html`
210219
<uui-button
211220
id="btn-add"
212-
href=${ifDefined(this._modalRouteBuilderNewProperty?.({ sortOrder: -1 }))}
221+
href=${ifDefined(this._newPropertyPath)}
213222
label=${this.localize.term('contentTypeEditor_addProperty')}
214223
look="placeholder"></uui-button>
215224
`,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export const UMB_PROPERTY_TYPE_WORKSPACE_ALIAS = 'Umb.Workspace.PropertyType';
2+
export const UMB_PROPERTY_TYPE_ENTITY_TYPE = 'property-type';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './property-type-workspace.context-token.js';
22
export * from './property-type-workspace.modal-token.js';
3+
export * from './paths.js';

src/packages/core/property-type/workspace/manifests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { UMB_PROPERTY_TYPE_WORKSPACE_ALIAS } from './constants.js';
1+
import { UMB_PROPERTY_TYPE_ENTITY_TYPE, UMB_PROPERTY_TYPE_WORKSPACE_ALIAS } from './constants.js';
22
import { UmbSubmitWorkspaceAction } from '@umbraco-cms/backoffice/workspace';
33
import type { ManifestTypes } from '@umbraco-cms/backoffice/extension-registry';
44

@@ -10,7 +10,7 @@ export const manifests: Array<ManifestTypes> = [
1010
alias: UMB_PROPERTY_TYPE_WORKSPACE_ALIAS,
1111
api: () => import('./property-type-workspace.context.js'),
1212
meta: {
13-
entityType: 'property-type',
13+
entityType: UMB_PROPERTY_TYPE_ENTITY_TYPE,
1414
},
1515
},
1616
{
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { UmbPathPattern } from '@umbraco-cms/backoffice/router';
2+
import { UMB_PROPERTY_TYPE_ENTITY_TYPE } from './constants';
3+
import { UMB_WORKSPACE_PATH_PATTERN } from '@umbraco-cms/backoffice/workspace';
4+
import { UMB_SETTINGS_SECTION_PATHNAME } from '@umbraco-cms/backoffice/settings';
5+
6+
export const UMB_PROPERTY_TYPE_WORKSPACE_PATH = UMB_WORKSPACE_PATH_PATTERN.generateAbsolute({
7+
sectionName: UMB_SETTINGS_SECTION_PATHNAME,
8+
entityType: UMB_PROPERTY_TYPE_ENTITY_TYPE,
9+
});
10+
11+
export const UMB_CREATE_PROPERTY_TYPE_WORKSPACE_PATH_PATTERN = new UmbPathPattern<{
12+
containerUnique: string;
13+
}>('create/:containerUnique', UMB_PROPERTY_TYPE_WORKSPACE_PATH);
14+
15+
export const UMB_EDIT_PROPERTY_TYPE_WORKSPACE_PATH_PATTERN = new UmbPathPattern<{ unique: string }>('edit/:unique');

src/packages/core/property-type/workspace/property-type-workspace-editor.element.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,9 @@ import { UMB_PROPERTY_TYPE_WORKSPACE_CONTEXT } from './property-type-workspace.c
22
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
33
import { customElement, css, html, state, property } from '@umbraco-cms/backoffice/external/lit';
44
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
5-
import { UmbRepositoryItemsManager } from '@umbraco-cms/backoffice/repository';
6-
import type { UmbDocumentTypeItemModel } from '@umbraco-cms/backoffice/document-type';
7-
import { UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS } from '@umbraco-cms/backoffice/document-type';
8-
95
@customElement('umb-property-type-workspace-editor')
106
export class UmbPropertyTypeWorkspaceEditorElement extends UmbLitElement {
117
//
12-
#itemManager = new UmbRepositoryItemsManager<UmbDocumentTypeItemModel>(
13-
this,
14-
UMB_DOCUMENT_TYPE_ITEM_REPOSITORY_ALIAS,
15-
(x) => x.unique,
16-
);
17-
188
#workspaceContext?: typeof UMB_PROPERTY_TYPE_WORKSPACE_CONTEXT.TYPE;
199

2010
@state()
@@ -26,8 +16,11 @@ export class UmbPropertyTypeWorkspaceEditorElement extends UmbLitElement {
2616
constructor() {
2717
super();
2818

29-
this.consumeContext(UMB_PROPERTY_TYPE_WORKSPACE_CONTEXT, (instance) => {
30-
this.#workspaceContext = instance;
19+
this.consumeContext(UMB_PROPERTY_TYPE_WORKSPACE_CONTEXT, (context) => {
20+
this.#workspaceContext = context;
21+
this.observe(context.name, (name) => {
22+
this._name = name;
23+
});
3124
this.#workspaceContext?.createPropertyDatasetContext(this);
3225
});
3326
}

src/packages/core/property-type/workspace/property-type-workspace.modal-token.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { UmbWorkspaceModalData, UmbWorkspaceModalValue } from '@umbraco-cms/backoffice/modal';
22
import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
3+
import { UMB_PROPERTY_TYPE_ENTITY_TYPE } from './constants';
34

45
export interface UmbPropertyTypeWorkspaceData extends UmbWorkspaceModalData {
56
contentTypeUnique: string;
@@ -17,7 +18,7 @@ export const UMB_PROPERTY_TYPE_WORKSPACE_MODAL = new UmbModalToken<
1718
type: 'sidebar',
1819
size: 'small',
1920
},
20-
data: { entityType: 'property-type', preset: {}, contentTypeUnique: undefined as unknown as string },
21+
data: { entityType: UMB_PROPERTY_TYPE_ENTITY_TYPE, preset: {}, contentTypeUnique: undefined as unknown as string },
2122
},
2223
// Recast the type, so the entityType data prop is not required:
2324
) as UmbModalToken<Omit<UmbWorkspaceModalData, 'entityType'>, UmbWorkspaceModalValue>;

src/packages/core/property-type/workspace/views/settings/property-workspace-view-settings.element.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export class UmbPropertyTypeWorkspaceViewSettingsElement extends UmbLitElement i
170170
override render() {
171171
return this._data
172172
? html`
173-
<uui-box>
173+
<uui-box class="uui-text">
174174
<div class="container">
175175
<!-- TODO: Align styling across this and the property of document type workspace editor, or consider if this can go away for a different UX flow -->
176176
<uui-input
@@ -331,9 +331,7 @@ export class UmbPropertyTypeWorkspaceViewSettingsElement extends UmbLitElement i
331331
UmbTextStyles,
332332
css`
333333
:host {
334-
color: var(--uui-color-text);
335-
}
336-
#content {
334+
display: block;
337335
padding: var(--uui-size-layout-1);
338336
}
339337
#alias-input,

0 commit comments

Comments
 (0)