Skip to content

Commit

Permalink
add collaborationTheme field to visit and sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
c2d13p committed Oct 29, 2024
1 parent 8214c33 commit bc9488b
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 4 deletions.
34 changes: 33 additions & 1 deletion server/controllers/processes/sanityCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Staff = require('../../models/Staff')
const Institution = require('../../models/Institution')
const Seminar = require('../../models/EventSeminar')
const Event = require('../../models/EventConference')
const Visit = require('../../models/Visit')

router.get('/', async (req, res) => {
if (req.user === undefined || !req.user.roles.includes('admin')) {
Expand Down Expand Up @@ -126,6 +127,25 @@ router.get('/', async (req, res) => {
}
]);

const seminarsTBA = await Seminar.aggregate([
{
$match: {
$expr: { $lt: [{ $strLenCP: { $ifNull: ["$title", ""] } }, 5] }
}
}
]);

const visitsTBD = await Visit.aggregate([
{
$match: {
$and: [
{ $expr: { $lt: [{ $strLenCP: { $ifNull: ["$collaborationTheme", ""] } }, 5] } },
{ collaborationTheme: { $exists: true } }
]
}
}
]);

// find duplicated institutions
const duplicatedInstitutions = await Institution.aggregate([
{ $project: {
Expand Down Expand Up @@ -299,7 +319,19 @@ router.get('/', async (req, res) => {
}
])

return res.json({duplicatedNames, personsWithTrailingSpaces, institutionsWithTrailingSpaces, duplicatedEmails, missingMatricola, missingSSD, missingInstitutionCountry, duplicatedInstitutions, duplicatedSeminars, duplicatedEvents})
return res.json({
duplicatedNames,
personsWithTrailingSpaces,
institutionsWithTrailingSpaces,
duplicatedEmails,
missingMatricola,
missingSSD,
missingInstitutionCountry,
duplicatedInstitutions,
duplicatedSeminars,
duplicatedEvents,
seminarsTBA,
visitsTBD})
})

module.exports = router
2 changes: 2 additions & 0 deletions server/controllers/processes/visits.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ async function notifyVisit(visit_id, message) {
const startDate = visit.startDate.toLocaleDateString('it-IT')
const endDate = visit.endDate.toLocaleDateString('it-IT')
const notes = visit.notes
const collaborationTheme = visit.collaborationTheme
const universityFunded = visit.universityFunded ? 'sì' : 'no'
let text = message || ''

Expand All @@ -394,6 +395,7 @@ Visitatore/trice: ${person.firstName} ${person.lastName}
Affiliazione/i: ${affiliations}
Grant(s) utilizzato/i: ${grants}
Utilizzo di fondi di Ateneo: ${universityFunded}
Tema della collaborazione: ${collaborationTheme}
Albergo di cui si richiede la prenotazione di una camera: ${visit.requireHotel}
Richiesta di una postazione in un ufficio di Dipartimento: ${visit.requireRoom ? 'sì' : 'no'}
È previsto un seminario: ${visit.requireSeminar ? 'sì' : 'no'}
Expand Down
1 change: 1 addition & 0 deletions server/models/Visit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const visitSchema = new Schema({
affiliations: [{ type: ObjectId, label: 'affiliazioni al tempo della visita', ref: 'Institution' }],
startDate,
endDate,
collaborationTheme: { type: String, label: 'tema della collaborazione', default: ''},
requireRoom: { type: Boolean, label: 'richiede stanza', default: false },
requireSeminar: { type: Boolean, label: 'richiede seminario', default: false },
requireHotel: { type: String, label: 'albergo', default: ''},
Expand Down
18 changes: 18 additions & 0 deletions src/processes/SanityCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,24 @@ export default function SanityCheck() {
</td>
)}
/>
<CheckCard
title="Seminars TBA"
data={data.seminarsTBA}
renderRow={(item) => (
<td>
<a className="btn" href={`/event-seminar/${item._id}`}>{item.title}</a>
</td>
)}
/>
<CheckCard
title="Visits TBD"
data={data.visitsTBD}
renderRow={(item) => (
<td>
<a className="btn" href={`/visit/${item._id}`}>{item.collaborationTheme}</a>
</td>
)}
/>
<CheckCard
title="Person with trailing spaces"
data={data.personsWithTrailingSpaces}
Expand Down
18 changes: 15 additions & 3 deletions src/processes/Visit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useParams, useNavigate } from 'react-router-dom'
import { useQuery, useQueryClient } from 'react-query'

import { SelectPersonBlock, SelectPeopleBlock } from './SelectPeopleBlock'
import { GrantInput, InputRow, DateInput, TextInput, SelectInput } from '../components/Input'
import { GrantInput, InputRow, DateInput, StringInput, TextInput, SelectInput } from '../components/Input'
import { PrefixProvider } from './PrefixProvider'
import api from '../api'
import Loading from '../components/Loading'
Expand Down Expand Up @@ -241,6 +241,8 @@ function VisitDetailsBlock({data, setData, active, done, edit, variant, fetchSem
<br />
periodo: <b>{myDateFormat(data.startDate)}{myDateFormat(data.endDate)}</b>
<br />
tema: <b>{data.collaborationTheme}</b>
<br />
SSD: <b>{data.SSD}</b>
<br />
grants: {data?.grants?.length ? data.grants.map(grant => <span key={grant._id}><b>{grant.identifier}</b>&nbsp;</span>) : <i>nessun grant utilizzato</i>}
Expand Down Expand Up @@ -291,6 +293,16 @@ function ActiveVisitDetailsBlock({data, setData, done, variant, fetchSeminars})
<InputRow label="Data partenza" className="my-3">
<DateInput value={data.endDate} setValue={endDateSetter} defaultDate={data.startDate}/>
</InputRow>
<InputRow label="Tema collaborazione" className="my-3" l>
<div className="d-flex align-items-start">
<OverlayTrigger placement="left" overlay={<Tooltip id="grants-tooltip">
Indicare il tema della collaborazione da inserire nella lettera di incarico che Francesca dovrà scrivere.
Se il tema non è ancora definito inserire 'TBD' e aggiungere successivamente.</Tooltip>}>
<Button size="sm" style={{ marginRight: '10px' }}>?</Button>
</OverlayTrigger>
<StringInput value={data.collaborationTheme} setValue={setter(setData, "collaborationTheme")}/>
</div>
</InputRow>
<InputRow label="SSD" className="my-3">
<SelectInput value={data.SSD} setValue={setter(setData, "SSD")} options={["MAT/01", "MAT/02", "MAT/03", "MAT/04", "MAT/05", "MAT/06", "MAT/07", "MAT/08", "MAT/09",""]}/>
</InputRow>
Expand Down Expand Up @@ -358,8 +370,7 @@ function ActiveVisitDetailsBlock({data, setData, done, variant, fetchSeminars})
<InputRow className="my-3" label="Note">
<div className="d-flex align-items-start">
<OverlayTrigger placement="left" overlay={<Tooltip id="grants-tooltip">
Si consiglia di utilizzare le note per scrivere tutte le info rilevanti per Francesca, in particolare si suggerisce di utilizzare le note
per indicare il "tema della collaborazione" da inserire nella lettera di incarico che Francesca dovrà scrivere</Tooltip>}>
Si consiglia di utilizzare le note per scrivere tutte le info rilevanti per Francesca</Tooltip>}>
<Button size="sm" style={{ marginRight: '10px' }}>?</Button>
</OverlayTrigger>
<TextInput value={data.notes} setValue={setter(setData, "notes")}/>
Expand Down Expand Up @@ -399,6 +410,7 @@ function ActiveVisitDetailsBlock({data, setData, done, variant, fetchSeminars})
if (!data.startDate) return "Data di arrivo non inserita"
if (!data.endDate) return "Data di partenza non inserita"
if (new Date(data.startDate) > new Date(data.endDate)) return "Data di arrivo successiva alla data di partenza"
if (!data.collaborationTheme) return "Tema della collaborazione non inserito (scrivere 'TBD' se non ancora definito e aggiungere successivamente)"
}

function setReferencePeople(people) {
Expand Down

0 comments on commit bc9488b

Please sign in to comment.