Skip to content

Commit

Permalink
feat(ui): add new Publication, Work and Creator display pages
Browse files Browse the repository at this point in the history
  • Loading branch information
LordSputnik committed Jun 2, 2017
1 parent 5d98090 commit e8d3937
Show file tree
Hide file tree
Showing 4 changed files with 347 additions and 3 deletions.
132 changes: 132 additions & 0 deletions src/client/components/pages/entities/creator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Copyright (C) 2017 Ben Ockmore
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

import * as bootstrap from 'react-bootstrap';
import * as entityHelper from '../../../helpers/entity';

import EntityFooter from './footer';
import EntityIdentifiers from './identifiers';
import EntityImage from './image';
import EntityRelationships from './relationships';
import EntityTitle from './title';
import React from 'react';

const {extractAttribute, getTypeAttribute, getEntityUrl} = entityHelper;
const {Col, Row} = bootstrap;


function CreatorAttributes({creator}) {
const type = getTypeAttribute(creator.creatorType).data;
const gender = extractAttribute(creator.gender, 'name');
const beginArea = extractAttribute(creator.beginArea, 'name');
const endArea = extractAttribute(creator.endArea, 'name');
const beginDate = extractAttribute(creator.beginDate);
const endDate = extractAttribute(creator.endDate);

return (
<div>
<Row>
<Col md={3}>
<dl>
<dt>Type</dt>
<dd>{type}</dd>
</dl>
</Col>
<Col md={3}>
<dl>
<dt>Gender</dt>
<dd>{gender}</dd>
</dl>
</Col>
<Col md={3}>
<dl>
<dt>Begin Date</dt>
<dd>{beginDate}</dd>
<dt>Begin Area</dt>
<dd>{beginArea}</dd>
</dl>
</Col>
{
creator.ended &&
<Col md={3}>
<dl>
<dt>End Date</dt>
<dd>{endDate}</dd>
<dt>End Area</dt>
<dd>{endArea}</dd>
</dl>
</Col>
}
</Row>
</div>
);
}
CreatorAttributes.displayName = 'CreatorAttributes';
CreatorAttributes.propTypes = {
creator: React.PropTypes.object.isRequired
};


function CreatorDisplayPage({entity, identifierTypes}) {
const urlPrefix = getEntityUrl(entity);
return (
<div>
<Row className="entity-display-background">
<Col className="entity-display-image-box text-center" md={2}>
<EntityImage
backupIcon="user"
imageUrl={entity.imageUrl}
/>
</Col>
<Col md={10}>
<EntityTitle entity={entity}/>
<CreatorAttributes creator={entity}/>
</Col>
</Row>
<Row>
<Col md={8}>
<EntityRelationships
entityUrl={urlPrefix}
relationships={entity.relationships}
/>
</Col>
<Col md={4}>
<EntityIdentifiers
identifierSet={entity.identifierSet}
identifierTypes={identifierTypes}
/>
</Col>
</Row>
<hr className="margin-top-d40"/>
<EntityFooter
entityUrl={urlPrefix}
lastModified={entity.revision.revision.createdAt}
/>
</div>
);
}
CreatorDisplayPage.displayName = 'CreatorDisplayPage';
CreatorDisplayPage.propTypes = {
entity: React.PropTypes.object.isRequired,
identifierTypes: React.PropTypes.array
};
CreatorDisplayPage.defaultProps = {
identifierTypes: []
};

export default CreatorDisplayPage;
103 changes: 103 additions & 0 deletions src/client/components/pages/entities/publication.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Copyright (C) 2017 Ben Ockmore
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

import * as bootstrap from 'react-bootstrap';
import * as entityHelper from '../../../helpers/entity';

import EditionTable from './edition-table';
import EntityFooter from './footer';
import EntityIdentifiers from './identifiers';
import EntityImage from './image';
import EntityRelationships from './relationships';
import EntityTitle from './title';
import React from 'react';

const {getTypeAttribute, getEntityUrl} = entityHelper;
const {Col, Row} = bootstrap;

function PublicationAttributes({publication}) {
const type = getTypeAttribute(publication.publicationType).data;

return (
<div>
<Row>
<Col md={3}>
<dl>
<dt>Type</dt>
<dd>{type}</dd>
</dl>
</Col>
</Row>
</div>
);
}
PublicationAttributes.displayName = 'PublicationAttributes';
PublicationAttributes.propTypes = {
publication: React.PropTypes.object.isRequired
};


function PublicationDisplayPage({entity, identifierTypes}) {
const urlPrefix = getEntityUrl(entity);
return (
<div>
<Row className="entity-display-background">
<Col className="entity-display-image-box text-center" md={2}>
<EntityImage
backupIcon="th-list"
imageUrl={entity.imageUrl}
/>
</Col>
<Col md={10}>
<EntityTitle entity={entity}/>
<PublicationAttributes publication={entity}/>
</Col>
</Row>
<EditionTable entity={entity}/>
<Row>
<Col md={8}>
<EntityRelationships
entityUrl={urlPrefix}
relationships={entity.relationships}
/>
</Col>
<Col md={4}>
<EntityIdentifiers
identifierSet={entity.identifierSet}
identifierTypes={identifierTypes}
/>
</Col>
</Row>
<hr className="margin-top-d40"/>
<EntityFooter
entityUrl={urlPrefix}
lastModified={entity.revision.revision.createdAt}
/>
</div>
);
}
PublicationDisplayPage.displayName = 'PublicationDisplayPage';
PublicationDisplayPage.propTypes = {
entity: React.PropTypes.object.isRequired,
identifierTypes: React.PropTypes.array
};
PublicationDisplayPage.defaultProps = {
identifierTypes: []
};

export default PublicationDisplayPage;
109 changes: 109 additions & 0 deletions src/client/components/pages/entities/work.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Copyright (C) 2017 Ben Ockmore
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

import * as bootstrap from 'react-bootstrap';
import * as entityHelper from '../../../helpers/entity';

import EntityFooter from './footer';
import EntityIdentifiers from './identifiers';
import EntityImage from './image';
import EntityRelationships from './relationships';
import EntityTitle from './title';
import React from 'react';

const {getLanguageAttribute, getTypeAttribute, getEntityUrl} = entityHelper;
const {Col, Row} = bootstrap;


function WorkAttributes({work}) {
const type = getTypeAttribute(work.workType).data;
const languages = getLanguageAttribute(work).data;

return (
<div>
<Row>
<Col md={3}>
<dl>
<dt>Type</dt>
<dd>{type}</dd>
</dl>
</Col>
<Col md={3}>
<dl>
<dt>Language</dt>
<dd>{languages}</dd>
</dl>
</Col>
</Row>
</div>
);
}
WorkAttributes.displayName = 'WorkAttributes';
WorkAttributes.propTypes = {
work: React.PropTypes.object.isRequired
};


function WorkDisplayPage({entity, identifierTypes}) {
const urlPrefix = getEntityUrl(entity);
return (
<div>
<Row className="entity-display-background">
<Col className="entity-display-image-box text-center" md={2}>
<EntityImage
backupIcon="file-text-o"
imageUrl={entity.imageUrl}
/>
</Col>
<Col md={10}>
<EntityTitle entity={entity}/>
<WorkAttributes work={entity}/>
</Col>
</Row>
<Row>
<Col md={8}>
<EntityRelationships
entityUrl={urlPrefix}
relationships={entity.relationships}
/>
</Col>
<Col md={4}>
<EntityIdentifiers
identifierSet={entity.identifierSet}
identifierTypes={identifierTypes}
/>
</Col>
</Row>
<hr className="margin-top-d40"/>
<EntityFooter
entityUrl={urlPrefix}
lastModified={entity.revision.revision.createdAt}
/>
</div>
);
}
WorkDisplayPage.displayName = 'WorkDisplayPage';
WorkDisplayPage.propTypes = {
entity: React.PropTypes.object.isRequired,
identifierTypes: React.PropTypes.array
};
WorkDisplayPage.defaultProps = {
identifierTypes: []
};

export default WorkDisplayPage;
6 changes: 3 additions & 3 deletions src/server/routes/entity/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import * as handler from '../../helpers/handler';
import * as propHelpers from '../../helpers/props';
import * as search from '../../helpers/search';
import * as utils from '../../helpers/utils';
import CreatorPage from '../../../client/components/pages/entity/creator';
import CreatorPage from '../../../client/components/pages/entities/creator';
import DeletionForm from '../../../client/components/forms/deletion';
import EditionPage from '../../../client/components/pages/entities/edition';
import EntityContainer from '../../../client/containers/entity';
Expand All @@ -31,11 +31,11 @@ import Layout from '../../../client/containers/layout';
import Log from 'log';
import Promise from 'bluebird';
import PublicationPage from
'../../../client/components/pages/entity/publication';
'../../../client/components/pages/entities/publication';
import PublisherPage from '../../../client/components/pages/entities/publisher';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import WorkPage from '../../../client/components/pages/entity/work';
import WorkPage from '../../../client/components/pages/entities/work';
import _ from 'lodash';
import config from '../../helpers/config';

Expand Down

0 comments on commit e8d3937

Please sign in to comment.