| 1 |
<html> |
| 2 |
|
| 3 |
<head> |
| 4 |
<title>Grid Bug</title> |
| 5 |
|
| 6 |
<script type="text/javascript" src="../../../dojo/dojo.js" |
| 7 |
data-dojo-config="isDebug:false, parseOnLoad: true"></script> |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
<style type="text/css"> |
| 12 |
@import "../resources/Grid.css"; |
| 13 |
@import "../resources/tundraGrid.css"; |
| 14 |
@import "../../../dojo/resources/dojo.css"; |
| 15 |
@import "../../../dijit/themes/tundra/tundra.css"; |
| 16 |
@import "../../../dijit/tests/css/dijitTests.css"; |
| 17 |
</style> |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
<script type="text/javascript"> |
| 22 |
dojo.require("dojox.grid.DataGrid"); |
| 23 |
dojo.require("dojo.data.ItemFileReadStore"); |
| 24 |
dojo.require("dijit.form.CheckBox"); |
| 25 |
dojo.require("dojo.date.locale"); |
| 26 |
|
| 27 |
var drc={}; |
| 28 |
drc.gridData = { |
| 29 |
identifier: 'id', |
| 30 |
label: 'id', |
| 31 |
items: [ |
| 32 |
{ id: 5301, created: 1204243230266, completed: 1204244264554, status: 'COMPLETED', completion_log: null, instructor_decision: 'YES', course: 'AGB 322', section: '02', exam_date: 1204920600000, end_time: 1204925100000 }, |
| 33 |
{ id: 5401, created: 1204314408874, completed: 1204834363267, status: 'COMPLETED', completion_log: null, instructor_decision: null, course: 'AGB 322', section: '02', exam_date: 1205176200000, end_time: 1204314408000 }, |
| 34 |
{ id: 5402, created: 1204314413361, completed: 1204834364132, status: 'COMPLETED', completion_log: null, instructor_decision: null, course: 'AGB 322', section: '02', exam_date: 1205176200000, end_time: 1204314413000 }, |
| 35 |
{ id: 5403, created: 1204315176468, completed: 1205787777855, status: 'COMPLETED', completion_log: null, instructor_decision: null, course: 'AGB 322', section: '02', exam_date: 1205960400000, end_time: 1204315176000 }, |
| 36 |
{ id: 5404, created: 1204335924874, completed: 1205165567663, status: 'COMPLETED', completion_log: null, instructor_decision: null, course: 'FRSC 415', section: '03', exam_date: 1205338200000, end_time: 1204335924000 }, |
| 37 |
{ id: 5405, created: 1204741820851, completed: 1204743423882, status: 'COMPLETED', completion_log: null, instructor_decision: 'somethinginvalid', course: 'FRSC 415', section: '02', exam_date: 1206731400000, end_time: 1206746700000 }, |
| 38 |
{ id: 5406, created: 1204744307957, completed: 1205274662191, status: 'TERMINATED', completion_log: null, instructor_decision: null, course: 'FRSC 415', section: '02', exam_date: 1206731400000, end_time: 1204744307000 }, |
| 39 |
{ id: 5407, created: 1204840355867, completed: 1205537683853, status: 'COMPLETED', completion_log: null, instructor_decision: 'YES', course: 'FRSC 415', section: '02', exam_date: 1206040200000, end_time: 1206055500000 }, |
| 40 |
{ id: 5504, created: 1205274223961, completed: 1205274408372, status: 'COMPLETED', completion_log: 'APPROVED', instructor_decision: 'YES', course: 'AGB 322', section: '01', exam_date: 1207579200000, end_time: 1207586400000 }, |
| 41 |
{ id: 5505, created: 1205274698075, completed: 1205274757197, status: 'TERMINATED', completion_log: null, instructor_decision: null, course: 'AGB 322', section: '01', exam_date: 1206974400000, end_time: 1205274698000 }, |
| 42 |
{ id: 5506, created: 1205274723562, completed: 1206628811409, status: 'COMPLETED', completion_log: 'TIMEOUT', instructor_decision: null, course: 'AGB 322', section: '01', exam_date: 1206974400000, end_time: 1205274723000 }, |
| 43 |
{ id: 4807, created: 1203037851016, completed: 1204045887212, status: 'COMPLETED', completion_log: null, instructor_decision: null, course: 'FRSC 415', section: '03', exam_date: 1204218600000, end_time: null }, |
| 44 |
{ id: 4808, created: 1203037857289, completed: 1204045888187, status: 'COMPLETED', completion_log: null, instructor_decision: null, course: 'FRSC 415', section: '03', exam_date: 1204218600000, end_time: null }, |
| 45 |
{ id: 4809, created: 1203039859756, completed: 1203970285117, status: 'COMPLETED', completion_log: null, instructor_decision: null, course: 'AGB 322', section: '02', exam_date: 1204143000000, end_time: null }, |
| 46 |
{ id: 4810, created: 1203039862593, completed: 1203970285693, status: 'COMPLETED', completion_log: null, instructor_decision: null, course: 'AGB 322', section: '02', exam_date: 1204143000000, end_time: null }, |
| 47 |
{ id: 4811, created: 1203039914652, completed: 1203970286217, status: 'COMPLETED', completion_log: null, instructor_decision: null, course: 'FRSC 415', section: '02', exam_date: 1204143000000, end_time: null }, |
| 48 |
{ id: 4812, created: 1203039917115, completed: 1203970286693, status: 'COMPLETED', completion_log: null, instructor_decision: null, course: 'FRSC 415', section: '02', exam_date: 1204143000000, end_time: null }, |
| 49 |
{ id: 4813, created: 1203718608148, completed: 1204226860378, status: 'COMPLETED', completion_log: null, instructor_decision: null, course: 'WVIT 463', section: '01', exam_date: 1204330200000, end_time: null }, |
| 50 |
{ id: 4816, created: 1203720084402, completed: 1207077016546, status: 'COMPLETED', completion_log: null, instructor_decision: null, course: 'AGB 322', section: '02', exam_date: 1207249800000, end_time: null }, |
| 51 |
{ id: 5201, created: 1203725528974, completed: 1204243139125, status: 'TERMINATED', completion_log: null, instructor_decision: null, course: 'AGB 322', section: '02', exam_date: 1204747800000, end_time: null }, |
| 52 |
{ id: 5702, created: 1206489796519, completed: null, status: 'RUNNING', completion_log: null, instructor_decision: null, course: 'AGB 322', section: '01', exam_date: 1207320000000, end_time: 1206489796000 }, |
| 53 |
{ id: 5701, created: 1206462566705, completed: 1207077017340, status: 'COMPLETED', completion_log: 'TIMEOUT', instructor_decision: null, course: 'FRSC 415', section: '02', exam_date: 1207249800000, end_time: 1206462566000 }, |
| 54 |
{ id: 5703, created: 1206489800523, completed: null, status: 'RUNNING', completion_log: null, instructor_decision: null, course: 'AGB 322', section: '01', exam_date: 1207320000000, end_time: 1206489800000 }, |
| 55 |
{ id: 5704, created: 1206555988187, completed: 1207072817249, status: 'COMPLETED', completion_log: 'TIMEOUT', instructor_decision: null, course: 'FRSC 415', section: '02', exam_date: 1207245600000, end_time: 1206555988000 }, |
| 56 |
{ id: 5705, created: 1206556755331, completed: 1206557243510, status: 'COMPLETED', completion_log: 'APPROVED', instructor_decision: 'WITH_MODS', course: 'AGB 322', section: '01', exam_date: 1207320000000, end_time: 1207324020000 }, |
| 57 |
{ id: 5706, created: 1206557320052, completed: 1206557366393, status: 'COMPLETED', completion_log: 'APPROVED', instructor_decision: 'YES', course: 'FRSC 415', section: '02', exam_date: 1207336200000, end_time: 1207340220000 }, |
| 58 |
{ id: 5601, created: 1205522914023, completed: 1205522971080, status: 'COMPLETED', completion_log: 'REJECTED', instructor_decision: 'NO', course: 'FRSC 415', section: '02', exam_date: 1206645000000, end_time: 1205522914000 }, |
| 59 |
{ id: 5602, created: 1205522920401, completed: 1205523821411, status: 'COMPLETED', completion_log: 'APPROVED', instructor_decision: 'WITH_MODS', course: 'FRSC 415', section: '02', exam_date: 1206645000000, end_time: 1206660300000 }, |
| 60 |
{ id: 5603, created: 1205530930988, completed: 1205537697586, status: 'COMPLETED', completion_log: 'REJECTED', instructor_decision: 'NO', course: 'AGB 322', section: '02', exam_date: 1206558600000, end_time: 1205530930000 }, |
| 61 |
{ id: 5604, created: 1205539366682, completed: 1205881854926, status: 'COMPLETED', completion_log: 'APPROVED', instructor_decision: 'YES', course: 'WVIT 463', section: '01', exam_date: 1206745800000, end_time: 1206755700000 }, |
| 62 |
{ id: 5605, created: 1205539369772, completed: 1205539670553, status: 'COMPLETED', completion_log: 'APPROVED', instructor_decision: 'YES', course: 'WVIT 463', section: '01', exam_date: 1206745800000, end_time: 1206755700000 }, |
| 63 |
{ id: 5606, created: 1205882032439, completed: 1205967437022, status: 'COMPLETED', completion_log: 'APPROVED', instructor_decision: 'WITH_MODS', course: 'FRSC 415', section: '03', exam_date: 1206720600000, end_time: 1206725100000 }, |
| 64 |
{ id: 5607, created: 1206035981735, completed: 1206461410540, status: 'COMPLETED', completion_log: 'TIMEOUT', instructor_decision: null, course: 'FRSC 415', section: '03', exam_date: 1206634200000, end_time: 1206035981000 }, |
| 65 |
{ id: 5608, created: 1206035986106, completed: 1206461411245, status: 'COMPLETED', completion_log: 'TIMEOUT', instructor_decision: null, course: 'FRSC 415', section: '03', exam_date: 1206634200000, end_time: 120603598600 } |
| 66 |
] |
| 67 |
}; |
| 68 |
|
| 69 |
drc.filterPast = true; |
| 70 |
|
| 71 |
drc.courseFormat = function(course, rowIndex){ |
| 72 |
var item = this.grid.getItem(rowIndex); |
| 73 |
var sec = this.grid.store.getValue(item, "section"); |
| 74 |
return course+"-"+sec; |
| 75 |
} |
| 76 |
|
| 77 |
drc.fullDateFormat = function(dateTime){ |
| 78 |
if(dateTime == null){ |
| 79 |
return null; |
| 80 |
} |
| 81 |
var d = new Date(); |
| 82 |
d.setTime(dateTime); |
| 83 |
return dojo.date.locale.format(d, {datePattern:"MMM d y h:mm a",selector:'date'}); |
| 84 |
} |
| 85 |
|
| 86 |
drc.timeFormat = function(dateTime){ |
| 87 |
if(dateTime == null){ |
| 88 |
return null; |
| 89 |
} |
| 90 |
var d = new Date(); |
| 91 |
d.setTime(dateTime); |
| 92 |
return dojo.date.locale.format(d, {datePattern:"h:mm a",selector:'time'}); |
| 93 |
} |
| 94 |
|
| 95 |
drc.filterPastChecked = function(value){ |
| 96 |
drc.filterPast = this.checked; |
| 97 |
drc.grid.filter(null, true); |
| 98 |
} |
| 99 |
|
| 100 |
drc.statusFormat = function(value, rowIndex){ |
| 101 |
var item = this.grid.getItem(rowIndex); |
| 102 |
var store = this.grid.store; |
| 103 |
var state = store.getValue(item, "status"); |
| 104 |
var completion_log = store.getValue(item, "completion_log"); |
| 105 |
var instructor_decision = store.getValue(item, "instructor_decision"); |
| 106 |
var finishTime = store.getValue(item, "completed"); |
| 107 |
|
| 108 |
if(state == 'RUNNING'){ |
| 109 |
return 'Pending Instructor Approval'; |
| 110 |
} |
| 111 |
|
| 112 |
var s = ''; |
| 113 |
if(state == 'TERMINATED'){ |
| 114 |
s += 'Canceled' |
| 115 |
} |
| 116 |
else if(state == 'COMPLETED'){ |
| 117 |
if(completion_log == 'APPROVED'){ |
| 118 |
s += 'Approved'; |
| 119 |
if(instructor_decision == 'WITH_MODS'){ |
| 120 |
s += ' with modifications'; |
| 121 |
} |
| 122 |
} |
| 123 |
else if(completion_log == 'REJECTED'){ |
| 124 |
s += 'Denied'; |
| 125 |
} |
| 126 |
else if(completion_log == 'TIMEOUT'){ |
| 127 |
s += 'Expired'; |
| 128 |
} |
| 129 |
else{ |
| 130 |
s += completion_log; |
| 131 |
} |
| 132 |
} |
| 133 |
return s; |
| 134 |
} |
| 135 |
|
| 136 |
drc.onBeforeRow = function(inDataIndex, inRow){ |
| 137 |
if(inDataIndex < 0){ |
| 138 |
inRow[0].hidden = false; |
| 139 |
return; |
| 140 |
} |
| 141 |
var item = this.grid.getItem(inDataIndex); |
| 142 |
if(!item){ return; } |
| 143 |
var store = this.grid.store; |
| 144 |
if(inDataIndex >= 0) { |
| 145 |
if (drc.filterPast) { |
| 146 |
//If exam date is past, don't show |
| 147 |
var exam_date = store.getValue(item, "exam_date"); |
| 148 |
if (exam_date < 1207088855078) { //use static time value so filter will always have something to filter |
| 149 |
inRow[0].hidden = true; |
| 150 |
return; |
| 151 |
} |
| 152 |
} |
| 153 |
} |
| 154 |
inRow[0].hidden=false; |
| 155 |
} |
| 156 |
|
| 157 |
drc.viewButtonFormat = function(value, rowIndex){ |
| 158 |
return '<a class="drc-view-button" href="' |
| 159 |
+ drc.baseActionURL + '?submittedform=view&processId='+value+'"/>'; |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
dojo.addOnLoad(function() { |
| 164 |
console.debug("initializing..."); |
| 165 |
|
| 166 |
var check = new dijit.form.CheckBox({checked:true},"altTestingPastCheck"); |
| 167 |
dojo.connect(check,"onClick", drc.filterPastChecked); |
| 168 |
|
| 169 |
var jsonStore = new dojo.data.ItemFileReadStore({ data: drc.gridData }); |
| 170 |
|
| 171 |
var layout = [{ |
| 172 |
onBeforeRow: drc.onBeforeRow, |
| 173 |
noscroll: true, |
| 174 |
cells: [ |
| 175 |
{name: 'Id',field:'id',width:3}, |
| 176 |
{name: 'Created',field:'created',formatter:drc.fullDateFormat,width:11}, |
| 177 |
{name: 'Status',field:'status',formatter:drc.statusFormat,width:13}, |
| 178 |
{name: 'Completed',field:'completed',formatter:drc.fullDateFormat,width:11}, |
| 179 |
{name: 'Course',field:'course',formatter:drc.courseFormat,width:7}, |
| 180 |
{name: 'Exam Date', field:'exam_date',formatter:drc.fullDateFormat,width:11}, |
| 181 |
{name: 'End Time', field:'end_time', formatter:drc.timeFormat,width:6}, |
| 182 |
{name: 'View',field:'id',width:3,formatter:drc.viewButtonFormat} |
| 183 |
] |
| 184 |
}]; |
| 185 |
|
| 186 |
|
| 187 |
drc.grid = new dojox.grid.DataGrid({store:jsonStore,structure:layout,query: { id: '*' },rowsPerPage:20, |
| 188 |
autoHeight:true,autoWidth:true,style:"clear:both;"},"altTestingMainGrid"); |
| 189 |
drc.grid.startup(); |
| 190 |
|
| 191 |
console.debug("done."); |
| 192 |
}); |
| 193 |
|
| 194 |
</script> |
| 195 |
|
| 196 |
</head> |
| 197 |
|
| 198 |
<body class="tundra"> |
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
<div id="altTestingPastCheck"></div> |
| 203 |
<label for="altTestingPastCheck">Filter past exams (Exam Date before Apr 1, 2008)</label> |
| 204 |
|
| 205 |
<div style="background: red; padding: 10px 10px 10px 10px"> |
| 206 |
<div id="altTestingMainGrid"></div> |
| 207 |
</div> |
| 208 |
|
| 209 |
|
| 210 |
</body> |
| 211 |
</html> |