Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dist_plainjs/manually_maintained_types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ declare global {
ts4nfdiGateway: boolean;
singleSuggestionRow?: boolean;
showApiSource?: boolean;
subTreeIris?: string;
}
)=>void,
createDataContent:(props:{
Expand Down
268 changes: 156 additions & 112 deletions dist_plainjs/terminology-service-suite.js

Large diffs are not rendered by default.

306 changes: 153 additions & 153 deletions dist_plainjs/terminology-service-suite.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ export type AutocompleteWidgetProps = EuiComboBoxProps<string> & ParameterObj &
* Whether to show the api source in the result list or not. Default is true. Only when the API gateway is selected.
*/
showApiSource?: boolean;
/**
* Comma-separated list of terms Iris. Used for narrowing down the results to sub-tree of the given terms. Example: http://purl.obolibrary.org/obo/OBI_0000070,http://purl.obolibrary.org/obo/IAO_0000027
*/
subTreeIris?: string;
};

export type DataContentWidgetProps = ApiObj & ParameterObj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export {
WithLongForm,
WithDescriptionAndShortForm,
TibNFDI4CHEM,
TibDataPlant
TibDataPlant,
SubTreeFiltering
} from "./AutocompleteWidgetStories"


Expand Down
14 changes: 12 additions & 2 deletions src/components/widgets/AutocompleteWidget/AutocompleteWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function AutocompleteWidget(props: AutocompleteWidgetProps) {
placeholder,
singleSelection,
singleSuggestionRow,
subTreeIris,
ts4nfdiGateway = false,
showApiSource = true,
...rest
Expand All @@ -39,6 +40,8 @@ function AutocompleteWidget(props: AutocompleteWidgetProps) {

const visColors = euiPaletteColorBlind();
const visColorsBehindText = euiPaletteColorBlindBehindText();



/**
* The current search value
Expand All @@ -55,6 +58,12 @@ function AutocompleteWidget(props: AutocompleteWidgetProps) {
*/
const [selectedOptions, setSelectedOptions] = useState<Array<EuiComboBoxOptionOption<any>>>([]);

/**
* update the input url parameter in case a list of iris for subtree filtering is given.
* */
const updatedParameter = subTreeIris ? (parameter + `&childrenOf=${subTreeIris}`) : parameter;


// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const renderOption = (option, searchValue) => {
Expand Down Expand Up @@ -157,7 +166,7 @@ function AutocompleteWidget(props: AutocompleteWidgetProps) {
{query: option.iri},
undefined,
undefined,
parameter,
updatedParameter,

ts4nfdiGateway
).then((response) => {
Expand Down Expand Up @@ -227,7 +236,7 @@ function AutocompleteWidget(props: AutocompleteWidgetProps) {
{ query: searchValue },
undefined,
undefined,
parameter,
updatedParameter,
ts4nfdiGateway
).then((response) => {
if (response) {
Expand Down Expand Up @@ -378,6 +387,7 @@ function WrappedAutocompleteWidget(props: AutocompleteWidgetProps) {
ts4nfdiGateway={props.ts4nfdiGateway}
singleSuggestionRow={props.singleSuggestionRow}
showApiSource={props.showApiSource}
subTreeIris={props.subTreeIris}
/>
</QueryClientProvider>
</EuiProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ window['SemLookPWidgets'].createAutocomplete(
ts4nfdiGateway:${args.ts4nfdiGateway},
singleSuggestionRow:${args.singleSuggestionRow},
showApiSource:${args.showApiSource},
subTreeIris: "${args.subTreeIris}",
},
document.querySelector('#autocomplete_widget_container_${num}')
)
Expand All @@ -61,5 +62,6 @@ export {
AllowAddingCustomTerms,
WithGermanInput,
WithLongForm,
WithDescriptionAndShortForm
WithDescriptionAndShortForm,
SubTreeFiltering
} from "./AutocompleteWidgetStories"
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
selectionChangedEventArgType, showApiSourceArgType,
singleSelectionArgType,
singleSuggestionRowArgType,
ts4nfdiGatewayArgType
ts4nfdiGatewayArgType,
subTreeIrisArgType
} from "../../../stories/storyArgs";

export const AutocompleteWidgetStoryArgTypes = {
Expand All @@ -20,6 +21,7 @@ export const AutocompleteWidgetStoryArgTypes = {
...selectionChangedEventArgType,
...placeholderArgType,
...preselectedArgType,
...subTreeIrisArgType,
...parameterArgType,
...hasShortSelectedLabelArgType,
...allowCustomTermsArgType,
Expand All @@ -42,6 +44,7 @@ export const AutocompleteWidgetStoryArgsReact = {
preselected: [],
showApiSource: true,
parameter: "ontology=mesh,efo&type=class&collection=nfdi4health&fieldList=description,label,iri,ontology_name,type,short_form",
subTreeIris: ""
},
};

Expand All @@ -57,6 +60,7 @@ export const AutocompleteWidgetStoryArgsHTML = {
preselected: [],
showApiSource: true,
parameter: "ontology=mesh,efo&type=class&collection=nfdi4health&fieldList=description,label,iri,ontology_name,type,short_form",
subTreeIris: ""
},
};

Expand Down Expand Up @@ -174,4 +178,12 @@ export const TibDataPlant = {
api: globals.TIB_API_ENDPOINT,
parameter: "classification=DataPLANT&schema=collection",
}
};

export const SubTreeFiltering = {
args: {
api: globals.TIB_API_ENDPOINT,
subTreeIris: "http://purl.obolibrary.org/obo/OBI_0000070,http://purl.obolibrary.org/obo/IAO_0000027",
parameter: ""
}
};
9 changes: 9 additions & 0 deletions src/stories/storyArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ export const iriArgType = {
type: { summary: "string" }
}
};
export const subTreeIrisArgType = {
subTreeIris: {
required: false,
description: `Comma-separated list of terms Iris. Used for narrowing down the results to sub-tree of the given terms.
Example: http://purl.obolibrary.org/obo/OBI_0000070,http://purl.obolibrary.org/obo/IAO_0000027
`,
type: { summary: "string" }
}
};
export const ontologyIdArgType = {
ontologyId: {
required: false,
Expand Down