Property type: Vary in the same way as the owner Document Type (#20751)
set new property type preset to vary if document type varies
This commit is contained in:
@@ -137,7 +137,7 @@ export class UmbContentTypeDesignEditorPropertiesElement extends UmbLitElement {
|
|||||||
public set containerId(value: string | null | undefined) {
|
public set containerId(value: string | null | undefined) {
|
||||||
if (value === this._containerId) return;
|
if (value === this._containerId) return;
|
||||||
this._containerId = value;
|
this._containerId = value;
|
||||||
this.createPropertyTypeWorkspaceRoutes();
|
this.#createPropertyTypeWorkspaceRoutes();
|
||||||
this.#propertyStructureHelper.setContainerId(value);
|
this.#propertyStructureHelper.setContainerId(value);
|
||||||
this.#addPropertyModal?.setUniquePathValue('container-id', value === null ? 'root' : value);
|
this.#addPropertyModal?.setUniquePathValue('container-id', value === null ? 'root' : value);
|
||||||
this.#editPropertyModal?.setUniquePathValue('container-id', value === null ? 'root' : value);
|
this.#editPropertyModal?.setUniquePathValue('container-id', value === null ? 'root' : value);
|
||||||
@@ -153,6 +153,12 @@ export class UmbContentTypeDesignEditorPropertiesElement extends UmbLitElement {
|
|||||||
>;
|
>;
|
||||||
|
|
||||||
#propertyStructureHelper = new UmbContentTypePropertyStructureHelper<UmbContentTypeModel>(this);
|
#propertyStructureHelper = new UmbContentTypePropertyStructureHelper<UmbContentTypeModel>(this);
|
||||||
|
#initResolver?: () => void;
|
||||||
|
#initReject?: (reason?: any) => void;
|
||||||
|
#init = new Promise<void>((resolve, reject) => {
|
||||||
|
this.#initResolver = resolve;
|
||||||
|
this.#initReject = reject;
|
||||||
|
});
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
editContentTypePath?: string;
|
editContentTypePath?: string;
|
||||||
@@ -199,22 +205,34 @@ export class UmbContentTypeDesignEditorPropertiesElement extends UmbLitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._ownerContentTypeUnique = workspaceContext?.structure.getOwnerContentTypeUnique();
|
this._ownerContentTypeUnique = workspaceContext?.structure.getOwnerContentTypeUnique();
|
||||||
this.createPropertyTypeWorkspaceRoutes();
|
this.#createPropertyTypeWorkspaceRoutes();
|
||||||
|
|
||||||
this.observe(
|
const varyByCulturePromise =
|
||||||
workspaceContext?.variesByCulture,
|
this.observe(
|
||||||
(variesByCulture) => {
|
workspaceContext?.variesByCulture,
|
||||||
this._ownerContentTypeVariesByCulture = variesByCulture;
|
(variesByCulture) => {
|
||||||
},
|
this._ownerContentTypeVariesByCulture = variesByCulture;
|
||||||
'observeOwnerVariesByCulture',
|
},
|
||||||
);
|
'observeOwnerVariesByCulture',
|
||||||
this.observe(
|
)?.asPromise() ?? Promise.reject();
|
||||||
workspaceContext?.variesBySegment,
|
const varyBySegmentPromise =
|
||||||
(variesBySegment) => {
|
this.observe(
|
||||||
this._ownerContentTypeVariesBySegment = variesBySegment;
|
workspaceContext?.variesBySegment,
|
||||||
},
|
(variesBySegment) => {
|
||||||
'observeOwnerVariesBySegment',
|
this._ownerContentTypeVariesBySegment = variesBySegment;
|
||||||
);
|
},
|
||||||
|
'observeOwnerVariesBySegment',
|
||||||
|
)?.asPromise() ?? Promise.reject();
|
||||||
|
|
||||||
|
if (this.#initResolver) {
|
||||||
|
Promise.all([varyByCulturePromise, varyBySegmentPromise])
|
||||||
|
.then(() => {
|
||||||
|
this.#initResolver?.();
|
||||||
|
this.#initResolver = undefined;
|
||||||
|
this.#initReject = undefined;
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.observe(this.#propertyStructureHelper.propertyStructure, (propertyStructure) => {
|
this.observe(this.#propertyStructureHelper.propertyStructure, (propertyStructure) => {
|
||||||
this._properties = propertyStructure;
|
this._properties = propertyStructure;
|
||||||
@@ -222,7 +240,13 @@ export class UmbContentTypeDesignEditorPropertiesElement extends UmbLitElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createPropertyTypeWorkspaceRoutes() {
|
override disconnectedCallback(): void {
|
||||||
|
super.disconnectedCallback();
|
||||||
|
this.#initReject?.(new Error('Component disconnected'));
|
||||||
|
}
|
||||||
|
|
||||||
|
async #createPropertyTypeWorkspaceRoutes() {
|
||||||
|
await this.#init;
|
||||||
if (!this._ownerContentTypeUnique || this._containerId === undefined) return;
|
if (!this._ownerContentTypeUnique || this._containerId === undefined) return;
|
||||||
|
|
||||||
// Note: Route for adding a new property
|
// Note: Route for adding a new property
|
||||||
@@ -247,6 +271,12 @@ export class UmbContentTypeDesignEditorPropertiesElement extends UmbLitElement {
|
|||||||
}
|
}
|
||||||
preset.sortOrder = sortOrderInt;
|
preset.sortOrder = sortOrderInt;
|
||||||
}
|
}
|
||||||
|
if (this._ownerContentTypeVariesByCulture) {
|
||||||
|
preset.variesByCulture = true;
|
||||||
|
}
|
||||||
|
if (this._ownerContentTypeVariesBySegment) {
|
||||||
|
preset.variesBySegment = true;
|
||||||
|
}
|
||||||
return { data: { contentTypeUnique: this._ownerContentTypeUnique, preset: preset } };
|
return { data: { contentTypeUnique: this._ownerContentTypeUnique, preset: preset } };
|
||||||
})
|
})
|
||||||
.observeRouteBuilder((routeBuilder) => {
|
.observeRouteBuilder((routeBuilder) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user