is it possible to disable and re-enable user modeling in modeler ?
Hi @Hauw_Ric,
The question is often asked here in the forum. You can, e.g., refer to this solution to switch between the Modeler
and the Viewer
.
If you don’t know about the Viewer
before, please have a look at this example.
thanks for the reply
i already try solution from this thread
there was an error
Module not found: Can't resolve 'lodash/collection/forEach'
this is what i try
ReadOnly.js
'use strict';
var forEach = require('lodash/collection/forEach');
var HIGH_PRIORITY = 10001;
.....
index.js
import ReadOnly from './ReadOnly';
export default {
__init__: [ 'readOnly' ],
customRules: [ 'type', ReadOnly ]
};
and then import it to my main file
import Read from "./Read/ReadOnly.js";
my file have same structure like this thread
is lodash
installed in your project?
Note: We also offer a tinier lib which also offers forEach
functionality: min-dash
yes i can find lodash folder inside node_modules
i tried using import and still module not found
import forEach from 'lodash/collection/forEach';
Can you maybe share your complete setup/project? It’s hard to reproduce from outside…
Oftentimes removing the node_modules
completely and npm install
again can do the trick.
Also, have a look at this.
thanks i already solve my problem
by remove node and npm install again then change
var forEach = require('lodash/forEach');
but there was an error
Error: No provider for "readOnly" (Resolving: readOnly)
after use this command from solution
modeler.get('readOnly').readOnly(true);
Your error comes from the fact, the code you posted is not correctly exposing the module, you’ll have to
// ./read-only/index.js
import ReadOnly from './ReadOnly';
export default {
__init__: [ 'readOnly' ],
readOnly: [ 'type', ReadOnly ]
};
// ./app.js
import readOnlyModule from "./read-only"; // location to your module
var modeler = new BpmnModeler({
container: '#js-canvas',
keyboard: {
bindTo: document
},
additionalModules: [
readOnlyModule
]
});
modeler.get('readOnly').readOnly(true);
thanks it works and I commented on some code from ReadOnly.js
// ignoreWhenReadOnly(editorActions._actions, 'undo');
// ignoreWhenReadOnly(editorActions._actions, 'redo');
// ignoreWhenReadOnly(editorActions._actions, 'copy');
// ignoreWhenReadOnly(editorActions._actions, 'paste');
// ignoreWhenReadOnly(editorActions._actions, 'removeSelection');
// ignoreWhenReadOnly(editorActions._actions, 'spaceTool');
// ignoreWhenReadOnly(editorActions._actions, 'lassoTool');
// ignoreWhenReadOnly(editorActions._actions, 'globalConnectTool');
// ignoreWhenReadOnly(editorActions._actions, 'distributeElements');
// ignoreWhenReadOnly(editorActions._actions, 'alignElements');
// ignoreWhenReadOnly(editorActions._actions, 'directEditing');
because there was an error undo,redo,… already registered
The code from the topic you mentioned doesn’t work anymore. I had to fix it in bpmn-js-token-simulation.
Have a look: https://github.com/bpmn-io/bpmn-js-token-simulation/commit/273ce65136ab633cbc0fe366ad376089939be541
The issue with ignoreIfModelingDisabled(dragging, 'init');
seems to be that even dragging the whole diagram within its viewport (using the hand tool) does no longer work. Additionally, the edges still show their waypoints on hover. The disabled modeler therefore is not as convenient as the viewer (and without the possibility to move the diagram within its viewport it is almost unusable…).