UI: Refactoring

This commit is contained in:
Artem Dzhereleiko 2024-05-27 11:48:22 +03:00
parent 616fa5c6ec
commit 011fcf1cbd
2 changed files with 7 additions and 13 deletions

View File

@ -47,7 +47,7 @@
<mat-icon>search</mat-icon> <mat-icon>search</mat-icon>
</button> </button>
<input matInput <input matInput
[formControl]="ruleNodeTypeSearch" (focusin)="focus(true)" (focusout)="focus(false)" [formControl]="ruleNodeTypeSearch"
placeholder="{{'rulenode.search' | translate}}"/> placeholder="{{'rulenode.search' | translate}}"/>
<button mat-icon-button matSuffix class="tb-small" <button mat-icon-button matSuffix class="tb-small"
[fxShow]="ruleNodeTypeSearch.value !== ''" [fxShow]="ruleNodeTypeSearch.value !== ''"

View File

@ -77,10 +77,10 @@ import {
} from '@shared/models/rule-node.models'; } from '@shared/models/rule-node.models';
import { FcRuleNodeModel, FcRuleNodeTypeModel, RuleChainMenuContextInfo } from './rulechain-page.models'; import { FcRuleNodeModel, FcRuleNodeTypeModel, RuleChainMenuContextInfo } from './rulechain-page.models';
import { RuleChainService } from '@core/http/rule-chain.service'; import { RuleChainService } from '@core/http/rule-chain.service';
import { NEVER, Observable, of, ReplaySubject, startWith, skip, Subject } from 'rxjs'; import { NEVER, Observable, of, ReplaySubject, skip, startWith, Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged, mergeMap, takeUntil, tap } from 'rxjs/operators'; import { debounceTime, distinctUntilChanged, mergeMap, takeUntil, tap } from 'rxjs/operators';
import { ISearchableComponent } from '../../models/searchable-component.models'; import { ISearchableComponent } from '../../models/searchable-component.models';
import { deepClone, isDefinedAndNotNull } from '@core/utils'; import { deepClone, isDefinedAndNotNull, isEqual } from '@core/utils';
import { RuleNodeDetailsComponent } from '@home/pages/rulechain/rule-node-details.component'; import { RuleNodeDetailsComponent } from '@home/pages/rulechain/rule-node-details.component';
import { RuleNodeLinkComponent } from './rule-node-link.component'; import { RuleNodeLinkComponent } from './rule-node-link.component';
import { DialogComponent } from '@shared/components/dialog.component'; import { DialogComponent } from '@shared/components/dialog.component';
@ -167,8 +167,6 @@ export class RuleChainPageComponent extends PageComponent
ruleNodeSearch = ''; ruleNodeSearch = '';
ruleNodeTypeSearch = this.fb.control('', {nonNullable: true}); ruleNodeTypeSearch = this.fb.control('', {nonNullable: true});
ruleNodeTypeSearchFocus = false;
ruleChain: RuleChain; ruleChain: RuleChain;
ruleChainMetaData: RuleChainMetaData; ruleChainMetaData: RuleChainMetaData;
@ -296,10 +294,6 @@ export class RuleChainPageComponent extends PageComponent
).subscribe(() => this.updateRuleChainLibrary()); ).subscribe(() => this.updateRuleChainLibrary());
} }
focus(focus: boolean) {
this.ruleNodeTypeSearchFocus = focus;
}
ngAfterViewChecked(){ ngAfterViewChecked(){
this.changeDetector.detectChanges(); this.changeDetector.detectChanges();
} }
@ -373,7 +367,7 @@ export class RuleChainPageComponent extends PageComponent
if (!this.hotKeys.length) { if (!this.hotKeys.length) {
this.hotKeys.push( this.hotKeys.push(
new Hotkey('ctrl+a', (event: KeyboardEvent) => { new Hotkey('ctrl+a', (event: KeyboardEvent) => {
if (this.enableHotKeys && !this.ruleNodeTypeSearchFocus) { if (this.enableHotKeys && isEqual(event.currentTarget, event.target)) {
event.preventDefault(); event.preventDefault();
this.ruleChainCanvas.modelService.selectAll(); this.ruleChainCanvas.modelService.selectAll();
return false; return false;
@ -384,7 +378,7 @@ export class RuleChainPageComponent extends PageComponent
); );
this.hotKeys.push( this.hotKeys.push(
new Hotkey('ctrl+c', (event: KeyboardEvent) => { new Hotkey('ctrl+c', (event: KeyboardEvent) => {
if (this.enableHotKeys && !this.ruleNodeTypeSearchFocus) { if (this.enableHotKeys && isEqual(event.currentTarget, event.target)) {
event.preventDefault(); event.preventDefault();
this.copyRuleNodes(); this.copyRuleNodes();
return false; return false;
@ -395,7 +389,7 @@ export class RuleChainPageComponent extends PageComponent
); );
this.hotKeys.push( this.hotKeys.push(
new Hotkey('ctrl+v', (event: KeyboardEvent) => { new Hotkey('ctrl+v', (event: KeyboardEvent) => {
if (this.enableHotKeys && !this.ruleNodeTypeSearchFocus) { if (this.enableHotKeys && isEqual(event.currentTarget, event.target)) {
event.preventDefault(); event.preventDefault();
if (this.itembuffer.hasRuleNodes()) { if (this.itembuffer.hasRuleNodes()) {
this.pasteRuleNodes(); this.pasteRuleNodes();
@ -442,7 +436,7 @@ export class RuleChainPageComponent extends PageComponent
); );
this.hotKeys.push( this.hotKeys.push(
new Hotkey('del', (event: KeyboardEvent) => { new Hotkey('del', (event: KeyboardEvent) => {
if (this.enableHotKeys && !this.ruleNodeTypeSearchFocus) { if (this.enableHotKeys && isEqual(event.currentTarget, event.target)) {
event.preventDefault(); event.preventDefault();
this.ruleChainCanvas.modelService.deleteSelected(); this.ruleChainCanvas.modelService.deleteSelected();
return false; return false;