Prev | Current Page 833 | Next

Frank Zammetti

"Practical DWR 2 Projects"

util.addRows(). This allows us to define how the element
is created. The function we define here has the responsibility of instantiating a
CHAPTER 9 n TIMEKEEPER: DWR EVEN MAKES PROJECT MANAGEMENT FUN! 497
element, manipulating it any way we want, and returning it. Here, we??™re using this feature to
do row color striping, to ensure the rows in the table alternate colors.
Creating the Timesheet Entry Table on the Home Page
Next up is the creation of the timesheet table where the user can book time against projects:
var cellFuncs = [
function(data) { return data.split("~~")[0]; },
function(data) { return data.split("~~")[1]; },
...SNIP...
];
if (timekeeper.currentUser.id == project.projectManager ||
isUserAssignedToProject) {
var hoursBooked = new Array();
var projectHours = 0;
for (var j = 0; j < 7; j++) {
var d = new Date();
d.setTime(d - (timekeeper.oneDay * j));
d.setHours(0, 0, 0, 0);
var timesheetItem = timekeeper.getBookedTimeForProjectByDate(
project.id, d)
hoursBooked.push(timesheetItem);
if (timesheetItem != null) {
projectHours += timesheetItem.hours;
dayTotals[j] += timesheetItem.hours;
}
}
dwr.util.addRows("divHome_bookTimeList",
[
project.


Pages:
821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845