Skip to content

Commit

Permalink
[publication] Add columns to publications (#7361)
Browse files Browse the repository at this point in the history
    Added data columns to the publication module:
    - Project,
    - Date published,
    - Journal,
    - link and
    - publishing status (dropdown menu with: in progress or published)
  • Loading branch information
pierre-p-s committed Oct 14, 2022
1 parent 6c3fa07 commit 663536d
Show file tree
Hide file tree
Showing 8 changed files with 231 additions and 14 deletions.
7 changes: 7 additions & 0 deletions SQL/0000-00-00-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2335,6 +2335,13 @@ CREATE TABLE `publication` (
`Title` varchar(255) NOT NULL,
`RejectedReason` varchar(255) default NULL,
`Description` text NOT NULL,
`journal` varchar(255) DEFAULT NULL,
`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 AND 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 @@ -533,7 +545,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 @@ -566,6 +584,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 @@ -67,6 +67,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 @@ -80,11 +90,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 @@ -114,6 +124,7 @@ function getData($db) : array
);
$collabs = array_combine($collabs, $collabs);

$data['projectOptions'] = $projectOptions;
$data['users'] = $users;
$data['uploadTypes'] = getUploadTypes();
$data['existingTitles'] = $titles;
Expand All @@ -134,12 +145,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 @@ -169,13 +183,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

0 comments on commit 663536d

Please sign in to comment.