Skip to content

Commit

Permalink
FT-1553 Added details about subject, event and group to sample overvi…
Browse files Browse the repository at this point in the history
…ew screen
  • Loading branch information
roberthorlings committed Jul 28, 2015
1 parent 1d04cb3 commit 06b609b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
30 changes: 30 additions & 0 deletions grails-app/controllers/dbnp/studycapturing/StudyController.groovy
Expand Up @@ -117,6 +117,36 @@ class StudyController {
render datatableData as JSON
}


/**
* Returns data for a templated datatable with samples.
*
* Due to the formatting of the data, this is a separate method
* @return
*/
def dataTableSamples() {
// As we add columns to the table, we should shift the sort column
def sortColumn = params.int( "iSortCol_0" )

if( sortColumn > 3 )
params.iSortCol_0 = sortColumn - 3

def datatableData = getTemplatedDatatablesData({ sample ->
def defaultData = datatablesService.defaultEntityFormatter(sample)

// Remove the IDs, as they are irrelevant for now
defaultData = defaultData.tail()

// Add additional columns
defaultData.add(1, sample.parentSubject?.name )
defaultData.add(2, sample.parentEvent?.event?.name )
defaultData.add(3, sample.parentEvent?.eventGroup?.name )

defaultData
})
render datatableData as JSON
}

/**
* Returns data for a templated datatable. The type of entities is based on the template given.
* @return
Expand Down
10 changes: 8 additions & 2 deletions grails-app/views/study/samples.gsp
Expand Up @@ -24,11 +24,17 @@

<g:each in="${templates}" var="template">
<h3>Template: ${template.name}</h3>
<table id="samplesTable_${template.id}" data-templateId="${template.id}" data-fieldPrefix="sample" data-formId="sampleForm" class="samplesTable" rel="${g.createLink(action:"dataTableEntities", id: study.id, params: [template: template.id])}">
<table id="samplesTable_${template.id}" data-templateId="${template.id}" data-fieldPrefix="sample" data-formId="sampleForm" class="samplesTable" rel="${g.createLink(action:"dataTableSamples", id: study.id, params: [template: template.id])}">
<thead>
<tr>
<th data-fieldname="name">Name</th>
<th data-fieldname="subject" class="nonsortable">Subject</th>
<th data-fieldname="event" class="nonsortable">Event</th>
<th data-fieldname="group" class="nonsortable">Group</th>
<g:each in="${domainFields + template.getFields()}" var="field">
<th data-fieldname="${field.escapedName()}">${field.name}</th>
<g:unless test="${field.name == 'name'}">
<th data-fieldname="${field.escapedName()}">${field.name}</th>
</g:unless>
</g:each>
</tr>
</thead>
Expand Down

0 comments on commit 06b609b

Please sign in to comment.