...
|
...
|
@@ -20,6 +20,7 @@ import { |
20
|
20
|
ElementRef,
|
21
|
21
|
HostBinding,
|
22
|
22
|
Inject,
|
|
23
|
+ OnDestroy,
|
23
|
24
|
OnInit,
|
24
|
25
|
QueryList,
|
25
|
26
|
SkipSelf,
|
...
|
...
|
@@ -64,7 +65,7 @@ import { |
64
|
65
|
} from '@shared/models/rule-node.models';
|
65
|
66
|
import { FcRuleNodeModel, FcRuleNodeTypeModel, RuleChainMenuContextInfo } from './rulechain-page.models';
|
66
|
67
|
import { RuleChainService } from '@core/http/rule-chain.service';
|
67
|
|
-import { fromEvent, NEVER, Observable, of } from 'rxjs';
|
|
68
|
+import { fromEvent, NEVER, Observable, of, Subscription } from 'rxjs';
|
68
|
69
|
import { debounceTime, distinctUntilChanged, mergeMap, tap } from 'rxjs/operators';
|
69
|
70
|
import { ISearchableComponent } from '../../models/searchable-component.models';
|
70
|
71
|
import { deepClone } from '@core/utils';
|
...
|
...
|
@@ -85,7 +86,7 @@ import Timeout = NodeJS.Timeout; |
85
|
86
|
encapsulation: ViewEncapsulation.None
|
86
|
87
|
})
|
87
|
88
|
export class RuleChainPageComponent extends PageComponent
|
88
|
|
- implements AfterViewInit, OnInit, HasDirtyFlag, ISearchableComponent {
|
|
89
|
+ implements AfterViewInit, OnInit, OnDestroy, HasDirtyFlag, ISearchableComponent {
|
89
|
90
|
|
90
|
91
|
get isDirty(): boolean {
|
91
|
92
|
return this.isDirtyValue || this.isImport;
|
...
|
...
|
@@ -234,6 +235,8 @@ export class RuleChainPageComponent extends PageComponent |
234
|
235
|
|
235
|
236
|
flowchartConstants = FlowchartConstants;
|
236
|
237
|
|
|
238
|
+ private rxSubscription: Subscription;
|
|
239
|
+
|
237
|
240
|
private tooltipTimeout: Timeout;
|
238
|
241
|
|
239
|
242
|
constructor(protected store: Store<AppState>,
|
...
|
...
|
@@ -247,7 +250,13 @@ export class RuleChainPageComponent extends PageComponent |
247
|
250
|
public dialogService: DialogService,
|
248
|
251
|
public fb: FormBuilder) {
|
249
|
252
|
super(store);
|
250
|
|
- this.init();
|
|
253
|
+
|
|
254
|
+ this.rxSubscription = this.route.data.subscribe(
|
|
255
|
+ () => {
|
|
256
|
+ this.reset();
|
|
257
|
+ this.init();
|
|
258
|
+ }
|
|
259
|
+ );
|
251
|
260
|
}
|
252
|
261
|
|
253
|
262
|
ngOnInit() {
|
...
|
...
|
@@ -266,6 +275,11 @@ export class RuleChainPageComponent extends PageComponent |
266
|
275
|
this.ruleChainCanvas.adjustCanvasSize(true);
|
267
|
276
|
}
|
268
|
277
|
|
|
278
|
+ ngOnDestroy() {
|
|
279
|
+ super.ngOnDestroy();
|
|
280
|
+ this.rxSubscription.unsubscribe();
|
|
281
|
+ }
|
|
282
|
+
|
269
|
283
|
onSearchTextUpdated(searchText: string) {
|
270
|
284
|
this.ruleNodeSearch = searchText;
|
271
|
285
|
this.updateRuleNodesHighlight();
|
...
|
...
|
@@ -299,87 +313,100 @@ export class RuleChainPageComponent extends PageComponent |
299
|
313
|
this.createRuleChainModel();
|
300
|
314
|
}
|
301
|
315
|
|
|
316
|
+ private reset(): void {
|
|
317
|
+ this.selectedObjects = [];
|
|
318
|
+ this.ruleChainModel.nodes = [];
|
|
319
|
+ this.ruleChainModel.edges = [];
|
|
320
|
+ this.ruleNodeTypesModel = {};
|
|
321
|
+ if (this.ruleChainCanvas) {
|
|
322
|
+ this.ruleChainCanvas.adjustCanvasSize(true);
|
|
323
|
+ }
|
|
324
|
+ this.updateRuleNodesHighlight();
|
|
325
|
+ }
|
|
326
|
+
|
302
|
327
|
private initHotKeys(): void {
|
303
|
|
- this.hotKeys.push(
|
304
|
|
- new Hotkey('ctrl+a', (event: KeyboardEvent) => {
|
305
|
|
- if (this.enableHotKeys) {
|
306
|
|
- event.preventDefault();
|
307
|
|
- this.ruleChainCanvas.modelService.selectAll();
|
308
|
|
- return false;
|
309
|
|
- }
|
310
|
|
- return true;
|
311
|
|
- }, ['INPUT', 'SELECT', 'TEXTAREA'],
|
312
|
|
- this.translate.instant('rulenode.select-all-objects'))
|
313
|
|
- );
|
314
|
|
- this.hotKeys.push(
|
315
|
|
- new Hotkey('ctrl+c', (event: KeyboardEvent) => {
|
316
|
|
- if (this.enableHotKeys) {
|
317
|
|
- event.preventDefault();
|
318
|
|
- this.copyRuleNodes();
|
319
|
|
- return false;
|
320
|
|
- }
|
321
|
|
- return true;
|
322
|
|
- }, ['INPUT', 'SELECT', 'TEXTAREA'],
|
323
|
|
- this.translate.instant('rulenode.copy-selected'))
|
324
|
|
- );
|
325
|
|
- this.hotKeys.push(
|
326
|
|
- new Hotkey('ctrl+v', (event: KeyboardEvent) => {
|
327
|
|
- if (this.enableHotKeys) {
|
328
|
|
- event.preventDefault();
|
329
|
|
- if (this.itembuffer.hasRuleNodes()) {
|
330
|
|
- this.pasteRuleNodes();
|
|
328
|
+ if (!this.hotKeys.length) {
|
|
329
|
+ this.hotKeys.push(
|
|
330
|
+ new Hotkey('ctrl+a', (event: KeyboardEvent) => {
|
|
331
|
+ if (this.enableHotKeys) {
|
|
332
|
+ event.preventDefault();
|
|
333
|
+ this.ruleChainCanvas.modelService.selectAll();
|
|
334
|
+ return false;
|
331
|
335
|
}
|
332
|
|
- return false;
|
333
|
|
- }
|
334
|
|
- return true;
|
335
|
|
- }, ['INPUT', 'SELECT', 'TEXTAREA'],
|
336
|
|
- this.translate.instant('action.paste'))
|
337
|
|
- );
|
338
|
|
- this.hotKeys.push(
|
339
|
|
- new Hotkey('esc', (event: KeyboardEvent) => {
|
340
|
|
- if (this.enableHotKeys) {
|
341
|
|
- event.preventDefault();
|
342
|
|
- event.stopPropagation();
|
343
|
|
- this.ruleChainCanvas.modelService.deselectAll();
|
344
|
|
- return false;
|
345
|
|
- }
|
346
|
|
- return true;
|
347
|
|
- }, ['INPUT', 'SELECT', 'TEXTAREA'],
|
348
|
|
- this.translate.instant('rulenode.deselect-all-objects'))
|
349
|
|
- );
|
350
|
|
- this.hotKeys.push(
|
351
|
|
- new Hotkey('ctrl+s', (event: KeyboardEvent) => {
|
352
|
|
- if (this.enableHotKeys) {
|
353
|
|
- event.preventDefault();
|
354
|
|
- this.saveRuleChain();
|
355
|
|
- return false;
|
356
|
|
- }
|
357
|
|
- return true;
|
358
|
|
- }, ['INPUT', 'SELECT', 'TEXTAREA'],
|
359
|
|
- this.translate.instant('action.apply'))
|
360
|
|
- );
|
361
|
|
- this.hotKeys.push(
|
362
|
|
- new Hotkey('ctrl+z', (event: KeyboardEvent) => {
|
363
|
|
- if (this.enableHotKeys) {
|
364
|
|
- event.preventDefault();
|
365
|
|
- this.revertRuleChain();
|
366
|
|
- return false;
|
367
|
|
- }
|
368
|
|
- return true;
|
369
|
|
- }, ['INPUT', 'SELECT', 'TEXTAREA'],
|
370
|
|
- this.translate.instant('action.decline-changes'))
|
371
|
|
- );
|
372
|
|
- this.hotKeys.push(
|
373
|
|
- new Hotkey('del', (event: KeyboardEvent) => {
|
374
|
|
- if (this.enableHotKeys) {
|
375
|
|
- event.preventDefault();
|
376
|
|
- this.ruleChainCanvas.modelService.deleteSelected();
|
377
|
|
- return false;
|
378
|
|
- }
|
379
|
|
- return true;
|
380
|
|
- }, ['INPUT', 'SELECT', 'TEXTAREA'],
|
381
|
|
- this.translate.instant('rulenode.delete-selected-objects'))
|
382
|
|
- );
|
|
336
|
+ return true;
|
|
337
|
+ }, ['INPUT', 'SELECT', 'TEXTAREA'],
|
|
338
|
+ this.translate.instant('rulenode.select-all-objects'))
|
|
339
|
+ );
|
|
340
|
+ this.hotKeys.push(
|
|
341
|
+ new Hotkey('ctrl+c', (event: KeyboardEvent) => {
|
|
342
|
+ if (this.enableHotKeys) {
|
|
343
|
+ event.preventDefault();
|
|
344
|
+ this.copyRuleNodes();
|
|
345
|
+ return false;
|
|
346
|
+ }
|
|
347
|
+ return true;
|
|
348
|
+ }, ['INPUT', 'SELECT', 'TEXTAREA'],
|
|
349
|
+ this.translate.instant('rulenode.copy-selected'))
|
|
350
|
+ );
|
|
351
|
+ this.hotKeys.push(
|
|
352
|
+ new Hotkey('ctrl+v', (event: KeyboardEvent) => {
|
|
353
|
+ if (this.enableHotKeys) {
|
|
354
|
+ event.preventDefault();
|
|
355
|
+ if (this.itembuffer.hasRuleNodes()) {
|
|
356
|
+ this.pasteRuleNodes();
|
|
357
|
+ }
|
|
358
|
+ return false;
|
|
359
|
+ }
|
|
360
|
+ return true;
|
|
361
|
+ }, ['INPUT', 'SELECT', 'TEXTAREA'],
|
|
362
|
+ this.translate.instant('action.paste'))
|
|
363
|
+ );
|
|
364
|
+ this.hotKeys.push(
|
|
365
|
+ new Hotkey('esc', (event: KeyboardEvent) => {
|
|
366
|
+ if (this.enableHotKeys) {
|
|
367
|
+ event.preventDefault();
|
|
368
|
+ event.stopPropagation();
|
|
369
|
+ this.ruleChainCanvas.modelService.deselectAll();
|
|
370
|
+ return false;
|
|
371
|
+ }
|
|
372
|
+ return true;
|
|
373
|
+ }, ['INPUT', 'SELECT', 'TEXTAREA'],
|
|
374
|
+ this.translate.instant('rulenode.deselect-all-objects'))
|
|
375
|
+ );
|
|
376
|
+ this.hotKeys.push(
|
|
377
|
+ new Hotkey('ctrl+s', (event: KeyboardEvent) => {
|
|
378
|
+ if (this.enableHotKeys) {
|
|
379
|
+ event.preventDefault();
|
|
380
|
+ this.saveRuleChain();
|
|
381
|
+ return false;
|
|
382
|
+ }
|
|
383
|
+ return true;
|
|
384
|
+ }, ['INPUT', 'SELECT', 'TEXTAREA'],
|
|
385
|
+ this.translate.instant('action.apply'))
|
|
386
|
+ );
|
|
387
|
+ this.hotKeys.push(
|
|
388
|
+ new Hotkey('ctrl+z', (event: KeyboardEvent) => {
|
|
389
|
+ if (this.enableHotKeys) {
|
|
390
|
+ event.preventDefault();
|
|
391
|
+ this.revertRuleChain();
|
|
392
|
+ return false;
|
|
393
|
+ }
|
|
394
|
+ return true;
|
|
395
|
+ }, ['INPUT', 'SELECT', 'TEXTAREA'],
|
|
396
|
+ this.translate.instant('action.decline-changes'))
|
|
397
|
+ );
|
|
398
|
+ this.hotKeys.push(
|
|
399
|
+ new Hotkey('del', (event: KeyboardEvent) => {
|
|
400
|
+ if (this.enableHotKeys) {
|
|
401
|
+ event.preventDefault();
|
|
402
|
+ this.ruleChainCanvas.modelService.deleteSelected();
|
|
403
|
+ return false;
|
|
404
|
+ }
|
|
405
|
+ return true;
|
|
406
|
+ }, ['INPUT', 'SELECT', 'TEXTAREA'],
|
|
407
|
+ this.translate.instant('rulenode.delete-selected-objects'))
|
|
408
|
+ );
|
|
409
|
+ }
|
383
|
410
|
}
|
384
|
411
|
|
385
|
412
|
updateRuleChainLibrary() {
|
...
|
...
|
|