set readonly state on block manager from ui editor elements

This commit is contained in:
Mads Rasmussen
2024-10-07 15:55:49 +02:00
parent 6ecc3de2ea
commit 4aa83ffced
2 changed files with 48 additions and 0 deletions

View File

@@ -123,6 +123,7 @@ export class UmbPropertyEditorUIBlockGridElement
},
'motherObserver',
);
this.observe(
propertyContext?.alias,
(alias) => {
@@ -130,6 +131,30 @@ export class UmbPropertyEditorUIBlockGridElement
},
'observePropertyAlias',
);
// If the current property is readonly all inner block content should also be readonly.
this.observe(
observeMultiple([propertyContext.isReadOnly, propertyContext.variantId]),
([isReadOnly, variantId]) => {
const unique = 'UMB_PROPERTY_CONTEXT';
if (variantId === undefined) return;
if (isReadOnly) {
const state = {
unique,
variantId,
message: '',
};
debugger;
this.#managerContext.readOnlyState.addState(state);
} else {
this.#managerContext.readOnlyState.removeState(unique);
}
},
'observeIsReadOnly',
);
});
this.consumeContext(UMB_PROPERTY_DATASET_CONTEXT, (context) => {

View File

@@ -203,7 +203,30 @@ export class UmbPropertyEditorUIBlockListElement
},
'motherObserver',
);
// If the current property is readonly all inner block content should also be readonly.
this.observe(
observeMultiple([context.isReadOnly, context.variantId]),
([isReadOnly, variantId]) => {
const unique = 'UMB_PROPERTY_CONTEXT';
if (variantId === undefined) return;
if (isReadOnly) {
const state = {
unique,
variantId,
message: '',
};
this.#managerContext.readOnlyState.addState(state);
} else {
this.#managerContext.readOnlyState.removeState(unique);
}
},
'observeIsReadOnly',
);
});
this.consumeContext(UMB_PROPERTY_DATASET_CONTEXT, (context) => {
this.#managerContext.setVariantId(context.getVariantId());
});