set readonly state on block manager from ui editor elements
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user