This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdefault-functionality.js
More file actions
475 lines (475 loc) · 17.5 KB
/
default-functionality.js
File metadata and controls
475 lines (475 loc) · 17.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var ej2_react_diagrams_1 = require("@syncfusion/ej2-react-diagrams");
var sample_base_1 = require("../common/sample-base");
require("./font-icons.css");
/**
* Diagram Default sample
*/
//Initializes the nodes for the diagram
var nodes = [
{
id: "NewIdea",
height: 60,
offsetX: 300,
offsetY: 80,
shape: { type: "Flow", shape: "Terminator" },
annotations: [
{
content: "Place Order"
}
]
},
{
id: "Meeting",
height: 60,
offsetX: 300,
offsetY: 160,
shape: { type: "Flow", shape: "Process" },
annotations: [
{
content: "Start Transaction"
}
]
},
{
id: "BoardDecision",
height: 60,
offsetX: 300,
offsetY: 240,
shape: { type: "Flow", shape: "Process" },
annotations: [
{
content: "Verification"
}
]
},
{
id: "Project",
height: 60,
offsetX: 300,
offsetY: 330,
shape: { type: "Flow", shape: "Decision" },
annotations: [
{
content: "Credit card valid?"
}
]
},
{
id: "End",
height: 60,
offsetX: 300,
offsetY: 430,
shape: { type: "Flow", shape: "Decision" },
annotations: [
{
content: "Funds available?"
}
]
},
{
id: "node11",
height: 60,
offsetX: 545,
offsetY: 330,
shape: { type: "Flow", shape: "Process" },
annotations: [
{
content: "Enter payment method"
}
]
},
{
id: "transaction_entered",
height: 60,
offsetX: 300,
offsetY: 630,
shape: { type: "Flow", shape: "Terminator" },
annotations: [
{
content: "Log transaction"
}
]
},
{
id: "node12",
height: 60,
offsetX: 480,
offsetY: 630,
shape: { type: "Flow", shape: "Process" },
annotations: [
{
content: "Reconcile the entries"
}
]
},
{
id: "transaction_completed",
height: 60,
offsetX: 300,
offsetY: 530,
shape: { type: "Flow", shape: "Process" },
annotations: [
{
content: "Complete Transaction"
}
]
},
{
id: "Data",
height: 45,
offsetX: 110,
offsetY: 530,
shape: { type: "Flow", shape: "Data" },
annotations: [
{
content: "Send e-mail",
margin: { left: 25, right: 25 }
}
]
},
{
id: "node10",
height: 70,
offsetX: 475,
offsetY: 530,
shape: { type: "Flow", shape: "DirectData" },
annotations: [
{ content: "Customer Database", margin: { left: 25, right: 25 } }
]
}
];
//Initializes the connector for the diagram
var connectors = [
{
id: "connector1",
sourceID: "NewIdea",
targetID: "Meeting"
},
{ id: "connector2", sourceID: "Meeting", targetID: "BoardDecision" },
{ id: "connector3", sourceID: "BoardDecision", targetID: "Project" },
{
id: "connector4",
sourceID: "Project",
annotations: [{ content: "Yes", style: { fill: "white" } }],
targetID: "End"
},
{
id: "connector5",
sourceID: "End",
annotations: [{ content: "Yes", style: { fill: "white" } }],
targetID: "transaction_completed"
},
{
id: "connector6",
sourceID: "transaction_completed",
targetID: "transaction_entered"
},
{ id: "connector7", sourceID: "transaction_completed", targetID: "Data" },
{ id: "connector8", sourceID: "transaction_completed", targetID: "node10" },
{
id: "connector9",
sourceID: "node11",
targetID: "Meeting",
segments: [{ direction: "Top", type: 'Orthogonal', length: 120 }]
},
{
id: "connector10",
sourceID: "End",
annotations: [{ content: "No", style: { fill: "white" } }],
targetID: "node11",
segments: [{ direction: "Right", type: 'Orthogonal', length: 100 }]
},
{
id: "connector11",
sourceID: "Project",
annotations: [{ content: "No", style: { fill: "white" } }],
targetID: "node11"
},
{
id: "connector12",
style: { strokeDashArray: "2,2" },
sourceID: "transaction_entered",
targetID: "node12"
}
];
//Initialize the flowshapes for the symbol palatte
var flowshapes = [
{ id: "Terminator", shape: { type: "Flow", shape: "Terminator" } },
{ id: "Process", shape: { type: "Flow", shape: "Process" } },
{ id: "Decision", shape: { type: "Flow", shape: "Decision" } },
{ id: "Document", shape: { type: "Flow", shape: "Document" } },
{
id: "PreDefinedProcess",
shape: { type: "Flow", shape: "PreDefinedProcess" }
},
{ id: "PaperTap", shape: { type: "Flow", shape: "PaperTap" } },
{ id: "DirectData", shape: { type: "Flow", shape: "DirectData" } },
{ id: "SequentialData", shape: { type: "Flow", shape: "SequentialData" } },
{ id: "Sort", shape: { type: "Flow", shape: "Sort" } },
{ id: "MultiDocument", shape: { type: "Flow", shape: "MultiDocument" } },
{ id: "Collate", shape: { type: "Flow", shape: "Collate" } },
{ id: "SummingJunction", shape: { type: "Flow", shape: "SummingJunction" } },
{ id: "Or", shape: { type: "Flow", shape: "Or" } },
{ id: "InternalStorage", shape: { type: "Flow", shape: "InternalStorage" } },
{ id: "Extract", shape: { type: "Flow", shape: "Extract" } },
{ id: "ManualOperation", shape: { type: "Flow", shape: "ManualOperation" } },
{ id: "Merge", shape: { type: "Flow", shape: "Merge" } },
{
id: "OffPageReference",
shape: { type: "Flow", shape: "OffPageReference" }
},
{
id: "SequentialAccessStorage",
shape: { type: "Flow", shape: "SequentialAccessStorage" }
},
{ id: "Annotation", shape: { type: "Flow", shape: "Annotation" } },
{ id: "Annotation2", shape: { type: "Flow", shape: "Annotation2" } },
{ id: "Data", shape: { type: "Flow", shape: "Data" } },
{ id: "Card", shape: { type: "Flow", shape: "Card" } },
{ id: "Delay", shape: { type: "Flow", shape: "Delay" } }
];
//Initializes connector symbols for the symbol palette
var connectorSymbols = [
{
id: "Link1",
type: "Orthogonal",
sourcePoint: { x: 0, y: 0 },
targetPoint: { x: 60, y: 60 },
targetDecorator: { shape: "Arrow" },
style: { strokeWidth: 1 }
},
{
id: "link3",
type: "Orthogonal",
sourcePoint: { x: 0, y: 0 },
targetPoint: { x: 60, y: 60 },
style: { strokeWidth: 1 },
targetDecorator: { shape: "None" }
},
{
id: "Link21",
type: "Straight",
sourcePoint: { x: 0, y: 0 },
targetPoint: { x: 60, y: 60 },
targetDecorator: { shape: "Arrow" },
style: { strokeWidth: 1 }
},
{
id: "link23",
type: "Straight",
sourcePoint: { x: 0, y: 0 },
targetPoint: { x: 60, y: 60 },
style: { strokeWidth: 1 },
targetDecorator: { shape: "None" }
},
{
id: "link33",
type: "Bezier",
sourcePoint: { x: 0, y: 0 },
targetPoint: { x: 60, y: 60 },
style: { strokeWidth: 1 },
targetDecorator: { shape: "None" }
}
];
var interval;
interval = [
1,
9,
0.25,
9.75,
0.25,
9.75,
0.25,
9.75,
0.25,
9.75,
0.25,
9.75,
0.25,
9.75,
0.25,
9.75,
0.25,
9.75,
0.25,
9.75
];
var gridlines = {
lineColor: "#e0e0e0",
lineIntervals: interval
};
var Default = (function (_super) {
__extends(Default, _super);
function Default() {
return _super !== null && _super.apply(this, arguments) || this;
}
Default.prototype.rendereComplete = function () {
addEvents();
};
Default.prototype.render = function () {
return (React.createElement("div", { className: "control-pane" },
React.createElement("div", { className: "control-section" },
React.createElement("div", { style: { width: "100%" } },
React.createElement("div", { className: "sb-mobile-palette-bar" },
React.createElement("div", { id: "palette-icon", style: { float: "right", role: "button" }, className: "e-ddb-icons1 e-toggle-palette" })),
React.createElement("div", { id: "palette-space", className: "sb-mobile-palette" },
React.createElement(ej2_react_diagrams_1.SymbolPaletteComponent, { id: "symbolpalette", expandMode: "Multiple", palettes: [
{
id: "flow",
expanded: true,
symbols: flowshapes,
iconCss: "e-diagram-icons1 e-diagram-flow",
title: "Flow Shapes"
},
{
id: "connectors",
expanded: true,
symbols: connectorSymbols,
iconCss: "e-diagram-icons1 e-diagram-connector",
title: "Connectors"
}
], width: "100%", height: "700px", symbolHeight: 60, symbolWidth: 60, getNodeDefaults: function (symbol) {
if (symbol.id === "Terminator" ||
symbol.id === "Process" ||
symbol.id === "Delay") {
symbol.width = 80;
symbol.height = 40;
}
else if (symbol.id === "Decision" ||
symbol.id === "Document" ||
symbol.id === "PreDefinedProcess" ||
symbol.id === "PaperTap" ||
symbol.id === "DirectData" ||
symbol.id === "MultiDocument" ||
symbol.id === "Data") {
symbol.width = 50;
symbol.height = 40;
}
else {
symbol.width = 50;
symbol.height = 50;
}
}, symbolMargin: { left: 15, right: 15, top: 15, bottom: 15 }, getSymbolInfo: function (symbol) {
return { fit: true };
} })),
React.createElement("div", { id: "diagram-space", className: "sb-mobile-diagram" },
React.createElement(ej2_react_diagrams_1.DiagramComponent, { id: "diagram", width: "100%", height: "700px", snapSettings: {
horizontalGridlines: gridlines,
verticalGridlines: gridlines
}, nodes: nodes, connectors: connectors, getNodeDefaults: function (node) {
var obj = {};
if (obj.width === undefined) {
obj.width = 145;
}
else {
var ratio = 100 / obj.width;
obj.width = 100;
obj.height *= ratio;
}
obj.style = { fill: "#357BD2", strokeColor: "white" };
obj.annotations = [
{ style: { color: "white", fill: "transparent" } }
];
//Set ports
obj.ports = getPorts(node);
return obj;
}, getConnectorDefaults: function (obj) {
if (obj.id.indexOf("connector") !== -1) {
obj.type = "Orthogonal";
obj.targetDecorator = {
shape: "Arrow",
width: 10,
height: 10
};
}
},
//Sets the Node style for DragEnter element.
dragEnter: function (args) {
var obj = args.element;
if (obj instanceof ej2_react_diagrams_1.Node) {
var oWidth = obj.width;
var oHeight = obj.height;
var ratio = 100 / obj.width;
obj.width = 100;
obj.height *= ratio;
obj.offsetX += (obj.width - oWidth) / 2;
obj.offsetY += (obj.height - oHeight) / 2;
obj.style = { fill: "#357BD2", strokeColor: "white" };
}
} })))),
React.createElement("div", { id: "action-description" },
React.createElement("p", null, "This sample visualizes the processing of an order placed using credit card with built-in flow shapes.")),
React.createElement("div", { id: "description" },
React.createElement("p", null,
"This example shows how to create a simple flow chart using the diagram control. The ",
React.createElement("code", null, "nodes"),
" property can be used to define different stages of a process. To define the flow between different stages, the ",
React.createElement("code", null, "connectors"),
" property can be used. The ",
React.createElement("code", null, "getNodeDefaults"),
" and",
" ",
React.createElement("code", null, "getConnectorDefaults"),
" properties define the default behavior of shapes and connectors."),
React.createElement("p", null,
"To easily build flow diagrams, few shapes are predefined and added to symbol palette. You can drag-and-drop predefined shapes into the drawing area. The ",
React.createElement("code", null, "symbols"),
" property allows you to add predefined symbols to the palette."),
React.createElement("p", null, "In this example, undo and redo support is enabled."),
React.createElement("p", { style: { fontWeight: 500 } }, "Injecting Module"),
React.createElement("p", null,
"The diagram component\u2019s features are segregated into individual feature-wise modules. To enable undo and redo support, inject",
" ",
React.createElement("code", null, "UndoRedo"),
" module into ",
React.createElement("code", null, "services"),
"."),
React.createElement("br", null))));
};
return Default;
}(sample_base_1.SampleBase));
exports.Default = Default;
function getPorts(obj) {
var ports = [
{ id: "port1", shape: "Circle", offset: { x: 0, y: 0.5 } },
{ id: "port2", shape: "Circle", offset: { x: 0.5, y: 1 } },
{ id: "port3", shape: "Circle", offset: { x: 1, y: 0.5 } },
{ id: "port4", shape: "Circle", offset: { x: 0.5, y: 0 } }
];
return ports;
}
var isMobile;
function addEvents() {
isMobile = window.matchMedia('(max-width:550px)').matches;
if (isMobile) {
var paletteIcon = document.getElementById('palette-icon');
if (paletteIcon) {
paletteIcon.addEventListener('click', openPalette, false);
}
}
}
function openPalette() {
var paletteSpace = document.getElementById('palette-space');
isMobile = window.matchMedia('(max-width:550px)').matches;
if (isMobile) {
if (!paletteSpace.classList.contains('sb-mobile-palette-open')) {
paletteSpace.classList.add('sb-mobile-palette-open');
}
else {
paletteSpace.classList.remove('sb-mobile-palette-open');
}
}
}