bpmn-io / bpmn-js-properties-panel

A properties panel for bpmn-js.
MIT License
286 stars 196 forks source link

test: verify properties panel works in read-only mode #1013

Open nikku opened 6 months ago

nikku commented 6 months ago

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

What is left is three issues:


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:

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

nikku commented 6 months ago

@nithinssabu the results of our exploration.

Try it out via

git clone git@github.com:bpmn-io/bpmn-js-properties-panel.git
cd bpmn-js-properties-panel
npm install 
npm run dev
nithinssabu commented 6 months ago

@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.

nikku commented 6 months ago

@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 commented 5 months ago

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

philippfromme commented 5 months ago

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

nithinssabu commented 5 months ago

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

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

nithinssabu commented 5 months ago

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

nithinssabu commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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?

nikku commented 3 months ago

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