New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dmn-js

Package Overview
Dependencies
Maintainers
3
Versions
185
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dmn-js - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

lib/features/column-drag/ColumnDrag.js

4

Gruntfile.js

@@ -22,3 +22,3 @@ 'use strict';

tests: 'test',
dist: 'dist'
dist: '../bower-dmn-js/dist'
},

@@ -80,3 +80,3 @@

styles: {
files: { 'dist/css/dmn-js.css': 'styles/dmn-js.less' }
files: { '<%= config.dist %>/css/dmn-js.css': 'styles/dmn-js.less' }
}

@@ -83,0 +83,0 @@ },

@@ -45,87 +45,94 @@ 'use strict';

function updateColspans(evt) {
if(evt._type === 'column') {
var cells = elementRegistry.filter(function(element) {
return element._type === 'cell' && element.row === self.row;
});
var cells = elementRegistry.filter(function(element) {
return element._type === 'cell' && element.row === self.row;
});
var inputs = cells.filter(function(cell) {
return cell.column.businessObject && cell.column.businessObject.inputExpression;
});
var inputs = cells.filter(function(cell) {
return cell.column.businessObject && cell.column.businessObject.inputExpression;
});
forEach(inputs, function(input) {
if(!input.column.previous.businessObject) {
// first cell of the inputs array has the colspan attribute set
input.colspan = inputs.length;
forEach(inputs, function(input) {
if(!input.column.previous.businessObject) {
// first cell of the inputs array has the colspan attribute set
input.colspan = inputs.length;
var node;
if(rules.allowed('column.create')) {
node = domify('Input <a class="dmn-icon-plus"></a>');
node.querySelector('a').addEventListener('mouseup', function() {
var col = input.column;
while(col.next && col.next.businessObject.$type === 'dmn:InputClause') {
col = col.next;
}
var node;
if(rules.allowed('column.create')) {
node = domify('Input <a class="dmn-icon-plus"></a>');
node.querySelector('a').addEventListener('mouseup', function() {
var col = input.column;
while(col.next && col.next.businessObject.$type === 'dmn:InputClause') {
col = col.next;
}
var newColumn = {
id: ids.next(),
previous: col,
name: '',
isInput: true
};
var newColumn = {
id: ids.next(),
previous: col,
name: '',
isInput: true
};
eventBus.fire('ioLabel.createColumn', {
newColumn: newColumn
});
eventBus.fire('ioLabel.createColumn', {
newColumn: newColumn
});
} else {
node = domify('Input');
}
input.content = node;
});
} else {
node = domify('Input');
}
});
var outputs = cells.filter(function(cell) {
return cell.column.businessObject && cell.column.businessObject.$instanceOf('dmn:OutputClause');
});
input.content = node;
} else {
input.colspan = 1;
}
});
forEach(outputs, function(output) {
if(output.column.previous.businessObject.inputExpression) {
// first cell of the outputs array has the colspan attribute set
output.colspan = outputs.length;
var outputs = cells.filter(function(cell) {
return cell.column.businessObject && cell.column.businessObject.$instanceOf('dmn:OutputClause');
});
var node;
if(rules.allowed('column.create')) {
node = domify('Output <a class="dmn-icon-plus"></a>');
node.querySelector('a').addEventListener('mouseup', function() {
var col = output.column;
while(col.next && col.next.businessObject && col.next.businessObject.$type === 'dmn:OutputClause') {
col = col.next;
}
forEach(outputs, function(output) {
if(output.column.previous.businessObject.inputExpression) {
// first cell of the outputs array has the colspan attribute set
output.colspan = outputs.length;
var newColumn = {
id: ids.next(),
previous: col,
name: '',
isInput: false
};
var node;
if(rules.allowed('column.create')) {
node = domify('Output <a class="dmn-icon-plus"></a>');
node.querySelector('a').addEventListener('mouseup', function() {
var col = output.column;
while(col.next && col.next.businessObject && col.next.businessObject.$type === 'dmn:OutputClause') {
col = col.next;
}
eventBus.fire('ioLabel.createColumn', {
newColumn: newColumn
});
var newColumn = {
id: ids.next(),
previous: col,
name: '',
isInput: false
};
eventBus.fire('ioLabel.createColumn', {
newColumn: newColumn
});
} else {
node = domify('Output');
}
output.content = node;
});
} else {
node = domify('Output');
}
});
if(cells.length > 0) {
graphicsFactory.update('row', cells[0].row, elementRegistry.getGraphics(cells[0].row.id));
output.content = node;
} else {
output.colspan = 1;
}
});
if(cells.length > 0) {
graphicsFactory.update('row', cells[0].row, elementRegistry.getGraphics(cells[0].row.id));
}
}
eventBus.on(['cells.added', 'cells.removed'], updateColspans);
eventBus.on(['cells.added', 'cells.removed'], function(evt) {
if(evt._type === 'column') {
updateColspans();
}
});
eventBus.on(['column.move.applied'], updateColspans);
}

@@ -132,0 +139,0 @@

'use strict';
var calculateSelectionUpdate = require('selection-update');
function getSelection(node) {
var selectObj = document.getSelection();
if(selectObj.rangeCount > 0) {
var range = selectObj.getRangeAt(0);
return {
start: range.startOffset,
end: range.endOffset
};
}
return {
start: 0,
end: 0
};
}
function updateSelection(newSelection, gfx) {
var range = document.createRange();
var sel = document.getSelection();
if(gfx.childNodes[0].firstChild) {
range.setStart(gfx.childNodes[0].firstChild, newSelection.start);
range.setEnd(gfx.childNodes[0].firstChild, newSelection.end);
} else {
range.setStart(gfx.childNodes[0], 0);
range.setEnd(gfx.childNodes[0], 0);
}
sel.removeAllRanges();
sel.addRange(range);
}
/**

@@ -64,3 +98,6 @@ * A handler that implements reversible addition of rows.

var selection = getSelection();
var newSelection = calculateSelectionUpdate(selection, gfx.textContent, context.content);
this._graphicsFactory.update('cell', el, gfx);
updateSelection(newSelection, gfx);

@@ -86,5 +123,3 @@ return context;

}
} else {
if(el.column.isAnnotationsColumn) {

@@ -104,8 +139,10 @@ // revert the annotations of a rule

}
}
var selection = getSelection();
var newSelection = calculateSelectionUpdate(selection, gfx.textContent, context.oldContent);
this._graphicsFactory.update('cell', el, gfx);
updateSelection(newSelection, gfx);
return context;
};

@@ -141,2 +141,80 @@ 'use strict';

function moveRow(event) {
var source = event.context.source.businessObject;
var target = event.context.target.businessObject;
var rulesArray = source.$parent.rule;
var targetIdx;
// remove source from list
var sourceIdx = rulesArray.indexOf(source);
rulesArray.splice(sourceIdx, 1);
if(event.type.indexOf('.executed') !== -1) {
// add source at target position
targetIdx = rulesArray.indexOf(target);
rulesArray.splice(targetIdx + (event.context.above ? 0 : 1), 0, source);
} else if (event.type.indexOf('.reverted') !== -1) {
// add source at previousBelow
var previousBelow = event.context.previousBelow.businessObject;
if(previousBelow) {
targetIdx = rulesArray.indexOf(previousBelow);
rulesArray.splice(targetIdx, 0, source);
} else {
rulesArray.push(source);
}
}
}
function moveColumn(event) {
var source = event.context.source.businessObject;
var target = event.context.target.businessObject;
var isInput = source.$type === 'dmn:InputClause';
var targetIdx;
var columns = source.$parent[isInput ? 'input' : 'output'];
var rules = source.$parent.rule;
// remove source from columns
var sourceIdx = columns.indexOf(source);
columns.splice(sourceIdx, 1);
if(event.type.indexOf('.executed') !== -1) {
// add source at target position
targetIdx = columns.indexOf(target);
columns.splice(targetIdx + !event.context.left, 0, source);
// move all entries in the rules array
forEach(rules, function(rule) {
var array = rule[isInput ? 'inputEntry' : 'outputEntry'];
var element = array.splice(sourceIdx, 1)[0];
array.splice(targetIdx + !event.context.left, 0, element);
});
} else if (event.type.indexOf('.reverted') !== -1) {
// add source at previousRight
var previousRight = event.context.previousRight.businessObject;
if(previousRight && previousRight.$type === source.$type) {
targetIdx = columns.indexOf(previousRight);
columns.splice(targetIdx, 0, source);
forEach(rules, function(rule) {
var array = rule[isInput ? 'inputEntry' : 'outputEntry'];
var element = array.splice(sourceIdx, 1)[0];
array.splice(targetIdx, 0, element);
});
} else {
columns.push(source);
forEach(rules, function(rule) {
var array = rule[isInput ? 'inputEntry' : 'outputEntry'];
var element = array.splice(sourceIdx, 1)[0];
array.push(element);
});
}
}
eventBus.fire('column.move.applied');
}
this.executed([ 'column.create' ], setColumnParent);

@@ -146,2 +224,4 @@ this.executed([ 'row.create' ], setParent);

this.executed([ 'row.delete' ], deleteRule);
this.executed([ 'row.move' ], moveRow);
this.executed([ 'column.move' ], moveColumn);

@@ -151,3 +231,5 @@ this.reverted([ 'column.create' ], unsetParent);

this.reverted([ 'column.delete' ], setColumnParent);
this.reverted([ 'row.delete'], setParent);
this.reverted([ 'row.delete' ], setParent);
this.reverted([ 'row.move' ], moveRow);
this.reverted([ 'column.move' ], moveColumn);
}

@@ -154,0 +236,0 @@

@@ -96,8 +96,8 @@ 'use strict';

if(cell.row.isClauseRow) {
// change the clause name
if(cell.column.businessObject.name !== content) {
// change the clause label
if(cell.column.businessObject.label !== content) {
this._commandStack.execute('cell.edit', context);
}
} else if(cell.row.isMappingsRow) {
if(cell.content.output !== content) {
if(cell.content.name !== content.trim()) {
this._commandStack.execute('cell.edit', context);

@@ -107,5 +107,5 @@ }

var previousContent = cell.content;
if((!cell.column.isAnnotationsColumn && (!previousContent && context.content !== '') ||
(previousContent && context.content !== previousContent.text)) ||
(cell.column.isAnnotationsColumn && cell.row.businessObject.description !== context.content)) {
if((!cell.column.isAnnotationsColumn && (!previousContent && context.content.trim() !== '') ||
(previousContent && context.content.trim() !== previousContent.text)) ||
(cell.column.isAnnotationsColumn && cell.row.businessObject.description !== context.content.trim())) {
// only execute edit command if content changed

@@ -112,0 +112,0 @@ this._commandStack.execute('cell.edit', context);

@@ -115,3 +115,5 @@ 'use strict';

require('./features/context-menu'),
require('table-js/lib/features/keyboard')
require('table-js/lib/features/keyboard'),
require('table-js/lib/features/row-drag'),
require('./features/column-drag')
];

@@ -118,0 +120,0 @@

@@ -22,3 +22,4 @@ 'use strict';

entriesType.rule = !!(context.row && context.row.businessObject &&
!context.row.businessObject.$instanceOf('dmn:DecisionTable'));
!context.row.businessObject.$instanceOf('dmn:DecisionTable') &&
context.column.id !== 'utilityColumn');

@@ -28,2 +29,4 @@ if (context.column &&

context.column.id !== 'annotations' &&
context.row.id !== 'mappingsRow' &&
context.row.id !== 'typeRow' &&
!context.row.isLabelRow) {

@@ -30,0 +33,0 @@ if (context.column.businessObject.inputExpression) {

{
"name": "dmn-js",
"version": "0.3.1",
"version": "0.4.0",
"description": "A dmn toolkit and web modeler",

@@ -70,4 +70,2 @@ "scripts": {

"dependencies": {
"dmn-moddle": "^0.2.3",
"table-js": "^0.3.0",
"bootstrap": "^3.3.5",

@@ -77,2 +75,3 @@ "brfs": "^1.4.0",

"didi": "^0.0.4",
"dmn-moddle": "^0.2.3",
"ids": "^0.1.0",

@@ -82,4 +81,6 @@ "inherits": "^2.0.1",

"min-dom": "^0.2.0",
"object-refs": "^0.1.0"
"object-refs": "^0.1.0",
"selection-update": "^0.1.2",
"table-js": "^0.4.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc