Commit 86d3eb18 authored by nickstiffler's avatar nickstiffler Committed by Yannis Barlas

feat(*): separate main editors and section editors

parent 967fa00c
......@@ -70,7 +70,7 @@ const navLinks = (location, currentUser) => {
const isEditor =
currentUser &&
(currentUser.auth.isGlobalEditor ||
currentUser.auth.isAssignedEditor.includes(id))
currentUser.auth.isAssignedSectionEditor.includes(id))
const dashboardLink = (
<Action active={isDashboard} to="/dashboard">
......
......@@ -15,6 +15,7 @@ const CURRENT_USER = gql`
isAcceptedReviewerForVersion
isAssignedCurator
isAssignedEditor
isAssignedSectionEditor
isAssignedScienceOfficer
isAuthor
isGlobal
......
......@@ -520,11 +520,10 @@ const initialValidations = {
}),
imageCaption: yup
.string()
.test(
'image-caption-not-empty',
'Image caption is required',
val => stripHTML(val).length > 0,
),
.test('image-caption-not-empty', 'Image caption is required', val => {
if (!val) return false
return stripHTML(val).length > 0
}),
laboratory: yup.object().shape({
name: yup.string(),
// .test(
......@@ -542,11 +541,10 @@ const initialValidations = {
// ),
patternDescription: yup
.string()
.test(
'pattern-description-not-empty',
'Text is required',
val => stripHTML(val).length > 0,
),
.test('pattern-description-not-empty', 'Text is required', val => {
if (!val) return false
return stripHTML(val).length > 0
}),
reagents: yup.string(),
references: yup.array(
yup
......@@ -588,13 +586,10 @@ const initialValidations = {
// validateWBExists,
// )
}),
title: yup
.string()
.test(
'title-not-empty',
'Title is required',
val => stripHTML(val).length > 0,
),
title: yup.string().test('title-not-empty', 'Title is required', val => {
if (!val) return false
return stripHTML(val).length > 0
}),
}
const geneExpression = {
......
......@@ -148,6 +148,13 @@ const mapProps = args => {
const scienceOfficer =
scienceOfficerTeam.members[0] && scienceOfficerTeam.members[0].user
formattedData.scienceOfficer = scienceOfficer
const sectionEditorTeam = manuscript.teams.find(
t => t.role === 'sectionEditor',
)
const sectionEditor =
sectionEditorTeam.members[0] && sectionEditorTeam.members[0].user
formattedData.sectionEditor = sectionEditor
}
if (type === 'reviewer') {
......
......@@ -18,8 +18,10 @@ const Label = styled.span`
text-transform: capitalize;
&:before {
content: '\\2014';
/* content: '\\2014'; */
content: '\\2022';
padding: 0 ${th('gridUnit')};
/* padding-right: ${th('gridUnit')}; */
}
&:after {
......
......@@ -49,7 +49,8 @@ const EditorSectionItem = props => {
id: articleId,
author,
// authorIds,
// editor,
editor,
sectionEditor,
// scienceOfficer,
// updateAssignedEditor,
// updateAssignedScienceOfficer,
......@@ -62,6 +63,8 @@ const EditorSectionItem = props => {
<SectionItemWithStatus
actionsComponent={ActionsComponent}
author={author}
editor={editor}
sectionEditor={sectionEditor}
{...props}
/>
......
......@@ -14,7 +14,7 @@ const StatusRowWrapper = styled.div`
/* margin-bottom: calc(${th('gridUnit')}); */
`
const AuthorWrapper = styled.div`
const NameWrapper = styled.div`
font-size: ${th('fontSizeBaseSmall')};
margin-left: ${th('gridUnit')};
`
......@@ -25,8 +25,10 @@ const Label = styled.span`
text-transform: capitalize;
&:before {
content: '\\2014';
padding: 0 ${th('gridUnit')};
/* content: '\\2014'; */
content: '\\2022';
/* padding: 0 ${th('gridUnit')}; */
padding-right: ${th('gridUnit')};
}
&:after {
......@@ -34,41 +36,57 @@ const Label = styled.span`
}
`
const Author = props => {
const { author } = props
const DashboardName = props => {
const { name, label } = props
return (
author && (
<AuthorWrapper>
<Label>submitting author</Label>
{author}
</AuthorWrapper>
name && (
<NameWrapper>
<Label>{label}</Label>
{name}
</NameWrapper>
)
)
}
const StatusRow = props => {
const { author, displayStatus, updated } = props
const { author, displayStatus, editor, sectionEditor, updated } = props
const authorValue = author ? `${author.firstName} ${author.lastName}` : ''
const editorValue = editor ? editor.displayName : ''
const sectionEditorValue = sectionEditor ? sectionEditor.displayName : ''
return (
<StatusRowWrapper>
<StatusItem label={displayStatus} />
{updated && <DashboardItemDate label="Last updated" value={updated} />}
{author && <Author author={authorValue} />}
{author && <DashboardName label="submitting author" name={authorValue} />}
{editor && <DashboardName label="main editor" name={editorValue} />}
{sectionEditor && (
<DashboardName label="section editor" name={sectionEditorValue} />
)}
</StatusRowWrapper>
)
}
const SectionItemWithStatus = props => {
const { actionsComponent, author, displayStatus, title, updated } = props
const {
actionsComponent,
author,
displayStatus,
editor,
sectionEditor,
title,
updated,
} = props
return (
<>
<StatusRow
author={author}
displayStatus={displayStatus}
editor={editor}
sectionEditor={sectionEditor}
updated={updated}
/>
<SectionItem rightComponent={actionsComponent} title={title} />
......
......@@ -25,11 +25,11 @@ const Article = props => {
const isAdmin = currentUser.admin
// const { isAcceptedReviewerForVersion, isGlobal } = currentUser.auth
const { isGlobalEditor, isAssignedEditor } = currentUser.auth
const { isGlobalEditor, isAssignedSectionEditor } = currentUser.auth
const isAuthor = currentUser.auth.isAuthor.includes(manuscriptId)
const isEditor =
isAdmin || isGlobalEditor || isAssignedEditor.includes(manuscriptId)
isAdmin || isGlobalEditor || isAssignedSectionEditor.includes(manuscriptId)
const isReviewer = currentUser.auth.isAcceptedReviewerForManuscript.includes(
manuscriptId,
)
......@@ -136,7 +136,12 @@ const Article = props => {
}
if (isEditor) {
return <EditorView manuscriptId={manuscriptId} />
return (
<EditorView
manuscriptId={manuscriptId}
showEditorAssignment={isGlobalEditor || isAdmin}
/>
)
}
if (isReviewer) {
......@@ -147,7 +152,7 @@ const Article = props => {
return <ScienceOfficerView manuscriptId={manuscriptId} />
}
return <div>articlez</div>
return null
}
export default Article
......@@ -13,11 +13,19 @@ const getManuscriptTeam = manuscriptTeams => {
const manuscriptEditors = membersOfTeam(manuscriptTeams, 'editor')
const manuscriptEditor = manuscriptEditors && manuscriptEditors[0]
const manuscriptSectionEditors = membersOfTeam(
manuscriptTeams,
'sectionEditor',
)
const manuscriptSectionEditor =
manuscriptSectionEditors && manuscriptSectionEditors[0]
const manuscriptSOs = membersOfTeam(manuscriptTeams, 'scienceOfficer')
const manuscriptSO = manuscriptSOs && manuscriptSOs[0]
return {
editor: manuscriptEditor,
sectionEditor: manuscriptSectionEditor,
scienceOfficer: manuscriptSO,
}
}
......
import { unionBy } from 'lodash'
import {
getInvitedReviewersTeam,
getManuscriptTeam,
......@@ -73,11 +71,8 @@ export default (data, mutations) => {
const scienceOfficers = disableAuthors(globalScienceOfficers, authorIds)
const curators = disableAuthors(globalCurators, authorIds)
// either a global or a section editor can be assigned as editor on a manuscript
const editors = disableAuthors(
unionBy(globalEditors, globalSectionEditors, 'id'),
authorIds,
)
const editors = disableAuthors(globalEditors, authorIds)
const sectionEditors = disableAuthors(globalSectionEditors, authorIds)
/**
* Manuscript-level teams
......@@ -85,12 +80,16 @@ export default (data, mutations) => {
// const manuscriptCuratorTeam = manuscript.teams.find(t => t.role === 'curator')
const manuscriptEditorTeam = manuscript.teams.find(t => t.role === 'editor')
const manuscriptSectionEditorTeam = manuscript.teams.find(
t => t.role === 'sectionEditor',
)
const manuscriptSOTeam = manuscript.teams.find(
t => t.role === 'scienceOfficer',
)
const {
editor: assignedEditor,
sectionEditor: assignedSectionEditor,
scienceOfficer: assignedScienceOfficer,
} = getManuscriptTeam(manuscript.teams)
......@@ -231,11 +230,19 @@ export default (data, mutations) => {
// curatorMembers.push(values.curator.id)
const editorMembers = []
if (values.editor && values.editor.id) editorMembers.push(values.editor.id)
if (values.editor && values.editor.id) {
editorMembers.push(values.editor.id)
}
const sectionEditorMembers = []
if (values.sectionEditor && values.sectionEditor.id) {
sectionEditorMembers.push(values.sectionEditor.id)
}
const scienceOfficerMembers = []
if (values.scienceOfficer && values.scienceOfficer.id)
if (values.scienceOfficer && values.scienceOfficer.id) {
scienceOfficerMembers.push(values.scienceOfficer.id)
}
// console.log('ct', curatorTeamId, curatorMembers)
// console.log('et', editorTeamId, editorMembers)
......@@ -253,6 +260,10 @@ export default (data, mutations) => {
teamId: manuscriptEditorTeam.id,
members: editorMembers,
},
{
teamId: manuscriptSectionEditorTeam.id,
members: sectionEditorMembers,
},
{
teamId: manuscriptSOTeam.id,
members: scienceOfficerMembers,
......@@ -275,10 +286,12 @@ export default (data, mutations) => {
return {
editors,
sectionEditors,
scienceOfficers,
curators,
assignedEditor,
assignedSectionEditor,
assignedScienceOfficer,
doi,
......
......@@ -42,7 +42,7 @@ const Label = ({ created, index }) => (
)
const EditorView = props => {
const { manuscriptId } = props
const { showEditorAssignment, manuscriptId } = props
/**
* Handle modals with state
......@@ -186,8 +186,10 @@ const EditorView = props => {
*/
let rightSections
let editors, scienceOfficers /* curators */
let assignedEditor, assignedScienceOfficer /* assignedCurator */
let editors, sectionEditors, scienceOfficers /* curators */
let assignedEditor,
assignedSectionEditor,
assignedScienceOfficer /* assignedCurator */
let sendModalChatMessage, setDataType, updateManuscriptTeams, updateMetadata
if (!editorLoading && editorData) {
......@@ -202,9 +204,11 @@ const EditorView = props => {
;({
assignedEditor,
assignedSectionEditor,
assignedScienceOfficer,
editors,
sectionEditors,
scienceOfficers,
// curators,
......@@ -254,6 +258,8 @@ const EditorView = props => {
} = version
const editorName = assignedEditor && assignedEditor.displayName
const sectionEditorName =
assignedSectionEditor && assignedSectionEditor.displayName
const scienceOfficerName =
assignedScienceOfficer && assignedScienceOfficer.displayName
......@@ -287,6 +293,7 @@ const EditorView = props => {
reviews={reviews}
scienceOfficerChatMessages={scienceOfficerChatMessages}
scienceOfficerName={scienceOfficerName}
sectionEditorName={sectionEditorName}
sendScienceOfficerChatMessage={sendScienceOfficerChatMessage}
showDataType={latest}
showDataTypeSelection
......@@ -296,7 +303,7 @@ const EditorView = props => {
showMetadata={latest}
showPreviousReviewers={latest && versions.length > 1}
showReviewersChat
showReviews
showReviews={dataType}
showScienceOfficerChat={latest}
showTeamManager
// startChatExpanded
......@@ -333,12 +340,15 @@ const EditorView = props => {
<ManuscriptTeamManager
assignedEditor={assignedEditor}
assignedScienceOfficer={assignedScienceOfficer}
assignedSectionEditor={assignedSectionEditor}
// curators={curators}
editors={editors}
// isOpen
isOpen={showTeamManager}
onRequestClose={() => setShowTeamManager(false)}
scienceOfficers={scienceOfficers}
sectionEditors={sectionEditors}
showEditorAssignment={showEditorAssignment}
updateTeams={updateManuscriptTeams}
/>
)}
......@@ -370,6 +380,7 @@ const EditorView = props => {
EditorView.propTypes = {
manuscriptId: PropTypes.bool.isRequired,
showEditorAssignment: PropTypes.bool.isRequired,
}
export default EditorView
......@@ -53,6 +53,12 @@ const createManuscript = async (_, variables, ctx) => {
objectType: 'article',
role: 'editor',
},
{
name: `section-editor-${manuscript.id}`,
objectId: manuscript.id,
objectType: 'article',
role: 'sectionEditor',
},
{
name: `science-officer-${manuscript.id}`,
objectId: manuscript.id,
......@@ -278,7 +284,7 @@ const manuscripts = async (_, { role }, ctx) => {
return sortResult(res)
}
if (role === 'scienceOfficer') {
if (role === 'scienceOfficer' || role === 'sectionEditor') {
const res = await Manuscript.query()
.leftJoin('teams', 'manuscripts.id', 'teams.object_id')
.leftJoin('team_members as members', 'members.team_id', 'teams.id')
......@@ -289,19 +295,6 @@ const manuscripts = async (_, { role }, ctx) => {
return sortResult(res)
}
if (role === 'sectionEditor') {
const res = await Manuscript.query()
.leftJoin('teams', 'manuscripts.id', 'teams.object_id')
.leftJoin('team_members as members', 'members.team_id', 'teams.id')
.leftJoin('users', 'users.id', 'members.user_id')
.where({
role: 'editor',
userId,
})
return sortResult(res)
}
return null
}
......
......@@ -27,6 +27,7 @@ type Auth {
isAcceptedReviewerForVersion: [ID!]!
isAssignedCurator: [ID!]!
isAssignedEditor: [ID!]!
isAssignedSectionEditor: [ID!]!
isAssignedScienceOfficer: [ID!]!
isGlobal: Boolean!
isGlobalCurator: Boolean!
......
......@@ -88,6 +88,19 @@ const createClientAuth = async userId => {
m => m.manuscriptId,
)
/*
Manuscripts that the user is assigned to as a section editor
*/
const sectionEditorManuscripts = await manuscriptFromMemberQuery().where({
role: 'sectionEditor',
userId,
})
const isAssignedSectionEditor = sectionEditorManuscripts.map(
m => m.manuscriptId,
)
/*
Manuscripts that the user is assigned to as an editor
*/
......@@ -135,6 +148,7 @@ const createClientAuth = async userId => {
isAcceptedReviewerForVersion,
isAssignedCurator,
isAssignedEditor,
isAssignedSectionEditor,
isAssignedScienceOfficer,
isAuthor,
isGlobal,
......
......@@ -53,6 +53,7 @@ const EditorPanel = props => {
reviews,
scienceOfficerChatMessages,
scienceOfficerName,
sectionEditorName,
sendScienceOfficerChatMessage,
showDataType,
showDataTypeSelection,
......@@ -85,6 +86,7 @@ const EditorPanel = props => {
editorName={editorName}
onClickTeamManager={onClickTeamManager}
scienceOfficerName={scienceOfficerName}
sectionEditorName={sectionEditorName}
showTeamManager={showTeamManager}
/>
)}
......@@ -178,6 +180,8 @@ EditorPanel.propTypes = {
authorName: PropTypes.string,
/** Assigned editor's display name */
editorName: PropTypes.string,
/** Assigned section editor's display name */
sectionEditorName: PropTypes.string,
/** Assigned science officer's display name */
scienceOfficerName: PropTypes.string,
......@@ -285,6 +289,7 @@ EditorPanel.defaultProps = {
reviews: [],
scienceOfficerName: null,
scienceOfficerChatMessages: [],
sectionEditorName: null,
sendScienceOfficerChatMessage: null,
showDataType: false,
showDataTypeSelection: false,
......
......@@ -22,6 +22,7 @@ const InfoSection = props => {
authorEmail,
authorName,
editorName,
sectionEditorName,
scienceOfficerName,
onClickTeamManager,
showTeamManager,
......@@ -29,10 +30,15 @@ const InfoSection = props => {
const teamValues = [
{
label: 'Editor',
label: 'Main Editor',
status: 'primary',
value: editorName,
},
{
label: 'Section Editor',
status: 'primary',
value: sectionEditorName,
},
{
label: 'Science Officer',
status: 'primary',
......@@ -64,6 +70,7 @@ InfoSection.propTypes = {
authorEmail: PropTypes.string.isRequired,
authorName: PropTypes.string.isRequired,
editorName: PropTypes.string,
sectionEditorName: PropTypes.string,
scienceOfficerName: PropTypes.string,
onClickTeamManager: PropTypes.func,
showTeamManager: PropTypes.bool,
......@@ -71,6 +78,7 @@ InfoSection.propTypes = {
InfoSection.defaultProps = {
editorName: null,
sectionEditorName: null,
scienceOfficerName: null,
onClickTeamManager: null,
showTeamManager: false,
......
......@@ -95,12 +95,15 @@ const Role = props => {
const ManuscriptTeamManager = props => {
const {
assignedCurator,
// assignedCurator,
assignedEditor,
assignedSectionEditor,
assignedScienceOfficer,
// curators,
editors,
sectionEditors,
scienceOfficers,
showEditorAssignment,
updateTeams,
...rest
} = props
......@@ -108,6 +111,7 @@ const ManuscriptTeamManager = props => {
const initialValues = {
// curator: assignedCurator || null,
editor: assignedEditor || null,
sectionEditor: assignedSectionEditor || null,
scienceOfficer: assignedScienceOfficer || null,
}
......@@ -138,12 +142,22 @@ const ManuscriptTeamManager = props => {
<Ribbon message={warningMessage} status="warning" />
<SelectWrapper>
{showEditorAssignment && (
<Role
label="main editor"
name="editor"
options={editors}
setFieldValue={setFieldValue}
value={values.editor}
/>
)}
<Role
label="editor"
name="editor"
options={editors}
label="section editor"
name="sectionEditor"
options={sectionEditors}
setFieldValue={setFieldValue}
value={values.editor}
value={values.sectionEditor}
/>
<Role
......
......@@ -33,6 +33,7 @@ const makeReviews = amount =>
const authorEmail = internet.exampleEmail()
const authorName = name.findName()
const editorName = name.findName()
const sectionEditorName = name.findName()
const scienceOfficerName = name.findName()
export const Base = () => {
......@@ -73,6 +74,7 @@ export const Base = () => {
reviews={makeReviews(2)}
scienceOfficerChatMessages={soMessages}
scienceOfficerName={scienceOfficerName}
sectionEditorName={sectionEditorName}
sendScienceOfficerChatMessage={sendSoMessage}
showDataType
showDataTypeSelection
......@@ -132,6 +134,7 @@ export const ScenarioPreviousVersion = () => {
reviews={makeReviews(2)}
scienceOfficerChatMessages={soMessages}
scienceOfficerName={scienceOfficerName}
sectionEditorName={sectionEditorName}
sendScienceOfficerChatMessage={sendSoMessage}
showDecision
showReviewersChat
......
......@@ -10,6 +10,7 @@ export const Base = () => (
editorName={name.findName()}
onClickTeamManager={() => console.log('clicked team manager')}
scienceOfficerName={name.findName()}
sectionEditorName={name.findName()}
showTeamManager
/>
)
......
Markdown is supported
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