Changeset 220 for trunk/grails-app/views/eventDescription
- Timestamp:
- Mar 1, 2010, 5:48:25 PM (13 years ago)
- Location:
- trunk/grails-app/views/eventDescription
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/views/eventDescription/edit.gsp
r120 r220 6 6 <meta name="layout" content="main" /> 7 7 <g:set var="entityName" value="${message(code: 'eventDescription.label', default: 'EventDescription')}" /> 8 <g:setProvider library="jquery"/> 8 9 <title><g:message code="default.edit.label" args="[entityName]" /></title> 9 10 </head> 11 10 12 <body> 11 13 <div class="nav"> … … 14 16 <span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></span> 15 17 </div> 18 19 20 16 21 <div class="body"> 17 22 <h1><g:message code="default.edit.label" args="[entityName]" /></h1> … … 24 29 </div> 25 30 </g:hasErrors> 31 32 33 26 34 <g:form method="post" > 27 35 <g:hiddenField name="id" value="${eventDescriptionInstance?.id}" /> … … 30 38 <table> 31 39 <tbody> 32 33 <tr class="prop"> 34 <td valign="top" class="name"> 35 <label for="protocol"><g:message code="eventDescription.protocol.label" default="Protocol" /></label> 36 </td> 37 <td valign="top" class="value ${hasErrors(bean: eventDescriptionInstance, field: 'protocol', 'errors')}"> 38 <g:select name="protocol.id" from="${dbnp.studycapturing.ProtocolInstance.list()}" optionKey="id" value="${eventDescriptionInstance?.protocol?.id}" /> 39 </td> 40 </tr> 41 42 <tr class="prop"> 43 <td valign="top" class="name"> 44 <label for="description"><g:message code="eventDescription.description.label" default="Description" /></label> 45 </td> 46 <td valign="top" class="value ${hasErrors(bean: eventDescriptionInstance, field: 'description', 'errors')}"> 47 <g:textField name="description" value="${eventDescriptionInstance?.description}" /> 48 </td> 49 </tr> 50 40 51 41 <tr class="prop"> 52 42 <td valign="top" class="name"> … … 55 45 <td valign="top" class="value ${hasErrors(bean: eventDescriptionInstance, field: 'name', 'errors')}"> 56 46 <g:textField name="name" value="${eventDescriptionInstance?.name}" /> 47 </td> 48 </tr> 49 50 <tr class="prop"> 51 <td valign="top" class="name"> 52 <label for="description"><g:message code="eventDescription.description.label" default="Description" /></label> 53 </td> 54 <td valign="top" class="value ${hasErrors(bean: eventDescriptionInstance, field: 'description', 'errors')}"> 55 <g:textArea name="description" value="${eventDescriptionInstance?.description}" rows="8" cols="80" /> 57 56 </td> 58 57 </tr> … … 66 65 </td> 67 66 </tr> 68 67 68 <tr class="prop"> 69 <td valign="top" class="name"> 70 </td> 71 <td valign="top" class="value ${hasErrors(bean: eventDescriptionInstance, field: 'protocol', 'errors')}"> 72 </td> 73 </tr> 74 75 76 <tr class="prop"> 77 <g:if test="!editExisting"> 78 <td valign="top" class="name"> <label> This is a sampling event</label> </td> 79 <td> <INPUT TYPE="checkbox" NAME="isSampleCheckBox" VALUE="checkboxValue"> </td> 80 </g:if> 81 <g:else> 82 <tr class="prop"> 83 <td valign="top" class="name"> <label> This is a sampling event</label> </td> 84 <td valign="top" class="value ${hasErrors(bean: eventDescriptionInstance, field: 'protocol', 'errors')}"> 85 <label for="protocol"><g:message code="${eventDescriptionInstance.isSamplingEvent?'yes':'no'}" /></label> 86 </g:else> 87 </tr> 88 89 90 91 <tbody id="protocolPartial"> 92 <g:include action="showMyProtocol" controller="eventDescription" id="${eventDescriptionInstance.id}" /> 93 </tbody> 94 95 96 97 69 98 </tbody> 70 99 </table> -
trunk/grails-app/views/eventDescription/showMyProtocolEmpty.gsp
r150 r220 1 <% def list = [] %> 2 <g:each in="${protocolInstance.parameters}" > <% list.add( it )%> </g:each> 3 <% list.sort{ a,b -> a.name <=> b.name }%> 4 5 <g:each in="${list}"> 6 7 <tr class="prop"> 8 <td valign="top" class="name" width=200 > 9 <label for="protocol"><g:message code="${it.name}" /></label> 10 </td> 11 <td valign="top" class="name"> 12 <g:textField name="protocolParameter.${it.id}" value="" /> 13 </td> 14 </tr> 15 16 </g:each> 1 Button: add new Protocol Parameter -
trunk/grails-app/views/eventDescription/showMyProtocolFilled.gsp
r150 r220 1 <% def list = [] %> 2 <g:each in="${protocolInstance.parameters}" > <% list.add( it )%> </g:each> 3 <% list.sort{ a,b -> a.name <=> b.name }%> 4 5 <g:each in ="${list}" > 1 <script type="text/javascript"> 2 3 function addRowEmpty(id){ 4 var tbody = document.getElementById(id); 5 var row = document.createElement("tr"); 6 7 var newRowId='' 8 if(tbody.getElementsByTagName('tr').length<=0) { newRowId='0'; } 9 else { 10 var elements=tbody.getElementsByTagName('tr'); 11 var predecessor=elements[elements.length-1]; 12 newRowId=predecessor.id; 13 } 14 15 row.setAttribute('id',newRowId+'1'); 16 17 addTextFieldToRow(row,'classification',20); addTextFieldToRow(row,'unit',6); 18 var textField=addSelector(row,null); addTextFieldToRow(row,'reference',10); addTextFieldToRow(row,'description',20); 19 addTextElementToRow(row,textField,'option',6); addRowButton(row); tbody.appendChild(row); 20 } 21 22 23 function addRow(id,newId,name,unit,type,reference,description) { 24 25 var tbody = document.getElementById(id); 26 var row = document.createElement("tr"); 27 row.id=newId; 28 29 var newRowId='' 30 if(tbody.getElementsByTagName('tr').length<=0) { newRowId='0'; } 31 else { 32 var elements=tbody.getElementsByTagName('tr'); 33 var predecessor=elements[elements.length-1]; 34 newRowId=predecessor.id; 35 } 36 37 row.setAttribute('id',newRowId+'1'); 38 39 addTextFieldToRow(row,'classification',20).value=name; 40 addTextFieldToRow(row,'unit',6).value=unit; 41 var textField=addSelector(row,type); 42 addTextFieldToRow(row,'reference',10).value=reference; 43 addTextFieldToRow(row,'description',20).value=description; 44 addTextElementToRow(row,textField,'option',6); 45 addRowButton(row); 46 tbody.appendChild(row); 47 } 48 49 50 51 52 53 54 55 var parametertypes= new Array(); 56 <% dbnp.studycapturing.ProtocolParameterType.list().each{ print "parametertypes.push(\'${it}\');" } %> 57 58 59 60 function addRowButton(parent) { 61 var removeButton=document.createElement("input"); 62 var body=parent.parentNode; 63 removeButton.setAttribute('type','button'); 64 removeButton.setAttribute('onclick',"removeRow('" + parent.id + "')"); 65 removeButton.setAttribute('value','remove'); 66 var td=document.createElement('td'); 67 td.appendChild(removeButton); 68 parent.appendChild(td); 69 } 70 71 72 function addTextElementToRow(row,field,id,size){ 73 var td=document.createElement('td'); 74 td.setAttribute('id',id + '_' + row.id); 75 td.appendChild(field); 76 row.appendChild(td); 77 return field; 78 } 79 80 81 function addTextFieldToRow(row,id,size){ 82 var input=document.createElement("input"); 83 input.setAttribute('type','text'); 84 input.setAttribute('id',id); 85 input.setAttribute('size',size); 86 var td=document.createElement('td'); 87 td.appendChild(input); 88 row.appendChild(td); 89 return input; 90 } 91 92 93 function removeRow(rowId){ 94 var row = document.getElementById(rowId); 95 var body = row.parentNode; 96 body.removeChild(row); 97 } 98 99 100 function addSelector(row,selectedText){ 101 102 var selector=document.createElement("select"); 103 selector.setAttribute('id',"parameter_type"+row.id); 104 var selectedIndex=0; 105 for(i=0;i<parametertypes.length;i++) { 106 var option = document.createElement("option"); 107 var text = document.createTextNode(parametertypes[i]); 108 option.appendChild(text); 109 selector.appendChild(option); 110 if(selectedText!=null&&selectedText==parametertypes[i]) { 111 selectedIndex=i; 112 alert(selectedText); 113 } 114 } 115 116 // set label for selected element 117 selector.selectedIndex=selectedIndex; 118 var option=selector.options[selector.selectedIndex]; 119 var textNode = document.createTextNode(""); 120 option=selector.options[selector.selectedIndex]; 121 textNode.nodeValue=(option.value=='STRINGLIST') ? 'link stuff' : 'n.a.'; 122 123 124 // show edit link for STRINGLIST 125 selector.onchange=function(){ 126 option=this.options[this.selectedIndex]; 127 textNode.nodeValue=(option.value=='STRINGLIST') ? 'link stuff' : 'n.a.'; 128 } 129 130 // td for the selector 131 var td=document.createElement('td'); 132 td.appendChild(selector); 133 row.appendChild(td); 134 135 return textNode; 136 } 137 138 139 140 141 // testing, remove later 142 function doStuff(caller) { var row = caller.parentNode.parentNode; $("#"+row.id).hide(); } 143 144 145 </script> 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 <tr class="prop"> 182 <td id='test'> nope </td> 183 <td> <g:select name="selectedProtocol" from="${dbnp.studycapturing.Protocol.list()}" value="${protocol.id}" onchange= 184 "${remoteFunction( action:'showProtocolParameters', update:'showProtocolParameters', params:'\'something=\'+this.value', id:'this.id')} " /> 185 </td> 186 </tr> 187 188 189 <tr><td></td> 190 191 <td> 192 193 <table id="someId" > 194 195 196 <thead> 6 197 <tr class="prop"> 7 198 8 <td valign="top" class="name" width=200> 9 <label for="protocolInstance"><g:message code="${it.name}" /></label> 10 </td> 11 12 <td valign="top" class="name"> 13 <g:textField name="protocolParameter.${it.id}" value="${parameterStringValues[it.name]}" /> 14 </td> 199 <th valign="top" class="name" width=200> 200 <label for="protocolInstance">Name</label> 201 </th> 202 203 <th valign="top" class="name" width=200> 204 <label for="protocolInstance">Unit</label> 205 </th> 206 207 <th valign="top" class="name" width=200> 208 <label for="protocolInstance">Type</label> 209 </th> 210 211 <th valign="top" class="name" width=200> 212 <label for="protocolInstance">Reference</label> 213 </th> 214 215 <th valign="top" class="name" width=200> 216 <label for="protocolInstance">Description</label> 217 </th> 218 219 <th valign="top" class="name" width=200> 220 <label for="protocolInstance">Options</label> 221 </th> 222 223 <th valign="top" class="name" width=200> 224 <label for="protocolInstance">Delete </label> 225 </th> 226 15 227 </tr> 16 </g:each> 228 </thead> 229 230 231 232 <tbody id="showProtocolParameters"> 233 <g:include action="showProtocolParameters" controller="eventDescription" id="${description.id}" /> 234 </tbody> 235 236 237 <tbody> <tr> 238 <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td> <input type="button" value="Add Parameter" onclick="addRowEmpty('showProtocolParameters')"> </td> 239 </tr> </tbody> 240 241 </table> 242 243 244 </td> </tr>
Note: See TracChangeset
for help on using the changeset viewer.