Skip to content

Commit 663536d

Browse files
authored
[publication] Add columns to publications (#7361)
Added data columns to the publication module: - Project, - Date published, - Journal, - link and - publishing status (dropdown menu with: in progress or published)
1 parent 6c3fa07 commit 663536d

File tree

8 files changed

+231
-14
lines changed

8 files changed

+231
-14
lines changed

SQL/0000-00-00-schema.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,6 +2335,13 @@ CREATE TABLE `publication` (
23352335
`Title` varchar(255) NOT NULL,
23362336
`RejectedReason` varchar(255) default NULL,
23372337
`Description` text NOT NULL,
2338+
`journal` varchar(255) DEFAULT NULL,
2339+
`doi` text DEFAULT NULL,
2340+
`datePublication` date DEFAULT NULL,
2341+
`link` varchar(255) DEFAULT NULL,
2342+
`publishingStatus` enum('In Progress','Published') DEFAULT NULL,
2343+
`project` int(10) unsigned DEFAULT NULL,
2344+
CONSTRAINT `FK_publication_project` FOREIGN KEY (project) REFERENCES Project(ProjectID),
23382345
CONSTRAINT `PK_publication` PRIMARY KEY(`PublicationID`),
23392346
CONSTRAINT `FK_publication_UserID` FOREIGN KEY(`UserID`) REFERENCES `users` (`ID`),
23402347
CONSTRAINT `FK_publication_RatedBy` FOREIGN KEY(`RatedBy`) REFERENCES `users` (`ID`),
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
ALTER TABLE publication
2+
ADD COLUMN journal varchar(255) DEFAULT NULL,
3+
ADD COLUMN doi text DEFAULT NULL,
4+
ADD COLUMN datePublication date DEFAULT NULL,
5+
ADD COLUMN link varchar(255) DEFAULT NULL,
6+
ADD COLUMN publishingStatus enum('In Progress','Published') DEFAULT NULL,
7+
ADD COLUMN project int(10) unsigned DEFAULT NULL,
8+
ADD CONSTRAINT `FK_publication_project`
9+
FOREIGN KEY (project) REFERENCES Project(ProjectID);

modules/publication/ajax/FileUpload.php

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,14 @@ function uploadPublication() : void
5757
if ($exists) {
5858
showPublicationError('Submitted title already exists', 400);
5959
}
60-
$desc = $_POST['description'] ?? null;
61-
$leadInvest = $_POST['leadInvestigator'] ?? null;
60+
$desc = $_POST['description'] ?? null;
61+
$project = $_POST['project'] ?? null;
62+
$publishingStatus = $_POST['publishingStatus'] ?? null;
63+
$datePublication = $_POST['datePublication'] ?? null;
64+
$journal = $_POST['journal'] ?? null;
65+
$doi = $_POST['doi'] ?? null;
66+
$link = $_POST['link'] ?? null;
67+
$leadInvest = $_POST['leadInvestigator'] ?? null;
6268
$leadInvestEmail = $_POST['leadInvestigatorEmail'] ?? null;
6369

6470
// check if lead investigator already exists in collaborator table
@@ -68,8 +74,8 @@ function uploadPublication() : void
6874
'FROM publication_collaborator '.
6975
'WHERE Name = :n AND Email = :e',
7076
[
71-
'n' => $leadInvest,
7277
'e' => $leadInvestEmail,
78+
'n' => $leadInvest,
7379
]
7480
);
7581
if (empty($leadInvID)) {
@@ -94,6 +100,12 @@ function uploadPublication() : void
94100
'UserID' => $uid,
95101
'Title' => $title,
96102
'Description' => $desc,
103+
'project' => $project,
104+
'publishingStatus' => $publishingStatus,
105+
'datePublication' => $datePublication,
106+
'journal' => $journal,
107+
'doi' => $doi,
108+
'link' => $link,
97109
'LeadInvestigatorID' => $leadInvID,
98110
'DateProposed' => $today,
99111
];
@@ -533,7 +545,13 @@ function editProject() : void
533545
$statusID = $_POST['status'] ?? null;
534546
$rejectedReason = $_POST['rejectedReason'] ?? null;
535547
$description = $_POST['description'] ?? null;
536-
$leadInvestigator = $_POST['leadInvestigator'] ?? null;
548+
$project = $_POST['project'] ?? null;
549+
$publishingStatus = $_POST['publishingStatus'] ?? null;
550+
$datePublication = $_POST['datePublication'] ?? null;
551+
$journal = $_POST['journal'] ?? null;
552+
$doi = $_POST['doi'] ?? null;
553+
$link = $_POST['link'] ?? null;
554+
$leadInvestigator = $_POST['leadInvestigator'] ?? null;
537555
$leadInvestigatorEmail = $_POST['leadInvestigatorEmail'] ?? null;
538556

539557
$pubData = $db->pselectRow(
@@ -566,6 +584,24 @@ function editProject() : void
566584
if ($pubData['Description'] !== $description) {
567585
$toUpdate['Description'] = $description;
568586
}
587+
if ($pubData['project'] !== $project) {
588+
$toUpdate['project'] = $project;
589+
}
590+
if ($pubData['publishingStatus'] !== $publishingStatus) {
591+
$toUpdate['publishingStatus'] = $publishingStatus;
592+
}
593+
if ($pubData['datePublication'] !== $datePublication) {
594+
$toUpdate['datePublication'] = $datePublication;
595+
}
596+
if ($pubData['journal'] !== $journal) {
597+
$toUpdate['journal'] = $journal;
598+
}
599+
if ($pubData['doi'] !== $doi) {
600+
$toUpdate['doi'] = $doi;
601+
}
602+
if ($pubData['link'] !== $link) {
603+
$toUpdate['link'] = $link;
604+
}
569605
if ($pubData['LeadInvestigator'] !== $leadInvestigator) {
570606
$leadInvToUpdate['Name'] = $leadInvestigator;
571607
}

modules/publication/ajax/getData.php

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ function getData($db) : array
6767
[]
6868
);
6969

70+
$rawProject = $db->pselect(
71+
'SELECT ProjectID, Name FROM Project',
72+
[]
73+
);
74+
75+
$projectOptions = [];
76+
foreach ($rawProject as $dataProject) {
77+
$projectOptions[$dataProject['ProjectID']] = $dataProject['Name'];
78+
}
79+
7080
// merge variables and test names into one array
7181
$bvlVOIs = array_merge(
7282
array_column($bvlVOIs, 'Name'),
@@ -80,11 +90,11 @@ function getData($db) : array
8090

8191
// imaging VoIs -- filter out non-human readable DICOM tags
8292
$imgVOIs = $db->pselectCol(
83-
"SELECT DISTINCT p.Name FROM parameter_type p
84-
JOIN parameter_type_category_rel ptcr
85-
ON p.ParameterTypeID=ptcr.ParameterTypeID
86-
JOIN parameter_type_category ptc
87-
ON ptc.ParameterTypeCategoryID=ptcr.ParameterTypeCategoryID
93+
"SELECT DISTINCT p.Name FROM parameter_type p
94+
JOIN parameter_type_category_rel ptcr
95+
ON p.ParameterTypeID=ptcr.ParameterTypeID
96+
JOIN parameter_type_category ptc
97+
ON ptc.ParameterTypeCategoryID=ptcr.ParameterTypeCategoryID
8898
WHERE ptc.Name='MRI Variables'",
8999
[]
90100
);
@@ -114,6 +124,7 @@ function getData($db) : array
114124
);
115125
$collabs = array_combine($collabs, $collabs);
116126

127+
$data['projectOptions'] = $projectOptions;
117128
$data['users'] = $users;
118129
$data['uploadTypes'] = getUploadTypes();
119130
$data['existingTitles'] = $titles;
@@ -134,12 +145,15 @@ function getData($db) : array
134145
*/
135146
function getProjectData($db, $user, $id) : array
136147
{
137-
$query = 'SELECT Title, Description, DateProposed, '.
148+
$query = 'SELECT Title, Description, pr.Name as project, datePublication, '.
149+
'journal, link, publishingStatus, DateProposed, '.
138150
'pc.Name as LeadInvestigator, pc.Email as LeadInvestigatorEmail, '.
139151
'PublicationStatusID, UserID, RejectedReason '.
140152
'FROM publication p '.
141153
'LEFT JOIN publication_collaborator pc '.
142154
'ON p.LeadInvestigatorID = pc.PublicationCollaboratorID '.
155+
'LEFT JOIN Project pr '.
156+
'ON p.project = pr.ProjectID '.
143157
'WHERE p.PublicationID=:pid ';
144158
$result = $db->pselectRow(
145159
$query,
@@ -169,13 +183,22 @@ function getProjectData($db, $user, $id) : array
169183

170184
$usersWithEditPerm = $userIDs;
171185

172-
$title = htmlspecialchars_decode($result['Title']);
173-
$description = htmlspecialchars_decode($result['Description']);
174-
$rejectedReason = htmlspecialchars_decode($result['RejectedReason']);
186+
$title = htmlspecialchars_decode($result['Title']);
187+
$description = htmlspecialchars_decode($result['Description']);
188+
$datePublication = htmlspecialchars_decode($result['datePublication']);
189+
$journal = htmlspecialchars_decode($result['journal']);
190+
$link = htmlspecialchars_decode($result['link']);
191+
$publishingStatus = htmlspecialchars_decode($result['publishingStatus']);
192+
$rejectedReason = htmlspecialchars_decode($result['RejectedReason']);
175193

176194
$pubData = [
177195
'title' => $title,
178196
'description' => $description,
197+
'project' => $result['project'],
198+
'datePublication' => $datePublication,
199+
'journal' => $journal,
200+
'link' => $link,
201+
'publishingStatus' => $publishingStatus,
179202
'leadInvestigator' => $result['LeadInvestigator'],
180203
'leadInvestigatorEmail' => $result['LeadInvestigatorEmail'],
181204
'status' => $result['PublicationStatusID'],

modules/publication/jsx/projectFields.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,11 @@ class ProjectFormFields extends React.Component {
381381
Imaging: 'Imaging',
382382
};
383383

384+
const publishingStatusOptions = {
385+
'In Progress': 'In progress',
386+
'Published': 'Published',
387+
};
388+
384389
const allVOIs = this.props.allVOIs;
385390
let voiOptions = {};
386391
let type = this.props.formData.voiType;
@@ -392,6 +397,8 @@ class ProjectFormFields extends React.Component {
392397
voiOptions = Object.assign(bvlCopy, allVOIs.Imaging);
393398
}
394399

400+
const published = this.props.formData.publishingStatus==='Published';
401+
395402
return (
396403
<div>
397404
<TextareaElement
@@ -401,6 +408,56 @@ class ProjectFormFields extends React.Component {
401408
required={true}
402409
value={this.props.formData.description}
403410
/>
411+
<SelectElement
412+
name="project"
413+
label="Project"
414+
options={this.props.projectOptions}
415+
onUserInput={this.props.setFormData}
416+
required={true}
417+
value={this.props.formData.project}
418+
emptyOption={true}
419+
/>
420+
<SelectElement
421+
name="publishingStatus"
422+
label="Publishing status"
423+
options={publishingStatusOptions}
424+
onUserInput={this.props.setFormData}
425+
required={true}
426+
value={this.props.formData.publishingStatus}
427+
emptyOption={true}
428+
/>
429+
<DateElement
430+
name="datePublication"
431+
label="Date published"
432+
onUserInput={this.props.setFormData}
433+
required={published}
434+
value={this.props.formData.datePublication}
435+
disabled={!published}
436+
/>
437+
<TextboxElement
438+
name="journal"
439+
label="Journal"
440+
onUserInput={this.props.setFormData}
441+
required={published}
442+
value={this.props.formData.journal}
443+
disabled={!published}
444+
/>
445+
<TextboxElement
446+
name="doi"
447+
label="DOI"
448+
onUserInput={this.props.setFormData}
449+
required={false}
450+
value={this.props.formData.doi}
451+
disabled={!published}
452+
/>
453+
<TextboxElement
454+
name="link"
455+
label="Link"
456+
onUserInput={this.props.setFormData}
457+
required={published}
458+
value={this.props.formData.link}
459+
disabled={!published}
460+
/>
404461
<TextboxElement
405462
name="leadInvestigator"
406463
label="Lead Investigator"

modules/publication/jsx/uploadForm.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ class PublicationUploadForm extends React.Component {
266266
removeListItem={this.removeListItem}
267267
toggleEmailNotify={this.toggleEmailNotify}
268268
uploadTypes={this.state.Data.uploadTypes}
269+
projectOptions={this.state.Data.projectOptions}
269270
users={this.state.Data.users}
270271
allVOIs={this.state.Data.allVOIs}
271272
allKWs={this.state.Data.allKWs}

modules/publication/jsx/viewProject.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ class ViewProject extends React.Component {
100100
let formData = {
101101
title: data.title,
102102
description: data.description,
103+
project: data.project,
104+
publishingStatus: data.publishingStatus,
105+
datePublication: data.datePublication,
106+
journal: data.journal,
107+
link: data.link,
103108
leadInvestigator: data.leadInvestigator,
104109
leadInvestigatorEmail: data.leadInvestigatorEmail,
105110
notifyLead: false,
@@ -131,6 +136,7 @@ class ViewProject extends React.Component {
131136

132137
this.setState({
133138
formData: formData,
139+
projectOptions: data.projectOptions,
134140
users: data.users,
135141
statusOpts: data.statusOpts,
136142
userCanEdit: data.userCanEdit,
@@ -283,6 +289,31 @@ class ViewProject extends React.Component {
283289
label="Description"
284290
text={this.state.formData.description}
285291
/>
292+
<StaticElement
293+
name="project"
294+
label="Project"
295+
text={this.state.formData.project}
296+
/>
297+
<StaticElement
298+
name="publishingStatus"
299+
label="Publishing status"
300+
text={this.state.formData.publishingStatus}
301+
/>
302+
<StaticElement
303+
name="datePublication"
304+
label="Date published"
305+
text={this.state.formData.datePublication}
306+
/>
307+
<StaticElement
308+
name="journal"
309+
label="Journal"
310+
text={this.state.formData.journal}
311+
/>
312+
<StaticElement
313+
name="link"
314+
label="Link"
315+
text={this.state.formData.link}
316+
/>
286317
<StaticElement
287318
name="leadInvestigator"
288319
label="Lead Investigator"
@@ -319,6 +350,7 @@ class ViewProject extends React.Component {
319350
removeListItem={this.removeListItem}
320351
toggleEmailNotify={this.toggleEmailNotify}
321352
uploadTypes={this.state.uploadTypes}
353+
projectOptions={this.state.projectOptions}
322354
users={this.state.users}
323355
allVOIs={this.state.allVOIs}
324356
allKWs={this.state.allKWs}

0 commit comments

Comments
 (0)