diff --git a/src/Umbraco.Web.UI.Client/src/packages/content/content/workspace/content-detail-workspace-base.ts b/src/Umbraco.Web.UI.Client/src/packages/content/content/workspace/content-detail-workspace-base.ts index ab2082993443..2ca13eea8937 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/content/content/workspace/content-detail-workspace-base.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/content/content/workspace/content-detail-workspace-base.ts @@ -9,6 +9,7 @@ import type { UmbContentCollectionWorkspaceContext } from '../collection/content import type { UmbContentWorkspaceContext } from './content-workspace-context.interface.js'; import { UmbContentDetailValidationPathTranslator } from './content-detail-validation-path-translator.js'; import { UmbContentValidationToHintsManager } from './content-validation-to-hints.manager.js'; +import { UmbContentDetailWorkspaceTypeTransformController } from './content-detail-workspace-type-transform.controller.js'; import { appendToFrozenArray, mergeObservables, @@ -154,6 +155,9 @@ export abstract class UmbContentDetailWorkspaceContextBase< * @internal */ public readonly languages = this.#languages.asObservable(); + getLanguages(): Array { + return this.#languages.getValue(); + } protected readonly _segments = new UmbArrayState([], (x) => x.alias); @@ -178,12 +182,6 @@ export abstract class UmbContentDetailWorkspaceContextBase< #saveModalToken?: UmbModalToken, UmbContentVariantPickerValue>; #contentTypePropertyName: string; - /** - * Cache of property variation settings to detect changes when structure is updated. - * Used to trigger value migration when properties change from invariant to variant or vice versa. - */ - #propertyVariationCache = new Map(); - constructor( host: UmbControllerHost, args: UmbContentDetailWorkspaceContextArgs< @@ -228,6 +226,8 @@ export abstract class UmbContentDetailWorkspaceContextBase< this.view.hints, ); + new UmbContentDetailWorkspaceTypeTransformController(this as any); + this.variantOptions = mergeObservables( [this.variesByCulture, this.variesBySegment, this.variants, this.languages, this._segments.asObservable()], ([variesByCulture, variesBySegment, variants, languages, segments]) => { @@ -385,16 +385,6 @@ export abstract class UmbContentDetailWorkspaceContextBase< null, ); - // Observe property variation changes to trigger value migration when properties change - // from invariant to variant (or vice versa) via Infinite Editing - this.observe( - this.structure.contentTypeProperties, - (properties: Array) => { - this.#handlePropertyVariationChanges(properties); - }, - null, - ); - this.loadLanguages(); } @@ -1109,67 +1099,6 @@ export abstract class UmbContentDetailWorkspaceContextBase< variantId: UmbVariantId, ): UmbContentPropertyDatasetContext; - /** - * Handles property variation changes when the document type is updated via Infinite Editing. - * When a property's variation setting changes (e.g., from shared/invariant to variant or vice versa), - * this method reloads the document to get properly migrated values from the server. - */ - #handlePropertyVariationChanges(properties: Array): void { - // Skip if no current data or if this is initial load - const currentData = this._data.getCurrent(); - if (!currentData || this.#propertyVariationCache.size === 0) { - // Initial load - just populate the cache - for (const property of properties) { - this.#propertyVariationCache.set(property.alias, { - variesByCulture: property.variesByCulture, - variesBySegment: property.variesBySegment, - }); - } - return; - } - - // Check for variation setting changes - let hasChanges = false; - for (const property of properties) { - const cached = this.#propertyVariationCache.get(property.alias); - if (cached) { - if ( - cached.variesByCulture !== property.variesByCulture || - cached.variesBySegment !== property.variesBySegment - ) { - hasChanges = true; - } - } - // Update cache - this.#propertyVariationCache.set(property.alias, { - variesByCulture: property.variesByCulture, - variesBySegment: property.variesBySegment, - }); - } - - // If variation settings changed, reload to get properly migrated values - if (hasChanges) { - this.reload(); - } - } - - /** - * Override reload to process incoming data through the value migration pipeline. - * This ensures property values are properly transformed when variation settings change. - */ - public override async reload(): Promise { - const unique = this.getUnique(); - if (!unique) throw new Error('Unique is not set'); - const { data } = await this._detailRepository!.requestByUnique(unique); - - if (data) { - // Process the data through _processIncomingData to handle value migration - const processedData = await this._processIncomingData(data); - this._data.setPersisted(processedData); - this._data.setCurrent(processedData); - } - } - public override destroy(): void { this.structure.destroy(); this.#languageRepository.destroy(); diff --git a/src/Umbraco.Web.UI.Client/src/packages/content/content/workspace/content-detail-workspace-type-transform.controller.test.ts b/src/Umbraco.Web.UI.Client/src/packages/content/content/workspace/content-detail-workspace-type-transform.controller.test.ts new file mode 100644 index 000000000000..81925d37354b --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/content/content/workspace/content-detail-workspace-type-transform.controller.test.ts @@ -0,0 +1,341 @@ +import { expect } from '@open-wc/testing'; +import { UmbContentDetailWorkspaceTypeTransformController } from './content-detail-workspace-type-transform.controller.js'; +import { customElement } from '@umbraco-cms/backoffice/external/lit'; +import { UmbControllerHostElementMixin } from '@umbraco-cms/backoffice/controller-api'; +import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api'; +import type { UmbPropertyTypeModel } from '@umbraco-cms/backoffice/content-type'; +import type { UmbContentDetailModel } from '../types.js'; +import type { UmbEntityVariantModel } from '@umbraco-cms/backoffice/variant'; +import type { UmbLanguageDetailModel } from '@umbraco-cms/backoffice/language'; + +@customElement('umb-test-workspace-host') +class UmbTestWorkspaceHostElement extends UmbControllerHostElementMixin(HTMLElement) { + #propertyTypesState = new UmbObjectState | undefined>(undefined); + + structure = { + contentTypeProperties: this.#propertyTypesState.asObservable(), + }; + + #data: UmbContentDetailModel | undefined; + #languages: Array = [ + { unique: 'en-US', name: 'English (US)', isDefault: true } as UmbLanguageDetailModel, + { unique: 'da-DK', name: 'Danish', isDefault: false } as UmbLanguageDetailModel, + ]; + + getData(): UmbContentDetailModel | undefined { + return this.#data; + } + + setData(data: UmbContentDetailModel): void { + this.#data = data; + } + + getLanguages(): Array { + return this.#languages; + } + + setPropertyTypes(propertyTypes: Array): void { + this.#propertyTypesState.setValue(propertyTypes); + } +} + +describe('UmbContentDetailWorkspaceTypeTransformController', () => { + let mockWorkspace: UmbTestWorkspaceHostElement; + + beforeEach(() => { + mockWorkspace = new UmbTestWorkspaceHostElement(); + }); + + it('migrates invariant value to variant when property variation changes', async () => { + // Set up initial data with invariant value + mockWorkspace.setData({ + unique: 'test-doc', + values: [ + { + alias: 'testProperty', + value: 'invariant value', + culture: null, + segment: null, + editorAlias: 'test-editor', + }, + ], + } as UmbContentDetailModel); + + // Set initial property types (invariant) + const oldPropertyTypes: Array = [ + { + alias: 'testProperty', + variesByCulture: false, + variesBySegment: false, + } as UmbPropertyTypeModel, + ]; + mockWorkspace.setPropertyTypes(oldPropertyTypes); + + // Create controller - it will observe property type changes + new UmbContentDetailWorkspaceTypeTransformController(mockWorkspace as any); + + // Wait for initial observation + await new Promise((resolve) => setTimeout(resolve, 0)); + + // Change property to vary by culture + const newPropertyTypes: Array = [ + { + alias: 'testProperty', + variesByCulture: true, + variesBySegment: false, + } as UmbPropertyTypeModel, + ]; + mockWorkspace.setPropertyTypes(newPropertyTypes); + + // Wait for observation to trigger + await new Promise((resolve) => setTimeout(resolve, 0)); + + // Check that value was migrated to default culture + const data = mockWorkspace.getData(); + expect(data?.values.length).to.equal(1); + expect(data?.values[0]?.alias).to.equal('testProperty'); + expect(data?.values[0]?.value).to.equal('invariant value'); + expect(data?.values[0]?.culture).to.equal('en-US'); // Default language + expect(data?.values[0]?.segment).to.be.null; + }); + + it('migrates variant value to invariant when property variation changes', async () => { + // Set up initial data with variant values + mockWorkspace.setData({ + unique: 'test-doc', + values: [ + { + alias: 'testProperty', + value: 'en-US value', + culture: 'en-US', + segment: null, + editorAlias: 'test-editor', + }, + { + alias: 'testProperty', + value: 'da-DK value', + culture: 'da-DK', + segment: null, + editorAlias: 'test-editor', + }, + ], + } as UmbContentDetailModel); + + // Set initial property types (variant) + const oldPropertyTypes: Array = [ + { + alias: 'testProperty', + variesByCulture: true, + variesBySegment: false, + } as UmbPropertyTypeModel, + ]; + mockWorkspace.setPropertyTypes(oldPropertyTypes); + + // Create controller + new UmbContentDetailWorkspaceTypeTransformController(mockWorkspace as any); + + // Wait for initial observation + await new Promise((resolve) => setTimeout(resolve, 0)); + + // Change property to be invariant + const newPropertyTypes: Array = [ + { + alias: 'testProperty', + variesByCulture: false, + variesBySegment: false, + } as UmbPropertyTypeModel, + ]; + mockWorkspace.setPropertyTypes(newPropertyTypes); + + // Wait for observation to trigger + await new Promise((resolve) => setTimeout(resolve, 0)); + + // Check that both values were migrated to invariant + const data = mockWorkspace.getData(); + expect(data?.values.length).to.equal(2); + expect(data?.values[0]?.alias).to.equal('testProperty'); + expect(data?.values[0]?.value).to.equal('en-US value'); + expect(data?.values[0]?.culture).to.be.null; + expect(data?.values[1]?.alias).to.equal('testProperty'); + expect(data?.values[1]?.value).to.equal('da-DK value'); + expect(data?.values[1]?.culture).to.be.null; + }); + + it('preserves values during variation change', async () => { + // Set up initial data with invariant value + const originalValue = 'important data'; + mockWorkspace.setData({ + unique: 'test-doc', + values: [ + { + alias: 'testProperty', + value: originalValue, + culture: null, + segment: null, + editorAlias: 'test-editor', + }, + ], + } as UmbContentDetailModel); + + // Set initial property types (invariant) + const oldPropertyTypes: Array = [ + { + alias: 'testProperty', + variesByCulture: false, + variesBySegment: false, + } as UmbPropertyTypeModel, + ]; + mockWorkspace.setPropertyTypes(oldPropertyTypes); + + // Create controller + new UmbContentDetailWorkspaceTypeTransformController(mockWorkspace as any); + + // Wait for initial observation + await new Promise((resolve) => setTimeout(resolve, 0)); + + // Change property to vary by culture + const newPropertyTypes: Array = [ + { + alias: 'testProperty', + variesByCulture: true, + variesBySegment: false, + } as UmbPropertyTypeModel, + ]; + mockWorkspace.setPropertyTypes(newPropertyTypes); + + // Wait for observation to trigger + await new Promise((resolve) => setTimeout(resolve, 0)); + + // Verify the value was preserved + const data = mockWorkspace.getData(); + expect(data?.values[0]?.value).to.equal(originalValue); + }); + + it('does not modify data when variation does not change', async () => { + // Set up initial data + mockWorkspace.setData({ + unique: 'test-doc', + values: [ + { + alias: 'testProperty', + value: 'test value', + culture: null, + segment: null, + editorAlias: 'test-editor', + }, + ], + } as UmbContentDetailModel); + + // Set initial property types (invariant) + const oldPropertyTypes: Array = [ + { + alias: 'testProperty', + variesByCulture: false, + variesBySegment: false, + } as UmbPropertyTypeModel, + ]; + mockWorkspace.setPropertyTypes(oldPropertyTypes); + + // Create controller + new UmbContentDetailWorkspaceTypeTransformController(mockWorkspace as any); + + // Wait for initial observation + await new Promise((resolve) => setTimeout(resolve, 0)); + + // Get reference to original data + const originalData = mockWorkspace.getData(); + + // Update property types but keep variation the same + const newPropertyTypes: Array = [ + { + alias: 'testProperty', + variesByCulture: false, // Still invariant + variesBySegment: false, + } as UmbPropertyTypeModel, + ]; + mockWorkspace.setPropertyTypes(newPropertyTypes); + + // Wait for observation to trigger + await new Promise((resolve) => setTimeout(resolve, 0)); + + // Data should be the same object (not modified) + const currentData = mockWorkspace.getData(); + expect(currentData).to.equal(originalData); + }); + + it('handles multiple properties with different variations', async () => { + // Set up initial data with two properties + mockWorkspace.setData({ + unique: 'test-doc', + values: [ + { + alias: 'property1', + value: 'invariant value', + culture: null, + segment: null, + editorAlias: 'test-editor', + }, + { + alias: 'property2', + value: 'variant value', + culture: 'en-US', + segment: null, + editorAlias: 'test-editor', + }, + ], + } as UmbContentDetailModel); + + // Set initial property types + const oldPropertyTypes: Array = [ + { + alias: 'property1', + variesByCulture: false, + variesBySegment: false, + } as UmbPropertyTypeModel, + { + alias: 'property2', + variesByCulture: true, + variesBySegment: false, + } as UmbPropertyTypeModel, + ]; + mockWorkspace.setPropertyTypes(oldPropertyTypes); + + // Create controller + new UmbContentDetailWorkspaceTypeTransformController(mockWorkspace as any); + + // Wait for initial observation + await new Promise((resolve) => setTimeout(resolve, 0)); + + // Change variations: property1 becomes variant, property2 becomes invariant + const newPropertyTypes: Array = [ + { + alias: 'property1', + variesByCulture: true, // Now variant + variesBySegment: false, + } as UmbPropertyTypeModel, + { + alias: 'property2', + variesByCulture: false, // Now invariant + variesBySegment: false, + } as UmbPropertyTypeModel, + ]; + mockWorkspace.setPropertyTypes(newPropertyTypes); + + // Wait for observation to trigger + await new Promise((resolve) => setTimeout(resolve, 0)); + + // Check that both properties were migrated correctly + const data = mockWorkspace.getData(); + expect(data?.values.length).to.equal(2); + + // Property1: invariant -> variant (should get default culture) + const prop1 = data?.values.find((v) => v.alias === 'property1'); + expect(prop1?.value).to.equal('invariant value'); + expect(prop1?.culture).to.equal('en-US'); + + // Property2: variant -> invariant (should become null culture) + const prop2 = data?.values.find((v) => v.alias === 'property2'); + expect(prop2?.value).to.equal('variant value'); + expect(prop2?.culture).to.be.null; + }); +}); diff --git a/src/Umbraco.Web.UI.Client/src/packages/content/content/workspace/content-detail-workspace-type-transform.controller.ts b/src/Umbraco.Web.UI.Client/src/packages/content/content/workspace/content-detail-workspace-type-transform.controller.ts new file mode 100644 index 000000000000..9c8f3d64fcf4 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/content/content/workspace/content-detail-workspace-type-transform.controller.ts @@ -0,0 +1,107 @@ +import type { UmbContentDetailModel } from '../index.js'; +import type { UmbContentDetailWorkspaceContextBase } from './content-detail-workspace-base.js'; +import type { UmbPropertyTypeModel } from '@umbraco-cms/backoffice/content-type'; +import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api'; +import type { UmbEntityVariantModel } from '@umbraco-cms/backoffice/variant'; + +/** + * @class UmbContentDetailWorkspaceTypeTransformController + * @description - Controller to handle content detail workspace type transformations, such as property variation changes. + */ +export class UmbContentDetailWorkspaceTypeTransformController< + DetailModelType extends UmbContentDetailModel, +> extends UmbControllerBase { + #workspace: UmbContentDetailWorkspaceContextBase; + // Current property types, currently used to detect variation changes: + #propertyTypes?: Array; + + constructor(host: UmbContentDetailWorkspaceContextBase) { + super(host); + + this.#workspace = host; + + // Observe property variation changes to trigger value migration when properties change + // from invariant to variant (or vice versa) via Infinite Editing + this.observe( + host.structure.contentTypeProperties, + (propertyTypes: Array) => { + this.#handlePropertyTypeVariationChanges(this.#propertyTypes, propertyTypes); + this.#propertyTypes = propertyTypes; + }, + null, + ); + } + + async #handlePropertyTypeVariationChanges( + oldPropertyTypes: Array | undefined, + newPropertyTypes: Array | undefined, + ): Promise { + if (!oldPropertyTypes || !newPropertyTypes) { + return; + } + // Skip if no current data or if this is initial load + const currentData = this.#workspace.getData(); + if (!currentData) { + return; + } + + const defaultLanguage = this.#getDefaultLanguage(); + + // To spare a bit of energy we keep awareness of whether this brings any changes: + let hasChanges = false; + const values = currentData.values.map((v) => { + const transformation = this.#transformValueForVariationChange( + v, + oldPropertyTypes, + newPropertyTypes, + defaultLanguage, + ); + if (transformation.changed) { + hasChanges = true; + } + return transformation.value; + }); + + if (hasChanges) { + this.#workspace.setData({ ...currentData, values }); + } + } + + #getDefaultLanguage(): string { + const languages = this.#workspace.getLanguages(); + const defaultLanguage = languages.find((lang) => lang.isDefault)?.unique; + if (!defaultLanguage) { + throw new Error('Default language not found'); + } + return defaultLanguage; + } + + #transformValueForVariationChange( + value: any, + oldPropertyTypes: Array, + newPropertyTypes: Array, + defaultLanguage: string, + ): { value: any; changed: boolean } { + const oldType = oldPropertyTypes.find((p) => p.alias === value.alias); + const newType = newPropertyTypes.find((p) => p.alias === value.alias); + + // If we cant find both, we do not dare changing anything. Notice a composition may not have been loaded yet. + if (!oldType || !newType) { + return { value, changed: false }; + } + + // If variation hasn't changed, return unchanged + if (oldType.variesByCulture === newType.variesByCulture) { + return { value, changed: false }; + } + + // Variation has changed, migrate the value + if (newType.variesByCulture) { + // If it now varies by culture, set to default language + return { value: { ...value, culture: defaultLanguage }, changed: true }; + } else { + // If it no longer varies by culture, set to invariant + return { value: { ...value, culture: null }, changed: true }; + } + } +} diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property/property-value-preset/property-value-preset-variant-builder.controller.test.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property/property-value-preset/property-value-preset-variant-builder.controller.test.ts index 28adf7c6b105..45e63a2c5a1c 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property/property-value-preset/property-value-preset-variant-builder.controller.test.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property/property-value-preset/property-value-preset-variant-builder.controller.test.ts @@ -231,90 +231,5 @@ describe('UmbPropertyValuePresetVariantBuilderController', () => { expect(result[5]?.segment).to.be.equal('segmentB'); }); - it('migrates invariant value to variant when variation changes', async () => { - const ctrlHost = new UmbTestControllerHostElement(); - const ctrl = new UmbPropertyValuePresetVariantBuilderController(ctrlHost); - ctrl.setCultures(['en-US', 'da-DK']); - - // Set existing values as invariant (culture: null) - simulating before variation change - ctrl.setValues([ - { - alias: 'test', - value: 'invariant value', - culture: null, - segment: null, - editorAlias: 'test-editor-schema', - }, - ]); - - // Property now varies by culture (after variation change) - const propertyTypes: Array = [ - { - alias: 'test', - propertyEditorUiAlias: 'test-editor-ui', - propertyEditorSchemaAlias: 'test-editor-schema', - config: [], - typeArgs: { variesByCulture: true }, - }, - ]; - - const result = await ctrl.create(propertyTypes, { - entityType: 'test', - entityUnique: 'some-unique', - }); - - // Both culture variants should inherit the invariant value - // Note: When a value exists, the preset API preserves it without modification - expect(result.length).to.be.equal(2); - expect(result[0]?.value).to.be.equal('invariant value'); - expect(result[0]?.culture).to.be.equal('en-US'); - expect(result[1]?.value).to.be.equal('invariant value'); - expect(result[1]?.culture).to.be.equal('da-DK'); - }); - - it('migrates variant value to invariant when variation changes', async () => { - const ctrlHost = new UmbTestControllerHostElement(); - const ctrl = new UmbPropertyValuePresetVariantBuilderController(ctrlHost); - - // Set existing values as variant (culture-specific) - simulating before variation change - ctrl.setValues([ - { - alias: 'test', - value: 'en-US value', - culture: 'en-US', - segment: null, - editorAlias: 'test-editor-schema', - }, - { - alias: 'test', - value: 'da-DK value', - culture: 'da-DK', - segment: null, - editorAlias: 'test-editor-schema', - }, - ]); - - // Property is now invariant (after variation change) - const propertyTypes: Array = [ - { - alias: 'test', - propertyEditorUiAlias: 'test-editor-ui', - propertyEditorSchemaAlias: 'test-editor-schema', - config: [], - typeArgs: { variesByCulture: false }, - }, - ]; - - const result = await ctrl.create(propertyTypes, { - entityType: 'test', - entityUnique: 'some-unique', - }); - - // Invariant value should use first culture-specific value found - // Note: When a value exists, the preset API preserves it without modification - expect(result.length).to.be.equal(1); - expect(result[0]?.value).to.be.equal('en-US value'); - expect(result[0]?.culture).to.be.null; - }); }); }); diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property/property-value-preset/property-value-preset-variant-builder.controller.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property/property-value-preset/property-value-preset-variant-builder.controller.ts index 4032630f92aa..fd2ea003942c 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property/property-value-preset/property-value-preset-variant-builder.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property/property-value-preset/property-value-preset-variant-builder.controller.ts @@ -106,46 +106,15 @@ export class UmbPropertyValuePresetVariantBuilderController extends UmbPropertyV return args; } - /** - * Finds an existing value for a property, with fallback logic for variation setting changes. - * When a property changes from invariant to variant (or vice versa), the existing values - * may have a different culture/segment than what we're looking for. This method handles - * value migration by trying fallback lookups. - */ #findExistingValue(alias: string, variantId: UmbVariantId): unknown { - if (!this._existingValues) return undefined; + if (!this._existingValues) { + return undefined; + } - // First, try exact match (same alias + same culture/segment) const exactMatch = this._existingValues.find((x) => x.alias === alias && variantId.compare(x)); if (exactMatch) { return exactMatch.value; } - - // No exact match - try fallback for variation setting changes - // Get all values for this property alias - const valuesForAlias = this._existingValues.filter((x) => x.alias === alias); - if (valuesForAlias.length === 0) { - return undefined; - } - - // Fallback 1: If looking for a culture-specific value, try to use the invariant value - // This handles: invariant → variant migration - if (variantId.culture !== null) { - const invariantValue = valuesForAlias.find((x) => x.culture === null && x.segment === variantId.segment); - if (invariantValue) { - return invariantValue.value; - } - } - - // Fallback 2: If looking for an invariant value, try to use the first culture-specific value - // This handles: variant → invariant migration - if (variantId.culture === null) { - const anyVariantValue = valuesForAlias.find((x) => x.culture !== null && x.segment === variantId.segment); - if (anyVariantValue) { - return anyVariantValue.value; - } - } - return undefined; } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/workspace/entity-detail/entity-detail-workspace-base.ts b/src/Umbraco.Web.UI.Client/src/packages/core/workspace/entity-detail/entity-detail-workspace-base.ts index 51d3f3c03964..549b2927931c 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/workspace/entity-detail/entity-detail-workspace-base.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/workspace/entity-detail/entity-detail-workspace-base.ts @@ -156,6 +156,14 @@ export abstract class UmbEntityDetailWorkspaceContextBase< return this._data.getCurrent(); } + /** + * Get the current data + * @param {DetailModelType | undefined} data - New data of this workspace. + */ + setData(data: DetailModelType | undefined): void { + this._data.setCurrent(data); + } + /** * Get the persisted data * @returns { DetailModelType | undefined } The persisted data @@ -253,8 +261,7 @@ export abstract class UmbEntityDetailWorkspaceContextBase< } } } else if (data) { - const processedData = await this._scaffoldProcessData(data); - + const processedData = await this._processIncomingData(data); this._data.setPersisted(processedData); this._data.setCurrent(processedData); @@ -275,8 +282,9 @@ export abstract class UmbEntityDetailWorkspaceContextBase< const { data } = await this._detailRepository!.requestByUnique(unique); if (data) { - this._data.setPersisted(data); - this._data.setCurrent(data); + const processedData = await this._processIncomingData(data); + this._data.setPersisted(processedData); + this._data.setCurrent(processedData); } }