How to use dmn-js-shared - 10 common examples

To help you get started, we’ve selected a few dmn-js-shared examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bpmn-io / dmn-js / packages / dmn-js-drd / src / import / DrdTreeWalker.js View on Github external
function handleConnections(edges, element) {

    function deferConnection(semantic, property) {
      var id = parseID(property),
          edge = find(edges, matchPattern({ source: id }));

      if (edge) {
        deferred.push(function() {
          visit(semantic, edge);
        });
      }
    }

    if (is(element, 'dmn:Association')) {
      return deferConnection(element, element.sourceRef);
    }

    forEach([
      'informationRequirement',
      'knowledgeRequirement',
      'authorityRequirement'
    ], function(requirements) {
      forEach(element[requirements], function(requirement) {
        var properties = null;

        // get the href
        if (is(requirement, 'dmn:InformationRequirement')) {
          properties = [ 'requiredDecision', 'requiredInput' ];

        } else if (is(requirement, 'dmn:KnowledgeRequirement')) {
github bpmn-io / dmn-js / packages / dmn-js-decision-table / src / features / modeling / DmnUpdater.js View on Github external
updateRoot(element, oldRoot) {

    var newRoot = element.root;

    var businessObject = element.businessObject;

    if (is(element, 'dmn:DecisionRule')) {

      // we're removing
      if (oldRoot) {
        let oldTable = oldRoot.businessObject;

        let oldRules = oldTable.get('rule');
        let oldIdx = oldRules.indexOf(businessObject);

        // unwire Row <-> Table
        oldRules.splice(oldIdx, 1);
        businessObject.$parent = null;
      }

      // we're adding
      if (newRoot) {
        let newTable = newRoot.businessObject;
github bpmn-io / dmn-js / packages / dmn-js-decision-table / src / features / allowed-values / behavior / AllowedValuesUpdateBehavior.js View on Github external
this.postExecuted('updateProperties', event => {
      const {
        element,
        properties
      } = event.context;

      const actualProperties = isInput(element) ? properties.inputExpression : properties;

      if (actualProperties
        && actualProperties.typeRef
        && actualProperties.typeRef !== 'string') {

        const target = (
          is(element, 'dmn:LiteralExpression') ?
            element.$parent :
            element
        );

        // delete allowed values
        modeling.editAllowedValues(target, null);
      }
    });
  }
github bpmn-io / dmn-js / packages / dmn-js-decision-table / src / features / simple-string-edit / components / SimpleStringEditContextMenuComponent.js View on Github external
onKeyDown({ isValid, event }) {

    if (!isEnter(event.keyCode)) {
      return;
    }

    const { element } = this.props.context;

    const isInputClause = isInput(element.col);

    // stop ENTER propagation (and ContextMenu close)
    if (isInputClause || !isValid) {
      event.stopPropagation();
      event.preventDefault();
    }

    if (isValid) {
      if (isInputClause) {
        this.addUnaryTestsListItem();
      } else {
        this.onOutputValueInputClick();
      }
    }
  }
github bpmn-io / dmn-js / packages / dmn-js-decision-table / src / features / allowed-values / components / AllowedValuesEditing.js View on Github external
getAllowedValuesTarget() {
    const { element } = this.props.context;

    if (is(element, 'dmn:LiteralExpression')) {
      return element.$parent;
    } else {
      return element;
    }
  }
github bpmn-io / dmn-js / packages / dmn-js / lib / Viewer.js View on Github external
opens(element) {
          return is(element, 'dmn:Decision') && element.literalExpression;
        }
      }
github bpmn-io / dmn-js / packages / dmn-js-decision-table / src / features / decision-table-properties / components / DecisionTablePropertiesComponent.js View on Github external
render() {
    const root = this._sheet.getRoot();

    if (!is(root, 'dmn:DMNElement')) {
      return null;
    }

    const { id, name } = root.businessObject.$parent;

    return (
      <header>
        <h3 title="Decision Name">{ name }</h3>
        <h5 title="Decision Id">{ id }</h5>
      </header>
    );
  }
}
github bpmn-io / dmn-js / packages / dmn-js-drd / src / features / label-editing / LabelUtil.js View on Github external
function getLabelAttr(semantic) {
  if (is(semantic, 'dmn:Decision') ||
      is(semantic, 'dmn:BusinessKnowledgeModel') ||
      is(semantic, 'dmn:InputData') ||
      is(semantic, 'dmn:KnowledgeSource')) {

    return 'name';
  }

  if (is(semantic, 'dmn:TextAnnotation')) {
    return 'text';
  }
}
github bpmn-io / dmn-js / packages / dmn-js-drd / src / features / modeling / behavior / CreateConnectionBehavior.js View on Github external
function getRequirementType(source) {
  if (is(source, 'dmn:BusinessKnowledgeModel')) {
    return 'Knowledge';
  } else if (is(source, 'dmn:Decision')) {
    return 'Decision';
  } else if (is(source, 'dmn:InputData')) {
    return 'Input';
  } else if (is(source, 'dmn:KnowledgeSource')) {
    return 'Authority';
  }
}
github bpmn-io / dmn-js / packages / dmn-js-drd / src / features / modeling / ElementFactory.js View on Github external
ElementFactory.prototype._getDefaultSize = function(semantic) {

  if (is(semantic, 'dmn:Decision')) {
    return { width: 180, height: 80 };
  }

  if (is(semantic, 'dmn:InputData')) {
    return { width: 125, height: 45 };
  }

  if (is(semantic, 'dmn:KnowledgeSource')) {
    return { width: 100, height: 63 };
  }

  if (is(semantic, 'dmn:BusinessKnowledgeModel')) {
    return { width: 135, height: 46 };
  }

  return { width: 100, height: 80 };