Commit f39e26ba authored by Matija Obreza's avatar Matija Obreza
Browse files

Moved Links and Properties from ui/common to ui/catalog

parent 4217bf46
......@@ -12,6 +12,8 @@ import { loadPartner } from 'actions/partner';
import { Vocabulary } from 'model/vocabulary.model';
import { loadVocabulary } from 'actions/vocabulary';
import { Crop } from 'model/crop.model';
import { Link } from 'react-router';
interface IDatasetLinkProps extends React.Props<any> {
......@@ -140,5 +142,41 @@ const VocabularyLink_ = ({ to: vocabulary, edit = false, children, loadVocabular
const VocabularyLink = connect(({}) => ({}), (dispatch) => bindActionCreators({loadVocabulary}, dispatch)) (VocabularyLink_);
interface ICropLinkProps extends React.Props<any> {
code: string;
crops: Map<string, Crop>;
edit?: boolean;
}
class CropLink1 extends React.Component<ICropLinkProps, any> {
public render() {
const { code, crops, edit = false, children } = this.props;
const crop: Crop = crops.get(code);
const clickMe = (e) => {
console.log('You clicked me!', crop);
};
if (crop) {
if (edit) {
return (
<Link to={ `/crops/${crop.uuid}/edit` } onClick={ clickMe }>{ children || crop.title }</Link>
);
} else {
return (
// Could link to Crop page if we had one :-)
<span>{ children || crop.title }</span>
);
}
} else {
// no crop
return <span>{ children || code }</span>;
}
}
}
const CropLink = connect(({}) => ((state, ownProps) => ({ crops: state.lookups.crops })), null) (CropLink1);
export { DatasetLink, DescriptorLink, DescriptorListLink, FaoWiewsLink, PartnerLink, VocabularyLink };
export { DatasetLink, DescriptorLink, DescriptorListLink, FaoWiewsLink, PartnerLink, VocabularyLink, CropLink };
......@@ -9,7 +9,7 @@ import Button from 'material-ui/Button';
import { Descriptor } from 'model/descriptor.model';
import { VocabularyTerm } from 'model/vocabulary.model';
import { DescriptorLink, PartnerLink } from 'ui/common/Links';
import { DescriptorLink, PartnerLink } from 'ui/catalog/Links';
// TODO Introduce T function to the project
......
import * as React from 'react';
import { DescriptorList } from 'model/descriptor.model';
import { DescriptorListLink } from 'ui/common/Links';
import { Properties, PropertiesItem } from 'ui/common/Properties';
import { DescriptorListLink, CropLink } from 'ui/catalog/Links';
import { Properties, PropertiesItem } from 'ui/catalog/Properties';
import Card, { CardHeader, CardContent } from 'material-ui/Card';
import Divider from 'material-ui/Divider';
......@@ -19,7 +19,7 @@ const DescriptorListCard = ({descriptorList, className}: {descriptorList: Descri
<CardContent>
<Markdown className="mb-20" textLength={ 200 } source={ descriptorList.description } />
<Properties>
{ descriptorList.crop && <PropertiesItem title="Crop:">{ descriptorList.crop }</PropertiesItem> }
{ descriptorList.crop && <PropertiesItem title="Crop:"><CropLink code={ descriptorList.crop } /></PropertiesItem> }
<PropertiesItem title="Publisher:">{ descriptorList.publisher || <i>Not specified</i> }</PropertiesItem>
<PropertiesItem title="Version:">{ descriptorList.versionTag }</PropertiesItem>
</Properties>
......
......@@ -8,7 +8,7 @@ import Tabs, {Tab} from 'ui/common/Tabs';
import {Table, TableRow, TableCell} from 'ui/common/tables';
import PaginationComponent from 'ui/common/pagination';
import {ContentContainer} from 'ui/layout/Container';
import {DatasetLink, DescriptorLink, DescriptorListLink} from 'ui/common/Links';
import {DatasetLink, DescriptorLink, DescriptorListLink} from 'ui/catalog/Links';
import Paper from 'material-ui/Paper';
import Button from 'material-ui/Button';
......
......@@ -8,8 +8,8 @@ import Divider from 'material-ui/Divider';
import { Link } from 'react-router';
import Markdown from 'ui/common/markdown';
import { PartnerLink } from 'ui/common/Links';
import { Properties, PropertiesItem } from 'ui/common/Properties';
import { PartnerLink } from 'ui/catalog/Links';
import { Properties, PropertiesItem } from 'ui/catalog/Properties';
interface IDatasetCardProps extends React.ClassAttributes<any> {
className?: string;
......
......@@ -16,7 +16,7 @@ import confirm from 'utilities/confirmAlert';
import Authorize from 'ui/common/authorized/Authorize';
import Section from 'ui/common/layout/Section';
import Markdown from 'ui/common/markdown';
import { DatasetLink, DescriptorLink } from 'ui/common/Links';
import { DatasetLink, DescriptorLink } from 'ui/catalog/Links';
import Summary from './Summary';
import LocationMap from './LocationMap';
......
......@@ -13,7 +13,7 @@ import Loading from 'ui/common/Loading';
import Section from 'ui/common/layout/Section';
import Markdown from 'ui/common/markdown';
import ContentHeaderWithButton from 'ui/common/heading/ContentHeaderWithButton';
import { PartnerLink, DescriptorLink } from 'ui/common/Links';
import { PartnerLink, DescriptorLink } from 'ui/catalog/Links';
import { Table, TableRow, TableCell } from 'ui/common/tables';
import VocabularyCard from 'ui/pages/vocabulary/c/VocabularyCard';
......
......@@ -13,8 +13,8 @@ import Loading from 'ui/common/Loading';
import Markdown from 'ui/common/markdown';
import DescriptorCard from 'ui/catalog/descriptor/DescriptorCard';
import ContentHeaderWithButton from 'ui/common/heading/ContentHeaderWithButton';
import { PartnerLink, DescriptorListLink } from 'ui/common/Links';
import { Properties, PropertiesItem } from 'ui/common/Properties';
import { PartnerLink, DescriptorListLink, CropLink } from 'ui/catalog/Links';
import { Properties, PropertiesItem } from 'ui/catalog/Properties';
import Grid from 'material-ui/Grid';
import Card, {CardHeader, CardContent, CardActions } from 'material-ui/Card';
......@@ -124,7 +124,7 @@ class DescriptorListPage extends React.Component<IDescriptorListPageProps, any>
}
public render() {
const {classes, uuid, descriptorList} = this.props;
const {classes, uuid, descriptorList } = this.props;
const stillLoading: boolean = (! descriptorList || (uuid && (descriptorList.uuid !== uuid)));
......@@ -146,7 +146,7 @@ class DescriptorListPage extends React.Component<IDescriptorListPageProps, any>
<Properties>
{ descriptorList.crop &&
<PropertiesItem title="Crop:">{ descriptorList.crop }</PropertiesItem> }
<PropertiesItem title="Crop:"><CropLink code={ descriptorList.crop } /></PropertiesItem> }
<PropertiesItem title="Publisher:">{ descriptorList.publisher || <i>Not specified</i> }</PropertiesItem>
......
......@@ -9,7 +9,7 @@ import {Partner} from 'model/partner.model';
import confirm from 'utilities/confirmAlert';
import Loading from 'ui/common/Loading';
import Markdown from 'ui/common/markdown';
import {FaoWiewsLink} from 'ui/common/Links';
import {FaoWiewsLink} from 'ui/catalog/Links';
import Grid from 'material-ui/Grid';
import Card, {CardHeader, CardContent, CardActions} from 'material-ui/Card';
......
......@@ -12,7 +12,7 @@ import Section from 'ui/common/layout/Section';
import Markdown from 'ui/common/markdown';
import ContentHeaderWithButton from 'ui/common/heading/ContentHeaderWithButton';
import { Table, TableRow, TableCell } from 'ui/common/tables';
import { VocabularyLink } from 'ui/common/Links';
import { VocabularyLink } from 'ui/catalog/Links';
import Grid from 'material-ui/Grid';
import Card, { CardHeader, CardContent, CardActions } from 'material-ui/Card';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment