@dualbox/editor 1.0.69 → 1.0.70

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.
@@ -264,7 +264,8 @@ class DualboxEditor {
264
264
 
265
265
  this.loadCorePackages().then(() => {
266
266
  this.onReady(() => {
267
- var p = this.setApp(attrs.json || defaultApp);
267
+ var hasInputJson = !!attrs.json && !_.isEmpty(attrs.json);
268
+ var p = this.setApp(hasInputJson ? attrs.json : defaultApp);
268
269
  if (attrs.onLoaded) {
269
270
  p.then(attrs.onLoaded);
270
271
  }
@@ -1279,6 +1279,10 @@ class GraphNode {
1279
1279
  }
1280
1280
  }
1281
1281
 
1282
+ isInputHideable(inputName) {
1283
+ return this.isInputConnected(inputName) || this.hasDefaultValue(inputName);
1284
+ }
1285
+
1282
1286
  isInputVisible(inputName) {
1283
1287
  if (this.isInput() || this.isOutput()) {
1284
1288
  return true;
@@ -1286,29 +1290,33 @@ class GraphNode {
1286
1290
  if (this.isInputConnected(inputName)) {
1287
1291
  return true;
1288
1292
  } else {
1289
- var val = idx(this.def, o => o.graph.in.visible[inputName]);
1290
- if (val !== undefined) {
1291
- return val !== false;
1293
+ if (!this.hasDefaultValue(inputName)) {
1294
+ return true; // input that is not connected and has no default value must be visible
1292
1295
  } else {
1293
- // check if the app did set a default value for this input
1294
- var defaultVal = idx(this.def, o => o.defaultInputs[inputName]);
1295
- if (defaultVal !== undefined) {
1296
- return false; // make not visible when default value is set by the app
1297
- }
1296
+ var val = idx(this.def, o => o.graph.in.visible[inputName]);
1297
+ if (val !== undefined) {
1298
+ return val !== false;
1299
+ } else {
1300
+ // check if the app did set a default value for this input
1301
+ var defaultVal = idx(this.def, o => o.defaultInputs[inputName]);
1302
+ if (defaultVal !== undefined) {
1303
+ return false; // make not visible when default value is set by the app
1304
+ }
1298
1305
 
1299
- // else, make the input visible if the package didnt define a default value for it
1300
- var pkg = this.getPackage();
1301
- var pkgDef = idx(pkg, o => o.dualbox.input[inputName]);
1302
- if (pkgDef) {
1303
- if (pkgDef.visible === false) {
1304
- return false;
1305
- } else if (pkgDef.value !== undefined) {
1306
- return false;
1306
+ // else, make the input visible if the package didnt define a default value for it
1307
+ var pkg = this.getPackage();
1308
+ var pkgDef = idx(pkg, o => o.dualbox.input[inputName]);
1309
+ if (pkgDef) {
1310
+ if (pkgDef.visible === false) {
1311
+ return false;
1312
+ } else if (pkgDef.value !== undefined) {
1313
+ return false;
1314
+ } else {
1315
+ return true;
1316
+ }
1307
1317
  } else {
1308
1318
  return true;
1309
1319
  }
1310
- } else {
1311
- return true;
1312
1320
  }
1313
1321
  }
1314
1322
  }
@@ -311,7 +311,10 @@
311
311
  <button v-if="n.hasInputDesc(key)" type="button" class="btn btn-transparent" data-toggle="tooltip" data-placement="right" v-bind:title="n.getInputDesc(key)" style="padding: 0;"><i class="text-info far fa-question-circle"></i></button>
312
312
  </td>
313
313
  <td>
314
- <input class="input-visibility-toggle" type="checkbox" v-bind:data-id="n.id" v-bind:data-input="key" v-bind:checked="n.isInputVisible(key)" @change="toggleInputVisibility">
314
+ <input v-if="n.isInputHideable(key)" class="input-visibility-toggle" type="checkbox" v-bind:data-id="n.id" v-bind:data-input="key" v-bind:checked="n.isInputVisible(key)" @change="toggleInputVisibility">
315
+ <span v-else class="d-inline-block" tabindex="0" data-toggle="tooltip" data-trigger="hover" data-placement="top" data-original-title="Input is not connected, and has no default value. Cannot hide it yet.">
316
+ <input class="input-visibility-toggle" style="pointer-events: none;" type="checkbox" v-bind:checked="n.isInputVisible(key)" disabled>
317
+ </span>
315
318
  </td>
316
319
  <td>
317
320
  <!-- If there's a start, then we must edit the type -->
@@ -100,6 +100,7 @@ export default {
100
100
  created: function() {
101
101
  this.view = window.dualboxEditor.v;
102
102
  this.editor = null;
103
+ this.edited = false;
103
104
  this.initData();
104
105
  },
105
106
  mounted: function() {
@@ -121,6 +122,19 @@ export default {
121
122
  this.updateEditor();
122
123
  }
123
124
  },
125
+ beforeDestroy: function() {
126
+ // make sure the value was set
127
+ if( !this.emitted ) {
128
+ if( this.isBasicDataType()) {
129
+ var elt = $(this.$el).find('.edit-value-input');
130
+ var val = elt.val();
131
+ this.$emit("edited", val);
132
+ }
133
+ else {
134
+ this.saveChanges();
135
+ }
136
+ }
137
+ },
124
138
  methods: {
125
139
  hash: function() {
126
140
  var str = new String(this.v).toString();
@@ -232,26 +246,31 @@ export default {
232
246
 
233
247
  if( this.isTemplateType() ) {
234
248
  this.$emit("edited", this.serialize(this.deserializedValue));
249
+ this.emitted = true;
235
250
  }
236
251
  else if( this.isObjectType() ) {
237
252
  // emit the result to the parent Vue
238
253
  this.$emit("edited", this.editor.get());
254
+ this.emitted = true;
239
255
  }
240
256
  },
241
257
 
242
258
  setStringValue: function(e) {
243
259
  var val = $(e.target).val();
244
260
  this.$emit("edited", val);
261
+ this.emitted = true;
245
262
  },
246
263
 
247
264
  setBoolValue: function(e) {
248
265
  var val = $(e.target).val() == "true";
249
266
  this.$emit("edited", val);
267
+ this.emitted = true;
250
268
  },
251
269
 
252
270
  setNumberValue: function(e) {
253
271
  var val = parseFloat($(e.target).val());
254
272
  this.$emit("edited", val);
273
+ this.emitted = true;
255
274
  },
256
275
 
257
276
  setNullValue: function() {
@@ -142,10 +142,6 @@ import ContextMenu from '../ContextMenu';
142
142
  // jsplumb style definitins
143
143
  import PlumbStyle from '../PlumbStyle';
144
144
 
145
- jQuery.fn.mouseIsOver = function () {
146
- return $(this).parent().find($(this).selector + ":hover").length > 0;
147
- };
148
-
149
145
  export default {
150
146
  props: [
151
147
  "app", // the app model
@@ -194,11 +190,11 @@ export default {
194
190
  // We use this way because it's easier than to set a tabindex on the dualbox-graph-container
195
191
  // to capture keyboard events (will break modals)
196
192
  var self = this;
197
- $(document).keydown(function(e) {
193
+ this.keyDownHandler = function(e) {
198
194
  // Ensure event is not null
199
195
  e = e || window.event;
200
196
 
201
- if( $(self.$el).mouseIsOver() ) {
197
+ if( $(self.$el).is(":hover") ) {
202
198
  if ((e.which == 90 || e.keyCode == 90) && e.ctrlKey) { // ctrl + z
203
199
  self.view.c.undo();
204
200
  }
@@ -210,10 +206,14 @@ export default {
210
206
  self.view.c.deleteSelection();
211
207
  }
212
208
  }
213
- });
209
+ }
214
210
 
211
+ $(document).on("keydown", this.keyDownHandler);
215
212
  return await this.initializeListeners();
216
213
  },
214
+ destroyed: function() {
215
+ $(document).off("keydown", this.keyDownHandler);
216
+ },
217
217
  beforeUpdate: async function() {
218
218
  // Reset the JSPlumb instance
219
219
  this.resetJsPlumb();
@@ -324,14 +324,8 @@ export default {
324
324
  return new Promise((resolve) => this.jsPlumbInstance.ready(resolve));
325
325
  },
326
326
  methods: {
327
- undo : function() {
328
-
329
- },
330
- redo : function() {
331
-
332
- },
333
327
  deleteSelection() {
334
-
328
+ this.view.c.deleteSelection();
335
329
  },
336
330
 
337
331
  getCurrentMousePosition(e) {
@@ -430,7 +430,7 @@ span.name {
430
430
  <div class="names">
431
431
  <span class="name" v-for="key in getVisibleOutputs()" v-bind:class="{feedback: n.isFeedbackTarget(key)}" v-bind:data-output="key">
432
432
  <span v-if="n.hasLoop() && n.hasFeedback(key)">{{key}}</span>
433
- <span v-else-if="n.hasLoop() && !n.hasFeedback(key)" v-html='"&lt;"+key+"&gt;"'></span>
433
+ <span v-else-if="n.hasLoop() && !n.hasFeedback(key)">&lt;{{key}}&gt;</span>
434
434
  <span v-else>{{key}}</span>
435
435
 
436
436
  <span v-if="n.hasCacheActivated()">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dualbox/editor",
3
- "version": "1.0.69",
3
+ "version": "1.0.70",
4
4
  "description": "Editor of Dualbox apps",
5
5
  "browser": "js/dist/GraphEditor.js",
6
6
  "main": "js/dist/GraphEditor.js",