Changeset 241
- Timestamp:
- Mar 8, 2010, 12:19:54 AM (13 years ago)
- Location:
- trunk/grails-app/views/eventDescription
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/views/eventDescription/edit.gsp
r220 r241 11 11 12 12 <body> 13 14 13 15 <div class="nav"> 14 16 <span class="menuButton"><a class="home" href="${createLink(uri: '/')}">Home</a></span> … … 31 33 32 34 33 34 <g:form method="post">35 <% println eventDescriptionInstance.toString() %> 36 <g:form action="save" method="post" id="${eventDescriptionInstance.id}" onsubmit="addHiddenDialogsToForm();"> 35 37 <g:hiddenField name="id" value="${eventDescriptionInstance?.id}" /> 36 38 <g:hiddenField name="version" value="${eventDescriptionInstance?.version}" /> … … 89 91 90 92 91 <tbody id="protocolPartial">92 <g:include action="showMyProtocol" controller="eventDescription" id="${eventDescriptionInstance.id}" />93 </tbody>94 95 96 97 93 98 94 </tbody> 99 95 </table> 100 96 </div> 97 <g:include action="showMyProtocol" controller="eventDescription" id="${eventDescriptionInstance.id}" /> 101 98 <div class="buttons"> 102 <span class="button"><g: actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" /></span>103 <span class="button"><g: actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>99 <span class="button"><g:submitButton name="save" class="save" value="${message(code: 'default.save.label', default: 'Save')}" /></span> 100 <span class="button"><g:submitToRemote class="delete" action="list" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span> 104 101 </div> 105 102 </g:form> -
trunk/grails-app/views/eventDescription/showMyProtocolFilled.gsp
r233 r241 1 1 <script type="text/javascript"> 2 2 3 /* The following JS functions provide the dynamics of this view. 4 * Mainly, rows of parameters can be added or removed by the user. 5 * Additionally, each parameter can contain a STRINGLIST. In this case 6 * the a link is activated. On following this link the user can activate 7 * a dialog that displays all options of the STRINGLIST and edit them. */ 3 8 var parametertypes= new Array(); 9 var newRows=0; 4 10 <% dbnp.studycapturing.ProtocolParameterType.list().each{ print "parametertypes.push(\'${it}\');" } %> 5 11 12 /* create a prefix for all members of a protocol */ 13 function setName(element,protocolId) { 14 element.name='protocolId_'+protocolId+'_'+element.id; 15 } 6 16 7 17 function addRowEmpty(id){ 8 18 var tbody = document.getElementById(id); 9 19 var row = document.createElement("tr"); 10 11 var newRowId='' 12 if(tbody.getElementsByTagName('tr').length<=0) { newRowId='0'; } 13 else { 14 var elements=tbody.getElementsByTagName('tr'); 15 var predecessor=elements[elements.length-1]; 16 newRowId=predecessor.id; 17 } 18 19 row.setAttribute('id',newRowId+'1'); 20 row.setAttribute('id','new' + (newRows++) ); 20 21 21 22 addTextFieldToRow(row,'classification',20); addTextFieldToRow(row,'unit',6); 22 var textField=addSelector(row,null ); addTextFieldToRow(row,'reference',10); addTextFieldToRow(row,'description',20);23 var textField=addSelector(row,null,[]); addTextFieldToRow(row,'reference',10); addTextFieldToRow(row,'description',20); 23 24 addElementToRow(row,textField,'option',6); addRowButton(row); tbody.appendChild(row); 24 25 } 25 26 26 27 27 function addRow(id,newId,name,unit,type,reference,description ) {28 function addRow(id,newId,name,unit,type,reference,description,options) { 28 29 29 30 var tbody = document.getElementById(id); 30 31 var row = document.createElement("tr"); 31 row.id=newId; 32 33 var newRowId='' 34 if(tbody.getElementsByTagName('tr').length<=0) { newRowId='0'; } 35 else { 36 var elements=tbody.getElementsByTagName('tr'); 37 var predecessor=elements[elements.length-1]; 38 newRowId=predecessor.id; 39 } 40 41 row.setAttribute('id',newRowId+'1'); 32 row.setAttribute('id',newId); 42 33 43 34 addTextFieldToRow(row,'classification',20).value=name; 44 35 addTextFieldToRow(row,'unit',6).value=unit; 45 var textField=addSelector(row,type );36 var textField=addSelector(row,type,options); 46 37 addTextFieldToRow(row,'reference',10).value=reference; 47 38 addTextFieldToRow(row,'description',20).value=description; … … 56 47 var body=parent.parentNode; 57 48 removeButton.setAttribute('type','button'); 58 removeButton.setAttribute('onclick',"removeRow('" + parent.id + "') ");49 removeButton.setAttribute('onclick',"removeRow('" + parent.id + "');"); 59 50 removeButton.setAttribute('value','remove'); 60 51 var td=document.createElement('td'); … … 77 68 input.setAttribute('type','text'); 78 69 input.setAttribute('id',id); 70 input.setAttribute('name', 'row_' + row.id + '__' + id); 79 71 input.setAttribute('size',size); 80 72 var td=document.createElement('td'); … … 89 81 var body = row.parentNode; 90 82 body.removeChild(row); 83 jQuery(document.getElementById('dialog'+rowId)).remove(); 91 84 } 92 85 … … 107 100 108 101 109 function addRowToDialog(dialogTableBodyId) { 110 var tbody = document.getElementById(dialogTableBodyId); 102 function addRowToDialog(tbody,rowId) { 111 103 var input=document.createElement('input'); 104 var id = tbody.rows.length + 1; 105 input.setAttribute('name','parameterStringValue__new'+id+'__protocol__'+rowId); 112 106 tbody.insertRow(-1).insertCell(-1).appendChild(input); 113 } 114 107 } 115 108 116 109 … … 120 113 function addDialogForSelector(rowId,options) { 121 114 var dialog = document.createElement('div'); 122 dialog.setAttribute('id','dialog_'+rowId); 123 //var dialogText = document.createTextNode(dialog.id); 124 //dialog.appendChild(dialogText); 125 115 dialog.id='dialog'+rowId; 116 dialog.setAttribute('name','hiddenDialog'); 126 117 127 118 var table=document.createElement('table'); … … 135 126 tr.appendChild(tx); 136 127 137 for(i=0;i<options.length;i+ +){128 for(i=0;i<options.length;i+=2){ 138 129 var input=document.createElement('input'); 139 input.value=options[i]; 130 input.value=unescape(options[i]); 131 input.name='parameterStringValue__'+options[i+1]+'__protocol__'+rowId; 140 132 tbody.insertRow(-1).insertCell(-1).appendChild(input); 141 133 } … … 145 137 button.value='Add Option'; 146 138 dialog.appendChild(button); 147 button.onclick=function(){ addRowToDialog('options_'+dialog.id); } 148 139 button.onclick=function(){ addRowToDialog(tbody,rowId); } 149 140 150 141 return dialog; … … 152 143 153 144 154 function addSelector(row,selectedText ){145 function addSelector(row,selectedText,options){ 155 146 156 147 // add dialog for displaying paramter options 157 148 // preserve row's id 158 var options= [1,2,3,4,5,6,7,8,9];159 149 var dialog = addDialogForSelector(row.id,options); 160 150 161 151 162 152 var selector=document.createElement("select"); 163 selector.setAttribute('id',"parameter_type"+row.id); 153 selector.setAttribute('id',"type"+row.id); 154 setName(selector,row.id); 164 155 var selectedIndex=0; 165 156 for(i=0;i<parametertypes.length;i++) { … … 175 166 var td=document.createElement('td'); 176 167 td.appendChild(selector); 168 td.appendChild(dialog); // dialog 177 169 row.appendChild(td); 178 td.appendChild(dialog); // dialog179 jQuery(dialog).dialog({autoOpen:false}); 170 jQuery(dialog).dialog({ autoOpen:false, }); 171 180 172 181 173 var showDialogString = "jQuery('#"+ dialog.id + "').dialog('open');" … … 187 179 188 180 var anchor= document.createElement('a'); 189 anchor. setAttribute('name', 'myanchor');181 anchor.name='myanchor'; 190 182 var textNode=document.createTextNode(''); 191 183 option=selector.options[selector.selectedIndex]; … … 206 198 207 199 208 209 210 // testing, remove later 211 function doStuff(caller) { var row = caller.parentNode.parentNode; $("#"+row.id).hide(); } 212 200 function getElementsByClass (className) { 201 var all = document.all ? document.all : 202 document.getElementsByTagName('*'); 203 var elements = new Array(); 204 for (var e = 0; e < all.length; e++) 205 if (all[e].className == className) 206 elements[elements.length] = all[e]; 207 return elements; 208 } 209 210 211 212 function addHiddenDialogsToForm() { 213 var form=document.getElementById('showProtocolParameters'); 214 var dialogs=document.getElementsByName('hiddenDialog'); 215 for(i=0;i<dialogs.length;i++) { 216 form.appendChild(dialogs[i]); 217 } 218 } 219 220 function deleteHiddenDialogs() { 221 var dialogs=document.getElementsByName('hiddenDialog'); 222 for(i=0;i<dialogs.length;i++) { 223 jQuery(dialogs[i]).remove(); 224 } 225 } 213 226 214 227 </script> … … 228 241 229 242 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 243 <tr class="prop"> 251 <td id='test'> nope</td>252 <td> <g:select name="selectedProtocol" from="${dbnp.studycapturing.Protocol.list()}" value="${protocol .id}" optionKey="id" optionValue="name"253 onchange= "${remoteFunction( action:'showProtocolParameters', update:'showProtocolParameters', params:'\'id=\'+this.value' )} 244 <td id='test'> Protocol </td> 245 <td> <g:select name="selectedProtocol" from="${dbnp.studycapturing.Protocol.list()}" value="${protocol}" optionKey="id" optionValue="name" 246 onchange= "${remoteFunction( action:'showProtocolParameters', update:'showProtocolParameters', params:'\'id=\'+this.value' )}; deleteHiddenDialogs();" /> 254 247 </td> 255 248 </tr> … … 299 292 300 293 <tbody id="showProtocolParameters"> 301 <g:include action="showProtocolParameters" controller="eventDescription" id="${description.id} " />294 <g:include action="showProtocolParameters" controller="eventDescription" id="${description.id} params="[protocol:protocol]" /> 302 295 </tbody> 303 296 304 297 305 298 <tbody> <tr> 306 <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td> <input type="button" value="Add Parameter" onclick="addRowEmpty('showProtocolParameters')" > </td>299 <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td> <input type="button" value="Add Parameter" onclick="addRowEmpty('showProtocolParameters')"/> </td> 307 300 </tr> </tbody> 308 301 -
trunk/grails-app/views/eventDescription/showProtocolParameters.gsp
r233 r241 6 6 <% tableRowId=0 %> 7 7 <g:each in ="${list}" > 8 <script type="text/javascript"> 9 addRow('showProtocolParameters',"${list.id}","${it.name}","${it.unit}","${it.type}","${it.reference}","${it.description}"); 10 </script> 8 9 <g:if test="it.type==dbnp.studycapturing.ProtocolParameterType.STRINGLIST" > 10 <% def listEntries=it.listEntries.collect { it } %> 11 12 <script type="text/javascript"> 13 var tmpList = []; 14 <% listEntries.each{ print "tmpList.push( escape('${it}') ); tmpList.push( '${it.id}' );" } %> 15 addRow('showProtocolParameters',"${list.id[0]}","${it.name}","${it.unit}","${it.type}","${it.reference}","${it.description}", tmpList ); 16 delete tmpList; 17 </script> 18 </g:if> 19 <g:else> 20 <script type="text/javascript"> 21 addRow('showProtocolParameters',"${list.id[0]}","${it.name}","${it.unit}","${it.type}","${it.reference}","${it.description}", new Array() ); 22 </script> 23 </g:else> 11 24 </g:each>
Note: See TracChangeset
for help on using the changeset viewer.