Commit b29a610f7a9a1aa67a74f6412839ab3a217cb749

Authored by Vladyslav_Prykhodko
1 parent 6603d6f1

Open rule chain from rule node link

@@ -171,12 +171,27 @@ @@ -171,12 +171,27 @@
171 171
172 .fc-edit { 172 .fc-edit {
173 .fc-nodeedit, 173 .fc-nodeedit,
174 - .fc-nodedelete { 174 + .fc-nodedelete,
  175 + .fc-nodeopen {
175 box-sizing: content-box; 176 box-sizing: content-box;
176 border: solid 2px #fff; 177 border: solid 2px #fff;
177 background: #f83e05; 178 background: #f83e05;
178 outline: none; 179 outline: none;
179 } 180 }
  181 +
  182 + .fc-nodeopen{
  183 + top: 30px;
  184 + right: -14px;
  185 +
  186 + mat-icon{
  187 + width: 20px;
  188 + min-width: 20px;
  189 + height: 20px;
  190 + min-height: 20px;
  191 + font-size: 18px;
  192 + line-height: 18px;
  193 + }
  194 + }
180 } 195 }
181 196
182 .fc-arrow-marker { 197 .fc-arrow-marker {
@@ -20,6 +20,7 @@ import { @@ -20,6 +20,7 @@ import {
20 ElementRef, 20 ElementRef,
21 HostBinding, 21 HostBinding,
22 Inject, 22 Inject,
  23 + OnDestroy,
23 OnInit, 24 OnInit,
24 QueryList, 25 QueryList,
25 SkipSelf, 26 SkipSelf,
@@ -64,7 +65,7 @@ import { @@ -64,7 +65,7 @@ import {
64 } from '@shared/models/rule-node.models'; 65 } from '@shared/models/rule-node.models';
65 import { FcRuleNodeModel, FcRuleNodeTypeModel, RuleChainMenuContextInfo } from './rulechain-page.models'; 66 import { FcRuleNodeModel, FcRuleNodeTypeModel, RuleChainMenuContextInfo } from './rulechain-page.models';
66 import { RuleChainService } from '@core/http/rule-chain.service'; 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 import { debounceTime, distinctUntilChanged, mergeMap, tap } from 'rxjs/operators'; 69 import { debounceTime, distinctUntilChanged, mergeMap, tap } from 'rxjs/operators';
69 import { ISearchableComponent } from '../../models/searchable-component.models'; 70 import { ISearchableComponent } from '../../models/searchable-component.models';
70 import { deepClone } from '@core/utils'; 71 import { deepClone } from '@core/utils';
@@ -85,7 +86,7 @@ import Timeout = NodeJS.Timeout; @@ -85,7 +86,7 @@ import Timeout = NodeJS.Timeout;
85 encapsulation: ViewEncapsulation.None 86 encapsulation: ViewEncapsulation.None
86 }) 87 })
87 export class RuleChainPageComponent extends PageComponent 88 export class RuleChainPageComponent extends PageComponent
88 - implements AfterViewInit, OnInit, HasDirtyFlag, ISearchableComponent { 89 + implements AfterViewInit, OnInit, OnDestroy, HasDirtyFlag, ISearchableComponent {
89 90
90 get isDirty(): boolean { 91 get isDirty(): boolean {
91 return this.isDirtyValue || this.isImport; 92 return this.isDirtyValue || this.isImport;
@@ -234,6 +235,8 @@ export class RuleChainPageComponent extends PageComponent @@ -234,6 +235,8 @@ export class RuleChainPageComponent extends PageComponent
234 235
235 flowchartConstants = FlowchartConstants; 236 flowchartConstants = FlowchartConstants;
236 237
  238 + private rxSubscription: Subscription;
  239 +
237 private tooltipTimeout: Timeout; 240 private tooltipTimeout: Timeout;
238 241
239 constructor(protected store: Store<AppState>, 242 constructor(protected store: Store<AppState>,
@@ -247,7 +250,13 @@ export class RuleChainPageComponent extends PageComponent @@ -247,7 +250,13 @@ export class RuleChainPageComponent extends PageComponent
247 public dialogService: DialogService, 250 public dialogService: DialogService,
248 public fb: FormBuilder) { 251 public fb: FormBuilder) {
249 super(store); 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 ngOnInit() { 262 ngOnInit() {
@@ -266,6 +275,11 @@ export class RuleChainPageComponent extends PageComponent @@ -266,6 +275,11 @@ export class RuleChainPageComponent extends PageComponent
266 this.ruleChainCanvas.adjustCanvasSize(true); 275 this.ruleChainCanvas.adjustCanvasSize(true);
267 } 276 }
268 277
  278 + ngOnDestroy() {
  279 + super.ngOnDestroy();
  280 + this.rxSubscription.unsubscribe();
  281 + }
  282 +
269 onSearchTextUpdated(searchText: string) { 283 onSearchTextUpdated(searchText: string) {
270 this.ruleNodeSearch = searchText; 284 this.ruleNodeSearch = searchText;
271 this.updateRuleNodesHighlight(); 285 this.updateRuleNodesHighlight();
@@ -299,87 +313,100 @@ export class RuleChainPageComponent extends PageComponent @@ -299,87 +313,100 @@ export class RuleChainPageComponent extends PageComponent
299 this.createRuleChainModel(); 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 private initHotKeys(): void { 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 updateRuleChainLibrary() { 412 updateRuleChainLibrary() {
@@ -59,4 +59,9 @@ @@ -59,4 +59,9 @@
59 &times; 59 &times;
60 </div> 60 </div>
61 </section> 61 </section>
  62 + <section class="fc-edit" *ngIf="node.component.type === RuleNodeType.RULE_CHAIN">
  63 + <div class="fc-nodeedit fc-nodeopen" (click)="openRuleChain($event, node)">
  64 + <mat-icon class="material-icons" svgIcon="mdi:login"></mat-icon>
  65 + </div>
  66 + </section>
62 </div> 67 </div>
@@ -40,7 +40,8 @@ @@ -40,7 +40,8 @@
40 40
41 :host-context(.fc-edit) { 41 :host-context(.fc-edit) {
42 .fc-nodeedit, 42 .fc-nodeedit,
43 - .fc-nodedelete { 43 + .fc-nodedelete,
  44 + .fc-nodeopen {
44 box-sizing: content-box; 45 box-sizing: content-box;
45 border: solid 2px #fff; 46 border: solid 2px #fff;
46 background: #f83e05; 47 background: #f83e05;
@@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
17 import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; 17 import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
18 import { Component, OnInit } from '@angular/core'; 18 import { Component, OnInit } from '@angular/core';
19 import { FcNodeComponent } from 'ngx-flowchart/dist/ngx-flowchart'; 19 import { FcNodeComponent } from 'ngx-flowchart/dist/ngx-flowchart';
  20 +import { FcRuleNode, RuleNodeType } from '@shared/models/rule-node.models';
  21 +import { Router } from '@angular/router';
20 22
21 @Component({ 23 @Component({
22 // tslint:disable-next-line:component-selector 24 // tslint:disable-next-line:component-selector
@@ -27,8 +29,10 @@ import { FcNodeComponent } from 'ngx-flowchart/dist/ngx-flowchart'; @@ -27,8 +29,10 @@ import { FcNodeComponent } from 'ngx-flowchart/dist/ngx-flowchart';
27 export class RuleNodeComponent extends FcNodeComponent implements OnInit { 29 export class RuleNodeComponent extends FcNodeComponent implements OnInit {
28 30
29 iconUrl: SafeResourceUrl; 31 iconUrl: SafeResourceUrl;
  32 + RuleNodeType = RuleNodeType;
30 33
31 - constructor(private sanitizer: DomSanitizer) { 34 + constructor(private sanitizer: DomSanitizer,
  35 + private router: Router) {
32 super(); 36 super();
33 } 37 }
34 38
@@ -39,4 +43,12 @@ export class RuleNodeComponent extends FcNodeComponent implements OnInit { @@ -39,4 +43,12 @@ export class RuleNodeComponent extends FcNodeComponent implements OnInit {
39 } 43 }
40 } 44 }
41 45
  46 + openRuleChain($event: Event, node: FcRuleNode) {
  47 + if ($event) {
  48 + $event.stopPropagation();
  49 + }
  50 + if (node.targetRuleChainId) {
  51 + this.router.navigateByUrl(`/ruleChains/${node.targetRuleChainId}`);
  52 + }
  53 + }
42 } 54 }