rename to content type + use workspace entity type
This commit is contained in:
@@ -3,13 +3,13 @@ import {
|
||||
UmbPropertyTypeWorkspaceContext,
|
||||
} from './property-settings-modal.context.js';
|
||||
import type { UmbPropertySettingsModalData, UmbPropertySettingsModalValue } from './property-settings-modal.token.js';
|
||||
import { UMB_DOCUMENT_TYPE_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/document-type';
|
||||
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
|
||||
import type { UUIBooleanInputEvent, UUIInputEvent, UUISelectEvent } from '@umbraco-cms/backoffice/external/uui';
|
||||
import type { PropertyValueMap } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { css, html, nothing, customElement, state, ifDefined } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { css, html, nothing, customElement, state } from '@umbraco-cms/backoffice/external/lit';
|
||||
import { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal';
|
||||
import { generateAlias } from '@umbraco-cms/backoffice/utils';
|
||||
import { UMB_CONTENT_TYPE_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/content-type';
|
||||
// TODO: Could base take a token to get its types?.
|
||||
@customElement('umb-property-settings-modal')
|
||||
export class UmbPropertySettingsModalElement extends UmbModalBaseElement<
|
||||
@@ -52,19 +52,19 @@ export class UmbPropertySettingsModalElement extends UmbModalBaseElement<
|
||||
#context = new UmbPropertyTypeWorkspaceContext(this);
|
||||
|
||||
@state()
|
||||
private _documentVariesByCulture?: boolean;
|
||||
private _contentTypeVariesByCulture?: boolean;
|
||||
|
||||
@state()
|
||||
private _documentVariesBySegment?: boolean;
|
||||
private _contentTypeVariesBySegment?: boolean;
|
||||
|
||||
connectedCallback(): void {
|
||||
super.connectedCallback();
|
||||
|
||||
this.consumeContext(UMB_DOCUMENT_TYPE_WORKSPACE_CONTEXT, (instance) => {
|
||||
if (!this.data?.documentTypeId) return;
|
||||
this.consumeContext(UMB_CONTENT_TYPE_WORKSPACE_CONTEXT, (instance) => {
|
||||
if (!this.data?.contentTypeId) return;
|
||||
|
||||
this.observe(instance.variesByCulture, (variesByCulture) => (this._documentVariesByCulture = variesByCulture));
|
||||
this.observe(instance.variesBySegment, (variesBySegment) => (this._documentVariesBySegment = variesBySegment));
|
||||
this.observe(instance.variesByCulture, (variesByCulture) => (this._contentTypeVariesByCulture = variesByCulture));
|
||||
this.observe(instance.variesBySegment, (variesBySegment) => (this._contentTypeVariesBySegment = variesBySegment));
|
||||
}).skipHost();
|
||||
|
||||
this._originalPropertyData = this.value;
|
||||
@@ -362,10 +362,10 @@ export class UmbPropertySettingsModalElement extends UmbModalBaseElement<
|
||||
}
|
||||
|
||||
#renderVariationControls() {
|
||||
return this._documentVariesByCulture || this._documentVariesBySegment
|
||||
return this._contentTypeVariesByCulture || this._contentTypeVariesBySegment
|
||||
? html` <div class="container">
|
||||
<b>Variation</b>
|
||||
${this._documentVariesByCulture ? this.#renderVaryByCulture() : ''}
|
||||
${this._contentTypeVariesByCulture ? this.#renderVaryByCulture() : ''}
|
||||
</div>
|
||||
<hr />`
|
||||
: '';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { UmbModalToken } from '../../../modal/token/modal-token.js';
|
||||
import type { UmbPropertyTypeModel, UmbPropertyTypeScaffoldModel } from '@umbraco-cms/backoffice/content-type';
|
||||
|
||||
export type UmbPropertySettingsModalData = {
|
||||
documentTypeId: string;
|
||||
contentTypeId: string;
|
||||
};
|
||||
export type UmbPropertySettingsModalValue = UmbPropertyTypeModel | UmbPropertyTypeScaffoldModel;
|
||||
|
||||
|
||||
@@ -14,7 +14,11 @@ import {
|
||||
UMB_PROPERTY_SETTINGS_MODAL,
|
||||
} from '@umbraco-cms/backoffice/content-type';
|
||||
import { type UmbSorterConfig, UmbSorterController } from '@umbraco-cms/backoffice/sorter';
|
||||
import { type UmbModalRouteBuilder, UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/modal';
|
||||
import {
|
||||
type UmbModalRouteBuilder,
|
||||
UmbModalRouteRegistrationController,
|
||||
UMB_WORKSPACE_MODAL,
|
||||
} from '@umbraco-cms/backoffice/modal';
|
||||
|
||||
const SORTER_CONFIG: UmbSorterConfig<UmbPropertyTypeModel, UmbContentTypeWorkspacePropertyElement> = {
|
||||
getUniqueOfElement: (element) => {
|
||||
@@ -23,7 +27,7 @@ const SORTER_CONFIG: UmbSorterConfig<UmbPropertyTypeModel, UmbContentTypeWorkspa
|
||||
getUniqueOfModel: (modelEntry) => {
|
||||
return modelEntry.id;
|
||||
},
|
||||
identifier: 'document-type-property-sorter',
|
||||
identifier: 'content-type-property-sorter',
|
||||
itemSelector: 'umb-content-type-workspace-view-edit-property',
|
||||
//disabledItemSelector: '[inherited]',
|
||||
//TODO: Set the property list (sorter wrapper) to inherited, if its inherited
|
||||
@@ -115,20 +119,24 @@ export class UmbContentTypeWorkspaceViewEditPropertiesElement extends UmbLitElem
|
||||
}
|
||||
|
||||
#addPropertyModal: UmbModalRouteRegistrationController;
|
||||
#workspaceModal?: UmbModalRouteRegistrationController;
|
||||
|
||||
_propertyStructureHelper = new UmbContentTypePropertyStructureHelper<UmbContentTypeModel>(this);
|
||||
|
||||
@state()
|
||||
_propertyStructure: Array<UmbPropertyTypeModel> = [];
|
||||
private _propertyStructure: Array<UmbPropertyTypeModel> = [];
|
||||
|
||||
@state()
|
||||
_ownerDocumentType?: UmbContentTypeModel;
|
||||
private _ownerContentType?: UmbContentTypeModel;
|
||||
|
||||
@state()
|
||||
protected _modalRouteBuilderNewProperty?: UmbModalRouteBuilder;
|
||||
private _modalRouteBuilderNewProperty?: UmbModalRouteBuilder;
|
||||
|
||||
@state()
|
||||
_sortModeActive?: boolean;
|
||||
private _editContentTypePath?: string;
|
||||
|
||||
@state()
|
||||
private _sortModeActive?: boolean;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@@ -138,6 +146,18 @@ export class UmbContentTypeWorkspaceViewEditPropertiesElement extends UmbLitElem
|
||||
this.consumeContext(UMB_CONTENT_TYPE_WORKSPACE_CONTEXT, async (workspaceContext) => {
|
||||
this._propertyStructureHelper.setStructureManager(workspaceContext.structure);
|
||||
|
||||
const entityType = workspaceContext.getEntityType();
|
||||
|
||||
this.#workspaceModal?.destroy();
|
||||
this.#workspaceModal = new UmbModalRouteRegistrationController(this, UMB_WORKSPACE_MODAL)
|
||||
.addAdditionalPath(entityType)
|
||||
.onSetup(async () => {
|
||||
return { data: { entityType: entityType, preset: {} } };
|
||||
})
|
||||
.observeRouteBuilder((routeBuilder) => {
|
||||
this._editContentTypePath = routeBuilder({});
|
||||
});
|
||||
|
||||
this.observe(
|
||||
workspaceContext.isSorting,
|
||||
(isSorting) => {
|
||||
@@ -153,10 +173,10 @@ export class UmbContentTypeWorkspaceViewEditPropertiesElement extends UmbLitElem
|
||||
const docTypeObservable = workspaceContext.structure.ownerContentType;
|
||||
this.observe(
|
||||
docTypeObservable,
|
||||
(document) => {
|
||||
this._ownerDocumentType = document;
|
||||
(contentType) => {
|
||||
this._ownerContentType = contentType;
|
||||
},
|
||||
'observeOwnerDocumentType',
|
||||
'observeOwnerContentType',
|
||||
);
|
||||
});
|
||||
this.observe(this._propertyStructureHelper.propertyStructure, (propertyStructure) => {
|
||||
@@ -169,7 +189,7 @@ export class UmbContentTypeWorkspaceViewEditPropertiesElement extends UmbLitElem
|
||||
.addUniquePaths(['container-id'])
|
||||
.addAdditionalPath('add-property/:sortOrder')
|
||||
.onSetup(async (params) => {
|
||||
if (!this._ownerDocumentType || !this._containerId) return false;
|
||||
if (!this._ownerContentType || !this._containerId) return false;
|
||||
|
||||
const propertyData = await this._propertyStructureHelper.createPropertyScaffold(this._containerId);
|
||||
if (propertyData === undefined) return false;
|
||||
@@ -181,10 +201,10 @@ export class UmbContentTypeWorkspaceViewEditPropertiesElement extends UmbLitElem
|
||||
}
|
||||
propertyData.sortOrder = sortOrderInt + 1;
|
||||
}
|
||||
return { data: { documentTypeId: this._ownerDocumentType.unique }, value: propertyData };
|
||||
return { data: { contentTypeId: this._ownerContentType.unique }, value: propertyData };
|
||||
})
|
||||
.onSubmit(async (value) => {
|
||||
if (!this._ownerDocumentType) return false;
|
||||
if (!this._ownerContentType) return false;
|
||||
// TODO: The model requires a data-type to be set, we cheat currently. But this should be re-though when we implement validation(As we most likely will have to com up with partial models for the runtime model.) [NL]
|
||||
this._propertyStructureHelper.insertProperty(value as UmbPropertyTypeModel);
|
||||
return true;
|
||||
@@ -195,7 +215,7 @@ export class UmbContentTypeWorkspaceViewEditPropertiesElement extends UmbLitElem
|
||||
}
|
||||
|
||||
render() {
|
||||
return this._ownerDocumentType
|
||||
return this._ownerContentType
|
||||
? html`
|
||||
<div id="property-list" ?sort-mode-active=${this._sortModeActive}>
|
||||
${repeat(
|
||||
@@ -205,8 +225,9 @@ export class UmbContentTypeWorkspaceViewEditPropertiesElement extends UmbLitElem
|
||||
return html`
|
||||
<umb-content-type-workspace-view-edit-property
|
||||
data-umb-property-id=${property.id}
|
||||
owner-document-type-id=${ifDefined(this._ownerDocumentType!.unique)}
|
||||
owner-document-type-name=${ifDefined(this._ownerDocumentType!.name)}
|
||||
owner-content-type-id=${ifDefined(this._ownerContentType!.unique)}
|
||||
owner-content-type-name=${ifDefined(this._ownerContentType!.name)}
|
||||
.editContentTypePath=${this._editContentTypePath}
|
||||
?inherited=${property.container?.id !== this.containerId}
|
||||
?sort-mode-active=${this._sortModeActive}
|
||||
.propertyStructureHelper=${this._propertyStructureHelper}
|
||||
|
||||
@@ -2,11 +2,7 @@ import { UmbDataTypeDetailRepository } from '@umbraco-cms/backoffice/data-type';
|
||||
import type { UUIInputElement } from '@umbraco-cms/backoffice/external/uui';
|
||||
import { UUIInputEvent } from '@umbraco-cms/backoffice/external/uui';
|
||||
import { css, html, customElement, property, state, ifDefined, nothing } from '@umbraco-cms/backoffice/external/lit';
|
||||
import {
|
||||
UMB_WORKSPACE_MODAL,
|
||||
UmbModalRouteRegistrationController,
|
||||
umbConfirmModal,
|
||||
} from '@umbraco-cms/backoffice/modal';
|
||||
import { UmbModalRouteRegistrationController, umbConfirmModal } from '@umbraco-cms/backoffice/modal';
|
||||
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
|
||||
import { generateAlias } from '@umbraco-cms/backoffice/utils';
|
||||
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
|
||||
@@ -29,7 +25,6 @@ export class UmbContentTypeWorkspacePropertyElement extends UmbLitElement {
|
||||
#dataTypeDetailRepository = new UmbDataTypeDetailRepository(this);
|
||||
|
||||
#settingsModal;
|
||||
#workspaceModal;
|
||||
|
||||
@property({ attribute: false })
|
||||
public set propertyStructureHelper(value: UmbContentTypePropertyStructureHelper<UmbContentTypeModel> | undefined) {
|
||||
@@ -57,7 +52,6 @@ export class UmbContentTypeWorkspacePropertyElement extends UmbLitElement {
|
||||
this._property = value;
|
||||
this.#checkInherited();
|
||||
this.#settingsModal.setUniquePathValue('propertyId', value?.id?.toString());
|
||||
//this.#workspaceModal.setUniquePathValue('propertyId', value?.id?.toString());
|
||||
this.setDataType(this._property?.dataType?.unique);
|
||||
this.requestUpdate('property', oldValue);
|
||||
}
|
||||
@@ -76,18 +70,18 @@ export class UmbContentTypeWorkspacePropertyElement extends UmbLitElement {
|
||||
@property({ type: Boolean, reflect: true, attribute: 'sort-mode-active' })
|
||||
public sortModeActive = false;
|
||||
|
||||
@property({ type: String, attribute: 'owner-document-type-id' })
|
||||
public ownerDocumentTypeId?: string;
|
||||
@property({ type: String, attribute: 'owner-content-type-id' })
|
||||
public ownerContentTypeId?: string;
|
||||
|
||||
@property({ type: String, attribute: 'owner-document-type-name' })
|
||||
public ownerDocumentTypeName?: string;
|
||||
@property({ type: String, attribute: 'owner-content-type-name' })
|
||||
public ownerContentTypeName?: string;
|
||||
|
||||
@property({ type: String, attribute: 'edit-content-type-path' })
|
||||
public editContentTypePath?: string;
|
||||
|
||||
@state()
|
||||
protected _modalRoute?: string;
|
||||
|
||||
@state()
|
||||
protected _editDocumentTypePath?: string;
|
||||
|
||||
@state()
|
||||
private _dataTypeName?: string;
|
||||
|
||||
@@ -99,11 +93,11 @@ export class UmbContentTypeWorkspacePropertyElement extends UmbLitElement {
|
||||
this.#settingsModal = new UmbModalRouteRegistrationController(this, UMB_PROPERTY_SETTINGS_MODAL)
|
||||
.addUniquePaths(['propertyId'])
|
||||
.onSetup(() => {
|
||||
const documentTypeId = this.ownerDocumentTypeId;
|
||||
if (documentTypeId === undefined) return false;
|
||||
const id = this.ownerContentTypeId;
|
||||
if (id === undefined) return false;
|
||||
const propertyData = this.property;
|
||||
if (propertyData === undefined) return false;
|
||||
return { data: { documentTypeId }, value: propertyData };
|
||||
return { data: { contentTypeId: id }, value: propertyData };
|
||||
})
|
||||
.onSubmit((result) => {
|
||||
this._partialUpdate(result as UmbPropertyTypeModel);
|
||||
@@ -111,16 +105,6 @@ export class UmbContentTypeWorkspacePropertyElement extends UmbLitElement {
|
||||
.observeRouteBuilder((routeBuilder) => {
|
||||
this._modalRoute = routeBuilder(null);
|
||||
});
|
||||
|
||||
this.#workspaceModal = new UmbModalRouteRegistrationController(this, UMB_WORKSPACE_MODAL)
|
||||
//.addUniquePaths(['propertyId'])
|
||||
.addAdditionalPath('document-type')
|
||||
.onSetup(() => {
|
||||
return { data: { entityType: 'document-type', preset: {} } };
|
||||
})
|
||||
.observeRouteBuilder((routeBuilder) => {
|
||||
this._editDocumentTypePath = routeBuilder({});
|
||||
});
|
||||
}
|
||||
|
||||
async #checkInherited() {
|
||||
@@ -224,8 +208,8 @@ export class UmbContentTypeWorkspacePropertyElement extends UmbLitElement {
|
||||
<uui-icon name="icon-merge"></uui-icon>
|
||||
<span
|
||||
>${this.localize.term('contentTypeEditor_inheritedFrom')}
|
||||
<a href=${this._editDocumentTypePath + 'edit/' + this.ownerDocumentTypeId}>
|
||||
${this.ownerDocumentTypeName ?? '??'}
|
||||
<a href=${this.editContentTypePath + 'edit/' + this.ownerContentTypeId}>
|
||||
${this.ownerContentTypeName ?? '??'}
|
||||
</a>
|
||||
</span>
|
||||
</uui-tag>
|
||||
|
||||
@@ -15,7 +15,7 @@ import { type UmbSorterConfig, UmbSorterController } from '@umbraco-cms/backoffi
|
||||
const SORTER_CONFIG: UmbSorterConfig<UmbPropertyTypeContainerModel, UmbContentTypeWorkspaceViewEditGroupElement> = {
|
||||
getUniqueOfElement: (element) => element.group?.id,
|
||||
getUniqueOfModel: (modelEntry) => modelEntry.id,
|
||||
identifier: 'document-type-container-sorter',
|
||||
identifier: 'content-type-container-sorter',
|
||||
itemSelector: '.container-handle',
|
||||
containerSelector: '.container-list',
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ export class UmbContentTypeWorkspaceViewEditElement extends UmbLitElement implem
|
||||
#sorter = new UmbSorterController<PropertyTypeContainerModelBaseModel, UUITabElement>(this, {
|
||||
getUniqueOfElement: (element) => element.getAttribute('data-umb-tabs-id'),
|
||||
getUniqueOfModel: (tab) => tab.id,
|
||||
identifier: 'document-type-tabs-sorter',
|
||||
identifier: 'content-type-tabs-sorter',
|
||||
itemSelector: 'uui-tab',
|
||||
containerSelector: 'uui-tab-group',
|
||||
disabledItemSelector: '#root-tab',
|
||||
@@ -285,7 +285,7 @@ export class UmbContentTypeWorkspaceViewEditElement extends UmbLitElement implem
|
||||
tab.id,
|
||||
);
|
||||
|
||||
// Check if it collides with another tab name of this same document-type, if so adjust name:
|
||||
// Check if it collides with another tab name of this same content-type, if so adjust name:
|
||||
if (changedName) {
|
||||
newName = changedName;
|
||||
(event.target as HTMLInputElement).value = newName;
|
||||
|
||||
@@ -169,7 +169,7 @@ export class UmbMemberTypeWorkspaceViewEditPropertiesElement extends UmbLitEleme
|
||||
if (memberTypeId === undefined) return false;
|
||||
const propertyData = await this._propertyStructureHelper.createPropertyScaffold(this._containerId);
|
||||
if (propertyData === undefined) return false;
|
||||
return { data: { documentTypeId: memberTypeId }, value: propertyData };
|
||||
return { data: { contentTypeId: memberTypeId }, value: propertyData };
|
||||
})
|
||||
.onSubmit((value) => {
|
||||
if (!value.dataType) {
|
||||
|
||||
@@ -95,7 +95,7 @@ export class UmbMemberTypeWorkspacePropertyElement extends UmbLitElement {
|
||||
if (memberTypeId === undefined) return false;
|
||||
const propertyData = this.property;
|
||||
if (propertyData === undefined) return false;
|
||||
return { data: { documentTypeId: memberTypeId }, value: propertyData };
|
||||
return { data: { contentTypeId: memberTypeId }, value: propertyData };
|
||||
})
|
||||
.onSubmit((result) => {
|
||||
if (!result.dataType) {
|
||||
|
||||
Reference in New Issue
Block a user