add readonly state manager to block entry context
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
mergeObservables,
|
||||
observeMultiple,
|
||||
} from '@umbraco-cms/backoffice/observable-api';
|
||||
import { encodeFilePath } from '@umbraco-cms/backoffice/utils';
|
||||
import { encodeFilePath, UmbReadOnlyVariantStateManager } from '@umbraco-cms/backoffice/utils';
|
||||
import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';
|
||||
import type {
|
||||
UmbContentTypeModel,
|
||||
@@ -50,6 +50,8 @@ export abstract class UmbBlockEntryContext<
|
||||
#hasExpose = new UmbBooleanState(undefined);
|
||||
hasExpose = this.#hasExpose.asObservable();
|
||||
|
||||
public readonly readOnlyState = new UmbReadOnlyVariantStateManager(this);
|
||||
|
||||
// Workspace alike methods, to enables editing of data without the need of a workspace (Custom views and block grid inline editing mode for example).
|
||||
getEntityType() {
|
||||
return 'block';
|
||||
@@ -409,6 +411,7 @@ export abstract class UmbBlockEntryContext<
|
||||
this.#observeBlockType();
|
||||
this.#observeContentData();
|
||||
this.#observeSettingsData();
|
||||
this.#observeReadOnlyState();
|
||||
}
|
||||
|
||||
abstract _gotManager(): void;
|
||||
@@ -491,6 +494,31 @@ export abstract class UmbBlockEntryContext<
|
||||
);
|
||||
}
|
||||
|
||||
#observeReadOnlyState() {
|
||||
if (!this._manager) return;
|
||||
|
||||
this.observe(
|
||||
observeMultiple([this._manager.readOnlyState.isReadOnly, this._manager.variantId]),
|
||||
([isReadOnly, variantId]) => {
|
||||
const unique = 'UMB_BLOCK_MANAGER_CONTEXT';
|
||||
if (variantId === undefined) return;
|
||||
|
||||
if (isReadOnly) {
|
||||
const state = {
|
||||
unique,
|
||||
variantId,
|
||||
message: '',
|
||||
};
|
||||
|
||||
this.readOnlyState?.addState(state);
|
||||
} else {
|
||||
this.readOnlyState?.removeState(unique);
|
||||
}
|
||||
},
|
||||
'observeIsReadOnly',
|
||||
);
|
||||
}
|
||||
|
||||
#getContentStructure() {
|
||||
if (!this._manager) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user