Commit 784b3060 authored by Viacheslav Pavlov's avatar Viacheslav Pavlov Committed by Matija Obreza

Explore: Filter suggestions

- Suggestions for "institute.code", "taxonomy.genus", "countryOfOrigin.code3"
- Added BooleanTermedFilter
parent 12ec1698
......@@ -66,7 +66,9 @@
"createdDate": "Created on",
"lastModifiedDate": "Last modified",
"textSearch": "Text search",
"keyword": "Keyword search"
"keyword": "Keyword search",
"noFilters": "No available filters",
"suggestedFilters": "Suggested filters"
},
"fileUploader": {
"chooseFiles": "Choose files to upload",
......
......@@ -36,7 +36,8 @@
"gt": "{{what}} >",
"accessions": {
"crop": "Crop",
"acceNumb": "Accession number",
"crops": "Crops",
"accessionNumber": "Accession number",
"seqNo": "Sequential number",
"sampStat": "Biological status",
"storage": "Storage",
......@@ -52,14 +53,14 @@
"bio15": "Precipitation seasonality"
}
},
"holder": {
"institute": {
"code": "Holder",
"networks": "Network",
"owner": {
"uuid": "Data provider"
},
"country": {
"iso3": "Holder country",
"code3": "Holder country",
"region": "Holder region"
}
},
......@@ -68,8 +69,11 @@
"species": "Species",
"subtaxa": "Subtaxa"
},
"origin": {
"iso3": "Provenance"
"owner": {
"uuid": "Data provider"
},
"countryOfOrigin": {
"code3": "Provenance"
},
"taxonomy": {
"genus": "Genus",
......@@ -107,17 +111,20 @@
},
"subsets": {
"title": "Title",
"crop": "Crop",
"crops": "Crop",
"institutes": "Institute code",
"description": "Description",
"state": "Status",
"dateCreated": "Date created"
"dateCreated": "Date created",
"owner": {
"uuid": "Data provider"
}
},
"wiews": {
"code": "Institute code",
"accessions": "Accessions in Genesys",
"country": {
"iso3": "Country code"
"code3": "Country code"
},
"owner": {
"uuid": "Data provider"
......@@ -139,14 +146,14 @@
},
"datasets": {
"_text": "Keywords",
"accessionRef": {
"accessionRefs": {
"acceNumb": "Accession number",
"doi": "Accession DOI",
"genus": "Accession genus",
"instCode": "Accession holder"
},
"description": "Description",
"descriptor": {
"descriptors": {
"_text": "Descriptor keywords",
"title": "Descriptor title"
},
......@@ -155,7 +162,7 @@
"shortName": "Provider short name",
"wiewsCodes": "Owner WIEWS institute code"
},
"location": {
"locations": {
"country": "Evaluated in",
"latitude": "Latitude",
"longitude": "Longitude"
......@@ -163,7 +170,7 @@
"published": "Published",
"title": "Title",
"rights": "License",
"crop": "Crop",
"crops": "Crop",
"state": "Status"
},
"partner": {
......@@ -196,7 +203,7 @@
"category": "Category",
"columnName": "Column name",
"key": "Key crop descriptor",
"list": {
"descriptorLists": {
"uuid": "Descriptor list"
},
"owner": {
......
......@@ -16,6 +16,7 @@ import {
RECEIVE_ACCESSION_AUDIT_LOG,
RECEIVE_TILE_LAYER,
APPEND_ACCESSIONS,
APPEND_ACCESSIONS_WITH_SUGGESTIONS,
} from 'accessions/constants';
import AccessionService from 'service/genesys/AccessionService';
import ClimateService from 'service/genesys/ClimateService';
......@@ -32,6 +33,7 @@ const receiveAccessionMapInfo = (apiCall: ApiCall<any>) => ({
// Wrapped API calls
const apiListAccessions = createApiCaller(AccessionService.list, APPEND_ACCESSIONS);
const apiListAccessionSugestions = createApiCaller(AccessionService.listSuggestions, APPEND_ACCESSIONS_WITH_SUGGESTIONS);
const apiAccessionsOverview = createApiCaller(AccessionService.listOverview, RECEIVE_ACCESSION_OVERVIEW);
const apiAccessionsMapInfo = createApiCaller(AccessionService.mapInfo, RECEIVE_ACCESSION_MAPINFO);
......@@ -63,7 +65,7 @@ export const applyFilters = (filters: string | AccessionFilter, page: IPageReque
console.log('Applying new filter', filters);
dispatch(showSnackbar('Applying filters...'));
return dispatch(apiListAccessions(filters, page))
return dispatch(apiListAccessionSugestions(filters, page))
.then((paged) => {
dispatch(updateRoute(paged));
dispatch(showSnackbar(`Filters applied.`));
......
export const APPEND_ACCESSIONS = 'accessions/APPEND_ACCESSIONS';
export const APPEND_ACCESSIONS_WITH_SUGGESTIONS = 'accessions/APPEND_ACCESSIONS_WITH_SUGGESTIONS';
export const RECEIVE_ACCESSION_OVERVIEW = 'accessions/RECEIVE_ACCESSION_OVERVIEW';
export const RECEIVE_TILE_LAYER = 'accessions/RECEIVE_TILE_LAYER';
export const RECEIVE_ACCESSION_AUDIT_LOG = 'accessions/RECEIVE_ACCESSION_AUDIT_LOG';
......
......@@ -7,7 +7,7 @@ import {
APPEND_ACCESSIONS,
RECEIVE_ACCESSION_MAPINFO,
RECEIVE_ACCESSION_AUDIT_LOG,
RECEIVE_TILE_LAYER,
RECEIVE_TILE_LAYER, APPEND_ACCESSIONS_WITH_SUGGESTIONS,
} from 'accessions/constants';
import FilteredPage from 'model/FilteredPage';
......@@ -22,6 +22,7 @@ const INITIAL_STATE: {
accession: ApiCall<Accession>;
auditLog: ApiCall<AccessionAuditLog>,
paged: ApiCall<FilteredPage<Accession>>;
suggestions: any;
overview: ApiCall<AccessionOverview>;
mapInfo: ApiCall<AccessionMapInfo>;
mapLayers: MapLayer[]
......@@ -29,6 +30,7 @@ const INITIAL_STATE: {
accession: null,
auditLog: null,
paged: null,
suggestions: null,
overview: null,
mapInfo: null,
mapLayers: AVAILABLE_LAYERS,
......@@ -96,6 +98,22 @@ function publicAccessions(state = INITIAL_STATE, action: IReducerAction) {
// overview: { $set: null },
});
}
case APPEND_ACCESSIONS_WITH_SUGGESTIONS: {
const {apiCall: {loading, error, timestamp, data}} = action.payload;
return update(state, {
paged: {
$set: {
loading,
error,
timestamp,
data: FilteredPage.merge(state.paged && state.paged.data, data),
},
},
suggestions: {$set: data ? data.suggestions : state.suggestions},
// mapInfo: { $set: null },
// overview: { $set: null },
});
}
case RECEIVE_ACCESSION_MAPINFO: {
const { apiCall } = action.payload;
......
......@@ -42,15 +42,27 @@ class BrowsePage extends BrowsePageTemplate<Accession> {
}
public render() {
const { paged, loadMoreData, filterCode, currentTab, loading, t} = this.props;
const { paged, loadMoreData, filterCode, currentTab, loading, suggestions, crops, t} = this.props;
const slug: string = this.state.authenticated ? 'download-authenticated' : 'download-anonymous';
const renderAccession = (s: Accession, index: number) => {
return <AccessionCard key={ s.uuid } index={ index } accession={ s } />;
};
const suggestionTerms = new Map();
if (suggestions) {
Object.keys(suggestions).forEach((key) => {
const overviewEl = suggestions[key];
const terms = new Map();
overviewEl.terms.forEach((term) => terms.set(term.term, term.count));
suggestionTerms.set(key, terms);
});
}
return (
<PageLayout sidebar={
<AccessionFilters initialValues={ paged && paged.filter || {} } onSubmit={ this.myApplyFilters } />
<AccessionFilters initialValues={ paged && paged.filter || {} } onSubmit={ this.myApplyFilters } terms={ suggestionTerms } crops={ crops }/>
}>
<PageTitle title={ t('accessions.public.p.browse.title') }/>
<ContentHeader title={ t('accessions.public.p.browse.title') } subTitle={ t('accessions.public.p.browse.subTitle') } />
......@@ -100,6 +112,8 @@ class BrowsePage extends BrowsePageTemplate<Accession> {
}
const mapStateToProps = (state, ownProps) => ({
suggestions: state.accessions.public.suggestions,
crops: state.crop.public.list ? state.crop.public.list.data : undefined,
paged: state.accessions.public.paged ? state.accessions.public.paged.data : undefined,
loading: state.accessions.public.paged ? state.accessions.public.paged.loading : false,
filterCode: ownProps.match.params.filterCode,
......
import * as React from 'react';
import { connect } from 'react-redux';
import { reduxForm } from 'redux-form';
import {translate} from 'react-i18next';
......@@ -6,25 +7,27 @@ import { ACCESSION_FILTERFORM } from 'accessions/constants';
import FiltersBlock from 'ui/common/filter/FiltersBlock';
import CollapsibleComponentSearch from 'ui/common/filter/CollapsibleComponentSearch';
import BooleanFilter from 'ui/common/filter/BooleanFilter';
import NumberFilter from 'ui/common/filter/NumberFilter';
import StringFilter from 'ui/common/filter/StringFilter';
import StringArrFilter from 'ui/common/filter/StringArrFilter';
import Accession from 'model/accession/Accession';
import DateFilter from 'ui/common/filter/DateFilter';
import CropFilter from 'crop/ui/c/CropFilter';
import BooleanFilter from 'ui/common/filter/BooleanFilter';
const AccessionFilters = ({handleSubmit, initialValues, initialize, t, ...other}) => {
const AccessionFilters = ({handleSubmit, initialValues, initialize, terms, crops, t, ...other}) => {
// console.log('AccessionFilters', initialValues);
return (
<FiltersBlock title={ t('accessions.public.f.filtersTitle') } handleSubmit={ handleSubmit } initialize={ initialize } { ...other }>
<CollapsibleComponentSearch title={ t('accessions.public.f.historic') }>
<BooleanFilter name="historic"/>
<BooleanFilter
name="historic"
terms={ terms && terms.get('historic') }
/>
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('common:f.textSearch') }>
<StringArrFilter name="holder.code" label={ t('accessions.common.instituteCode') } placeholder="NGA039"/>
<StringArrFilter name="holder.country.iso3" label={ t('accessions.model.institute.country.iso3') } placeholder="NGA"/>
<StringFilter name="acceNumb" searchType="contains" label={ t('accessions.common.acceNumb') } placeholder="IRGC"/>
<StringArrFilter name="institute.code" terms={ terms && terms.get('institute.code') } label={ t('accessions.common.instituteCode') } placeholder="NGA039"/>
<StringArrFilter name="institute.country.code3" label={ t('accessions.model.institute.country.iso3') } placeholder="NGA"/>
<StringFilter name="accessionNumber" searchType="contains" label={ t('accessions.common.acceNumb') } placeholder="IRGC"/>
<NumberFilter name="seqNo" label={ t('accessions.public.f.seqNumber') } />
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('common:f.dateSearch') }>
......@@ -32,15 +35,21 @@ const AccessionFilters = ({handleSubmit, initialValues, initialize, t, ...other}
<DateFilter name="lastModifiedDate" label={ t('common:f.lastModifiedDate') }/>
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('accessions.public.f.crop') }>
<CropFilter/>
<StringArrFilter
name="crop"
valueField="shortName"
labelField="name"
options={ crops }
terms={ terms && terms.get('crop.shortName') }
/>
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('accessions.common.taxonomy') }>
<StringArrFilter name="taxa.genus" label={ t('accessions.common.genus') } placeholder="Hordeum"/>
<StringArrFilter name="taxa.species" label={ t('accessions.common.species') } placeholder="vulgare"/>
<StringFilter name="taxa.subtaxa" searchType="contains" label={ t('accessions.public.f.subtaxon') } placeholder=""/>
<StringArrFilter name="taxonomy.genus" terms={ terms && terms.get('taxonomy.genus') } label={ t('accessions.common.genus') } placeholder="Hordeum"/>
<StringArrFilter name="taxonomy.species" label={ t('accessions.common.species') } placeholder="vulgare"/>
<StringFilter name="taxonomy.subtaxa" searchType="contains" label={ t('accessions.public.f.subtaxon') } placeholder=""/>
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('accessions.public.f.originOfMaterial') }>
<StringArrFilter name="origin.iso3" label={ t('accessions.common.countryOfOrigin') } placeholder="SVN"/>
<StringArrFilter name="countryOfOrigin.code3" terms={ terms && terms.get('countryOfOrigin.code3') } label={ t('accessions.common.countryOfOrigin') } placeholder="SVN"/>
<NumberFilter name="geo.latitude" label={ t('geo.common.latitude') } />
<NumberFilter name="geo.longitude" label={ t('geo.common.longitude') } />
<NumberFilter name="geo.elevation" label={ t('accessions.public.f.elevation') } />
......@@ -67,24 +76,55 @@ const AccessionFilters = ({handleSubmit, initialValues, initialize, t, ...other}
<NumberFilter name="geo.climate.bio19" label={ t('accessions.climate.bio19') } />
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('accessions.common.sampStat') }>
<StringArrFilter name="sampStat" options={ Accession.SAMPSTAT } />
<StringArrFilter
name="sampStat"
options={ Accession.SAMPSTAT }
byKey
terms={ terms && terms.get('sampStat') }
/>
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('accessions.common.storageType') }>
<StringArrFilter name="storage" options={ Accession.STORAGE } />
<StringArrFilter
name="storage"
options={ Accession.STORAGE }
byKey
terms={ terms && terms.get('storage') }
/>
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('accessions.public.f.status') }>
<BooleanFilter name="historic" label={ t('accessions.public.f.historic') } />
<BooleanFilter name="available" label={ t('accessions.public.f.available') } />
<BooleanFilter name="mlsStatus" label={ t('accessions.public.f.mlsStatus') } />
<BooleanFilter name="sgsv" label={ t('accessions.public.f.sgsv') } />
<BooleanFilter name="images" label={ t('accessions.public.f.images') } />
<BooleanFilter
name="available"
label={ t('accessions.public.f.available') }
terms={ terms && terms.get('available') }
/>
<BooleanFilter
name="mlsStatus"
label={ t('accessions.public.f.mlsStatus') }
terms={ terms && terms.get('mlsStatus') }
/>
<BooleanFilter
name="sgsv"
label={ t('accessions.public.f.sgsv') }
terms={ terms && terms.get('sgsv') }
/>
<BooleanFilter
name="images"
label={ t('accessions.public.f.images') }
terms={ terms && terms.get('images') }
initialValues
/>
</CollapsibleComponentSearch>
</FiltersBlock>
);
};
const mapStateToProps = (state, ownProps) => ({
crops: state.crop.public.list ? state.crop.public.list.data : undefined,
});
export default translate()(reduxForm({
enableReinitialize: true,
destroyOnUnmount: false,
form: ACCESSION_FILTERFORM,
})(AccessionFilters));
})(connect(mapStateToProps)(AccessionFilters)));
......@@ -10,31 +10,11 @@ interface IProps extends React.ClassAttributes<any> {
}
class CropFilter extends React.Component<IProps, any> {
private options: object = {};
public componentWillMount() {
const { crops } = this.props;
if (crops && crops.length > 0) {
this.options = {};
crops.sort((a, b) => a.name.localeCompare(b.name)).forEach((crop) => {
this.options[crop.shortName] = crop.name;
});
}
}
public componentWillReceiveProps(nextProps) {
const { crops } = nextProps;
if (crops && crops.length > 0) {
this.options = {};
crops.sort((a, b) => a.name.localeCompare(b.name)).forEach((crop) => {
this.options[crop.shortName] = crop.name;
});
}
}
public render() {
const {crops} = this.props;
return (
<StringArrFilter name="crop" options={ this.options } />
<StringArrFilter name="crop" options={ crops && crops.sort((a, b) => a.name.localeCompare(b.name)) } valueField="shortName" labelField="name" { ...this.props }/>
);
}
}
......
......@@ -19,24 +19,24 @@ import LicenceFilter from 'ui/common/filter/LicenceFilter';
const DatasetFilters = ({ handleSubmit, initialize, t, ...other }) => (
<FiltersBlock title={ t('datasets.common.modelName_plural') } handleSubmit={ handleSubmit } initialize={ initialize }{ ...other }>
<TextFilter name="_text" label={ t('datasets.public.f.keywordSearch') } placeholder={ t('datasets.public.f.rice') } className="pb-10 pr-20 pl-20 pt-10"/>
<TextFilter name="descriptor._text" label={ t('datasets.public.f.traitKeywords') } placeholder={ t('datasets.public.f.rice') } className="pt-10 pr-20 pl-20 pb-20"/>
<TextFilter name="descriptors._text" label={ t('datasets.public.f.traitKeywords') } placeholder={ t('datasets.public.f.rice') } className="pt-10 pr-20 pl-20 pb-20"/>
<CollapsibleComponentSearch title={ t('datasets.public.f.partner') }>
<StringArrFilter name="owner.wiewsCodes" label={ t('datasets.public.f.faoWiews') } placeholder="COL003"/>
<PartnerFilter name="owner" label="datasets.public.f.partner"/>
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('datasets.public.f.evaluationSite') }>
<StringArrFilter name="location.country" label={ t('datasets.public.f.countryEv') } placeholder={ t('datasets.public.f.countryPlaceholder') }/>
<NumberFilter name="location.latitude" label={ t('datasets.public.f.latitude') }/>
<NumberFilter name="location.longitude" label={ t('datasets.public.f.longitude') }/>
<StringArrFilter name="locations.userCountry" label={ t('datasets.public.f.countryEv') } placeholder={ t('datasets.public.f.countryPlaceholder') }/>
<NumberFilter name="locations.decimalLatitude" label={ t('datasets.public.f.latitude') }/>
<NumberFilter name="locations.decimalLongitude" label={ t('datasets.public.f.longitude') }/>
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('datasets.public.f.crop') }>
<CropFilter/>
<CropFilter name="crops"/>
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('datasets.public.f.accession') }>
<StringArrFilter name="accessionRef.genus" label={ t('datasets.public.f.genus') } placeholder={ t('datasets.public.f.genusPlaceholder') }/>
<StringFilter name="accessionRef.acceNumb" searchType="contains" label={ t('datasets.public.f.accNumber') } placeholder="IRGC100"/>
<StringArrFilter name="accessionRef.instCode" label={ t('datasets.public.f.faoWiews') } placeholder="PHL001"/>
<StringArrFilter name="accessionRef.doi" label={ t('datasets.public.f.accDoi') } placeholder="10.xxxx/yyyyy"/>
<StringArrFilter name="accessionRefs.genus" label={ t('datasets.public.f.genus') } placeholder={ t('datasets.public.f.genusPlaceholder') }/>
<StringFilter name="accessionRefs.acceNumb" searchType="contains" label={ t('datasets.public.f.accNumber') } placeholder="IRGC100"/>
<StringArrFilter name="accessionRefs.instCode" label={ t('datasets.public.f.faoWiews') } placeholder="PHL001"/>
<StringArrFilter name="accessionRefs.doi" label={ t('datasets.public.f.accDoi') } placeholder="10.xxxx/yyyyy"/>
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('datasets.public.f.licence') }>
<LicenceFilter name={ t('datasets.public.f.rights') } className="p-20"/>
......
......@@ -7,6 +7,7 @@ import { approveDataset, deleteDataset, loadMoreDatasets, unpublishDataset, publ
import Dataset from 'model/catalog/Dataset';
import { DatasetLink } from 'ui/genesys/Links';
import { PublishState } from 'model/common.model';
import DashboardDescriptorFilters from 'datasets/ui/dashboard/c/DashboardFilters';
import ActionButton from 'ui/common/buttons/ActionButton';
const renderDataLink = ({ row, children, needCurrent, t }) => (
......@@ -32,6 +33,7 @@ const mapStateToProps = (state, ownProps) => ({
tab: 'datasets',
dataClassName: Dataset.clazz,
filterCode: ownProps.match.params.filterCode,
filterComponent: DashboardDescriptorFilters,
renderDataLink,
renderActions,
});
......
import * as React from 'react';
import { reduxForm } from 'redux-form';
import { translate } from 'react-i18next';
import { DASHBOARD_FILTERFORM } from 'constants/dashboard';
import FiltersBlock from 'ui/common/filter/FiltersBlock';
import CollapsibleComponentSearch from 'ui/common/filter/CollapsibleComponentSearch';
import CropFilter from 'crop/ui/c/CropFilter';
import TextFilter from 'ui/common/filter/TextFilter';
import Authorize from 'ui/common/authorized/Authorize';
import PartnerFilter from 'partners/ui/c/PartnerFilter';
import StatusFilter from 'ui/catalog/dashboard/c/StatusFilter'; // move
const DashboardFilters = ({ handleSubmit, initialize, t, ...other }) => (
<FiltersBlock
title={ t('descriptors.dashboard.f.title') }
handleSubmit={ handleSubmit }
initialize={ initialize }
{ ...other }
>
<CollapsibleComponentSearch title={ t('descriptors.dashboard.f.status') }>
<StatusFilter/>
</CollapsibleComponentSearch>
<TextFilter
name="_text" label={ t('descriptors.dashboard.f.keywordSearch') }
placeholder={ t('descriptors.dashboard.f.rice') }
className="p-20"
/>
<Authorize role="ROLE_ADMINISTRATOR">
<PartnerFilter name="owner" label={ t('descriptors.dashboard.f.selectOwner') } className="p-20"/>
</Authorize>
<CollapsibleComponentSearch title={ t('descriptors.dashboard.f.crop') }>
<CropFilter name="crops"/>
</CollapsibleComponentSearch>
</FiltersBlock>
);
export default translate()(reduxForm({
enableReinitialize: true,
destroyOnUnmount: false,
form: DASHBOARD_FILTERFORM,
})(DashboardFilters));
......@@ -18,7 +18,7 @@ const DescriptorFilters = ({ handleSubmit, initialize, t, ...other }) => (
<FiltersBlock title={ t('descriptors.common.modelName_plural') } handleSubmit={ handleSubmit } initialize={ initialize } { ...other }>
<TextFilter name="_text" label={ t('common:f.keyword') } placeholder={ t('descriptors.public.f.rice') } className="p-20"/>
<PartnerFilter name="owner" label={ t('descriptors.public.f.partner') } className="p-20"/>
<DescriptorListPicker name="list" label={ t('descriptors.public.f.select') } className="p-20"/>
<DescriptorListPicker name="descriptorLists" label={ t('descriptors.public.f.select') } className="p-20"/>
<CollapsibleComponentSearch title={ t('descriptors.public.f.crop') }>
<CropFilter/>
</CollapsibleComponentSearch>
......
......@@ -20,11 +20,11 @@ const AccessionFilters = ({handleSubmit, initialValues, initialize, t, ...other}
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('common:f.textSearch') }>
<StringArrFilter name="code" label={ t('institutes.common.instituteCode') } placeholder="NGA039"/>
<StringFilter name="name" label={ t('institutes.public.f.instituteName') } searchType="contains" placeholder="Plant Genetic Resources Unit"/>
<StringFilter name="fullName" label={ t('institutes.public.f.instituteName') } searchType="contains" placeholder="Plant Genetic Resources Unit"/>
<PartnerFilter name="owner" label="institutes.public.f.partner"/>
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('geo.common.location') }>
<StringArrFilter name="country.iso3" label="geo.common.country" placeholder="SVN"/>
<StringArrFilter name="country.code3" label="geo.common.country" placeholder="SVN"/>
</CollapsibleComponentSearch>
</FiltersBlock>
);
......
......@@ -4,31 +4,36 @@ import InstituteFilter from 'model/genesys/InstituteFilter';
import NumberFilter from 'model/filter/NumberFilter';
import StringFilter from 'model/filter/StringFilter';
import TaxonomyFilter from 'model/genesys/TaxonomyFilter';
import ClimateFilter from 'model/genesys/ClimateFilter';
import AccessionGeoFilter from './AccessionGeoFilter';
/*
* Defined in Swagger as '#/definitions/AccessionFilter'
*/
class AccessionFilter {
public acceNumb?: StringFilter;
public accessionNumber?: StringFilter;
public aliases: StringFilter;
public active?: boolean;
public available?: boolean;
public createdBy?: number[];
public countryOfOrigin: CountryFilter;
public createdDate?: DateFilter;
public crop?: string[];
public cropName?: string;
public doi?: string[];
public elevation?: NumberFilter;
public geo?: { latitude?: NumberFilter, longitude?: NumberFilter, climate?: ClimateFilter };
public geo?: AccessionGeoFilter;
public historic?: boolean;
public holder?: InstituteFilter;
public images?: boolean;
public inTrust: boolean;
public institute: InstituteFilter;
public lists: string[];
public id?: number[];
public lastModifiedBy?: number[];
public lastModifiedDate?: DateFilter;
public latitude?: NumberFilter;
public longitude?: NumberFilter;
public mlsStatus?: boolean;
public origin?: CountryFilter;
public pdci: NumberFilter;
public sampStat?: number[];
public seqNo?: NumberFilter;
public taxa?: TaxonomyFilter;
......@@ -36,7 +41,7 @@ class AccessionFilter {
public version?: number[];
public sgsv?: boolean;
public storage?: number[];
public images?: boolean;
public taxonomy: TaxonomyFilter;
public NOT?: AccessionFilter;
}
......
import ClimateFilter from 'model/genesys/ClimateFilter';
import NumberFilter from 'model/filter/NumberFilter';
/*
* Defined in Swagger as '#/definitions/AccessionGeoFilter'
*/
class AccessionGeoFilter {
public climate: ClimateFilter;
public elevation: NumberFilter;
public latitude: NumberFilter;
public longitude: NumberFilter;
public referenced: boolean;
}
export default AccessionGeoFilter;
import Accession from './Accession';
import FilteredPage from '../FilteredPage';
/*
* Defined in Swagger as '#/definitions/AccessionSuggestionPage'
*/
class AccessionSuggestionPage extends FilteredPage<Accession> {
public suggestions: any;
}
export default AccessionSuggestionPage;
......@@ -3,7 +3,7 @@
* Defined in Swagger as '#/definitions/CountryFilter'
*/
class CountryFilter {
public iso3: string[];
public code3: string[];
}
......
......@@ -10,6 +10,7 @@ import AccessionMapInfo from 'model/accession/AccessionMapInfo';
import FilteredPage, { IPageRequest } from 'model/FilteredPage';
import {AccessionRef} from 'model/accession/AccessionRef';
import AccessionAuditLog from 'model/accession/AccessionAuditLog';
import AccessionSuggestionPage from 'model/accession/AccessionSuggestionPage';
const URL_GET_BY_DOI = `/api/v1/acn/{doi}`; // UrlTemplate doesn't like the / in DOI
const URL_GET_BY_UUID = UrlTemplate.parse(`/api/v1/acn/{uuid}`);
......@@ -22,6 +23,7 @@ const URL_GET_DETAILS_BY_DOI = `/api/v1/acn/details/{doi}`; // UrlTemplate doesn
const URL_GET_DETAILS_BY_UUID = UrlTemplate.parse(`/api/v1/acn/details/{uuid}`);
const URL_TO_UUID = `/api/v1/acn/toUUID`;
const URL_LIST = `/api/v1/acn/list`;
const URL_LIST_SUGGESTIONS = `/api/v1/acn/list-suggestions`;
const URL_LIST_OVERVIEW = `/api/v1/acn/overview`;
const URL_MAPINFO = `/api/v1/acn/mapinfo`;
......@@ -234,6 +236,36 @@ class AccessionService {
}).then(({ data }) => data as FilteredPage<Accession>);
}
/**
* listSuggestions at /api/v1/acn/list-suggestions
*
* @param filter filter
* @param f f
* @param page undefined
* @param xhrConfig additional xhr config
*/
public static listSuggestions(filter: string | AccessionFilter, page: IPageRequest, xhrConfig?): Promise<AccessionSuggestionPage> {
const qs = QueryString.stringify({
f: typeof filter === 'string' ? filter : undefined,
p: page.page || undefined,
l: page.size || 100,
d: page && page.direction ? page.direction : Accession.DEFAULT_SORT.direction,
s: page.properties || Accession.DEFAULT_SORT.property,
}, {});
const apiUrl = URL_LIST_SUGGESTIONS + (qs ? `?${qs}` : '');
// console.log(`Fetching from ${apiUrl}`);
const content = { data: typeof filter === 'string' ? null : { ...filter } };
return axiosBackend.request({
...xhrConfig,
url: apiUrl,
method: 'POST',
...content,
}).then(({ data }) => data as AccessionSuggestionPage);
}
public static listAllByUuid(UUIDs: string[], xhrConfig?): Promise<Accession[]> {
const apiUrl = URL_LIST_BY_UUID;
......
......@@ -23,7 +23,7 @@ const SubsetFilters = ({handleSubmit, initialValues, initialize, t, ...other}) =
<StringFilter name="description" searchType="contains" label={ t('subsets.public.f.description') } placeholder={ t('subsets.public.f.descriptionPlaceholder') }/>
</CollapsibleComponentSearch>
<CollapsibleComponentSearch title={ t('subsets.public.f.crop') }>
<CropFilter />
<CropFilter name="crops" />
</CollapsibleComponentSearch>
</FiltersBlock>
);
......