Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[publication] Add columns to publications #7361

Merged
merged 14 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion SQL/0000-00-00-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ CREATE TABLE `mri_violations_log` (
PRIMARY KEY (`LogID`),
CONSTRAINT `FK_tarchive_mriViolationsLog_1`
FOREIGN KEY (`TarchiveID`) REFERENCES `tarchive` (`TarchiveID`),
CONSTRAINT `FK_mri_checks_group_1`
CONSTRAINT `FK_mri_checks_group_1`
FOREIGN KEY (`MriProtocolChecksGroupID`) REFERENCES `mri_protocol_checks_group` (`MriProtocolChecksGroupID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Expand Down Expand Up @@ -2156,6 +2156,11 @@ CREATE TABLE `publication` (
`Title` varchar(255) NOT NULL,
`RejectedReason` varchar(255) default NULL,
`Description` text NOT NULL,
`journal` varchar(255) DEFAULT NULL,
pierre-p-s marked this conversation as resolved.
Show resolved Hide resolved
`doi` text DEFAULT NULL,
`datePublication` date DEFAULT NULL,
`link` varchar(255) DEFAULT NULL,
`publishingStatus` enum('In Progress','Published') DEFAULT NULL,
CONSTRAINT `PK_publication` PRIMARY KEY(`PublicationID`),
CONSTRAINT `FK_publication_UserID` FOREIGN KEY(`UserID`) REFERENCES `users` (`ID`),
CONSTRAINT `FK_publication_RatedBy` FOREIGN KEY(`RatedBy`) REFERENCES `users` (`ID`),
Expand Down
6 changes: 6 additions & 0 deletions SQL/Cleanup_patches/2021-03-01-publication-add-columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ALTER TABLE publication
ADD COLUMN journal varchar(255) DEFAULT NULL,
ADD COLUMN doi text DEFAULT NULL,
ADD COLUMN datePublication date DEFAULT NULL,
ADD COLUMN link varchar(255) DEFAULT NULL,
ADD COLUMN publishingStatus enum('In Progress','Published') DEFAULT NULL;
37 changes: 33 additions & 4 deletions modules/publication/ajax/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ function uploadPublication() : void
if ($exists) {
showPublicationError('Submitted title already exists', 400);
}
$desc = $_POST['description'] ?? null;
$leadInvest = $_POST['leadInvestigator'] ?? null;
$desc = $_POST['description'] ?? null;
$publishingStatus = $_POST['publishingStatus'] ?? null;
$datePublication = $_POST['datePublication'] ?? null;
$journal = $_POST['journal'] ?? null;
$doi = $_POST['doi'] ?? null;
$link = $_POST['link'] ?? null;
$leadInvest = $_POST['leadInvestigator'] ?? null;
$leadInvestEmail = $_POST['leadInvestigatorEmail'] ?? null;

// check if lead investigator already exists in collaborator table
Expand All @@ -68,7 +73,6 @@ function uploadPublication() : void
'FROM publication_collaborator '.
'WHERE Name = :n OR Email = :e',
[
'n' => $leadInvest,
'e' => $leadInvestEmail,
]
);
Expand All @@ -94,6 +98,11 @@ function uploadPublication() : void
'UserID' => $uid,
'Title' => $title,
'Description' => $desc,
'publishingStatus' => $publishingStatus,
'datePublication' => $datePublication,
'journal' => $journal,
'doi' => $doi,
'link' => $link,
'LeadInvestigatorID' => $leadInvID,
'DateProposed' => $today,
];
Expand Down Expand Up @@ -513,7 +522,12 @@ function editProject() : void
$statusID = $_POST['status'] ?? null;
$rejectedReason = $_POST['rejectedReason'] ?? null;
$description = $_POST['description'] ?? null;
$leadInvestigator = $_POST['leadInvestigator'] ?? null;
$publishingStatus = $_POST['publishingStatus'] ?? null;
$datePublication = $_POST['datePublication'] ?? null;
$journal = $_POST['journal'] ?? null;
$doi = $_POST['doi'] ?? null;
$link = $_POST['link'] ?? null;
$leadInvestigator = $_POST['leadInvestigator'] ?? null;
$leadInvestigatorEmail = $_POST['leadInvestigatorEmail'] ?? null;

$pubData = $db->pselectRow(
Expand Down Expand Up @@ -546,6 +560,21 @@ function editProject() : void
if ($pubData['Description'] !== $description) {
$toUpdate['Description'] = $description;
}
if ($pubData['publishingStatus'] !== $publishingStatus) {
$toUpdate['publishingStatus'] = $publishingStatus;
}
if ($pubData['datePublication'] !== $datePublication) {
$toUpdate['datePublication'] = $datePublication;
}
if ($pubData['journal'] !== $journal) {
$toUpdate['journal'] = $journal;
}
if ($pubData['doi'] !== $doi) {
$toUpdate['doi'] = $doi;
}
if ($pubData['link'] !== $link) {
$toUpdate['link'] = $link;
}
if ($pubData['LeadInvestigator'] !== $leadInvestigator) {
$leadInvToUpdate['Name'] = $leadInvestigator;
}
Expand Down
27 changes: 18 additions & 9 deletions modules/publication/ajax/getData.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ function getData($db) : array

// imaging VoIs -- filter out non-human readable DICOM tags
$imgVOIs = $db->pselectCol(
"SELECT DISTINCT p.Name FROM parameter_type p
JOIN parameter_type_category_rel ptcr
ON p.ParameterTypeID=ptcr.ParameterTypeID
JOIN parameter_type_category ptc
ON ptc.ParameterTypeCategoryID=ptcr.ParameterTypeCategoryID
"SELECT DISTINCT p.Name FROM parameter_type p
JOIN parameter_type_category_rel ptcr
ON p.ParameterTypeID=ptcr.ParameterTypeID
JOIN parameter_type_category ptc
ON ptc.ParameterTypeCategoryID=ptcr.ParameterTypeCategoryID
WHERE ptc.Name='MRI Variables'",
[]
);
Expand Down Expand Up @@ -132,7 +132,8 @@ function getData($db) : array
*/
function getProjectData($db, $user, $id) : array
{
$query = 'SELECT Title, Description, DateProposed, '.
$query = 'SELECT Title, Description, datePublication, journal, '.
'link, publishingStatus, DateProposed, '.
'pc.Name as LeadInvestigator, pc.Email as LeadInvestigatorEmail, '.
'PublicationStatusID, UserID, RejectedReason '.
'FROM publication p '.
Expand Down Expand Up @@ -167,13 +168,21 @@ function getProjectData($db, $user, $id) : array

$usersWithEditPerm = $userIDs;

$title = htmlspecialchars_decode($result['Title']);
$description = htmlspecialchars_decode($result['Description']);
$rejectedReason = htmlspecialchars_decode($result['RejectedReason']);
$title = htmlspecialchars_decode($result['Title']);
$description = htmlspecialchars_decode($result['Description']);
$datePublication = htmlspecialchars_decode($result['datePublication']);
$journal = htmlspecialchars_decode($result['journal']);
$link = htmlspecialchars_decode($result['link']);
$publishingStatus = htmlspecialchars_decode($result['publishingStatus']);
$rejectedReason = htmlspecialchars_decode($result['RejectedReason']);

$pubData = [
'title' => $title,
'description' => $description,
'datePublication' => $datePublication,
'journal' => $journal,
'link' => $link,
'publishingStatus' => $publishingStatus,
'leadInvestigator' => $result['LeadInvestigator'],
'leadInvestigatorEmail' => $result['LeadInvestigatorEmail'],
'status' => $result['PublicationStatusID'],
Expand Down
48 changes: 48 additions & 0 deletions modules/publication/jsx/projectFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@ class ProjectFormFields extends React.Component {
Imaging: 'Imaging',
};

const publishingStatusOptions = {
'In Progress': 'In progress',
'Published': 'Published',
};

const allVOIs = this.props.allVOIs;
let voiOptions = {};
let type = this.props.formData.voiType;
Expand All @@ -392,6 +397,8 @@ class ProjectFormFields extends React.Component {
voiOptions = Object.assign(bvlCopy, allVOIs.Imaging);
}

const published = this.props.formData.publishingStatus==='Published';

return (
<div>
<TextareaElement
Expand All @@ -401,6 +408,47 @@ class ProjectFormFields extends React.Component {
required={true}
value={this.props.formData.description}
/>
<SelectElement
name="publishingStatus"
label="Publishing status"
options={publishingStatusOptions}
onUserInput={this.props.setFormData}
required={true}
value={this.props.formData.publishingStatus}
emptyOption={true}
/>
<DateElement
name="datePublication"
label="Date published"
onUserInput={this.props.setFormData}
required={published}
value={this.props.formData.datePublication}
disabled={!published}
/>
<TextboxElement
name="journal"
label="Journal"
onUserInput={this.props.setFormData}
required={published}
value={this.props.formData.journal}
disabled={!published}
/>
<TextboxElement
name="doi"
label="DOI"
onUserInput={this.props.setFormData}
required={false}
value={this.props.formData.doi}
disabled={!published}
/>
<TextboxElement
name="link"
label="Link"
onUserInput={this.props.setFormData}
required={published}
value={this.props.formData.link}
disabled={!published}
/>
<TextboxElement
name="leadInvestigator"
label="Lead Investigator"
Expand Down
9 changes: 9 additions & 0 deletions modules/publication/jsx/publicationIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ class PublicationIndex extends React.Component {
</td>
);
}
if (column === 'Publishing Status') {
let status = '';
if (cell === 'inProgress') {
pierre-p-s marked this conversation as resolved.
Show resolved Hide resolved
status = 'In Progress';
} else if (cell === 'published') {
status = 'Published';
}
return <td className={classes}>{status}</td>;
}
return <td className={classes}>{cell}</td>;
}
}
Expand Down
24 changes: 24 additions & 0 deletions modules/publication/jsx/viewProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ class ViewProject extends React.Component {
let formData = {
title: data.title,
description: data.description,
publishingStatus: data.publishingStatus,
datePublication: data.datePublication,
journal: data.journal,
link: data.link,
leadInvestigator: data.leadInvestigator,
leadInvestigatorEmail: data.leadInvestigatorEmail,
notifyLead: false,
Expand Down Expand Up @@ -283,6 +287,26 @@ class ViewProject extends React.Component {
label="Description"
text={this.state.formData.description}
/>
<StaticElement
name="publishingStatus"
label="Publishing status"
text={this.state.formData.publishingStatus}
/>
<StaticElement
name="datePublication"
label="Date published"
text={this.state.formData.datePublication}
/>
<StaticElement
name="journal"
label="Journal"
text={this.state.formData.journal}
/>
<StaticElement
name="link"
label="Link"
text={this.state.formData.link}
/>
<StaticElement
name="leadInvestigator"
label="Lead Investigator"
Expand Down
34 changes: 33 additions & 1 deletion modules/publication/php/publication.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ class Publication extends \NDB_Menu_Filter_Form
"LEFT JOIN publication_keyword pk ".
"ON pkr.PublicationKeywordID=pk.PublicationKeywordID ".
"LEFT JOIN publication_users_edit_perm_rel puepr ".
"ON puepr.PublicationID=p.PublicationID ";
"ON puepr.PublicationID=p.PublicationID ".
"LEFT JOIN users u ".
"ON u.ID=p.UserID ";
$query .= " WHERE 1=1 ";
// allow user access to module if they have edit
// access to any project proposal
Expand All @@ -104,6 +106,11 @@ class Publication extends \NDB_Menu_Filter_Form
'pcli.Name as LeadInvestigator',
'p.DateProposed',
'ps.Label', // Status (Approved, Pending, Rejected, etc.)
'p.journal',
'p.link',
'p.publishingStatus',
'p.datePublication',
'u.Real_name',
'p.Description',
'GROUP_CONCAT(DISTINCT pc.Name)', // Collaborators
// vv Variables of Interest vv
Expand All @@ -122,6 +129,11 @@ class Publication extends \NDB_Menu_Filter_Form
'Lead Investigator',
'Date Proposed',
'Approval Status',
'Journal',
'Link',
'Publishing Status',
'Date published',
'Project Proposal Creator',
'Description',
'Collaborators',
'Variables Of Interest',
Expand Down Expand Up @@ -194,10 +206,30 @@ class Publication extends \NDB_Menu_Filter_Form
'keywords',
'Keywords'
);

$this->addBasicText(
'variablesOfInterest',
'Variables of Interest'
);

$this->addBasicText(
'journal',
'Journal'
);

$this->addBasicText(
'link',
'Link'
);

$this->addSelect(
'publishingStatus',
'Publishing Status',
[
'published' => 'Published',
pierre-p-s marked this conversation as resolved.
Show resolved Hide resolved
'inProgress' => 'In Progress'
]
);
}


Expand Down