Skip to content

Commit

Permalink
Merge pull request #228 from ts4nfdi/fix/autocomplete-preselected-use…
Browse files Browse the repository at this point in the history
…legacy

Fix/autocomplete preselected uselegacy
  • Loading branch information
jusa3 authored Mar 7, 2025
2 parents cfe4fd2 + 68aae2d commit e99bcd6
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 95 deletions.
21 changes: 18 additions & 3 deletions dist_plainjs/terminology-service-suite.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist_plainjs/terminology-service-suite.min.js

Large diffs are not rendered by default.

19 changes: 18 additions & 1 deletion src/api/OlsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,23 @@ export class OlsApi implements HierarchyBuilder {
return result;
}

private buildParamsForEntities(parameter?: string) {
const result: any = {};
if (parameter) {
const paramsSplitted = parameter.split("&");

paramsSplitted.forEach((param: string) => {
const key: string = param.split("=")[0];
const value: string = param.split("=")[1];
const finalKey = key === "ontology" ? "ontologyId" : key;
if (finalKey === "ontologyId" || finalKey === "type") {
result[finalKey] = value;
}
});
}
return result;
}

private buildParamsForSelect(
queryParams: SuggestQueryParams,
paginationParams?: PaginationParams,
Expand Down Expand Up @@ -503,7 +520,7 @@ export class OlsApi implements HierarchyBuilder {
: "";
const params = {
iri: contentParams?.termIri,
...this.buildOtherParams(parameter),
...this.buildParamsForEntities(parameter),
};
return this.makeCall(
queryPrefix + "entities",
Expand Down
23 changes: 0 additions & 23 deletions src/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,6 @@ import Reified from "../model/Reified";
import { EuiButtonColor } from "@elastic/eui/src/components/button/button";

type ParameterObj = {
/**
* Additional parameters to pass to the API.
*
* This parameters can be used to filter the search results. Each parameter can be combined via
* the special character <i><b>&</b></i>. The values of a parameter key can be combined with a comma sign
* <i><b>,</b></i>. The following keys could be used:<br/> <br/>
* <table>
* <thead><tr><th>Parameter</th><th>Description</th></tr></thead>
* <tr><td>ontology</td><td>Restrict a search to a set of ontologies e.g. ontology=uberon,mesh</td></tr>
* <tr><td>type</td><td>Restrict a search to an entity type, one of {class,property,individual,ontology}</td></tr>
* <tr><td>slim</td><td>Restrict a search to a particular set of slims by name</td></tr>
* <tr><td>fieldList</td><td>Specify the fields to return. Defaults are <b>{iri,label,short_form,obo_id,ontology_name,ontology_prefix,description,type}</b></td></tr>
* <tr><td>obsoletes</td><td>Set to true to include obsolete terms in the results</td></tr>
* <tr><td>local</td><td>Set to true to only return terms that are in a defining ontology, e.g. only return matches to gene ontology terms in the gene ontology, and exclude ontologies where those terms are also referenced</td></tr>
* <tr><td>childrenOf</td><td>You can restrict a search to all children of a given term. Supply a list of IRI for the terms that you want to search under (subclassOf/is-a relation only)</td></tr>
* <tr><td>allChildrenOf</td><td>You can restrict a search to all children of a given term. Supply a list of IRI for the terms that you want to search under (subclassOf/is-a plus any hierarchical/transitive properties like 'part of' or 'develops from')</td></tr>
* <tr><td>rows</td><td>Set results per page</td></tr>
* <tr><td>start</td><td>Set the results page number</td></tr>
* <tr><td>lang</td><td>Set the language for the response e.g. <b><i>en</i></b>, <b><i>de</i></b>, <b><i>fr</i></b>. The default value is <b><i>en</i></b>.</td></tr>
* <tr><td>collection</td><td>Restrict a search to a terminology subset e.g. <b><i>collection=nfdi4health</i></b></td></tr>
* <tr><td>database</td><td>Restrict a search via the API Gateway to specific terminology software stacks, choose from <b><i>ols</i></b>, <b><i>ontoportal</i></b>, or <b><i>skosmos</i></b></td></tr>
* </table>
*/
parameter?: string;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ export {
WithPreselectedValueAndUnresolvedIriOLS3,
WithPreselectedValueOLS4v2,
WithPreselectedMultipleValuesOLS4,
SubtreeDirectSubtypes,
SubtreeDirectAndIndirectSubtypes,
} from "./AutocompleteWidgetStories";
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function AutocompleteWidget(props: AutocompleteWidgetProps) {
ts4nfdiGateway = false,
showApiSource = true,
className,
useLegacy = false,
useLegacy,
...rest
} = props;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,6 @@ export {
WithPreselectedValueAndUnresolvedIriOLS3,
WithPreselectedValueOLS4v2,
WithPreselectedMultipleValuesOLS4,
SubtreeDirectSubtypes,
SubtreeDirectAndIndirectSubtypes,
} from "./AutocompleteWidgetStories";
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ export const WithPreselectedValueOLS4v2 = {
iri: "http://purl.bioontology.org/ontology/MESH/D000086382",
},
],
parameter: "",
parameter: "ontology=snomed,mesh&type=class&fieldList=description,label,iri,ontology_name,type,short_form",
allowCustomTerms: true,
},
};

Expand Down Expand Up @@ -238,3 +239,23 @@ export const TibDataPlant = {
parameter: "classification=DataPLANT&schema=collection",
},
};

export const SubtreeDirectSubtypes = {
args: {
api: globals.ZBMED_OLS4_API,
allowCustomTerms: true,
useLegacy: true,
parameter:
"ontology=snomed&type=class&collection=nfdi4health&fieldList=description,label,iri,ontology_name,type,short_form&childrenOf=http://snomed.info/id/22298006",
},
}

export const SubtreeDirectAndIndirectSubtypes = {
args: {
api: globals.ZBMED_OLS4_API,
allowCustomTerms: true,
useLegacy: true,
parameter:
"ontology=snomed&type=class&collection=nfdi4health&fieldList=description,label,iri,ontology_name,type,short_form&AllChildrenOf=http://snomed.info/id/22298006",
},
}
86 changes: 22 additions & 64 deletions src/stories/storyArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,70 +116,28 @@ export const parameterArgType = {
required: false,
type: { summary: "string" },
defaultValue: { summary: undefined },
markdownDescription: `Additional parameters to pass to the API.<br><br>
This parameters can be used to filter the search results. Each parameter can be combined with the special character <i><b>&</b></i>. The values of a parameter key can be combined with a comma sign (<i><b>,</b></i>). The following keys can be used:<br><br>
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>ontology</td>
<td>Restrict a search to a set of ontologies e.g. ontology=uberon,mesh</td>
</tr>
<tr>
<td>type</td>
<td>Restrict a search to an entity type, one of {class,property,individual,ontology}</td>
</tr>
<tr>
<td>slim</td>
<td>Restrict a search to a particular set of slims by name</td>
</tr>
<tr>
<td>fieldList</td>
<td>Specify the fields to return. Defaults are <b>iri,label,short_form,obo_id,ontology_name,ontology_prefix,description,type</b></td>
</tr>
<tr>
<td>obsoletes</td>
<td>Set to true to include obsolete terms in the results</td>
</tr>
<tr>
<td>local</td>
<td>Set to true to only return terms that are in a defining ontology, e.g. only return matches to gene ontology terms in the gene ontology, and exclude ontologies where those terms are also referenced</td>
</tr>
<tr>
<td>childrenOf</td>
<td>You can restrict a search to all children of a given term. Supply a list of IRI for the terms that you want to search under (subclassOf/is-a relation only)</td>
</tr>
<tr>
<td>allChildrenOf</td>
<td>You can restrict a search to all children of a given term. Supply a list of IRI for the terms that you want to search under (subclassOf/is-a plus any hierarchical/transitive properties like 'part of' or 'develops from')</td>
</tr>
<tr>
<td>rows</td>
<td>Set results per page</td>
</tr>
<tr>
<td>start</td>
<td>Set the results page number</td>
</tr>
<tr>
<td>lang</td>
<td>Set the language for the response e.g. <b><i>en</i></b>, <b><i>de</i></b>, <b><i>fr</i></b>. The default value is <b><i>en</i></b></td>
</tr>
<tr>
<td>collection</td>
<td>Restrict a search to a terminology subset e.g. <b><i>collection=nfdi4health</i></b></td>
</tr>
<tr>
<td>database</td>
<td>Restrict a search via the API Gateway to specific terminology software stacks, choose from <b><i>ols</i></b>, <b><i>ontoportal</i></b>, or <b><i>skosmos</i></b></td>
</tr>
</tbody>
</table>`,
description: `
Additional parameters to pass to the API.
These parameters can be used to filter the search results. Each parameter can be combined with the special character **&**. The values of a parameter key can be combined with a comma (**,**). The following keys can be used:
| Parameter | Description |
|---------------|------------|
| **ontology** | Restrict a search to a set of ontologies, e.g., \`ontology=uberon,mesh\`. |
| **type** | Restrict a search to an entity type, one of \`{class, property, individual, ontology}\`. |
| **slim** | Restrict a search to a particular set of slims by name. |
| **fieldList** | Specify the fields to return. Defaults are **iri, label, short_form, obo_id, ontology_name, ontology_prefix, description, type**. |
| **obsoletes** | Set to \`true\` to include obsolete terms in the results. |
| **local** | Set to \`true\` to only return terms that are in a defining ontology, e.g., only return matches to gene ontology terms in the gene ontology, and exclude ontologies where those terms are also referenced. |
| **childrenOf** | Restrict a search to all children of a given term. Supply a list of IRI for the terms that you want to search under (subclassOf/is-a relation only). Example: \`childrenOf\` the Snomed CT term *Myocardial infarction (disorder)* (→ heart attack) results in returning direct subclasses such as *ST elevation myocardial infarction (STEMI)* or sub-subclasses such as *STEMI of anterior wall*. The search term *Coronary artery occlusion* will return, among other things, *Acute myocardial infarction due to left coronary artery occlusion* because it's a child of *Acute myocardial infarction*, which is a child of *Myocardial infarction*. |
| **allChildrenOf** | Similar to \`childrenOf\`, but includes hierarchical/transitive properties like *"part of"* or *"develops from"*. Example: \`allChildrenOf\` the Snomed CT term *Myocardial infarction (disorder)* (→ heart attack) results in returning direct subclasses, sub-subclasses, and all other descendant terms. The search term *Coronary artery occlusion* will return, among other things, *Coronary occlusion* because it is a causative agent of *Myocardial infarction*. |
| **rows** | Set results per page. |
| **start** | Set the results page number. |
| **lang** | Set the language for the response, e.g., **\`en\`**, **\`de\`**, **\`fr\`**. The default value is **\`en\`**. |
| **collection** | Restrict a search to a terminology subset, e.g., \`collection=nfdi4health\`. |
| **database** | Restrict a search via the API Gateway to specific terminology software stacks. Choose from **\`ols\`**, **\`ontoportal\`**, or **\`skosmos\`**. |
`
},
};
export const hasShortSelectedLabelArgType = {
Expand Down

0 comments on commit e99bcd6

Please sign in to comment.