Changeset 526 for trunk


Ignore:
Timestamp:
Jun 4, 2010, 11:42:05 AM (13 years ago)
Author:
duh
Message:
  • beta version of loading and editing a study using the wizard
Location:
trunk/grails-app
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy

    r520 r526  
    8282                                success()
    8383                        }
    84                         on("next").to "study"
     84                        on("next") {
     85                                // clean the flow scope
     86                                flow.remove('study')
     87                                flow.remove('subjects')
     88                                flow.remove('subjectTemplates')
     89                                flow.remove('event')
     90                                flow.remove('events')
     91                                flow.remove('eventGroups')
     92                                flow.remove('eventTemplates')
     93                        }.to "study"
    8594                        on("modify").to "modify"
    8695                }
     
    100109                        }.to "start"
    101110                        on("next") {
    102                                 // TODO: loading a study is not yet implemented
    103                                 //       create a error stating this feature is
    104                                 //       not yet implemented
    105                                 flash.errors = [:]
    106                                 this.appendErrorMap(
    107                                         ['study': 'Loading a study and modifying it has not yet been implemented. Please press \'cancel\' to go back to the initial page...'],
    108                                         flash.errors
    109                                 )
    110 
    111                                 error()
    112                         }.to "modify"
     111                                // load study
     112                                try {
     113                                        flow.study = Study.findByTitle(params.study)
     114
     115                                        // recreate subjects
     116                                        flow.subjects = [:]
     117                                        flow.subjectTemplates = [:]
     118                                        flow.study.subjects.each() { subject ->
     119                                                def subjectIncrement = flow.subjects.size()
     120                                                flow.subjects[ subjectIncrement ] = subject
     121
     122                                                // add subject template?
     123                                                if (!flow.subjectTemplates[ subject.template.name ]) {
     124                                                        flow.subjectTemplates[ subject.template.name ] = [
     125                                                                name: subject.template.name,
     126                                                                template: subject.template,
     127                                                                subjects: [:]
     128                                                        ]
     129                                                }
     130
     131                                                // reference subject in template
     132                                                flow.subjectTemplates[ subject.template.name ].subjects[ flow.subjectTemplates[ subject.template.name ].subjects.size() ] = subjectIncrement
     133                                        }
     134
     135                                        // recreate events
     136                                        flow.events = []
     137                                        flow.eventGroups = []
     138                                        flow.eventTemplates     = [:]
     139                                        flow.study.events.each() { event ->
     140                                                def eventIncrement = flow.events.size()
     141                                                flow.events[ eventIncrement ] = event
     142
     143                                                // add event template?
     144                                                if (!flow.eventTemplates[ event.template.name ]) {
     145                                                        flow.eventTemplates[ event.template.name ] = [
     146                                                                name: event.template.name,
     147                                                                template: event.template,
     148                                                                events: new ArrayList()
     149                                                        ]
     150                                                }
     151
     152                                                // reference event in template
     153                                                flow.eventTemplates[ event.template.name ].events[ flow.eventTemplates[ event.template.name ].events.size() ] = eventIncrement
     154
     155                                                // set dummy event
     156                                                flow.event = event
     157                                        }
     158
     159                                        // recreate sample events
     160                                        flow.study.samplingEvents.each() { event ->
     161                                                def eventIncrement = flow.events.size()
     162                                                flow.events[ eventIncrement ] = event
     163
     164                                                // add event template?
     165                                                if (!flow.eventTemplates[ event.template.name ]) {
     166                                                        flow.eventTemplates[ event.template.name ] = [
     167                                                                name: event.template.name,
     168                                                                template: event.template,
     169                                                                events: new ArrayList()
     170                                                        ]
     171                                                }
     172
     173                                                // reference event in template
     174                                                flow.eventTemplates[ event.template.name ].events[ flow.eventTemplates[ event.template.name ].events.size() ] = eventIncrement
     175
     176                                                // set dummy event
     177                                                flow.event = event
     178                                        }
     179
     180                                        // recreate eventGroups
     181                                        flow.study.eventGroups.each() { eventGroup ->
     182                                                flow.eventGroups[ flow.eventGroups.size() ] = eventGroup
     183                                        }
     184
     185                                        success()
     186                                } catch (Exception e) {
     187                                        error()
     188                                }
     189                        }.to "study"
    113190                }
    114191
     
    176253                                        flow.subjectTemplates = [:]
    177254                                }
     255
    178256                                success()
    179257                        }
     
    670748         */
    671749        def handleSubjects(flow, flash, params) {
    672                 def names = [:];
    673                 def errors = false;
    674                 def id = 0;
    675 
     750                def names = [:]
     751                def errors = false
     752                def id = 0
     753
     754println flow.subjects
    676755                // iterate through subject templates
    677756                flow.subjectTemplates.each() { subjectTemplate ->
    678757                        // iterate through subjects
    679                         subjectTemplate.getValue().subjects.each() { subjectIncrement, subjectId ->
     758                        subjectTemplate.value.subjects.each() { subjectIncrement, subjectId ->
    680759                                // iterate through fields (= template fields and domain properties)
    681760                                flow.subjects[ subjectId ].giveFields().each() { subjectField ->
  • trunk/grails-app/views/common/_topnav.gsp

    r482 r526  
    99      <ul class="subnav">
    1010        <li><g:link controller="study" action="list">View studies</g:link></li>
    11         <li><g:link controller="wizard" action="index">Create study</g:link></li>
     11                  <li><g:link controller="wizard" action="index">Create study</g:link></li>
     12                  <li><g:link controller="wizard" action="index">Edit study</g:link></li>
    1213      </ul>
    1314     </li>
  • trunk/grails-app/views/wizard/pages/_events.gsp

    r510 r526  
    6767        <g:each var="eventTemplate" in="${eventTemplates}">
    6868                <g:set var="showHeader" value="${true}" />
    69                 <h1>${eventTemplate.getValue().name}</h1>
     69                <h1>${eventTemplate.value.name}</h1>
    7070        <div class="table">
    71                 <g:each var="eventId" in="${eventTemplate.getValue().events}">
     71                <g:each var="eventId" in="${eventTemplate.value.events}">
    7272                        <g:if test="${showHeader}">
    7373                        <g:set var="showHeader" value="${false}" />
  • trunk/grails-app/views/wizard/pages/_modify.gsp

    r359 r526  
    1717<wizard:pageContent>
    1818
     19        <span class="info">
     20                <span class="title">Edit a study</span>
     21                Select the study you would like to modify.
     22                <b><i>Note: this functionality is currently in beta and has not been verified properly... use with care!</i></b>
     23        </span>
     24
    1925        <wizard:studyElement name="study" description="Study" error="study" value="">
    20                 The study you would like to load and modify
     26                The study you would like to load and edit
    2127        </wizard:studyElement>
    2228
    23         <span class="info">
    24                 <span class="todo">TODO</span>
    25                 <ul>
    26                         <li>this feature has not yet been implemented</li>
    27                 </ul>
    28         </span>
    29 
    30         <!-- g:render template="pages/demo" //-->
    31 
    3229</wizard:pageContent>
  • trunk/grails-app/views/wizard/pages/_start.gsp

    r455 r526  
    2121        <wizard:ajaxButton name="next" class="bigbutton" value="Create a new study" alt="Create a new study" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" afterSuccess="onWizardPage()" />
    2222
    23         <wizard:ajaxButton name="modify" class="bigbutton" value="Modify an existing study" alt="Modify an existing study" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" afterSuccess="onWizardPage()" />
     23        <wizard:ajaxButton name="modify" class="bigbutton" value="Edit an existing study" alt="Edit an existing study" url="[controller:'wizard',action:'pages']" update="[success:'wizardPage',failure:'wizardError']" afterSuccess="onWizardPage()" />
    2424
    2525        <span class="info">
     
    3636                You can do this by choosing Studies > Import data in the menu.
    3737                This part of the applications will help you to upload large studies. This import function can be used for all study components (study, subject and event information) at once.
    38             <span class="title">Modify an existing study</span>
     38            <span class="title">Edit an existing study</span>
    3939                Only study owners can modify a their own studies. This part of the application can be used to extend the study information, for instance with new measurements.
    4040        </span>
  • trunk/grails-app/views/wizard/pages/_study.gsp

    r518 r526  
    2020                In this step of the step-by-step study capturing tool all the basic information of a study can be filled out.
    2121                Keep in mind that the more and the more specific the information that is filled out, the more valuable the system will be.
    22                 Only the fields with an asterisks are obligatory.
    23                 Pick the study template of choice (currently a fixed set) and define your study values. In this prototype the
    24                 templated fields (below the 'note' box) are not yet handled so you can leave them empty for now.
     22                Only the fields with an asterisks are obligatory. Pick the study template of choice (currently a fixed set) and define your study values.
    2523        </span>
    2624       
  • trunk/grails-app/views/wizard/pages/_subjects.gsp

    r469 r526  
    7171</g:if>
    7272
    73         <g:if env="development">
    74         <span class="info">
    75                 <span class="known">Known issues</span>
    76                 <ul>
    77                         <li>autocomplete fields (like ontologies) deselect the selected rows and hence don't replicate</li>
    78                         <li>ontology fields should replicate value <i>and</i> hidden fields</li>
    79                         <li>ontology hidden fields should be processed by the back-end as well (not yet implemented)</li>
    80                         <li>ontology fields now show suggestions for <i>all</i> available ontologies. This has to be narrowed down in the future.</li>
    81                         <li>ontology hidden fields should be handled by the taglibrary / controller as well</li>
    82                 </ul>
    83         </span>
    84         </g:if>
    85 
    8673</wizard:pageContent>
Note: See TracChangeset for help on using the changeset viewer.