Changeset 5701
- Timestamp:
- Aug 17, 2011, 2:31:27 PM (12 years ago)
- Location:
- trunk/www
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/biomaterials/extracts/edit_extract.jsp
r5687 r5701 387 387 var subtypeId = ItemSubtype.getSubtypeId('extract'); 388 388 var recentInfo = ItemSubtype.getRecentAndRelatedInfo(subtypeId, 'EXTRACT', ['PROTOCOL', 'BIOPLATE', 'TAG', 'SAMPLE', 'EXTRACT']); 389 protocolChanged = ItemSubtype.updateRecentItemsInList(frm.protocol_id, recentInfo.PROTOCOL['recent']); 390 ItemSubtype.updateDefaultItemsInList(frm.protocol_id, recentInfo.PROTOCOL['default']); 391 ItemSubtype.updateRecentItemsInList(frm.tag_id, recentInfo.TAG['recent']); 392 ItemSubtype.updateRecentItemsInList(frm.bioplate_id, recentInfo.BIOPLATE['recent']); 389 protocolChanged = ItemSubtype.updateSelectionList(frm.protocol_id, recentInfo.PROTOCOL['recent'], recentInfo.PROTOCOL['default']); 390 ItemSubtype.updateSelectionList(frm.tag_id, recentInfo.TAG['recent']); 391 ItemSubtype.updateSelectionList(frm.bioplate_id, recentInfo.BIOPLATE['recent']); 393 392 } 394 393 -
trunk/www/biomaterials/samples/edit_sample.jsp
r5687 r5701 366 366 var subtypeId = ItemSubtype.getSubtypeId('sample'); 367 367 var recentInfo = ItemSubtype.getRecentAndRelatedInfo(subtypeId, 'SAMPLE', ['PROTOCOL', 'BIOPLATE', 'BIOSOURCE', 'SAMPLE']); 368 protocolChanged = ItemSubtype.updateRecentItemsInList(frm.protocol_id, recentInfo.PROTOCOL['recent']); 369 ItemSubtype.updateDefaultItemsInList(frm.protocol_id, recentInfo.PROTOCOL['default']); 370 ItemSubtype.updateRecentItemsInList(frm.bioplate_id, recentInfo.BIOPLATE['recent']); 368 protocolChanged = ItemSubtype.updateSelectionList(frm.protocol_id, recentInfo.PROTOCOL['recent'], recentInfo.PROTOCOL['default']); 369 ItemSubtype.updateSelectionList(frm.bioplate_id, recentInfo.BIOPLATE['recent']); 371 370 } 372 371 -
trunk/www/include/scripts/subtypes.js
r5687 r5701 157 157 } 158 158 159 this.updateRecentItemsInList = function(list, recentItems, noNoneOption) 160 { 161 if (!list || !recentItems || !recentItems.length) return; 162 159 /** 160 Update the selection list with 'recently used' and 'project default' items. 161 Currently existing options under those headers will be cleared. 162 */ 163 this.updateSelectionList = function(list, recentItems, projectDefaults, noNoneOption) 164 { 163 165 var oldSelectedValue = list.selectedIndex >= 0 ? list[list.selectedIndex].value : 0; 164 var reselectItemId = 0; 165 166 // Find the current 'recently used' option in the list 167 // It should be the first entry which has a value == 0 168 // ignoring the 'none' option if present 169 var recentHeaderIndex = -1; 166 var reselectValue = 0; 167 168 // Find the first header option 170 169 for (var i = noNoneOption ? 0 : 1; i < list.length; i++) 171 170 { 172 171 if (list[i].value == 0) 173 172 { 174 // Found it -- remove all items below it 175 // but remember the ID of the currently selected 176 // item if it is removed (so we can select it again) 177 recentHeaderIndex = i; 178 if (list.selectedIndex > i) 173 // Found the header entry 174 // Remember the currently selected value if it is after header 175 if (list.selectedIndex > i) 179 176 { 180 reselect ItemId= list[list.selectedIndex].value;177 reselectValue = list[list.selectedIndex].value; 181 178 } 182 list.length = i+1; 183 } 184 } 185 186 // If index == -1 we didn't find it so we must add 'recently used' 187 if (recentHeaderIndex == -1) 188 { 189 var recentHeader = new Option('- recently used -', 0); 190 recentHeader.className = 'recentheader'; 191 recentHeader.disabled = true; 192 recentHeaderIndex = list.length; 193 list[recentHeaderIndex] = recentHeader; 194 } 195 196 // Add the new items to the end of the list 197 for (var i = 0; i < recentItems.length; i++) 198 { 199 var selected = reselectItemId == recentItems[i].id; 200 list[list.length] = new Option((i+1) + '. ' + recentItems[i].name, recentItems[i].id, false, selected); 201 } 202 203 // If no item is selected, select the first 'recently used' item. 204 if (list.selectedIndex == 0) 205 { 206 list.selectedIndex = recentHeaderIndex+1; 179 // Clear everything from the header and onwards 180 list.length = i; 181 } 182 } 183 184 var firstNewIndex = list.length + 1; 185 if (recentItems && recentItems.length) 186 { 187 // Add recently used items 188 var recentlyUsedHeader = new Option('- recently used -', 0); 189 recentlyUsedHeader.className = 'recentheader'; 190 recentlyUsedHeader.disabled = true; 191 list[list.length] = recentlyUsedHeader; 192 193 for (var i = 0; i < recentItems.length; i++) 194 { 195 var selected = reselectValue == recentItems[i].id; 196 list[list.length] = new Option((i+1) + '. ' + recentItems[i].name, recentItems[i].id, false, selected); 197 } 198 } 199 200 if (projectDefaults && projectDefaults.length) 201 { 202 // Add project default items 203 var projectDefaultHeader = new Option('- project default -', 0); 204 projectDefaultHeader.className = 'defaultheader'; 205 projectDefaultHeader.disabled = true; 206 list[list.length] = projectDefaultHeader; 207 208 for (var i = 0; i < projectDefaults.length; i++) 209 { 210 var selected = reselectValue == projectDefaults[i].id; 211 list[list.length] = new Option( projectDefaults[i].name, projectDefaults[i].id, false, selected); 212 } 213 } 214 215 // If no item is selected, select the first new item 216 if (list.selectedIndex == 0 && list.length > firstNewIndex) 217 { 218 list.selectedIndex = firstNewIndex; 207 219 } 208 220 … … 211 223 } 212 224 213 this.updateDefaultItemsInList = function(list, defaultItems, noNoneOption)214 {215 if (!list || !defaultItems || !defaultItems.length) return;216 var defaultHeader = new Option('- project default -', 0);217 defaultHeader.className = 'defaultheader';218 defaultHeader.disabled = true;219 list[list.length] = defaultHeader;220 // Add the new items to the end of the list221 for (var i = 0; i < defaultItems.length; i++)222 {223 list[list.length] = new Option(defaultItems[i].name, defaultItems[i].id);224 }225 }226 225 } 227 226 -
trunk/www/views/derivedbioassays/edit_bioassay.jsp
r5698 r5701 383 383 subtypeChanged = true; 384 384 var recentInfo = ItemSubtype.getRecentAndRelatedInfo(subtypeId, 'BIOASSAY', ['PROTOCOL', 'HARDWARE', 'SOFTWARE']); 385 protocolChanged = ItemSubtype.updateRecentItemsInList(frm.protocol_id, recentInfo.PROTOCOL['recent']); 386 ItemSubtype.updateDefaultItemsInList(frm.protocol_id, recentInfo.PROTOCOL['default']); 387 ItemSubtype.updateRecentItemsInList(frm.hardware_id, recentInfo.HARDWARE['recent']); 388 ItemSubtype.updateDefaultItemsInList(frm.hardware_id, recentInfo.HARDWARE['default']); 389 ItemSubtype.updateRecentItemsInList(frm.software_id, recentInfo.SOFTWARE['recent']); 390 ItemSubtype.updateDefaultItemsInList(frm.software_id, recentInfo.SOFTWARE['default']); 385 protocolChanged = ItemSubtype.updateSelectionList(frm.protocol_id, recentInfo.PROTOCOL['recent'], recentInfo.PROTOCOL['default']); 386 ItemSubtype.updateSelectionList(frm.hardware_id, recentInfo.HARDWARE['recent'], recentInfo.HARDWARE['default']); 387 ItemSubtype.updateSelectionList(frm.software_id, recentInfo.SOFTWARE['recent'], recentInfo.SOFTWARE['default']); 391 388 } 392 389 -
trunk/www/views/physicalbioassays/edit_bioassay.jsp
r5687 r5701 352 352 var subtypeId = ItemSubtype.getSubtypeId('bioassay'); 353 353 var recentInfo = ItemSubtype.getRecentAndRelatedInfo(subtypeId, 'BIOASSAY', ['PROTOCOL', 'HARDWARE']); 354 protocolChanged = ItemSubtype.updateRecentItemsInList(frm.protocol_id, recentInfo.PROTOCOL['recent']); 355 ItemSubtype.updateDefaultItemsInList(frm.protocol_id, recentInfo.PROTOCOL['default']); 356 ItemSubtype.updateRecentItemsInList(frm.hardware_id, recentInfo.HARDWARE['recent']); 357 ItemSubtype.updateDefaultItemsInList(frm.hardware_id, recentInfo.HARDWARE['default']); 354 355 protocolChanged = ItemSubtype.updateSelectionList(frm.protocol_id, recentInfo.PROTOCOL['recent'], recentInfo.PROTOCOL['default']); 356 ItemSubtype.updateSelectionList(frm.hardware_id, recentInfo.HARDWARE['recent'], recentInfo.HARDWARE['default']); 358 357 } 359 358 -
trunk/www/views/physicalbioassays/view_bioassay.jsp
r5685 r5701 280 280 } 281 281 %> 282 <a href="ajax.jsp?ID=<%=ID%>&item_id=<%=itemId %>&cmd=GetSources">test sources</a>283 282 <table class="form" cellspacing="0"> 284 283 <tr>
Note: See TracChangeset
for help on using the changeset viewer.