This commit is contained in:
Mads Rasmussen
2025-04-16 11:22:49 +02:00
parent 63485bca15
commit d391cff254
2 changed files with 9 additions and 14 deletions

View File

@@ -157,18 +157,4 @@ export class UmbContentWorkspaceDataManager<
.map((x) => new UmbVariantId(x.culture, x.segment)) ?? []
);
}
override async constructData(selectedVariantIds: Array<UmbVariantId>) {
let selection = selectedVariantIds;
// If we vary by segment we need to save all segments for a selected culture.
if (this._variesBySegment === true) {
const dataVariants = this.getCurrent()?.variants ?? [];
const selectedCultures = selectedVariantIds.map((x) => x.culture);
const selectedCulturesIncludingSegments = dataVariants.filter((x) => selectedCultures.includes(x.culture));
selection = selectedCulturesIncludingSegments.map((x) => UmbVariantId.Create(x));
}
return super.constructData(selection);
}
}

View File

@@ -84,6 +84,15 @@ export class UmbElementWorkspaceDataManager<ModelType extends UmbElementDetailMo
variantsToStore = [...selectedVariants, invariantVariantId];
}
// If we vary by segment we need to save all segments for a selected culture.
if (this._variesBySegment === true) {
const dataSegments = this.getCurrent()!.values.map((x) => x.segment);
variantsToStore = [
...variantsToStore,
...dataSegments.flatMap((segment) => variantsToStore.map((variant) => variant.toSegment(segment))),
];
}
const data = this.getCurrent();
if (!data) throw new Error('Current data is missing');
//if (!data.unique) throw new Error('Unique of current data is missing');