@dualbox/editor 1.0.72 → 1.0.73
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.
- package/html/editor.html +1 -1
- package/js/dist/GraphEditor.js +430 -395
- package/js/dist/GraphEditor.min.js +429 -394
- package/js/src/c/GraphController.js +66 -67
- package/js/src/m/GraphModel.js +34 -9
- package/js/src/m/History.js +23 -6
- package/js/src/v/GraphView.js +4 -0
- package/js/src/v/templates/editMainSettings.vue +1 -1
- package/js/src/v/templates/editNodeSettings.vue +4 -3
- package/js/src/v/templates/editValue.vue +123 -125
- package/js/src/v/templates/graphNode.vue +185 -200
- package/js/src/v/templates/main.vue +192 -175
- package/package.json +1 -1
|
@@ -23,46 +23,54 @@ class GraphController {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
registerNodeToInterface(id) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
var n = this.m.getNode(id);
|
|
28
|
+
if (n.isWidget()) {
|
|
29
|
+
var options = {};
|
|
30
|
+
var registerTargets = n.m.getSpecialUINodes(n.getRegisterType());
|
|
31
|
+
_.each(registerTargets, (n) => options[n.graphId] = n.graphId);
|
|
32
|
+
|
|
33
|
+
swal({
|
|
34
|
+
title: 'Select a registration target',
|
|
35
|
+
text: 'You just added a Widget node. It must be registered to an element of type ' + n.getRegisterType() +
|
|
36
|
+
" to work. Please choose one on the following list.",
|
|
37
|
+
input: 'select',
|
|
38
|
+
inputOptions: options
|
|
39
|
+
}).then(async (result) => {
|
|
40
|
+
if (result.value) {
|
|
41
|
+
// register the widget
|
|
42
|
+
this.registerWidget(n.id, result.value);
|
|
43
|
+
|
|
44
|
+
// find the panel of the target and put the widget on the same panel
|
|
45
|
+
var panel = this.m.getNode(result.value).getPanel();
|
|
46
|
+
this.m.addNodeToPanel(n.id, panel);
|
|
47
|
+
|
|
48
|
+
await this.v.repaint();
|
|
49
|
+
resolve();
|
|
50
|
+
} else {
|
|
51
|
+
reject("No registration target selected");
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
} else {
|
|
55
|
+
var options = {};
|
|
56
|
+
_.each(this.m.getPanels(), (name) => options[name] = name);
|
|
57
|
+
|
|
58
|
+
swal({
|
|
59
|
+
title: 'Select a panel',
|
|
60
|
+
text: 'You just added an UI. Please select in which panel of the app we should locate it.',
|
|
61
|
+
input: 'select',
|
|
62
|
+
inputOptions: options
|
|
63
|
+
}).then(async (result) => {
|
|
64
|
+
if (result.value) {
|
|
65
|
+
this.m.addNodeToPanel(id, result.value);
|
|
66
|
+
await this.v.repaint();
|
|
67
|
+
resolve();
|
|
68
|
+
} else {
|
|
69
|
+
reject("no panel selected");
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
// Add a node from the search results
|
|
@@ -80,32 +88,25 @@ class GraphController {
|
|
|
80
88
|
var pkg = this.e.packages[packageName];
|
|
81
89
|
if (pkg) {
|
|
82
90
|
// first, add node in the model
|
|
83
|
-
// batch it so add node + set position is 1 history change only
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
// batch it so add node + set position + register to UI is 1 history change only
|
|
92
|
+
this.m.batch(async () => {
|
|
93
|
+
var nodeInfo = this.m.addNode(id, pkg);
|
|
94
|
+
if (nodeInfo) {
|
|
95
|
+
if (pos) {
|
|
96
|
+
var node = this.m.getNode(nodeInfo.id);
|
|
97
|
+
node.setPosition(pos);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// if the node is an UI, we also need to add it to a panel
|
|
101
|
+
var n = this.m.getNode(id);
|
|
102
|
+
if (n.isUI()) {
|
|
103
|
+
await this.registerNodeToInterface(id);
|
|
104
|
+
}
|
|
90
105
|
}
|
|
91
106
|
});
|
|
92
107
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
var node = this.m.getNode(nodeInfo.id);
|
|
96
|
-
node.setPosition(pos);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// if model accepts the operation, add it to the view
|
|
100
|
-
//this.v.addNode(id, pkg);
|
|
101
|
-
this.v.repaint();
|
|
102
|
-
|
|
103
|
-
// if the node is an UI, we also need to add it to a panel
|
|
104
|
-
var n = this.m.getNode(id);
|
|
105
|
-
if (n.isUI()) {
|
|
106
|
-
this.registerNodeToInterface(id);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
108
|
+
// repaint
|
|
109
|
+
await this.v.repaint();
|
|
109
110
|
} else {
|
|
110
111
|
console.error('Package ' + packageName + ' not found');
|
|
111
112
|
}
|
|
@@ -280,11 +281,9 @@ class GraphController {
|
|
|
280
281
|
setEventProperty(id, index, prop, val) {
|
|
281
282
|
if (id.startsWith("#application-events-in")) {
|
|
282
283
|
var eventName = id.split('-')[id.split('-').length - 1];
|
|
283
|
-
|
|
284
|
-
def[prop] = val;
|
|
284
|
+
this.m.getCurrentApp().setEventIn(eventName, index, prop, val);
|
|
285
285
|
} else if (id.startsWith("#application-events-out")) {
|
|
286
|
-
|
|
287
|
-
def[prop] = val;
|
|
286
|
+
this.m.getCurrentApp().setEventOut(eventName, prop, val);
|
|
288
287
|
} else {
|
|
289
288
|
var def = this.m.getNode(id).getEvent(index);
|
|
290
289
|
def[prop] = val;
|
package/js/src/m/GraphModel.js
CHANGED
|
@@ -42,13 +42,14 @@ class GraphModel {
|
|
|
42
42
|
windows: null
|
|
43
43
|
};
|
|
44
44
|
this.data.app = null;
|
|
45
|
-
this.
|
|
45
|
+
this.defaultWindows = [
|
|
46
46
|
[this.e.rootAppName, null]
|
|
47
47
|
];
|
|
48
|
+
this.data.windows = _.clone(this.defaultWindows);
|
|
48
49
|
|
|
49
50
|
// An object to save/restore different states of this.data (ctrl-z/ctrl-y)
|
|
50
51
|
this.history = new History(this);
|
|
51
|
-
this.history.setOrigin(_.cloneDeep(this.data.root));
|
|
52
|
+
this.history.setOrigin(_.cloneDeep(this.data.root), _.clone(this.defaultWindows));
|
|
52
53
|
|
|
53
54
|
this.inputPrefix = "in-";
|
|
54
55
|
this.outputPrefix = "out-";
|
|
@@ -72,7 +73,7 @@ class GraphModel {
|
|
|
72
73
|
|
|
73
74
|
await this.addNativeTypes();
|
|
74
75
|
|
|
75
|
-
this.history.setOrigin(_.cloneDeep(this.data.root));
|
|
76
|
+
this.history.setOrigin(_.cloneDeep(this.data.root), _.clone(this.defaultWindows));
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
addNativeTypes() {
|
|
@@ -177,7 +178,6 @@ class GraphModel {
|
|
|
177
178
|
getCleanJson() {
|
|
178
179
|
var json = _.cloneDeep(this.data.root);
|
|
179
180
|
var parser = new AppParser(json);
|
|
180
|
-
console.log('Getting clean json');
|
|
181
181
|
parser.eachNode((json, id) => {
|
|
182
182
|
delete json.snapshot;
|
|
183
183
|
});
|
|
@@ -213,10 +213,23 @@ class GraphModel {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
// batch all changes in a function into one (for history save)
|
|
217
|
+
// if cb returns a Promise, return a Promise that will be resolved once it's all done
|
|
216
218
|
batch(cb) {
|
|
217
|
-
var
|
|
218
|
-
if (
|
|
219
|
-
|
|
219
|
+
var ret = this.history.batch(cb);
|
|
220
|
+
if (ret && ret.then) {
|
|
221
|
+
// it's a promise, wait for it
|
|
222
|
+
return Promise.resolve(ret).then((diff) => {
|
|
223
|
+
if (this.onChangeCb) {
|
|
224
|
+
this.onChangeCb(diff);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
} else {
|
|
228
|
+
// not a promise, ret is our diff
|
|
229
|
+
let diff = ret;
|
|
230
|
+
if (this.onChangeCb) {
|
|
231
|
+
this.onChangeCb(diff);
|
|
232
|
+
}
|
|
220
233
|
}
|
|
221
234
|
}
|
|
222
235
|
|
|
@@ -2394,11 +2407,23 @@ class Application {
|
|
|
2394
2407
|
}
|
|
2395
2408
|
|
|
2396
2409
|
getEventIn(name) {
|
|
2397
|
-
return
|
|
2410
|
+
return _.get(this.json, ["events", name, "in"]);
|
|
2398
2411
|
}
|
|
2399
2412
|
|
|
2400
2413
|
getEventOut(name) {
|
|
2401
|
-
return
|
|
2414
|
+
return _.get(this.json, ["events", name, "out"]);
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
setEventIn(appEventName, index, prop, val) {
|
|
2418
|
+
var def = this.m.getCurrentApp().getEventIn(appEventName)[index];
|
|
2419
|
+
def[prop] = val;
|
|
2420
|
+
this.m.save();
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
setEventOut(appEventName, prop, val) {
|
|
2424
|
+
var def = this.m.getCurrentApp().getEventOut(appEventName);
|
|
2425
|
+
def[prop] = val;
|
|
2426
|
+
this.m.save();
|
|
2402
2427
|
}
|
|
2403
2428
|
|
|
2404
2429
|
removeAppEvent(name) {
|
package/js/src/m/History.js
CHANGED
|
@@ -67,11 +67,11 @@ class History {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
setOrigin(origin) {
|
|
70
|
+
setOrigin(origin, windows) {
|
|
71
71
|
this.states = [];
|
|
72
72
|
this.current = -1;
|
|
73
73
|
this.origin = origin;
|
|
74
|
-
this.lastState = origin;
|
|
74
|
+
this.lastState = { root: origin, app: null, windows: windows || null };
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
getState(n) {
|
|
@@ -100,6 +100,7 @@ class History {
|
|
|
100
100
|
this.lastState = currentAppClone;
|
|
101
101
|
this.pushState(diff);
|
|
102
102
|
this.current++;
|
|
103
|
+
console.log("SAVED");
|
|
103
104
|
return {
|
|
104
105
|
diff: this.clone(diff),
|
|
105
106
|
hash: previousHash
|
|
@@ -140,14 +141,30 @@ class History {
|
|
|
140
141
|
|
|
141
142
|
// execute the callback and save the history as 1 change
|
|
142
143
|
batch(cb) {
|
|
143
|
-
this.ignore(cb);
|
|
144
|
-
|
|
144
|
+
let ret = this.ignore(cb);
|
|
145
|
+
if (ret && ret.then) {
|
|
146
|
+
// its a promise
|
|
147
|
+
return Promise.resolve(ret).then(() => {
|
|
148
|
+
return this.save();
|
|
149
|
+
});
|
|
150
|
+
} else {
|
|
151
|
+
return this.save();
|
|
152
|
+
}
|
|
145
153
|
}
|
|
146
154
|
|
|
155
|
+
// ignore history saves during the time of the callback
|
|
156
|
+
// if cb return a promise, wait until it's resolved and return a Promise
|
|
147
157
|
ignore(cb) {
|
|
148
158
|
this.holdSaving(true);
|
|
149
|
-
cb();
|
|
150
|
-
|
|
159
|
+
let ret = cb();
|
|
160
|
+
if (ret && ret.then) {
|
|
161
|
+
// its a promise
|
|
162
|
+
return Promise.resolve(ret).then(() => {
|
|
163
|
+
this.holdSaving(false);
|
|
164
|
+
});
|
|
165
|
+
} else {
|
|
166
|
+
this.holdSaving(false);
|
|
167
|
+
}
|
|
151
168
|
}
|
|
152
169
|
}
|
|
153
170
|
|
package/js/src/v/GraphView.js
CHANGED
|
@@ -147,6 +147,10 @@ class GraphView {
|
|
|
147
147
|
await this.hideCanvas();
|
|
148
148
|
await this.setNavigation();
|
|
149
149
|
|
|
150
|
+
// update the html and css editor
|
|
151
|
+
this.mainVue.htmlCode.refresh();
|
|
152
|
+
this.mainVue.cssCode.refresh();
|
|
153
|
+
|
|
150
154
|
// first deactivate the zoom
|
|
151
155
|
await this.zoomer.deactivate();
|
|
152
156
|
|
|
@@ -244,7 +244,7 @@ i.fa, i.fas, i.far {
|
|
|
244
244
|
</template>
|
|
245
245
|
<tr>
|
|
246
246
|
<td colspan="5" style="padding-top: 0px; padding-bottom: 0px;">
|
|
247
|
-
<button class="btn btn-sm btn-add-subevent" style="width: 100%;" @click="addSubEvent(key)">Add a subevent</button>
|
|
247
|
+
<button class="btn btn-secondary btn-sm btn-add-subevent" style="width: 100%;" @click="addSubEvent(key)">Add a subevent</button>
|
|
248
248
|
</td>
|
|
249
249
|
</tr>
|
|
250
250
|
</tbody>
|
|
@@ -174,8 +174,7 @@
|
|
|
174
174
|
<button class="btn btn-primary btn-save-node-name-change" :data-id="n.graphId" style="display: inline-block;" @click="saveNodeName">Save</button>
|
|
175
175
|
</div>
|
|
176
176
|
<div v-else class="dualbox-node-name">
|
|
177
|
-
<
|
|
178
|
-
<span class="dualbox-node-name-span text-truncate d-inline-block">{{n.graphId}}</span>
|
|
177
|
+
<span class="dualbox-node-name-span text-truncate d-inline-block" @click="editNodeName">{{n.graphId}}</span>
|
|
179
178
|
</div>
|
|
180
179
|
</h2>
|
|
181
180
|
<p style="margin-bottom: 0"><small class="edit-dualbox-node-package-name">{{n.getPackageName()}}</small></p>
|
|
@@ -494,7 +493,7 @@
|
|
|
494
493
|
</template>
|
|
495
494
|
<tr>
|
|
496
495
|
<td colspan="5" style="padding-top: 0px; padding-bottom: 0px;">
|
|
497
|
-
<button class="btn btn-sm" :data-id="n.id" style="width: 100%;" @click="addEvent">Add event</button>
|
|
496
|
+
<button class="btn btn-secondary btn-sm" :data-id="n.id" style="width: 100%;" @click="addEvent">Add event</button>
|
|
498
497
|
</td>
|
|
499
498
|
</tr>
|
|
500
499
|
</tbody>
|
|
@@ -762,6 +761,8 @@ export default {
|
|
|
762
761
|
},
|
|
763
762
|
|
|
764
763
|
editNodeName: function(e) {
|
|
764
|
+
e.preventDefault();
|
|
765
|
+
e.stopPropagation();
|
|
765
766
|
this.nowEditingNodeName = true;
|
|
766
767
|
},
|
|
767
768
|
|