@dualbox/editor 1.0.39 → 1.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,15 +3,19 @@ class Selector {
3
3
  this.parent = parent;
4
4
  this.container = container;
5
5
  // translateZ(0) avoid paint glitches in chrome as it forces a repaint every time
6
- this.div = $('<div/>', { id: 'selector', hidden: true, style: "border: 1px dotted #000; position: absolute; z-index: 100; transform: translateZ(0);" });
6
+ this.div = $('<div/>', {
7
+ id: 'selector',
8
+ hidden: true,
9
+ style: "border: 1px dotted #000; position: absolute; z-index: 100; transform: translateZ(0);"
10
+ });
7
11
  this.x1 = 0;
8
12
  this.x2 = 0;
9
13
  this.y1 = 0;
10
14
  this.y2 = 0;
11
15
 
12
16
  this.startEventHandler = this.onSelectionStart.bind(this);
13
- this.moveEventHandler = this.onSelectionMove.bind(this);
14
- this.stopEventHandler = this.onSelectionStop.bind(this);
17
+ this.moveEventHandler = this.onSelectionMove.bind(this);
18
+ this.stopEventHandler = this.onSelectionStop.bind(this);
15
19
 
16
20
  // offset difference relative to pageX/Y
17
21
  // we can't use offsetX and offsetY directly cause their value will be 0
@@ -32,10 +36,20 @@ class Selector {
32
36
  this.container.append(this.div);
33
37
  this.container.off('mousedown', this.startEventHandler);
34
38
  this.container.off('mousemove', this.moveEventHandler);
35
- this.container.off('mouseup', this.stopEventHandler);
39
+ this.container.off('mouseup', this.stopEventHandler);
36
40
  this.container.on('mousedown', this.startEventHandler);
37
41
  this.container.on('mousemove', this.moveEventHandler);
38
- this.container.on('mouseup', this.stopEventHandler);
42
+ this.container.on('mouseup', this.stopEventHandler);
43
+ }
44
+
45
+ each(cb) {
46
+ _.each(this.selection, selected => {
47
+ cb(selected);
48
+ });
49
+ }
50
+
51
+ isMultipleSelectionActive() {
52
+ return this.selection.length > 1;
39
53
  }
40
54
 
41
55
  getSelection() {
@@ -50,7 +64,7 @@ class Selector {
50
64
  isSelected(div) {
51
65
  var selected = false;
52
66
  _.each(this.selection, (selectedDiv) => {
53
- if( $(div).is( $(selectedDiv) ) ) {
67
+ if ($(div).is($(selectedDiv))) {
54
68
  selected = true;
55
69
  return false; // end of loop
56
70
  }
@@ -68,7 +82,7 @@ class Selector {
68
82
 
69
83
  // find the index
70
84
  _.each(this.selection, (selectedDiv, index) => {
71
- if( $(div).is( $(selectedDiv) ) ) {
85
+ if ($(div).is($(selectedDiv))) {
72
86
  i = index;
73
87
  return false; // end of loop
74
88
  }
@@ -79,32 +93,31 @@ class Selector {
79
93
  }
80
94
 
81
95
  toggleSelection(div) {
82
- if( this.isSelected(div) ) {
96
+ if (this.isSelected(div)) {
83
97
  this.removeFromSelection(div);
84
- }
85
- else {
98
+ } else {
86
99
  this.addToSelection(div);
87
100
  }
88
101
  this.handleSelectionMenu();
89
102
  }
90
103
 
91
- onSelect( cb ) {
104
+ onSelect(cb) {
92
105
  this.onSelectCb = cb;
93
106
  }
94
107
 
95
- onSelecting( cb ) {
108
+ onSelecting(cb) {
96
109
  this.onSelectingCb = cb;
97
110
  }
98
111
 
99
- onDeselect( cb ) {
112
+ onDeselect(cb) {
100
113
  this.onDeselectCb = cb;
101
114
  }
102
115
 
103
116
  reCalc() {
104
- var x3 = Math.min(this.x1,this.x2);
105
- var x4 = Math.max(this.x1,this.x2);
106
- var y3 = Math.min(this.y1,this.y2);
107
- var y4 = Math.max(this.y1,this.y2);
117
+ var x3 = Math.min(this.x1, this.x2);
118
+ var x4 = Math.max(this.x1, this.x2);
119
+ var y3 = Math.min(this.y1, this.y2);
120
+ var y4 = Math.max(this.y1, this.y2);
108
121
 
109
122
  this.div[0].style.left = (x3 - this.diffX) + 'px';
110
123
  this.div[0].style.top = (y3 - this.diffY) + 'px';
@@ -118,19 +131,19 @@ class Selector {
118
131
  // - it's over the container
119
132
  // - it's not over a container's button
120
133
  // - it's not over a "capture-left-click" item
121
- if( e.which === 1 &&
134
+ if (e.which === 1 &&
122
135
  this.container.find('.btn:hover').length == 0 &&
123
136
  this.container.find('.nodrag:hover').length == 0 &&
124
137
  this.container.find('.jtk-connector:hover').length == 0 &&
125
138
  this.container.find('.capture-left-click:hover').length == 0
126
139
  ) {
127
- if( this.container.is(':hover') ) {
140
+ if (this.container.is(':hover')) {
128
141
  // we're starting a selection
129
142
  e.preventDefault();
130
143
  e.stopPropagation();
131
144
 
132
145
  // remove previous selection
133
- if( this.onDeselectCb ) {
146
+ if (this.onDeselectCb) {
134
147
  this.onDeselectCb(this.selection);
135
148
  this.selection = [];
136
149
  }
@@ -150,7 +163,7 @@ class Selector {
150
163
  }
151
164
 
152
165
  onSelectionMove(e) {
153
- if( this.selecting ) {
166
+ if (this.selecting) {
154
167
  e.preventDefault();
155
168
  e.stopPropagation();
156
169
 
@@ -159,14 +172,14 @@ class Selector {
159
172
  this.y2 = e.pageY;
160
173
  this.reCalc();
161
174
 
162
- if( this.onSelectingCb ) {
175
+ if (this.onSelectingCb) {
163
176
  // now we have our area, find all divs in it and return
164
177
  // result to the onSelectCb
165
178
  this.findCardDivs({
166
- left : Math.min(this.x1, this.x2),
167
- right : Math.max(this.x1, this.x2),
168
- top : Math.min(this.y1, this.y2),
169
- bottom : Math.max(this.y1, this.y2)
179
+ left: Math.min(this.x1, this.x2),
180
+ right: Math.max(this.x1, this.x2),
181
+ top: Math.min(this.y1, this.y2),
182
+ bottom: Math.max(this.y1, this.y2)
170
183
  }, (divs) => {
171
184
  this.selection = divs;
172
185
  this.handleSelectionMenu();
@@ -177,7 +190,7 @@ class Selector {
177
190
  }
178
191
 
179
192
  onSelectionStop(e) {
180
- if( this.selecting && e.which === 1 ) {
193
+ if (this.selecting && e.which === 1) {
181
194
  e.preventDefault();
182
195
  e.stopPropagation();
183
196
 
@@ -185,14 +198,14 @@ class Selector {
185
198
  this.selecting = false;
186
199
  this.div[0].hidden = 1;
187
200
 
188
- if( this.onSelectCb ) {
201
+ if (this.onSelectCb) {
189
202
  // now we have our area, find all divs in it and return
190
203
  // result to the onSelectCb
191
204
  this.findCardDivs({
192
- left : Math.min(this.x1, this.x2),
193
- right : Math.max(this.x1, this.x2),
194
- top : Math.min(this.y1, this.y2),
195
- bottom : Math.max(this.y1, this.y2)
205
+ left: Math.min(this.x1, this.x2),
206
+ right: Math.max(this.x1, this.x2),
207
+ top: Math.min(this.y1, this.y2),
208
+ bottom: Math.max(this.y1, this.y2)
196
209
  }, (divs) => {
197
210
  this.selection = divs;
198
211
  this.handleSelectionMenu();
@@ -202,12 +215,12 @@ class Selector {
202
215
  }
203
216
  }
204
217
 
205
- findCardDivs( area, cb ) {
218
+ findCardDivs(area, cb) {
206
219
  var self = this;
207
220
  var selectedCards = [];
208
- this.container.find('.card, .connection-control').each(function() {
209
- if( self._intersects( $(this), area ) ) {
210
- selectedCards.push($(this));
221
+ this.container.find('.card, .connection-control').each(function () {
222
+ if (self._intersects($(this), area)) {
223
+ selectedCards.push($(this)[0]);
211
224
  }
212
225
  });
213
226
 
@@ -215,25 +228,24 @@ class Selector {
215
228
  }
216
229
 
217
230
  // utilities
218
- _intersects( div, area ) {
231
+ _intersects(div, area) {
219
232
  var r1 = $(div)[0].getBoundingClientRect();
220
233
  var r2 = area;
221
234
  var res = !(r2.left > r1.right ||
222
- r2.right < r1.left ||
223
- r2.top > r1.bottom ||
224
- r2.bottom < r1.top);
235
+ r2.right < r1.left ||
236
+ r2.top > r1.bottom ||
237
+ r2.bottom < r1.top);
225
238
  return res;
226
239
  }
227
240
 
228
241
  // show/hide the selection menu if we have more than 2 divs selected
229
242
  handleSelectionMenu() {
230
- if( this.selection.length > 1 ) {
243
+ if (this.selection.length > 1) {
231
244
  this.parent.view.div.find('.selection-menu').show();
232
- }
233
- else {
245
+ } else {
234
246
  this.parent.view.div.find('.selection-menu').hide();
235
247
  }
236
248
  }
237
249
  }
238
250
 
239
- export default Selector;
251
+ export default Selector;
@@ -344,7 +344,7 @@ export default {
344
344
  closeModal: function() {
345
345
  // don't mutate prop directly, mute the parent
346
346
  // this.display = false;
347
- this.$emit('close');
347
+ this.$emit('closed');
348
348
  },
349
349
 
350
350
  setSearchFocus : function() {
@@ -51,9 +51,9 @@
51
51
  }
52
52
 
53
53
  .edit-body {
54
- overflow-y: auto;
54
+ overflow-y: hidden;
55
55
  overflow-x: hidden;
56
- max-height: calc(100% - 80px);
56
+ max-height: calc(100% - 90px);
57
57
  }
58
58
 
59
59
  /* remove bs4 transition on collapsing */
@@ -130,20 +130,24 @@ i.fa, i.fas, i.far {
130
130
  pointer-events: none;
131
131
  }
132
132
 
133
+ .h100 {
134
+ height: 100%;
135
+ }
136
+
133
137
  </style>
134
138
 
135
139
  <template>
136
140
 
137
141
  <div class="edit-main-panel h100" id="edit-main-panel">
138
- <div style="padding-left: 10px; padding-top: 10px; padding-right: 10px;">
139
- <h2 class="edit-dualbox-app">
142
+ <div class="edit-main-presentation" style="padding-left: 10px; padding-top: 10px; padding-right: 10px; padding-bottom 10px;">
143
+ <h2 class="edit-dualbox-app" style="margin-bottom: none;">
140
144
  <div class="dualbox-node-name">
141
145
  <span class="text-truncate d-inline-block" style="width: 290px">Application</span>
142
146
  </div>
143
147
  </h2>
144
148
  </div>
145
149
 
146
- <div class="edit-body">
150
+ <div class="edit-body h100">
147
151
  <div class="card">
148
152
  <div class="card-header" id="dualbox-main-desc" data-toggle="collapse" data-target="#dualbox-main-desc-collapse" aria-expanded="false" aria-controls="dualbox-main-desc-collapse">
149
153
  <h5 class="mb-0 btn-link">Description</h5>
@@ -392,8 +396,22 @@ export default {
392
396
  mounted: function() {
393
397
  // bind tooltips
394
398
  $(this.$el).find('button[data-toggle="tooltip"]').tooltip();
399
+ this.fixMaxHeightForCategories();
400
+ },
401
+ updated: function() {
402
+ this.fixMaxHeightForCategories();
395
403
  },
396
404
  methods: {
405
+ // setup a max height for each menu, so a scroll appears if there's too much item in it
406
+ fixMaxHeightForCategories : function() {
407
+ let nbActiveCategories = $(this.$el).find('.edit-body > .card').length;
408
+ let headerHeight = $(this.$el).find('.edit-body > .card > .card-header').outerHeight();
409
+ let panelHeight = $(this.$el).height() - $(this.$el).find('.edit-main-presentation').outerHeight();
410
+ let maxCategoryHeight = panelHeight - nbActiveCategories * headerHeight;
411
+ $(this.$el).find('.edit-body').css('height', panelHeight);
412
+ $(this.$el).find('.edit-body > .card > .collapse > .card-body').css('max-height', maxCategoryHeight + "px");
413
+ },
414
+
397
415
  onEdited: function() {
398
416
  this.view.repaint();
399
417
  },
@@ -28,6 +28,7 @@
28
28
  font-size: 12px;
29
29
  padding-left: 5px;
30
30
  padding-right: 5px;
31
+ overflow-y: auto;
31
32
  }
32
33
 
33
34
  .table-desc {
@@ -86,9 +87,9 @@
86
87
  }
87
88
 
88
89
  .edit-body {
89
- overflow-y: auto;
90
+ overflow-y: hidden;
90
91
  overflow-x: hidden;
91
- max-height: calc(100% - 80px);
92
+ max-height: calc(100% - 90px);
92
93
  }
93
94
 
94
95
  .table-events .event-rooting {
@@ -158,11 +159,15 @@
158
159
  pointer-events: none;
159
160
  }
160
161
 
162
+ .h100 {
163
+ height: 100%;
164
+ }
165
+
161
166
  </style>
162
167
 
163
168
  <template>
164
169
  <div class="edit-node-panel h100" id="edit-node-panel" :key="n.id">
165
- <div style="padding-left: 10px; padding-top: 10px; padding-right: 10px;">
170
+ <div class="edit-node-presentation" style="padding-left: 10px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px;">
166
171
  <h2 class="edit-dualbox-node-id">
167
172
  <div v-if="nowEditingNodeName" class="dualbox-node-name-edit">
168
173
  <input type="text" class="form-control dualbox-node-name-input" style="display: inline-block;" :value="n.graphId" @keypress="changeNodeName" autofocus/>
@@ -173,11 +178,11 @@
173
178
  <span class="dualbox-node-name-span text-truncate d-inline-block">{{n.graphId}}</span>
174
179
  </div>
175
180
  </h2>
176
- <p><small class="edit-dualbox-node-package-name">{{n.getPackageName()}}</small></p>
181
+ <p style="margin-bottom: 0"><small class="edit-dualbox-node-package-name">{{n.getPackageName()}}</small></p>
177
182
  </div>
178
183
 
179
184
  <div class="edit-body">
180
- <div class="card">
185
+ <div class="card card-settings">
181
186
  <div class="card-header" id="dualbox-node-desc" data-toggle="collapse" data-target="#dualbox-node-desc-collapse" aria-expanded="true" aria-controls="dualbox-node-desc-collapse">
182
187
  <h5 class="mb-0 btn-link">Description</h5>
183
188
  </div>
@@ -248,8 +253,8 @@
248
253
 
249
254
  <div v-if="!n.isMetanode()">
250
255
  <label>
251
- <input class="input-worker-toggle" type="checkbox" v-bind:data-id="n.id" v-bind:checked="n.isParallel()" @change="toggleWorker()" />
252
- <span>Execute in a worker <button type="button" class="btn btn-transparent" data-toggle="tooltip" data-placement="top" title="Workers are separate contexts of executions that can execute long-running tasks without blocking the browser execution. Use this for heavy computations." style="padding: 0;"><i class="text-info far fa-question-circle"></i></button></span><br/><span v-if="isParallel" class="text-danger worker-warning" v-show="n.isParallel()">Due to some technical limitations, this will only affect the built bundle. Please run tests on the built bundle as well.</span>
256
+ <input class="input-worker-toggle" type="checkbox" v-bind:data-id="n.id" v-bind:checked="n.isParallel()" @change="toggleWorker" />
257
+ <span>Execute in a worker <button type="button" class="btn btn-transparent" data-toggle="tooltip" data-placement="top" title="Workers are separate contexts of executions that can execute long-running tasks without blocking the browser execution. Use this for heavy computations." style="padding: 0;"><i class="text-info far fa-question-circle"></i></button></span>
253
258
  </label>
254
259
  </div>
255
260
  </div>
@@ -622,6 +627,7 @@ export default {
622
627
  // adapt the style of the example graph node
623
628
  // remove the "position: absolute;" that messes up the display
624
629
  this.fixCardStyle();
630
+ this.fixMaxHeightForCategories();
625
631
 
626
632
  // allow tooltips
627
633
  this.activateTooltip();
@@ -639,6 +645,7 @@ export default {
639
645
  updated: function() {
640
646
  //console.log('[Updated] node-settings');
641
647
  this.fixCardStyle();
648
+ this.fixMaxHeightForCategories();
642
649
  this.activateTooltip();
643
650
  this.focus();
644
651
  },
@@ -665,6 +672,16 @@ export default {
665
672
  });
666
673
  },
667
674
 
675
+ // setup a max height for each menu, so a scroll appears if there's too much item in it
676
+ fixMaxHeightForCategories : function() {
677
+ let nbActiveCategories = $(this.$el).find('.edit-body > .card-settings').length;
678
+ let headerHeight = $(this.$el).find('.edit-body > .card-settings > .card-header').outerHeight();
679
+ let panelHeight = $(this.$el).height() - $(this.$el).find('.edit-node-presentation').outerHeight();
680
+ let maxCategoryHeight = panelHeight - nbActiveCategories * headerHeight;
681
+ $(this.$el).find('.edit-body').css('height', panelHeight);
682
+ $(this.$el).find('.edit-body > .card-settings > .collapse > .card-body').css('max-height', maxCategoryHeight + "px");
683
+ },
684
+
668
685
  activateTooltip: function() {
669
686
  $(this.$el).find('[data-toggle="tooltip"]').tooltip();
670
687
  },
@@ -715,7 +732,7 @@ export default {
715
732
 
716
733
  addEvent: function(e) {
717
734
  this.view.c.addEvent(this.n.id);
718
- this.$forceUpdate();
735
+ this.onEdited();
719
736
  },
720
737
 
721
738
  toggleInputVisibility: function(e) {
@@ -813,22 +830,17 @@ export default {
813
830
  // change options of closest .select-event-name according to this new target
814
831
  var targetNode = this.view.m.getNode(target);
815
832
  var targetEvents = targetNode.getEventsNames();
816
- var select = $(e.target).closest('tr').find('.select-event-name');
817
- select.html('');
818
- _.each(targetEvents, (eventName) => {
819
- select.append( $('<option/>', {
820
- value: eventName
821
- }).append(eventName));
822
- });
823
833
 
824
834
  var index = parseInt($(e.target).attr('data-index'));
825
835
  this.view.c.setEventTarget( this.n.id, index, target );
836
+ this.onEdited();
826
837
  },
827
838
 
828
839
  selectEventName: function(e) {
829
840
  var index = parseInt($(e.target).attr('data-index'));
830
841
  var val = $(e.target).val();
831
842
  this.view.c.setEventName( this.n.id, index, val );
843
+ this.onEdited();
832
844
  },
833
845
 
834
846
  toggleCache: function(e) {
@@ -840,6 +852,7 @@ export default {
840
852
  var val = $(e.target).is(':checked');
841
853
  this.view.c.setBoxParallel( this.n.id, val );
842
854
  this.isParallel = val;
855
+ this.onEdited();
843
856
  },
844
857
 
845
858
  editModuleDescription: function(e) {
@@ -878,7 +891,7 @@ export default {
878
891
  onEditAttributeType(attributeName, typeStr) {
879
892
  this.n.assignAttributeType(attributeName, typeStr);
880
893
  this.onEdited();
881
- this.view.repaint();
894
+ this.view.repaint();
882
895
  },
883
896
 
884
897
  onEditDefaultValue(val) {
@@ -923,12 +923,23 @@ export default {
923
923
  // resize the canvas if necessary
924
924
  self.$parent.canvasSizeHandler.debouncedResize();
925
925
 
926
- // set the new position in the graph model
927
- var el = self.$parent.jsPlumbInstance.getElement(id);
928
- $(el).ready(function() {
929
- var pos = self.$parent.jsPlumbInstance.getPosition(el);
930
- view.m.getNode(id).setPosition(pos);
931
- });
926
+ if( self.$parent.selector.isMultipleSelectionActive() ) {
927
+ // We just dropped a bunch of divs, ajust all their positions
928
+ self.view.m.history.batch(() => {
929
+ self.$parent.selector.each(div => {
930
+ var pos = self.$parent.jsPlumbInstance.getPosition(div);
931
+ view.m.getNode($(div).attr('id')).setPosition(pos);
932
+ });
933
+ });
934
+ }
935
+ else {
936
+ // We just dropped this one, set the new position in the graph model
937
+ var el = self.$parent.jsPlumbInstance.getElement(id);
938
+ $(el).ready(function() {
939
+ var pos = self.$parent.jsPlumbInstance.getPosition(el);
940
+ view.m.getNode(id).setPosition(pos);
941
+ });
942
+ }
932
943
  }
933
944
  });
934
945
  }
@@ -130,9 +130,8 @@
130
130
 
131
131
  .dualbox-graph-left-window {
132
132
  width: calc(100% - 35px);
133
- height: calc(100% - 20px);
133
+ height: calc(100% - 10px);
134
134
  margin-top: 10px;
135
- margin-bottom: 30px;
136
135
  /* background-color: #ECF2F8; */
137
136
  background-color: #f8f9fa;
138
137
  /* border: 1px solid grey; */