Changeset 233 for trunk/grails-app/views/eventDescription
- Timestamp:
- Mar 5, 2010, 9:08:23 AM (13 years ago)
- Location:
- trunk/grails-app/views/eventDescription
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/views/eventDescription/showMyProtocolFilled.gsp
r220 r233 1 1 <script type="text/javascript"> 2 3 var parametertypes= new Array(); 4 <% dbnp.studycapturing.ProtocolParameterType.list().each{ print "parametertypes.push(\'${it}\');" } %> 5 2 6 3 7 function addRowEmpty(id){ … … 17 21 addTextFieldToRow(row,'classification',20); addTextFieldToRow(row,'unit',6); 18 22 var textField=addSelector(row,null); addTextFieldToRow(row,'reference',10); addTextFieldToRow(row,'description',20); 19 add TextElementToRow(row,textField,'option',6); addRowButton(row); tbody.appendChild(row);23 addElementToRow(row,textField,'option',6); addRowButton(row); tbody.appendChild(row); 20 24 } 21 25 … … 42 46 addTextFieldToRow(row,'reference',10).value=reference; 43 47 addTextFieldToRow(row,'description',20).value=description; 44 add TextElementToRow(row,textField,'option',6);48 addElementToRow(row,textField,'option',6); 45 49 addRowButton(row); 46 50 tbody.appendChild(row); 47 51 } 48 49 50 51 52 53 54 55 var parametertypes= new Array();56 <% dbnp.studycapturing.ProtocolParameterType.list().each{ print "parametertypes.push(\'${it}\');" } %>57 58 52 59 53 … … 70 64 71 65 72 function add TextElementToRow(row,field,id,size){66 function addElementToRow(row,field,id,size){ 73 67 var td=document.createElement('td'); 74 68 td.setAttribute('id',id + '_' + row.id); … … 98 92 99 93 100 function addSelector(row,selectedText){ 94 // for the STRINGLIST type, display a link to show 95 // all optional values of the parameter. 96 function showLinkForSTRINGLIST(anchor,textNode,option,showDialogString,dialog) { 97 if(option.value=='STRINGLIST') { 98 textNode.nodeValue='edit'; 99 anchor.setAttribute('onclick',showDialogString); 100 } 101 else { 102 textNode.nodeValue='n.a.'; 103 anchor.setAttribute('onclick',''); 104 } 105 } 106 107 108 109 function addRowToDialog(dialogTableBodyId) { 110 var tbody = document.getElementById(dialogTableBodyId); 111 var input=document.createElement('input'); 112 tbody.insertRow(-1).insertCell(-1).appendChild(input); 113 } 114 115 116 117 // create the dialog for this STRINGLIST. 118 // the dialog holds all possible values this parameter can take. 119 // moreover, it is extendable. 120 function addDialogForSelector(rowId,options) { 121 var dialog = document.createElement('div'); 122 dialog.setAttribute('id','dialog_'+rowId); 123 //var dialogText = document.createTextNode(dialog.id); 124 //dialog.appendChild(dialogText); 125 126 127 var table=document.createElement('table'); 128 var tbody=document.createElement('tbody'); tbody.id='options_'+dialog.id; 129 var tr=document.createElement('tr'); 130 var th=document.createElement('th'); 131 var tx=document.createTextNode('Parameter Values'); 132 dialog.appendChild(table); 133 table.appendChild(tbody); 134 tbody.appendChild(tr); 135 tr.appendChild(tx); 136 137 for(i=0;i<options.length;i++){ 138 var input=document.createElement('input'); 139 input.value=options[i]; 140 tbody.insertRow(-1).insertCell(-1).appendChild(input); 141 } 142 143 var button=document.createElement('input'); 144 button.setAttribute('type','Button'); 145 button.value='Add Option'; 146 dialog.appendChild(button); 147 button.onclick=function(){ addRowToDialog('options_'+dialog.id); } 148 149 150 return dialog; 151 } 152 153 154 function addSelector(row,selectedText){ 155 156 // add dialog for displaying paramter options 157 // preserve row's id 158 var options= [1,2,3,4,5,6,7,8,9]; 159 var dialog = addDialogForSelector(row.id,options); 160 101 161 102 162 var selector=document.createElement("select"); … … 108 168 option.appendChild(text); 109 169 selector.appendChild(option); 110 if(selectedText!=null&&selectedText==parametertypes[i]) { 111 selectedIndex=i; 112 alert(selectedText); 113 } 170 if(selectedText!=null&&selectedText==parametertypes[i]) { selectedIndex=i; } 114 171 } 115 172 116 // set label for selected element117 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 STRINGLIST125 selector.onchange=function(){126 option=this.options[this.selectedIndex];127 textNode.nodeValue=(option.value=='STRINGLIST') ? 'link stuff' : 'n.a.';128 }129 173 130 174 // td for the selector … … 132 176 td.appendChild(selector); 133 177 row.appendChild(td); 134 135 return textNode; 178 td.appendChild(dialog); // dialog 179 jQuery(dialog).dialog({autoOpen:false}); 180 181 var showDialogString = "jQuery('#"+ dialog.id + "').dialog('open');" 182 183 184 // set label for selected element 185 selector.selectedIndex=selectedIndex; 186 var option=selector.options[selector.selectedIndex]; 187 188 var anchor= document.createElement('a'); 189 anchor.setAttribute('name', 'myanchor'); 190 var textNode=document.createTextNode(''); 191 option=selector.options[selector.selectedIndex]; 192 textNode.nodeValue=(option.value=='STRINGLIST') ? 'edit' : 'n.a.'; 193 showLinkForSTRINGLIST(anchor,textNode,option,showDialogString,dialog); 194 anchor.appendChild(textNode); 195 196 197 // show edit link for STRINGLIST 198 selector.onchange=function(){ 199 option=this.options[this.selectedIndex]; 200 showLinkForSTRINGLIST(anchor,textNode,option,showDialogString,dialog); 201 } 202 203 204 return anchor; 136 205 } 137 206 … … 181 250 <tr class="prop"> 182 251 <td id='test'> nope </td> 183 <td> <g:select name="selectedProtocol" from="${dbnp.studycapturing.Protocol.list()}" value="${protocol.id}" o nchange=184 "${remoteFunction( action:'showProtocolParameters', update:'showProtocolParameters', params:'\'something=\'+this.value', id:'this.id')} " />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' )} " /> 185 254 </td> 186 255 </tr> … … 188 257 189 258 <tr><td></td> 190 191 259 <td> 192 260 -
trunk/grails-app/views/eventDescription/showProtocolParameters.gsp
r221 r233 6 6 <% tableRowId=0 %> 7 7 <g:each in ="${list}" > 8 9 8 <script type="text/javascript"> 10 9 addRow('showProtocolParameters',"${list.id}","${it.name}","${it.unit}","${it.type}","${it.reference}","${it.description}"); 11 10 </script> 12 13 11 </g:each>
Note: See TracChangeset
for help on using the changeset viewer.