Filters.tsx 5.62 KB
Newer Older
1
2
import * as React from 'react';
import { reduxForm } from 'redux-form';
Viacheslav Pavlov's avatar
i18n    
Viacheslav Pavlov committed
3
import {translate} from 'react-i18next';
4

5
import { ACCESSION_FILTERFORM } from 'accessions/constants';
6
7
8

import FiltersBlock from 'ui/common/filter/FiltersBlock';
import CollapsibleComponentSearch from 'ui/common/filter/CollapsibleComponentSearch';
9
import BooleanFilter from 'ui/common/filter/BooleanFilter';
10
11
12
import NumberFilter from 'ui/common/filter/NumberFilter';
import StringFilter from 'ui/common/filter/StringFilter';
import StringArrFilter from 'ui/common/filter/StringArrFilter';
13
import Accession from 'model/accession/Accession';
14
import DateFilter from 'ui/common/filter/DateFilter';
15
import CropFilter from 'crop/ui/c/CropFilter';
16

Viacheslav Pavlov's avatar
i18n    
Viacheslav Pavlov committed
17
const AccessionFilters = ({handleSubmit, initialValues, initialize, t, ...other}) => {
18
19
  // console.log('AccessionFilters', initialValues);
  return (
Viacheslav Pavlov's avatar
i18n    
Viacheslav Pavlov committed
20
21
    <FiltersBlock title={ t('accessions.public.f.filtersTitle') } handleSubmit={ handleSubmit } initialize={ initialize } { ...other }>
      <CollapsibleComponentSearch title={ t('accessions.public.f.historic') }>
22
23
        <BooleanFilter name="historic"/>
      </CollapsibleComponentSearch>
Viacheslav Pavlov's avatar
i18n    
Viacheslav Pavlov committed
24
25
26
27
      <CollapsibleComponentSearch title={ t('common:f.textSearch') }>
        <StringArrFilter name="holder.code" label={ t('accessions.common.instituteCode') } placeholder="NGA039"/>
        <StringFilter name="acceNumb" searchType="contains" label={ t('accessions.common.acceNumb') } placeholder="IRGC"/>
        <NumberFilter name="seqNo" label={ t('accessions.public.f.seqNumber') } />
28
      </CollapsibleComponentSearch>
Viacheslav Pavlov's avatar
i18n    
Viacheslav Pavlov committed
29
30
      <CollapsibleComponentSearch title={ t('common:f.dateSearch') }>
        <DateFilter name="lastModifiedDate" label={ t('common:f.lastModifiedDate') }/>
31
      </CollapsibleComponentSearch>
32
33
34
      <CollapsibleComponentSearch title={ t('accessions.public.f.crop') }>
        <CropFilter/>
      </CollapsibleComponentSearch>
Viacheslav Pavlov's avatar
i18n    
Viacheslav Pavlov committed
35
36
37
38
      <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=""/>
39
      </CollapsibleComponentSearch>
Viacheslav Pavlov's avatar
i18n    
Viacheslav Pavlov committed
40
41
42
43
44
      <CollapsibleComponentSearch title={ t('accessions.public.f.originOfMaterial') }>
        <StringArrFilter name="origin.iso3" 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') } />
45
      </CollapsibleComponentSearch>
Matija Obreza's avatar
Matija Obreza committed
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
      <CollapsibleComponentSearch title={ t('accessions.public.f.climate') }>
        <NumberFilter name="geo.climate.bio1" label={ t('accessions.climate.bio1') } />
        <NumberFilter name="geo.climate.bio2" label={ t('accessions.climate.bio2') } />
        <NumberFilter name="geo.climate.bio3" label={ t('accessions.climate.bio3') } />
        <NumberFilter name="geo.climate.bio4" label={ t('accessions.climate.bio4') } />
        <NumberFilter name="geo.climate.bio5" label={ t('accessions.climate.bio5') } />
        <NumberFilter name="geo.climate.bio6" label={ t('accessions.climate.bio6') } />
        <NumberFilter name="geo.climate.bio7" label={ t('accessions.climate.bio7') } />
        <NumberFilter name="geo.climate.bio8" label={ t('accessions.climate.bio8') } />
        <NumberFilter name="geo.climate.bio9" label={ t('accessions.climate.bio9') } />
        <NumberFilter name="geo.climate.bio10" label={ t('accessions.climate.bio10') } />
        <NumberFilter name="geo.climate.bio11" label={ t('accessions.climate.bio11') } />
        <NumberFilter name="geo.climate.bio12" label={ t('accessions.climate.bio12') } />
        <NumberFilter name="geo.climate.bio13" label={ t('accessions.climate.bio13') } />
        <NumberFilter name="geo.climate.bio14" label={ t('accessions.climate.bio14') } />
        <NumberFilter name="geo.climate.bio15" label={ t('accessions.climate.bio15') } />
        <NumberFilter name="geo.climate.bio16" label={ t('accessions.climate.bio16') } />
        <NumberFilter name="geo.climate.bio17" label={ t('accessions.climate.bio17') } />
        <NumberFilter name="geo.climate.bio18" label={ t('accessions.climate.bio18') } />
        <NumberFilter name="geo.climate.bio19" label={ t('accessions.climate.bio19') } />
      </CollapsibleComponentSearch>
Viacheslav Pavlov's avatar
i18n    
Viacheslav Pavlov committed
67
      <CollapsibleComponentSearch title={ t('accessions.common.sampStat') }>
68
69
        <StringArrFilter name="sampStat" options={ Accession.SAMPSTAT } />
      </CollapsibleComponentSearch>
Viacheslav Pavlov's avatar
i18n    
Viacheslav Pavlov committed
70
      <CollapsibleComponentSearch title={ t('accessions.common.storageType') }>
71
72
        <StringArrFilter name="storage" options={ Accession.STORAGE } />
      </CollapsibleComponentSearch>
Viacheslav Pavlov's avatar
i18n    
Viacheslav Pavlov committed
73
74
75
76
77
      <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') } />
78
        <BooleanFilter name="images" label={ t('accessions.public.f.images') } />
79
      </CollapsibleComponentSearch>
80
81
82
83
    </FiltersBlock>
  );
};

Viacheslav Pavlov's avatar
i18n    
Viacheslav Pavlov committed
84
export default translate()(reduxForm({
85
    enableReinitialize: true,
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
86
    destroyOnUnmount: false,
87
    form: ACCESSION_FILTERFORM,
Viacheslav Pavlov's avatar
i18n    
Viacheslav Pavlov committed
88
})(AccessionFilters));