Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions app/Controllers/Http/SessionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ class SessionController {
const result = await Session.query()
.where('study_id', studyID)
.where('participant_id', participantID)
.firstOrFail()
.first()
if (!result) {
return response.status(404).json({ message: 'Cannot find database row for Session model' })
}
return response.json({ data: result })
}

Expand Down Expand Up @@ -110,16 +113,23 @@ class SessionController {
* @param {Response} ctx.response
*/
async update ({ request, response }) {
const validation = await validate(request.all(), {
study_id: 'integer',
participant_id: 'string',
const rules = {
data: 'required|json'
})
if (validation.fails()) {
return response.status(422).json(validation.messages())
}
const studyID = request.input('study_id', null)
const participantID = request.input('participant_id', null)

if (studyID !== null) {
rules.study_id = 'integer'
}
if (participantID !== null) {
rules.participant_id = 'string'
}

const validation = await validate(request.all(), rules)
if (validation.fails()) {
return response.status(422).json(validation.messages())
}
const data = request.input('data', {})
const record = await Session.query()
.where('study_id', studyID)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict'

/** @type {import('@adonisjs/lucid/src/Schema')} */
const Schema = use('Schema')

class MakeSessionColumnsNullable extends Schema {
up () {
this.alter('sessions', (table) => {
table.integer('study_id').unsigned().nullable().alter()
table.string('participant_id').nullable().alter()
})
}

down () {
// Keep nullable since the application requires it
this.alter('sessions', (table) => {
table.integer('study_id').unsigned().nullable().alter()
table.string('participant_id').nullable().alter()
})
}
}

module.exports = MakeSessionColumnsNullable
1 change: 1 addition & 0 deletions resources/assets/js/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const STUDIES = `${API_PREFIX}/studies`
export const PARTICIPANTS = `${API_PREFIX}/participants`
export const PARTICIPATIONS = `${API_PREFIX}/participations`
export const JOBS = `${API_PREFIX}/jobs`
export const SESSIONS = `${API_PREFIX}/sessions`

// Misc routes
export const RECOVER_PASSWORD = `${AUTH_PREFIX}/password/recover`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
</template>
</v-card-text>
<v-card-actions v-if="$auth.user.user_type_id === 1">
<v-btn @click="$emit('edit-participant-data')">
<v-icon left>
mdi-database
</v-icon>
Edit Participant Data
</v-btn>
<v-spacer />
<v-tooltip v-if="participant.studies_count > 0" bottom>
<template #activator="{ on, attrs }">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
style="width: 100%"
@clicked-edit="(id) => editing = id"
@clicked-delete="$emit('delete-participant', $event)"
@edit-participant-data="$emit('edit-participant-data', ptcp.identifier)"
/>
</v-fade-transition>
</v-card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
@changed-priority="fetchQueue"
@scroll-end="loadMore"
@reset-jobs="openResetJobsDialog"
@edit-session-data="$emit('edit-session-data', $event)"
/>
</v-card-text>
</v-card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@
:position="queue[item.id]"
/>
</v-list-item-content>
<v-list-item-action v-if="editable" style="max-width: 40px">
<v-tooltip left>
<template #activator="{ on, attrs }">
<v-btn
icon
small
v-bind="attrs"
v-on="on"
@click.stop="$emit('edit-session-data', item.identifier)"
>
<v-icon small>
mdi-database
</v-icon>
</v-btn>
</template>
Edit session data
</v-tooltip>
</v-list-item-action>
<v-list-item-action v-if="editable" style="max-width: 40px">
<v-tooltip left>
<template #activator="{ on, attrs }">
Expand Down
6 changes: 6 additions & 0 deletions resources/components/Studies/page/StudyInfo/StudyInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
</div>
<div v-else key="view">
<div class="d-flex justify-end">
<v-btn v-if="userCanEdit" @click="$emit('edit-study-data')">
<v-icon left>
mdi-database
</v-icon>
Edit Study Data
</v-btn>
<v-btn v-if="userCanEdit" color="primary" @click="editMode=true">
<v-icon left>
mdi-pencil
Expand Down
Loading