Skip to content
This repository was archived by the owner on Aug 19, 2019. It is now read-only.

Commit 6bd3fce

Browse files
authored
Merge pull request #160 from CrossRef/development
Merge mm-289, mm-316,mm-317 to master
2 parents 47c954d + c8496c2 commit 6bd3fce

File tree

17 files changed

+900
-93
lines changed

17 files changed

+900
-93
lines changed

app/actions/api.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,35 @@ export function getFormattedReference (doi) {
181181
})
182182
.then( result => result.json())
183183
}
184+
185+
186+
export function transferTitle (transferTitleState) {
187+
188+
return authorizedFetch(`${apiBaseUrl}/transferTitle`, {
189+
method:'post',
190+
headers: {Authorization: localStorage.getItem('auth')},
191+
body: JSON.stringify({
192+
message:transferTitleState
193+
})
194+
})
195+
.then(result => {
196+
if(result.status > 202) throw `Server Error ${result.status}: ${result.statusText}`
197+
return result.json()
198+
})
199+
}
200+
201+
export function getPublisherName (prefix) {
202+
return authorizedFetch(`${apiBaseUrl}/transferTitle?prefix=${prefix}`, {
203+
method: 'get',
204+
headers: {Authorization: localStorage.getItem('auth')}
205+
})
206+
.then(result => result.json())
207+
}
208+
export function getPublishers (work) {
209+
return authorizedFetch(`${apiBaseUrl}/transferTitle`, {
210+
method: 'get',
211+
headers: {Authorization: localStorage.getItem('auth')}
212+
})
213+
.then(result => result.json())
214+
215+
}

app/actions/application.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import {recordTitle, normalize} from '../utilities/helpers'
22
import _getCRState from './getCRState'
33
import * as api from './api'
4+
import {routes} from '../routing';
5+
import {browserHistory} from 'react-router';
46

57

68

@@ -242,3 +244,15 @@ export function moveArticles (selections, issue, pubDoi) {
242244
}
243245

244246

247+
248+
249+
250+
export function deletePublication (doi) {
251+
return async function(dispatch) {
252+
const result = await api.deleteItem(doi)
253+
dispatch({type: 'DELETEPUBLICATION', doi: doi})
254+
browserHistory.push(routes.publications)
255+
}
256+
}
257+
258+
Lines changed: 59 additions & 0 deletions
Loading
Lines changed: 59 additions & 0 deletions
Loading

app/components/AddIssueModal/addIssueCard.js renamed to app/components/AddIssueModal/addIssueView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {issueTooltips as tooltips} from '../../utilities/lists/tooltipMessages'
1616

1717

1818

19-
AddIssueCard.propTypes = {
19+
AddIssueView.propTypes = {
2020
save: is.func.isRequired,
2121
handler: is.func.isRequired,
2222
closeModal: is.func.isRequired,
@@ -28,7 +28,7 @@ AddIssueCard.propTypes = {
2828
}
2929

3030

31-
export default function AddIssueCard (props) {
31+
export default function AddIssueView (props) {
3232

3333
const { errors } = props;
3434
const volumeSectionRequired = !!(doiEntered(props.issue.volumeDoi, props.ownerPrefix) || urlEntered(props.issue.volumeUrl));

app/components/DepositHistoryPage/depositHistoryItem.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
import React, { Component } from 'react'
22
import is from 'prop-types'
33
import Moment from 'react-moment'
4+
import { connect } from 'react-redux'
45

56
import { Link } from 'react-router'
67
import {routes} from '../../routing'
78
import ErrorMessage from './errorMessage'
89

10+
const mapStateToProps = (state, props) => {
11+
return {
12+
prefixes: state.login.prefixes
13+
}
14+
}
915

10-
16+
@connect(mapStateToProps)
1117
export default class DepositHistoryItem extends Component {
1218
static propTypes = {
1319
history: is.object.isRequired,
1420
name: is.string.isRequired,
1521
activeErrorMessage: is.string.isRequired,
16-
errorMessageHandler: is.func.isRequired
22+
errorMessageHandler: is.func.isRequired,
23+
prefixes: is.array.isRequired
1724
};
1825

1926
constructor (props) {
@@ -30,11 +37,18 @@ export default class DepositHistoryItem extends Component {
3037

3138
const failedDeposit = this.props.history.status === 'Failed'
3239
const depositUpdate = this.props.history.depositTimestamp
40+
let doiDisplay;
41+
if(this.props.prefixes.indexOf(this.props.history.owner) !==-1 && this.props.history.pubDoi){
42+
doiDisplay= <Link className='pull-left add-record' to={`${routes.publications}/${encodeURIComponent(this.props.history.pubDoi)}/addarticle/${encodeURIComponent(this.props.history.doi)}`}>{title}</Link>;
43+
}else{
44+
doiDisplay=title
45+
}
3346

3447
return (
3548
<tr>
3649
<td className='firstTd'>{this.props.history.id}</td>
37-
<td><Link className='pull-left add-record' to={`${routes.publications}/${encodeURIComponent(this.props.history.pubDoi)}/addarticle/${encodeURIComponent(this.props.history.doi)}`}>{title}</Link></td>
50+
<td>{doiDisplay}
51+
</td>
3852
<td><Moment format="MMM DD">{this.props.history.date}</Moment></td>
3953
<td>Article</td>
4054
<td>{this.props.history.status}</td>

app/components/Publication/actionBar.js

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ import {routes} from '../../routing'
1111
export default class ActionBar extends Component {
1212

1313
static propTypes ={
14-
reduxControlModal: is.func.isRequired,
15-
reduxCartUpdate: is.func.isRequired,
16-
pubDoi: is.string.isRequired,
14+
newArticle: is.func.isRequired,
15+
addIssue: is.func.isRequired,
16+
transferTitle: is.func.isRequired,
1717
handleAddCart: is.func.isRequired,
1818
deleteSelections: is.func.isRequired,
19+
duplicateSelection: is.func.isRequired,
1920
selections: is.array.isRequired
2021
}
2122

@@ -28,13 +29,15 @@ export default class ActionBar extends Component {
2829
}
2930
}
3031

32+
3133
handleClick = e => {
3234
const element = $(e.target)
3335
if(!(element.parents('.actionBarDropDown').length || element.is('.actionBarDropDown, .tooltips'))) {
3436
this.setState({ actionMenuOpen: false, addRecordMenuOpen: false })
3537
}
3638
}
3739

40+
3841
componentWillUpdate (nextProps, nextState) {
3942
const aMenuIsOpen = nextState.actionMenuOpen || nextState.addRecordMenuOpen
4043
const aMenuClosed = (this.state.actionMenuOpen && !nextState.actionMenuOpen) || (this.state.addRecordMenuOpen && !nextState.addRecordMenuOpen)
@@ -46,21 +49,11 @@ export default class ActionBar extends Component {
4649
}
4750
}
4851

52+
4953
componentWillUnmount () {
5054
document.removeEventListener('click', this.handleClick, false)
5155
}
5256

53-
openAddIssueModal = () => {
54-
this.props.reduxControlModal({
55-
showModal: true,
56-
title: 'Create new issue/volume',
57-
style: 'addIssueModal',
58-
Component: AddIssueModal,
59-
props: {
60-
pubDoi: this.props.pubDoi
61-
}
62-
})
63-
}
6457

6558
onlyIssueSelected = () => {
6659
const selections = this.props.selections
@@ -76,25 +69,26 @@ export default class ActionBar extends Component {
7669

7770
render () {
7871
const onlyIssue = this.onlyIssueSelected()
79-
const { pubDoi, handleAddCart, deleteSelections, duplicateSelection, moveSelection } = this.props
72+
const { handleAddCart, deleteSelections, duplicateSelection, moveSelection, addIssue, newArticle, transferTitle } = this.props
8073
return (<div className='publication-actions'>
8174
<div className="pull-left add-record tooltips" onClick={() => this.setState({ addRecordMenuOpen: !this.state.addRecordMenuOpen, actionMenuOpen: false })}>
8275
Add record
8376
{this.state.addRecordMenuOpen && <div className='actionBarDropDown'>
84-
<p onClick={()=>browserHistory.push(`${routes.publications}/${encodeURIComponent(pubDoi)}/addarticle`)}>New article</p>
85-
<p onClick={this.openAddIssueModal}>New volume/issue</p>
77+
<p onClick={newArticle}>New article</p>
78+
<p onClick={addIssue}>New volume/issue</p>
8679
</div>}
8780
</div>
8881
<div className='pull-right'>
89-
<div className={`actions tooltips ${this.props.selections.length ? 'activeAction' : ''}`}
90-
onClick={this.props.selections.length ? () => this.setState({ actionMenuOpen : !this.state.actionMenuOpen, addRecordMenuOpen: false }) : null}
82+
<div className={`actions tooltips activeAction`}
83+
onClick={() => this.setState({ actionMenuOpen : !this.state.actionMenuOpen, addRecordMenuOpen: false })}
9184
>
9285
Action
9386
{this.state.actionMenuOpen && <div className='actionBarDropDown'>
94-
{!onlyIssue ? <p onClick={handleAddCart}>Add to deposit</p> : <p className="grayedOut">Add to deposit</p>}
95-
{!onlyIssue ? <p onClick={moveSelection}>Move to</p> : <p className="grayedOut">Move to</p>}
96-
{this.props.selections.length === 1 && !onlyIssue ? <p onClick={duplicateSelection}>Duplicate</p> : <p className="grayedOut">Duplicate</p>}
97-
<p onClick={deleteSelections}>Remove</p>
87+
{this.props.selections.length && !onlyIssue ? <p onClick={handleAddCart}>Add to deposit</p> : <p className="grayedOut">Add to deposit</p>}
88+
{this.props.selections.length && !onlyIssue ? <p onClick={moveSelection}>Move to</p> : <p className="grayedOut">Move to</p>}
89+
{this.props.selections.length && !onlyIssue ? <p onClick={duplicateSelection}>Duplicate</p> : <p className="grayedOut">Duplicate</p>}
90+
{this.props.selections.length ? <p onClick={deleteSelections}>Remove</p> : <p className="grayedOut">Remove</p>}
91+
<p onClick={transferTitle}>Transfer title</p>
9892
</div>}
9993
</div>
10094
</div>

0 commit comments

Comments
 (0)