From 1ffcbcfb0bc88d24e811dad94291e9bd364c77d6 Mon Sep 17 00:00:00 2001 From: Michael Hartung <michi@Michaels-MacBook-Pro.local> Date: Thu, 29 Jul 2021 11:01:17 +0200 Subject: [PATCH] query node in analysis network and more query term --- .../query-tile/query-tile.component.html | 4 ++-- .../query-tile/query-tile.component.scss | 3 +++ .../query-tile/query-tile.component.ts | 24 ++++++++++++------- src/styles.scss | 1 + 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/app/components/query-tile/query-tile.component.html b/src/app/components/query-tile/query-tile.component.html index df4695b1..016f15e1 100644 --- a/src/app/components/query-tile/query-tile.component.html +++ b/src/app/components/query-tile/query-tile.component.html @@ -1,8 +1,8 @@ <div class="content"> - <ng-select [items]="queryItems" bindLabel="label" bindValue="data" [virtualScroll]="true" class="custom" + <ng-select [items]="queryItems" bindLabel="data.label" bindValue="data.label" [virtualScroll]="true" class="custom" placeholder="Search..." [hideSelected]="true" [searchFn]="querySearch" (change)="select($event)" pTooltip="Find nodes in the network." tooltipPosition="top"> <ng-template ng-option-tmp let-item="item"> - <p>{{item.data.label}}</p> + <span>{{item.data.label}}</span> </ng-template> </ng-select> </div> diff --git a/src/app/components/query-tile/query-tile.component.scss b/src/app/components/query-tile/query-tile.component.scss index e69de29b..24dfe37d 100644 --- a/src/app/components/query-tile/query-tile.component.scss +++ b/src/app/components/query-tile/query-tile.component.scss @@ -0,0 +1,3 @@ +ng-select { + font-family: roboto; +} \ No newline at end of file diff --git a/src/app/components/query-tile/query-tile.component.ts b/src/app/components/query-tile/query-tile.component.ts index 4a413c1e..ba854487 100644 --- a/src/app/components/query-tile/query-tile.component.ts +++ b/src/app/components/query-tile/query-tile.component.ts @@ -14,14 +14,22 @@ export class QueryTileComponent { querySearch(term: string, item: Wrapper) { term = term.toLowerCase(); - const data = item.data as Node; - if (data.netexId === undefined) { - return data.label.toLowerCase().indexOf(term) > -1 || data.id.toLowerCase().indexOf(term) > -1 - } else { - data.ensg = data.ensg.map(x => x.toLowerCase()) - return data.symbol.toLowerCase().indexOf(term) > -1 || data.uniprotAc.toLowerCase().indexOf(term) > -1 || - data.label.toLowerCase().indexOf(term) > -1 || data.ensg.includes(term) || data.id.toLowerCase().indexOf(term) > -1 ; - } + const data = JSON.parse(JSON.stringify(item.data)); + // add possible missing attributes to not throw errors + if (data.ensg === undefined) {data.ensg = []}; + if (data.groupName === undefined) {data.groupName = ''}; + if (data.type === undefined) {data.type = ''}; + if (data.symbol === undefined) {data.symbol = ''}; + if (data.proteinName === undefined) {data.proteinName = ''}; + if (data.uniprotAc === undefined) {data.uniprotAc = ''}; + if (data.drugId === undefined) {data.drugId = ''}; + + data.ensg = data.ensg.map(x => x.toLowerCase()) + return data.symbol.toLowerCase().indexOf(term) > -1 || data.uniprotAc.toLowerCase().indexOf(term) > -1 || + data.label.toLowerCase().indexOf(term) > -1 || data.ensg.includes(term) || data.id.toLowerCase().indexOf(term) > -1 + || data.proteinName.toLowerCase().indexOf(term) > -1 || data.type.toLowerCase().indexOf(term) > -1 || + data.groupName.toLowerCase().indexOf(term) > -1 || data.drugId.toLowerCase().indexOf(term) > -1; + } select(item) { diff --git a/src/styles.scss b/src/styles.scss index ef29e719..afcb682d 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -1,6 +1,7 @@ @charset "utf-8"; @import url('https://fonts.googleapis.com/css?family=Varela+Round'); +@import "~@ng-select/ng-select/themes/material.theme.css"; @import "~bulma/bulma.sass"; @import '~bulma-tooltip'; @import "~animate.css/animate.min"; -- GitLab