diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content/property-dataset-context/content-property-dataset.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content/property-dataset-context/content-property-dataset.context.ts index 7fb54f6aff..6bbc2ab2c8 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/content/property-dataset-context/content-property-dataset.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content/property-dataset-context/content-property-dataset.context.ts @@ -4,7 +4,7 @@ import { UMB_PROPERTY_DATASET_CONTEXT } from '@umbraco-cms/backoffice/property'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import { UmbContextBase } from '@umbraco-cms/backoffice/class-api'; import { type Observable, map } from '@umbraco-cms/backoffice/external/rxjs'; -import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api'; +import { UmbBooleanState, UmbObjectState } from '@umbraco-cms/backoffice/observable-api'; import type { UmbVariantModel } from '@umbraco-cms/backoffice/variant'; import { UmbVariantId } from '@umbraco-cms/backoffice/variant'; import type { UmbContentTypeModel, UmbPropertyTypeModel } from '@umbraco-cms/backoffice/content-type'; @@ -30,6 +30,9 @@ export class UmbContentPropertyDatasetContext< culture = this.#currentVariant.asObservablePart((x) => x?.culture); segment = this.#currentVariant.asObservablePart((x) => x?.segment); + #currentVariantCultureIsReadOnly = new UmbBooleanState(false); + public currentVariantCultureIsReadOnly = this.#currentVariantCultureIsReadOnly.asObservable(); + getEntityType(): string { return this.#workspace.getEntityType(); } @@ -46,6 +49,10 @@ export class UmbContentPropertyDatasetContext< return this.#workspace.getVariant(this.#variantId); } + getCurrentVariantCultureIsReadOnly() { + return this.#currentVariantCultureIsReadOnly.getValue(); + } + constructor( host: UmbControllerHost, workspace: UmbContentWorkspaceContext, @@ -64,6 +71,18 @@ export class UmbContentPropertyDatasetContext< }, '_observeActiveVariant', ); + + this.observe( + this.#workspace.readOnlyState.states, + (states) => { + const isReadOnly = states.some( + (state) => state.unique.startsWith('UMB_CULTURE_') && state.variantId.equal(this.#variantId), + ); + + this.#currentVariantCultureIsReadOnly.setValue(isReadOnly); + }, + 'umbObserveReadOnlyStates', + ); } #createPropertyVariantId(property: UmbPropertyTypeModel) { diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property/property-dataset/property-dataset-context.interface.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property/property-dataset/property-dataset-context.interface.ts index 92527fa278..21359e8c57 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property/property-dataset/property-dataset-context.interface.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property/property-dataset/property-dataset-context.interface.ts @@ -25,6 +25,9 @@ export interface UmbPropertyDatasetContext extends UmbContext { getName(): string | undefined; readonly name: Observable; + getCurrentVariantCultureIsReadOnly(): boolean; + readonly currentVariantCultureIsReadOnly: Observable; + // Should it be possible to get the properties as a list of property aliases? //readonly properties: Observable>;