bpmn-js-properties-panel icon indicating copy to clipboard operation
bpmn-js-properties-panel copied to clipboard

test: verify properties panel works in read-only mode

Open nikku opened this issue 1 year ago • 11 comments

Context: https://github.com/camunda/web-modeler/issues/7623.

What is left is three issues:

  • Custom styling (marking fields as disabled)
  • Disabling form element focus (may need to be solved in properties panel)
  • Hiding (+) buttons

For the readonly properties panel case I could imagine to build dedicated support into the core:

const modelerWithReadonlyPropertiesPanel = new BpmnModeler({
  propertiesPanel: {
    readonly: true
  }
});

This would do the following:

  • mark inputs and checkboxes as readonly
  • do not show add markers for sections

...and would in the process solve the issue of editing and focus on the HTML level.

nikku avatar Jan 10 '24 10:01 nikku

@nithinssabu the results of our exploration.

Try it out via

git clone [email protected]:bpmn-io/bpmn-js-properties-panel.git
cd bpmn-js-properties-panel
npm install 
npm run dev

nikku avatar Jan 10 '24 10:01 nikku

@nikku If I try to dynamically attach the properties panel like this,

const propertiesPanel = modeler.get('propertiesPanel');
propertiesPanel.attachTo(propertiesContainer);

getting the following error, image

Can you please have a look? I spent quite some time on it.

nithinssabu avatar Jan 10 '24 17:01 nithinssabu

@nithinssabu We touched upon that issue yesterday already. It can also be reproduced in this test case. We currently rely on a "modeling ammended" $model to verify if IDs are valid: https://github.com/bpmn-io/bpmn-js-properties-panel/blob/14597b8ad83fce849da70bbece3f3b0d0c4c762f/src/provider/bpmn/utils/ValidationUtil.js#L18.

The ids are wired here and we want to mock them for the read-only panel.

nikku avatar Jan 11 '24 09:01 nikku

@nithinssabu For context, please share the web modeler issue you're currently working on.

nikku avatar Jan 15 '24 08:01 nikku

We already have styles for disabled="true" inputs, we're just not setting that attribute which we could based on the configuration.

philippfromme avatar Jan 15 '24 09:01 philippfromme

For context, please share the web modeler issue you're currently working on.

https://github.com/camunda/web-modeler/issues/7623

nithinssabu avatar Jan 15 '24 10:01 nithinssabu

@nikku Can I get permission to push changes to this branch?

nithinssabu avatar Jan 15 '24 10:01 nithinssabu

For my use case, I also need to get linting to work in the read-only mode. Currently getting the following error:

Error: No provider for "elementTemplates"! (Resolving: elementTemplates -> elementTemplates -> elementTemplates)
    at error (index.esm.js:136:1)
    at Object.get (index.esm.js:122:1)
    at NavigatedViewer.get (index.esm.js:176:1)
    at createModeler (BpmnPropertiesPanelRenderer.readonly.spec.js:142:35)
    at async Context.eval (BpmnPropertiesPanelRenderer.readonly.spec.js:177:20)

I pushed a commit reproducing this in the current test case. Can you please help me workaround this problem?

nithinssabu avatar Jan 15 '24 11:01 nithinssabu

Currently getting the following error:

I managed to get it to work by providing the CloudElementTemplatesPropertiesProviderModule https://github.com/bpmn-io/bpmn-js-properties-panel/pull/1013/commits/341d403372d287bd8a0db913532950d0024f636f ✅

nithinssabu avatar Jan 15 '24 13:01 nithinssabu

What is left is three issues:

  • Custom styling (marking fields as disabled)
  • Disabling form element focus (may need to be solved in properties panel)
  • Hiding (+) buttons

I was able to solve these using CSS and for the keyboard focus, using Javascript to set the readonly attribute on the input elements. Also, used MutationObserver to set this when the panel is re-drawn. https://github.com/bpmn-io/bpmn-js-properties-panel/pull/1013/commits/d8563b99ddb6ca0fc97880b2a8683b1336525815

https://github.com/bpmn-io/bpmn-js-properties-panel/assets/5987816/bbbf57f8-725f-4cfe-9d52-72e8a76e8a6b

@philippfromme I used readonly attribute instead of disabled because with disabled, it was not possible to tab through the elements. The user may want to focus the inputs and may be copy the value?

nithinssabu avatar Jan 15 '24 17:01 nithinssabu

Web modeler shipped without core support. Moving to backlog to track future improvement options.

nikku avatar Mar 14 '24 18:03 nikku