SubsetDisplay.tsx 2.4 KB
Newer Older
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
1
2
3
4
5
6
import * as React from 'react';
import {translate} from 'react-i18next';
import {withStyles} from '@material-ui/core/styles';
// util
import {log} from 'utilities/debug';
// models
7
8
9
import Subset from 'model/subset/Subset';
import Accession from 'model/accession/Accession';
import AccessionFilter from 'model/accession/AccessionFilter';
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
10
11
12
import {IPageRequest} from 'model/FilteredPage';
import Page from 'model/Page';
// ui
13
14
import SubsetCard from 'subsets/ui/c/SubsetCard';
import AccessionCard from 'accessions/ui/c/AccessionCard';
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
15
import PropertiesCard from 'ui/common/PropertiesCard';
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
16
17
18
19
20
21
22
import Grid from '@material-ui/core/Grid';

const styles = (theme) => ({
  accessionSection: {
    marginTop: '16px',
  },
  accessionCard: {
23
    // marginBottom: '8px',
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  },
});

interface IDetailInfoProps extends React.ClassAttributes<any> {
  t: any;
  classes: any;
  subset: Subset;
  listAccessions: (filter: string | AccessionFilter, page: IPageRequest) => Promise<Page<Accession>>;
  unpublishSubset?: (subset: Subset) => any;
  deleteSubset?: (subset: Subset) => any;
}

class DetailInfo extends React.Component<IDetailInfoProps, any> {

  public render() {
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
39
    const {classes, subset, t} = this.props;
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
40
41
42
43
44
45
46
47

    if (!subset) {
      log('Waiting for subset.');
      return null;
    }

    return (
      <div>
48
        <SubsetCard complete subset={ subset }/>
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
49
        <Grid container spacing={ 16 } className={ classes.accessionSection } justify={ 'space-between' }>
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
50
51
52
53
54
55
56
57
58
59
60
61
          { subset.creators &&
            <PropertiesCard
              propertyItemProps={ {numeric: false} }
              title="Subset creators"
              propertiesList={
                subset.creators.map((creator) => ({
                  title: t(`subset.creator.role.${creator.role}`),
                  value: (<span><b>{ creator.fullName }</b>{ creator.institutionalAffiliation && <span> { creator.institutionalAffiliation }</span> }</span>),
                }))
              }
            />
          }
62
63
64
65
66
67
          { subset.accessionRefs && subset.accessionRefs.map((accessionRef, index: number) => (
            accessionRef.accession &&
              <Grid key={ accessionRef.accession.uuid } item xs={ 12 } className={ classes.accessionCard }>
                <AccessionCard index={ index } accession={ accessionRef.accession }/>
              </Grid>
          )) }
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
68
69
70
71
72
73
74
75
        </Grid>
      </div>
    );
  }

}

export default translate()((withStyles as any)(styles)(DetailInfo));