Skip to content

Commit ec6260b

Browse files
committed
feat: add sticky field to transaction
1 parent 4f12244 commit ec6260b

5 files changed

Lines changed: 14 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-design-editor",
3-
"version": "0.0.84",
3+
"version": "0.0.85",
44
"description": "Design Editor Tools with React.js + ant.design + fabric.js",
55
"main": "dist/react-design-editor.cjs.js",
66
"module": "dist/react-design-editor.es.js",

src/canvas/constants/defaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ export const activeSelectionOption = {
7474
hasControls: true,
7575
};
7676

77-
export const propertiesToInclude = ['id', 'name', 'description', 'locked', 'editable', 'configuration'];
77+
export const propertiesToInclude = ['id', 'name', 'description', 'locked', 'editable', 'configuration', 'errors'];

src/canvas/handlers/TransactionHandler.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type StickyNodeFields = Partial<{
4848
configuration: any;
4949
name: string;
5050
description: string;
51+
errors: any;
5152
}>;
5253

5354
class TransactionHandler extends AbstractHandler {
@@ -155,6 +156,9 @@ class TransactionHandler extends AbstractHandler {
155156
// description
156157
if ('description' in anyObj) next.description = anyObj.description;
157158

159+
// errors
160+
if ('errors' in anyObj) next.errors = this.cloneDeep(anyObj.errors);
161+
158162
this.latestNodeSticky.set(id, next);
159163
}
160164
};
@@ -180,10 +184,13 @@ class TransactionHandler extends AbstractHandler {
180184
anyObj.configuration = this.cloneDeep(sticky.configuration);
181185
}
182186
if (Object.prototype.hasOwnProperty.call(sticky, 'name')) {
183-
anyObj.name = this.cloneDeep(sticky.name);
187+
anyObj.name = sticky.name;
184188
}
185189
if (Object.prototype.hasOwnProperty.call(sticky, 'description')) {
186-
anyObj.description = this.cloneDeep(sticky.description);
190+
anyObj.description = sticky.description;
191+
}
192+
if (Object.prototype.hasOwnProperty.call(sticky, 'errors')) {
193+
anyObj.errors = this.cloneDeep(sticky.errors);
187194
}
188195
}
189196
};

src/canvas/objects/Node.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const Node = fabric.util.createClass(fabric.Group, {
107107
left: this.nodeIcon.left + this.nodeIcon.width + 10,
108108
top: this.nodeIcon.top + this.nodeIcon.height / 2 - this.label.height / 2,
109109
});
110-
this.errorFlag.set({ visible: options.errors });
110+
this.setErrors(options.errors);
111111
if (options.descriptor.actionButton) {
112112
this.button.set({
113113
left: this.rect.left + this.rect.width - this.button.width + 1,
@@ -359,6 +359,7 @@ const Node = fabric.util.createClass(fabric.Group, {
359359
cloneable: this.get('cloneable'),
360360
fromPort: this.get('fromPort'),
361361
toPort: this.get('toPort'),
362+
errors: this.get('errors'),
362363
});
363364
},
364365
_render(ctx: CanvasRenderingContext2D) {

src/editors/workflow/WorkflowEditor.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ class WorkflowEditor extends React.Component {
244244
} else {
245245
selectedItem?.setErrors(false);
246246
}
247+
this.canvasRef.handler.transactionHandler.save('configuration');
247248
this.canvasRef.canvas.renderAll();
248249
}, 0);
249250
const configuration = Object.assign({}, selectedItem?.configuration, changedValues.configuration);

0 commit comments

Comments
 (0)