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
6 changes: 5 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,10 @@ 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
`datePublication` date DEFAULT NULL,
`link` varchar(255) DEFAULT NULL,
`publishingStatus` enum('inProgress','published') DEFAULT NULL,
pierre-p-s marked this conversation as resolved.
Show resolved Hide resolved
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
5 changes: 5 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,5 @@
ALTER TABLE publication
ADD COLUMN journal varchar(255) DEFAULT NULL,
ADD COLUMN datePublication date DEFAULT NULL,
ADD COLUMN link varchar(255) DEFAULT NULL,
ADD COLUMN publishingStatus enum('inProgress','published') DEFAULT NULL;
12 changes: 10 additions & 2 deletions modules/publication/ajax/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ function uploadPublication() : void
showPublicationError('Submitted title already exists', 400);
}
$desc = $_POST['description'] ?? null;
$leadInvest = $_POST['leadInvestigator'] ?? null;
$leadInvestEmail = $_POST['leadInvestigatorEmail'] ?? null;
$datePublication = $_POST['datePublication'] ?? null;
$journal = $_POST['journal'] ?? null;
$link = $_POST['link'] ?? null;
$publishingStatus = $_POST['publishingStatus'] ?? null;
$leadInvest = $_POST['leadInvestigator'] ?? null;
$leadInvestEmail = $_POST['leadInvestigatorEmail'] ?? null;

// check if lead investigator already exists in collaborator table
// use ID if exists, else insert
Expand Down Expand Up @@ -94,6 +98,10 @@ function uploadPublication() : void
'UserID' => $uid,
'Title' => $title,
'Description' => $desc,
'datePublication' => $datePublication,
'journal' => $journal,
'link' => $link,
'publishingStatus' => $publishingStatus,
'LeadInvestigatorID' => $leadInvID,
'DateProposed' => $today,
];
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
35 changes: 35 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',
};

let publishingStatusOptions = {
inProgress: 'In progress',
published: 'Published',
};

const allVOIs = this.props.allVOIs;
let voiOptions = {};
let type = this.props.formData.voiType;
Expand All @@ -401,6 +406,36 @@ class ProjectFormFields extends React.Component {
required={true}
value={this.props.formData.description}
/>
<DateElement
name="datePublication"
label="Date published"
onUserInput={this.props.setFormData}
required={true}
value={this.props.formData.datePublication}
/>
<TextboxElement
name="journal"
label="Journal"
onUserInput={this.props.setFormData}
required={true}
value={this.props.formData.journal}
/>
<TextboxElement
name="link"
label="Link"
onUserInput={this.props.setFormData}
required={true}
value={this.props.formData.link}
/>
<SelectElement
name="publishingStatus"
label="Publishing status"
options={publishingStatusOptions}
onUserInput={this.props.setFormData}
required={true}
value={this.props.formData.publishingStatus}
emptyOption={true}
/>
<TextboxElement
name="leadInvestigator"
label="Lead Investigator"
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,
datePublication: data.datePublication,
journal: data.journal,
link: data.link,
publishingStatus: data.publishingStatus,
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="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="publishingStatus"
label="Publishing status"
text={this.state.formData.publishingStatus}
/>
<StaticElement
name="leadInvestigator"
label="Lead Investigator"
Expand Down