From 5b6a18668e9681e7dcf165a56695df6b92629836 Mon Sep 17 00:00:00 2001 From: Nile Walker Date: Tue, 23 Feb 2021 23:34:56 -0500 Subject: [PATCH] Added Simple Search --- .../workflow-spec-list.component.html | 11 ++++++++++ .../workflow-spec-list.component.ts | 20 +++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/app/workflow-spec-list/workflow-spec-list.component.html b/src/app/workflow-spec-list/workflow-spec-list.component.html index 90ab1d2..21a595c 100644 --- a/src/app/workflow-spec-list/workflow-spec-list.component.html +++ b/src/app/workflow-spec-list/workflow-spec-list.component.html @@ -9,6 +9,14 @@ post_add Add category +
+
+ +
+
@@ -25,6 +33,8 @@ + +

{{cat.display_name}} ({{cat.name}})

@@ -87,6 +97,7 @@
No workflow specs in this category
+
diff --git a/src/app/workflow-spec-list/workflow-spec-list.component.ts b/src/app/workflow-spec-list/workflow-spec-list.component.ts index 64d24af..01ede38 100644 --- a/src/app/workflow-spec-list/workflow-spec-list.component.ts +++ b/src/app/workflow-spec-list/workflow-spec-list.component.ts @@ -23,9 +23,10 @@ import { } from '../_interfaces/dialog-data'; import {ApiErrorsComponent} from 'sartography-workflow-lib'; import {ActivatedRoute} from '@angular/router'; -import {map} from 'rxjs/operators'; +import {debounceTime, distinctUntilChanged, map, switchMap, tap} from 'rxjs/operators'; import {Location} from '@angular/common'; import {environment} from '../../environments/environment.runtime'; +import { FormControl } from '@angular/forms'; export interface WorkflowSpecCategoryGroup { @@ -50,6 +51,7 @@ export class WorkflowSpecListComponent implements OnInit { categories: WorkflowSpecCategory[]; moveUp = moveArrayElementUp; moveDown = moveArrayElementDown; + private searchField: FormControl; constructor( private api: ApiService, @@ -69,6 +71,11 @@ export class WorkflowSpecListComponent implements OnInit { this._loadWorkflowSpecCategories(); } }); + this.searchField = new FormControl(); + this.searchField.valueChanges.subscribe(value => { + this._loadWorkflowSpecs(null,value); + console.log(value); + }); } validateWorkflowSpec(wfs: WorkflowSpec) { @@ -196,9 +203,9 @@ export class WorkflowSpecListComponent implements OnInit { this._loadWorkflowSpecs(selectedSpecName); }); - } + } - private _loadWorkflowSpecs(selectedSpecName: String = null) { + private _loadWorkflowSpecs(selectedSpecName: String = null, searchSpecName: String = null) { this.api.getWorkflowSpecList().subscribe(wfs => { this.workflowSpecs = wfs; @@ -209,7 +216,12 @@ export class WorkflowSpecListComponent implements OnInit { if (wf.is_master_spec) { this.masterStatusSpec = wf; } else { - return wf.category_id === cat.id; + if (searchSpecName){ + return (wf.category_id === cat.id) && wf.display_name.toLowerCase().includes(searchSpecName.toLowerCase()); + } + else { + return wf.category_id === cat.id; + } } }) .sort(this.sortByDisplayOrder);