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 all 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
9 changes: 8 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,13 @@ 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,
`project` int(10) unsigned DEFAULT NULL,
CONSTRAINT `FK_publication_project` FOREIGN KEY (project) REFERENCES Project(ProjectID),
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
9 changes: 9 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,9 @@
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,
ADD COLUMN project int(10) unsigned DEFAULT NULL,
ADD CONSTRAINT `FK_publication_project`
FOREIGN KEY (project) REFERENCES Project(ProjectID);
44 changes: 40 additions & 4 deletions modules/publication/ajax/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ function uploadPublication() : void
if ($exists) {
showPublicationError('Submitted title already exists', 400);
}
$desc = $_POST['description'] ?? null;
$leadInvest = $_POST['leadInvestigator'] ?? null;
$desc = $_POST['description'] ?? null;
$project = $_POST['project'] ?? 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,8 +74,8 @@ function uploadPublication() : void
'FROM publication_collaborator '.
'WHERE Name = :n OR Email = :e',
[
'n' => $leadInvest,
'e' => $leadInvestEmail,
'n' => $leadInvest,
]
);
if (empty($leadInvID)) {
Expand All @@ -94,6 +100,12 @@ function uploadPublication() : void
'UserID' => $uid,
'Title' => $title,
'Description' => $desc,
'project' => $project,
'publishingStatus' => $publishingStatus,
'datePublication' => $datePublication,
'journal' => $journal,
'doi' => $doi,
'link' => $link,
'LeadInvestigatorID' => $leadInvID,
'DateProposed' => $today,
];
Expand Down Expand Up @@ -513,7 +525,13 @@ function editProject() : void
$statusID = $_POST['status'] ?? null;
$rejectedReason = $_POST['rejectedReason'] ?? null;
$description = $_POST['description'] ?? null;
$leadInvestigator = $_POST['leadInvestigator'] ?? null;
$project = $_POST['project'] ?? 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 +564,24 @@ function editProject() : void
if ($pubData['Description'] !== $description) {
$toUpdate['Description'] = $description;
}
if ($pubData['project'] !== $project) {
$toUpdate['project'] = $project;
}
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
41 changes: 32 additions & 9 deletions modules/publication/ajax/getData.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ function getData($db) : array
[]
);

$rawProject = $db->pselect(
'SELECT ProjectID, Name FROM Project',
[]
);

$projectOptions = [];
foreach ($rawProject as $dataProject) {
$projectOptions[$dataProject['ProjectID']] = $dataProject['Name'];
}

// merge variables and test names into one array
$bvlVOIs = array_merge(
array_column($bvlVOIs, 'Name'),
Expand All @@ -78,11 +88,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 @@ -112,6 +122,7 @@ function getData($db) : array
);
$collabs = array_combine($collabs, $collabs);

$data['projectOptions'] = $projectOptions;
$data['users'] = $users;
$data['uploadTypes'] = getUploadTypes();
$data['existingTitles'] = $titles;
Expand All @@ -132,12 +143,15 @@ function getData($db) : array
*/
function getProjectData($db, $user, $id) : array
{
$query = 'SELECT Title, Description, DateProposed, '.
$query = 'SELECT Title, Description, pr.Name as project, datePublication, '.
'journal, link, publishingStatus, DateProposed, '.
'pc.Name as LeadInvestigator, pc.Email as LeadInvestigatorEmail, '.
'PublicationStatusID, UserID, RejectedReason '.
'FROM publication p '.
'LEFT JOIN publication_collaborator pc '.
'ON p.LeadInvestigatorID = pc.PublicationCollaboratorID '.
'LEFT JOIN Project pr '.
'ON p.project = pr.ProjectID '.
'WHERE p.PublicationID=:pid ';
$result = $db->pselectRow(
$query,
Expand Down Expand Up @@ -167,13 +181,22 @@ 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,
'project' => $result['project'],
'datePublication' => $datePublication,
'journal' => $journal,
'link' => $link,
'publishingStatus' => $publishingStatus,
'leadInvestigator' => $result['LeadInvestigator'],
'leadInvestigatorEmail' => $result['LeadInvestigatorEmail'],
'status' => $result['PublicationStatusID'],
Expand Down
57 changes: 57 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,56 @@ class ProjectFormFields extends React.Component {
required={true}
value={this.props.formData.description}
/>
<SelectElement
name="project"
label="Project"
options={this.props.projectOptions}
onUserInput={this.props.setFormData}
required={true}
value={this.props.formData.project}
emptyOption={true}
/>
<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
1 change: 1 addition & 0 deletions modules/publication/jsx/uploadForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class PublicationUploadForm extends React.Component {
removeListItem={this.removeListItem}
toggleEmailNotify={this.toggleEmailNotify}
uploadTypes={this.state.Data.uploadTypes}
projectOptions={this.state.Data.projectOptions}
users={this.state.Data.users}
allVOIs={this.state.Data.allVOIs}
allKWs={this.state.Data.allKWs}
Expand Down
32 changes: 32 additions & 0 deletions modules/publication/jsx/viewProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ class ViewProject extends React.Component {
let formData = {
title: data.title,
description: data.description,
project: data.project,
publishingStatus: data.publishingStatus,
datePublication: data.datePublication,
journal: data.journal,
link: data.link,
leadInvestigator: data.leadInvestigator,
leadInvestigatorEmail: data.leadInvestigatorEmail,
notifyLead: false,
Expand Down Expand Up @@ -131,6 +136,7 @@ class ViewProject extends React.Component {

this.setState({
formData: formData,
projectOptions: data.projectOptions,
users: data.users,
statusOpts: data.statusOpts,
userCanEdit: data.userCanEdit,
Expand Down Expand Up @@ -283,6 +289,31 @@ class ViewProject extends React.Component {
label="Description"
text={this.state.formData.description}
/>
<StaticElement
name="project"
label="Project"
text={this.state.formData.project}
/>
<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 Expand Up @@ -319,6 +350,7 @@ class ViewProject extends React.Component {
removeListItem={this.removeListItem}
toggleEmailNotify={this.toggleEmailNotify}
uploadTypes={this.state.uploadTypes}
projectOptions={this.state.projectOptions}
users={this.state.users}
allVOIs={this.state.allVOIs}
allKWs={this.state.allKWs}
Expand Down