diff --git a/src/client/components/pages/entities/annotation.js b/src/client/components/pages/entities/annotation.js new file mode 100644 index 0000000000..f99de66115 --- /dev/null +++ b/src/client/components/pages/entities/annotation.js @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2020 Nicolas Pelletier + * + * 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 {Button, Col, Collapse, Row} from 'react-bootstrap'; +import PropTypes from 'prop-types'; +import React from 'react'; +import {formatDate} from '../../../helpers/utils'; + + +class EntityAnnotation extends React.Component { + constructor(props) { + super(props); + + this.state = { + open: false + }; + } + + handleToggleCollapse = () => { + this.setState(prevState => ({open: !prevState.open})); + }; + + render() { + const {annotation} = this.props.entity; + if (!annotation || !annotation.content) { + return null; + } + const lastModifiedDate = new Date(annotation.lastRevision.createdAt); + return ( + + +

Annotation

+ +

{annotation.content}

+
+ +

Last modified: {formatDate(lastModifiedDate)} + (revision #{annotation.lastRevisionId}) +

+ +
+ ); + } +} +EntityAnnotation.displayName = 'EntityAnnotation'; +EntityAnnotation.propTypes = { + entity: PropTypes.object.isRequired +}; + +export default EntityAnnotation; diff --git a/src/client/components/pages/entities/author.js b/src/client/components/pages/entities/author.js index 873bdee112..74ed4bbfbd 100644 --- a/src/client/components/pages/entities/author.js +++ b/src/client/components/pages/entities/author.js @@ -19,6 +19,7 @@ import * as bootstrap from 'react-bootstrap'; import * as entityHelper from '../../../helpers/entity'; +import EntityAnnotation from './annotation'; import EntityFooter from './footer'; import EntityImage from './image'; import EntityLinks from './links'; @@ -121,6 +122,7 @@ function AuthorDisplayPage({entity, identifierTypes}) { + {!entity.deleted && + {!entity.deleted && diff --git a/src/client/components/pages/entities/edition.js b/src/client/components/pages/entities/edition.js index e2edb9cfa7..12f8c2a45a 100644 --- a/src/client/components/pages/entities/edition.js +++ b/src/client/components/pages/entities/edition.js @@ -18,7 +18,7 @@ import * as bootstrap from 'react-bootstrap'; import * as entityHelper from '../../../helpers/entity'; - +import EntityAnnotation from './annotation'; import EntityFooter from './footer'; import EntityImage from './image'; import EntityLinks from './links'; @@ -139,6 +139,7 @@ function EditionDisplayPage({entity, identifierTypes}) { {editionGroupSection} + {!entity.deleted && + {!entity.deleted && diff --git a/src/client/components/pages/entities/work.js b/src/client/components/pages/entities/work.js index 16c055ace6..aaa262001c 100644 --- a/src/client/components/pages/entities/work.js +++ b/src/client/components/pages/entities/work.js @@ -20,6 +20,7 @@ import * as bootstrap from 'react-bootstrap'; import * as entityHelper from '../../../helpers/entity'; import EditionTable from './edition-table'; +import EntityAnnotation from './annotation'; import EntityFooter from './footer'; import EntityImage from './image'; import EntityLinks from './links'; @@ -91,6 +92,7 @@ function WorkDisplayPage({entity, identifierTypes}) { + {!entity.deleted && + Annotation + (optional) + + ); + + return ( +
+

+ Annotation +

+ + + + { + annotation && annotation.lastRevision && +

Last modified: {formatDate(new Date(annotation.lastRevision.createdAt))}

+ } +

+ Annotations allow you to enter freeform data that does not otherwise fit in the above form. + Do not submit any copyrighted text here. The contents will be made available to the public under open licenses. +

+ +
+
+ ); +} +AnnotationSection.displayName = 'AnnotationSection'; +AnnotationSection.propTypes = { + annotation: PropTypes.object.isRequired, + onAnnotationChange: PropTypes.func.isRequired +}; + +function mapStateToProps(rootState) { + return { + annotation: convertMapToObject(rootState.get('annotationSection')) + }; +} + + +function mapDispatchToProps(dispatch) { + return { + onAnnotationChange: (event) => + dispatch(debounceUpdateAnnotation(event.target.value)) + }; +} + +export default connect(mapStateToProps, mapDispatchToProps)(AnnotationSection); diff --git a/src/client/entity-editor/annotation-section/reducer.js b/src/client/entity-editor/annotation-section/reducer.js new file mode 100644 index 0000000000..ed22117785 --- /dev/null +++ b/src/client/entity-editor/annotation-section/reducer.js @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 Nicolas Pelletier + * + * 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 Immutable from 'immutable'; +import {UPDATE_ANNOTATION} from './actions'; + + +function reducer( + state = Immutable.Map({content: ''}), + action +) { + switch (action.type) { + case UPDATE_ANNOTATION: + return state.set('content', action.value); + // no default + } + return state; +} + +export default reducer; diff --git a/src/client/entity-editor/entity-editor.js b/src/client/entity-editor/entity-editor.js index bc271ca6d8..4404d9004f 100644 --- a/src/client/entity-editor/entity-editor.js +++ b/src/client/entity-editor/entity-editor.js @@ -20,6 +20,7 @@ import * as React from 'react'; import AliasEditor from './alias-editor/alias-editor'; +import AnnotationSection from './annotation-section/annotation-section'; import ButtonBar from './button-bar/button-bar'; import IdentifierEditor from './identifier-editor/identifier-editor'; import NameSection from './name-section/name-section'; @@ -30,12 +31,13 @@ import {connect} from 'react-redux'; type OwnProps = { - children: React.Element + children: React.Element, + heading: string }; type StateProps = { aliasEditorVisible: boolean, - identifierEditorVisible: boolean + identifierEditorVisible: boolean, }; type Props = StateProps & OwnProps; @@ -79,6 +81,7 @@ const EntityEditor = (props: Props) => { ) } + diff --git a/src/client/entity-editor/helpers.js b/src/client/entity-editor/helpers.js index 0cbe3439c0..bb18bd5452 100644 --- a/src/client/entity-editor/helpers.js +++ b/src/client/entity-editor/helpers.js @@ -29,6 +29,7 @@ import PublisherSectionMerge from './publisher-section/publisher-section-merge'; import WorkSection from './work-section/work-section'; import WorkSectionMerge from './work-section/work-section-merge'; import aliasEditorReducer from './alias-editor/reducer'; +import annotationSectionReducer from './annotation-section/reducer'; import authorSectionReducer from './author-section/reducer'; import buttonBarReducer from './button-bar/reducer'; import {combineReducers} from 'redux-immutable'; @@ -119,6 +120,7 @@ export function createRootReducer(entityType: string) { return combineReducers({ aliasEditor: aliasEditorReducer, + annotationSection: annotationSectionReducer, buttonBar: buttonBarReducer, [entityReducerKey]: entityReducer, identifierEditor: identifierEditorReducer, diff --git a/src/client/entity-editor/submission-section/submission-section.js b/src/client/entity-editor/submission-section/submission-section.js index 07fcc6e7f1..968ba23776 100644 --- a/src/client/entity-editor/submission-section/submission-section.js +++ b/src/client/entity-editor/submission-section/submission-section.js @@ -17,8 +17,8 @@ */ import {Alert, Button, Col, Row} from 'react-bootstrap'; +import {convertMapToObject, formatDate} from '../../helpers/utils'; import {debounceUpdateRevisionNote, submit} from './actions'; - import CustomInput from '../../input'; import PropTypes from 'prop-types'; import React from 'react'; @@ -67,25 +67,23 @@ function SubmissionSection({

Submit Your Edit

-

- {`An edit note will make your entries more credible. Reply to one or more of these questions in the textarea below: - - Where did you get your info from? A link is worth a thousand words. - - What kind of information did you provide? If you made any changes, what are they and why? - - Do you have any questions concerning the editing process you want to ask?`} -

-
- - - - - -
+ + + +

+ {`An edit note will make your entries more credible. Reply to one or more of these questions in the textarea below: + - Where did you get your info from? A link is worth a thousand words. + - What kind of information did you provide? If you made any changes, what are they and why? + - Do you have any questions concerning the editing process you want to ask?`} +

+ +