Browse Source

UI: Fixed hotkey event for search field on rule chain page

pull/10855/head
Artem Dzhereleiko 2 years ago
parent
commit
616fa5c6ec
  1. 2
      ui-ngx/src/app/modules/home/pages/rulechain/rulechain-page.component.html
  2. 14
      ui-ngx/src/app/modules/home/pages/rulechain/rulechain-page.component.ts

2
ui-ngx/src/app/modules/home/pages/rulechain/rulechain-page.component.html

@ -47,7 +47,7 @@
<mat-icon>search</mat-icon> <mat-icon>search</mat-icon>
</button> </button>
<input matInput <input matInput
[formControl]="ruleNodeTypeSearch" [formControl]="ruleNodeTypeSearch" (focusin)="focus(true)" (focusout)="focus(false)"
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 !== ''"

14
ui-ngx/src/app/modules/home/pages/rulechain/rulechain-page.component.ts

@ -167,6 +167,8 @@ 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;
@ -294,6 +296,10 @@ 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();
} }
@ -367,7 +373,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) { if (this.enableHotKeys && !this.ruleNodeTypeSearchFocus) {
event.preventDefault(); event.preventDefault();
this.ruleChainCanvas.modelService.selectAll(); this.ruleChainCanvas.modelService.selectAll();
return false; return false;
@ -378,7 +384,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) { if (this.enableHotKeys && !this.ruleNodeTypeSearchFocus) {
event.preventDefault(); event.preventDefault();
this.copyRuleNodes(); this.copyRuleNodes();
return false; return false;
@ -389,7 +395,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) { if (this.enableHotKeys && !this.ruleNodeTypeSearchFocus) {
event.preventDefault(); event.preventDefault();
if (this.itembuffer.hasRuleNodes()) { if (this.itembuffer.hasRuleNodes()) {
this.pasteRuleNodes(); this.pasteRuleNodes();
@ -436,7 +442,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) { if (this.enableHotKeys && !this.ruleNodeTypeSearchFocus) {
event.preventDefault(); event.preventDefault();
this.ruleChainCanvas.modelService.deleteSelected(); this.ruleChainCanvas.modelService.deleteSelected();
return false; return false;

Loading…
Cancel
Save