Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom rules ignored #933

Open
philippfromme opened this issue Jan 16, 2019 · 2 comments
Open

Custom rules ignored #933

philippfromme opened this issue Jan 16, 2019 · 2 comments
Labels
backlog Queued in backlog bug Something isn't working spring cleaning Could be cleaned up one day toolkit

Comments

@philippfromme
Copy link
Contributor

philippfromme commented Jan 16, 2019

Due to the way BpmnRules is implemented some rules can be used directly without the use of Rules#allowed. Therefore they can't be overridden by custom rules. This leads to a lot of frustration when people want to do exactly that.

Example:

// BpmnRules.js
function canConnect(source, target, connection) {
  // ...
}

BpmnRules.prototype.canConnect = canConnect; // ignores rules.allowed

is used directly

// Modeling.js

Modeling.prototype.connect = function(source, target, attrs, hints) {

  var bpmnRules = this._bpmnRules;

  if (!attrs) {
    attrs = bpmnRules.canConnect(source, target); // use rules.allowed('connection.create', ...) instead
  }

  if (!attrs) {
    return;
  }

  return this.createConnection(source, target, attrs, source.parent, hints);
};

Improvement

  • make sure BpmnRules uses 'rules.allowed' which will ensure that rules can be overridden

Related to this forum post

@philippfromme philippfromme added bug Something isn't working backlog Queued in backlog labels Jan 16, 2019
@nikku

This comment has been minimized.

@jan-ladleif
Copy link

Sorry to intrude, but this seems related to two issues I had when adding custom rules for chor-js.

  1. Basically what @philippfromme said: Since various classes call bpmnRules directly, e.g. bpmnRules.canConnect(source, target), one can not add refinements or additions to these rules by adding another RuleProvider. Instead, we need to override BpmnRules and inject our version globally (see our code).

  2. The rules themselves often call local helper functions instead of prototype functions. Example: The rule for connection.create calls the local canConnect(...) instead of the prototype variant.

    As a consequence, just overriding the prototype method has no effect. That's why we had to copy the code of all the rules to make sure they call the prototype.

@nikku nikku added spring cleaning Could be cleaned up one day toolkit and removed refactoring labels Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Queued in backlog bug Something isn't working spring cleaning Could be cleaned up one day toolkit
Projects
None yet
Development

No branches or pull requests

3 participants