...
|
...
|
@@ -62,6 +62,12 @@ export function RuleChainController($state, $scope, $compile, $q, $mdUtil, $time |
62
|
62
|
vm.isEditingRuleNodeLink = false;
|
63
|
63
|
|
64
|
64
|
vm.isLibraryOpen = true;
|
|
65
|
+
|
|
66
|
+ Object.defineProperty(vm, 'isLibraryOpenReadonly', {
|
|
67
|
+ get: function() { return vm.isLibraryOpen },
|
|
68
|
+ set: function() {}
|
|
69
|
+ });
|
|
70
|
+
|
65
|
71
|
vm.ruleNodeSearch = '';
|
66
|
72
|
|
67
|
73
|
vm.ruleChain = ruleChain;
|
...
|
...
|
@@ -140,6 +146,19 @@ export function RuleChainController($state, $scope, $compile, $q, $mdUtil, $time |
140
|
146
|
subtitle: $translate.instant('rulechain.rulechain')
|
141
|
147
|
};
|
142
|
148
|
contextInfo.items = [];
|
|
149
|
+ if (vm.modelservice.nodes.getSelectedNodes().length) {
|
|
150
|
+ contextInfo.items.push(
|
|
151
|
+ {
|
|
152
|
+ action: function () {
|
|
153
|
+ copyRuleNodes();
|
|
154
|
+ },
|
|
155
|
+ enabled: true,
|
|
156
|
+ value: "rulenode.copy-selected",
|
|
157
|
+ icon: "content_copy",
|
|
158
|
+ shortcut: "M-C"
|
|
159
|
+ }
|
|
160
|
+ );
|
|
161
|
+ }
|
143
|
162
|
contextInfo.items.push(
|
144
|
163
|
{
|
145
|
164
|
action: function ($event) {
|
...
|
...
|
@@ -170,17 +189,6 @@ export function RuleChainController($state, $scope, $compile, $q, $mdUtil, $time |
170
|
189
|
);
|
171
|
190
|
contextInfo.items.push(
|
172
|
191
|
{
|
173
|
|
- action: function (event) {
|
174
|
|
- copyRuleNodes(event);
|
175
|
|
- },
|
176
|
|
- enabled: true,
|
177
|
|
- value: "rulenode.copy-selected",
|
178
|
|
- icon: "content_copy",
|
179
|
|
- shortcut: "M-C"
|
180
|
|
- }
|
181
|
|
- );
|
182
|
|
- contextInfo.items.push(
|
183
|
|
- {
|
184
|
192
|
action: function () {
|
185
|
193
|
vm.modelservice.deleteSelected();
|
186
|
194
|
},
|
...
|
...
|
@@ -254,8 +262,8 @@ export function RuleChainController($state, $scope, $compile, $q, $mdUtil, $time |
254
|
262
|
);
|
255
|
263
|
contextInfo.items.push(
|
256
|
264
|
{
|
257
|
|
- action: function (event) {
|
258
|
|
- copyNode(event, node);
|
|
265
|
+ action: function () {
|
|
266
|
+ copyNode(node);
|
259
|
267
|
},
|
260
|
268
|
enabled: true,
|
261
|
269
|
value: "action.copy",
|
...
|
...
|
@@ -324,11 +332,32 @@ export function RuleChainController($state, $scope, $compile, $q, $mdUtil, $time |
324
|
332
|
}
|
325
|
333
|
})
|
326
|
334
|
.add({
|
|
335
|
+ combo: 'ctrl+c',
|
|
336
|
+ description: $translate.instant('rulenode.copy-selected'),
|
|
337
|
+ allowIn: ['INPUT', 'SELECT', 'TEXTAREA'],
|
|
338
|
+ callback: function (event) {
|
|
339
|
+ event.preventDefault();
|
|
340
|
+ copyRuleNodes();
|
|
341
|
+ }
|
|
342
|
+ })
|
|
343
|
+ .add({
|
|
344
|
+ combo: 'ctrl+v',
|
|
345
|
+ description: $translate.instant('action.paste'),
|
|
346
|
+ allowIn: ['INPUT', 'SELECT', 'TEXTAREA'],
|
|
347
|
+ callback: function (event) {
|
|
348
|
+ event.preventDefault();
|
|
349
|
+ if (itembuffer.hasRuleNodes()) {
|
|
350
|
+ pasteRuleNodes();
|
|
351
|
+ }
|
|
352
|
+ }
|
|
353
|
+ })
|
|
354
|
+ .add({
|
327
|
355
|
combo: 'esc',
|
328
|
356
|
description: $translate.instant('rulenode.deselect-all-objects'),
|
329
|
357
|
allowIn: ['INPUT', 'SELECT', 'TEXTAREA'],
|
330
|
358
|
callback: function (event) {
|
331
|
359
|
event.preventDefault();
|
|
360
|
+ event.stopPropagation();
|
332
|
361
|
vm.modelservice.deselectAll();
|
333
|
362
|
}
|
334
|
363
|
})
|
...
|
...
|
@@ -624,17 +653,11 @@ export function RuleChainController($state, $scope, $compile, $q, $mdUtil, $time |
624
|
653
|
}
|
625
|
654
|
}
|
626
|
655
|
|
627
|
|
- function copyNode(event, node) {
|
628
|
|
- var offset = angular.element(vm.canvasControl.modelservice.getCanvasHtmlElement()).offset();
|
629
|
|
- var x = Math.round(event.clientX - offset.left);
|
630
|
|
- var y = Math.round(event.clientY - offset.top);
|
631
|
|
- itembuffer.copyRuleNodes(x, y, [node], []);
|
|
656
|
+ function copyNode(node) {
|
|
657
|
+ itembuffer.copyRuleNodes([node], []);
|
632
|
658
|
}
|
633
|
659
|
|
634
|
|
- function copyRuleNodes(event) {
|
635
|
|
- var offset = angular.element(vm.canvasControl.modelservice.getCanvasHtmlElement()).offset();
|
636
|
|
- var x = Math.round(event.clientX - offset.left);
|
637
|
|
- var y = Math.round(event.clientY - offset.top);
|
|
660
|
+ function copyRuleNodes() {
|
638
|
661
|
var nodes = vm.modelservice.nodes.getSelectedNodes();
|
639
|
662
|
var edges = vm.modelservice.edges.getSelectedEdges();
|
640
|
663
|
var connections = [];
|
...
|
...
|
@@ -655,13 +678,23 @@ export function RuleChainController($state, $scope, $compile, $q, $mdUtil, $time |
655
|
678
|
connections.push(connection);
|
656
|
679
|
}
|
657
|
680
|
}
|
658
|
|
- itembuffer.copyRuleNodes(x, y, nodes, connections);
|
|
681
|
+ itembuffer.copyRuleNodes(nodes, connections);
|
659
|
682
|
}
|
660
|
683
|
|
661
|
684
|
function pasteRuleNodes(event) {
|
662
|
|
- var offset = angular.element(vm.canvasControl.modelservice.getCanvasHtmlElement()).offset();
|
663
|
|
- var x = Math.round(event.clientX - offset.left);
|
664
|
|
- var y = Math.round(event.clientY - offset.top);
|
|
685
|
+ var canvas = angular.element(vm.canvasControl.modelservice.getCanvasHtmlElement());
|
|
686
|
+ var x,y;
|
|
687
|
+ if (event) {
|
|
688
|
+ var offset = canvas.offset();
|
|
689
|
+ x = Math.round(event.clientX - offset.left);
|
|
690
|
+ y = Math.round(event.clientY - offset.top);
|
|
691
|
+ } else {
|
|
692
|
+ var scrollParent = canvas.parent();
|
|
693
|
+ var scrollTop = scrollParent.scrollTop();
|
|
694
|
+ var scrollLeft = scrollParent.scrollLeft();
|
|
695
|
+ x = scrollLeft + scrollParent.width()/2;
|
|
696
|
+ y = scrollTop + scrollParent.height()/2;
|
|
697
|
+ }
|
665
|
698
|
var ruleNodes = itembuffer.pasteRuleNodes(x, y, event);
|
666
|
699
|
if (ruleNodes) {
|
667
|
700
|
vm.modelservice.deselectAll();
|
...
|
...
|
|