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

Commit

Permalink
Merge pull request #160 from CrossRef/development
Browse files Browse the repository at this point in the history
Merge mm-289, mm-316,mm-317 to master
  • Loading branch information
MikeYalter authored Sep 12, 2018
2 parents 47c954d + c8496c2 commit 6bd3fce
Show file tree
Hide file tree
Showing 17 changed files with 900 additions and 93 deletions.
32 changes: 32 additions & 0 deletions app/actions/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,35 @@ export function getFormattedReference (doi) {
})
.then( result => result.json())
}


export function transferTitle (transferTitleState) {

return authorizedFetch(`${apiBaseUrl}/transferTitle`, {
method:'post',
headers: {Authorization: localStorage.getItem('auth')},
body: JSON.stringify({
message:transferTitleState
})
})
.then(result => {
if(result.status > 202) throw `Server Error ${result.status}: ${result.statusText}`
return result.json()
})
}

export function getPublisherName (prefix) {
return authorizedFetch(`${apiBaseUrl}/transferTitle?prefix=${prefix}`, {
method: 'get',
headers: {Authorization: localStorage.getItem('auth')}
})
.then(result => result.json())
}
export function getPublishers (work) {
return authorizedFetch(`${apiBaseUrl}/transferTitle`, {
method: 'get',
headers: {Authorization: localStorage.getItem('auth')}
})
.then(result => result.json())

}
14 changes: 14 additions & 0 deletions app/actions/application.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {recordTitle, normalize} from '../utilities/helpers'
import _getCRState from './getCRState'
import * as api from './api'
import {routes} from '../routing';
import {browserHistory} from 'react-router';



Expand Down Expand Up @@ -242,3 +244,15 @@ export function moveArticles (selections, issue, pubDoi) {
}





export function deletePublication (doi) {
return async function(dispatch) {
const result = await api.deleteItem(doi)
dispatch({type: 'DELETEPUBLICATION', doi: doi})
browserHistory.push(routes.publications)
}
}


59 changes: 59 additions & 0 deletions app/assets/assets/images/Publications/right_carrot_teal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions app/assets/assets/images/Publications/select_carrot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {issueTooltips as tooltips} from '../../utilities/lists/tooltipMessages'



AddIssueCard.propTypes = {
AddIssueView.propTypes = {
save: is.func.isRequired,
handler: is.func.isRequired,
closeModal: is.func.isRequired,
Expand All @@ -28,7 +28,7 @@ AddIssueCard.propTypes = {
}


export default function AddIssueCard (props) {
export default function AddIssueView (props) {

const { errors } = props;
const volumeSectionRequired = !!(doiEntered(props.issue.volumeDoi, props.ownerPrefix) || urlEntered(props.issue.volumeUrl));
Expand Down
20 changes: 17 additions & 3 deletions app/components/DepositHistoryPage/depositHistoryItem.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import React, { Component } from 'react'
import is from 'prop-types'
import Moment from 'react-moment'
import { connect } from 'react-redux'

import { Link } from 'react-router'
import {routes} from '../../routing'
import ErrorMessage from './errorMessage'

const mapStateToProps = (state, props) => {
return {
prefixes: state.login.prefixes
}
}


@connect(mapStateToProps)
export default class DepositHistoryItem extends Component {
static propTypes = {
history: is.object.isRequired,
name: is.string.isRequired,
activeErrorMessage: is.string.isRequired,
errorMessageHandler: is.func.isRequired
errorMessageHandler: is.func.isRequired,
prefixes: is.array.isRequired
};

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

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

return (
<tr>
<td className='firstTd'>{this.props.history.id}</td>
<td><Link className='pull-left add-record' to={`${routes.publications}/${encodeURIComponent(this.props.history.pubDoi)}/addarticle/${encodeURIComponent(this.props.history.doi)}`}>{title}</Link></td>
<td>{doiDisplay}
</td>
<td><Moment format="MMM DD">{this.props.history.date}</Moment></td>
<td>Article</td>
<td>{this.props.history.status}</td>
Expand Down
40 changes: 17 additions & 23 deletions app/components/Publication/actionBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import {routes} from '../../routing'
export default class ActionBar extends Component {

static propTypes ={
reduxControlModal: is.func.isRequired,
reduxCartUpdate: is.func.isRequired,
pubDoi: is.string.isRequired,
newArticle: is.func.isRequired,
addIssue: is.func.isRequired,
transferTitle: is.func.isRequired,
handleAddCart: is.func.isRequired,
deleteSelections: is.func.isRequired,
duplicateSelection: is.func.isRequired,
selections: is.array.isRequired
}

Expand All @@ -28,13 +29,15 @@ export default class ActionBar extends Component {
}
}


handleClick = e => {
const element = $(e.target)
if(!(element.parents('.actionBarDropDown').length || element.is('.actionBarDropDown, .tooltips'))) {
this.setState({ actionMenuOpen: false, addRecordMenuOpen: false })
}
}


componentWillUpdate (nextProps, nextState) {
const aMenuIsOpen = nextState.actionMenuOpen || nextState.addRecordMenuOpen
const aMenuClosed = (this.state.actionMenuOpen && !nextState.actionMenuOpen) || (this.state.addRecordMenuOpen && !nextState.addRecordMenuOpen)
Expand All @@ -46,21 +49,11 @@ export default class ActionBar extends Component {
}
}


componentWillUnmount () {
document.removeEventListener('click', this.handleClick, false)
}

openAddIssueModal = () => {
this.props.reduxControlModal({
showModal: true,
title: 'Create new issue/volume',
style: 'addIssueModal',
Component: AddIssueModal,
props: {
pubDoi: this.props.pubDoi
}
})
}

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

render () {
const onlyIssue = this.onlyIssueSelected()
const { pubDoi, handleAddCart, deleteSelections, duplicateSelection, moveSelection } = this.props
const { handleAddCart, deleteSelections, duplicateSelection, moveSelection, addIssue, newArticle, transferTitle } = this.props
return (<div className='publication-actions'>
<div className="pull-left add-record tooltips" onClick={() => this.setState({ addRecordMenuOpen: !this.state.addRecordMenuOpen, actionMenuOpen: false })}>
Add record
{this.state.addRecordMenuOpen && <div className='actionBarDropDown'>
<p onClick={()=>browserHistory.push(`${routes.publications}/${encodeURIComponent(pubDoi)}/addarticle`)}>New article</p>
<p onClick={this.openAddIssueModal}>New volume/issue</p>
<p onClick={newArticle}>New article</p>
<p onClick={addIssue}>New volume/issue</p>
</div>}
</div>
<div className='pull-right'>
<div className={`actions tooltips ${this.props.selections.length ? 'activeAction' : ''}`}
onClick={this.props.selections.length ? () => this.setState({ actionMenuOpen : !this.state.actionMenuOpen, addRecordMenuOpen: false }) : null}
<div className={`actions tooltips activeAction`}
onClick={() => this.setState({ actionMenuOpen : !this.state.actionMenuOpen, addRecordMenuOpen: false })}
>
Action
{this.state.actionMenuOpen && <div className='actionBarDropDown'>
{!onlyIssue ? <p onClick={handleAddCart}>Add to deposit</p> : <p className="grayedOut">Add to deposit</p>}
{!onlyIssue ? <p onClick={moveSelection}>Move to</p> : <p className="grayedOut">Move to</p>}
{this.props.selections.length === 1 && !onlyIssue ? <p onClick={duplicateSelection}>Duplicate</p> : <p className="grayedOut">Duplicate</p>}
<p onClick={deleteSelections}>Remove</p>
{this.props.selections.length && !onlyIssue ? <p onClick={handleAddCart}>Add to deposit</p> : <p className="grayedOut">Add to deposit</p>}
{this.props.selections.length && !onlyIssue ? <p onClick={moveSelection}>Move to</p> : <p className="grayedOut">Move to</p>}
{this.props.selections.length && !onlyIssue ? <p onClick={duplicateSelection}>Duplicate</p> : <p className="grayedOut">Duplicate</p>}
{this.props.selections.length ? <p onClick={deleteSelections}>Remove</p> : <p className="grayedOut">Remove</p>}
<p onClick={transferTitle}>Transfer title</p>
</div>}
</div>
</div>
Expand Down
Loading

0 comments on commit 6bd3fce

Please sign in to comment.