expose using the block variant id (#17525)
This commit is contained in:
@@ -8,6 +8,7 @@ import { UmbBooleanState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router';
|
||||
import { UMB_PROPERTY_DATASET_CONTEXT } from '@umbraco-cms/backoffice/property';
|
||||
import type { UmbVariantId } from '@umbraco-cms/backoffice/variant';
|
||||
|
||||
export class UmbBlockListEntriesContext extends UmbBlockEntriesContext<
|
||||
typeof UMB_BLOCK_LIST_MANAGER_CONTEXT,
|
||||
@@ -149,11 +150,7 @@ export class UmbBlockListEntriesContext extends UmbBlockEntriesContext<
|
||||
originData: UmbBlockListWorkspaceOriginData,
|
||||
) {
|
||||
await this._retrieveManager;
|
||||
const success = this._manager?.insert(layoutEntry, content, settings, originData) ?? false;
|
||||
if (success) {
|
||||
this._manager?.setOneExpose(layoutEntry.contentKey);
|
||||
}
|
||||
return success;
|
||||
return this._manager?.insert(layoutEntry, content, settings, originData) ?? false;
|
||||
}
|
||||
|
||||
// create Block?
|
||||
|
||||
@@ -575,7 +575,6 @@ export abstract class UmbBlockEntryContext<
|
||||
#gotVariantId() {
|
||||
const variantId = this.#variantId.getValue();
|
||||
if (!variantId || !this.#contentKey) return;
|
||||
// TODO: Handle variantId changes
|
||||
this.observe(
|
||||
this._manager?.hasExposeOf(this.#contentKey, variantId),
|
||||
(hasExpose) => {
|
||||
@@ -615,8 +614,9 @@ export abstract class UmbBlockEntryContext<
|
||||
}
|
||||
|
||||
public expose() {
|
||||
if (!this.#contentKey) return;
|
||||
this._manager?.setOneExpose(this.#contentKey);
|
||||
const variantId = this.#variantId.getValue();
|
||||
if (!variantId || !this.#contentKey) return;
|
||||
this._manager?.setOneExpose(this.#contentKey, variantId);
|
||||
}
|
||||
|
||||
//copy
|
||||
|
||||
@@ -45,6 +45,9 @@ export abstract class UmbBlockManagerContext<
|
||||
setVariantId(variantId: UmbVariantId | undefined) {
|
||||
this.#variantId.setValue(variantId);
|
||||
}
|
||||
getVariantId(): UmbVariantId | undefined {
|
||||
return this.#variantId.getValue();
|
||||
}
|
||||
|
||||
readonly #structures: Array<UmbContentTypeStructureManager> = [];
|
||||
|
||||
@@ -213,8 +216,7 @@ export abstract class UmbBlockManagerContext<
|
||||
setOneSettings(settingsData: UmbBlockDataModel) {
|
||||
this.#settings.appendOne(settingsData);
|
||||
}
|
||||
setOneExpose(contentKey: string) {
|
||||
const variantId = this.#variantId.getValue();
|
||||
setOneExpose(contentKey: string, variantId: UmbVariantId) {
|
||||
if (!variantId) return;
|
||||
this.#exposes.appendOne({ contentKey, ...variantId.toObject() });
|
||||
}
|
||||
|
||||
@@ -467,12 +467,14 @@ export class UmbBlockWorkspaceContext<LayoutDataType extends UmbBlockLayoutBaseM
|
||||
|
||||
expose() {
|
||||
const contentKey = this.#layout.value?.contentKey;
|
||||
if (!contentKey) throw new Error('Cannot expose block that does not exist.');
|
||||
if (!contentKey) throw new Error('Failed to expose block, missing content key.');
|
||||
this.#expose(contentKey);
|
||||
}
|
||||
|
||||
#expose(unique: string) {
|
||||
this.#blockManager?.setOneExpose(unique);
|
||||
const variantId = this.#variantId.getValue();
|
||||
if (!variantId) throw new Error('Failed to expose block, missing variant id.');
|
||||
this.#blockManager?.setOneExpose(unique, variantId);
|
||||
}
|
||||
|
||||
#modalRejected = () => {
|
||||
|
||||
Reference in New Issue
Block a user