fix data binding for the timelogs to the timelog table.

fixed formatting for convertToHours to correct for one decimal place minutes (less than 10).
added convertToDisplayTime method to convert the timelog timestamp to a logical format (hh:mm).
#15
This commit is contained in:
chris.watts90@outlook.com 2017-02-15 20:53:05 +00:00
parent 78acd50ba6
commit 7b5077ff5b
2 changed files with 21 additions and 20 deletions

View File

@ -199,9 +199,6 @@
<div id="datePickerContainer"> <div id="datePickerContainer">
<div id="weeklyDatePicker"></div> <div id="weeklyDatePicker"></div>
</div> </div>
<div class="form-group">
<input type="text" data-bind="value: $root.selectedCalendarWeek">
</div>
</div> </div>
<div class="col-md-9 col-xs-12 well"> <div class="col-md-9 col-xs-12 well">
<!-- main content panel. --> <!-- main content panel. -->
@ -209,12 +206,10 @@
<thead> <thead>
<tr> <tr>
<th>Day Of Week</th> <th>Day Of Week</th>
<!-- ko foreach: new Array(MaxDailyLogCount/2) -->
<th>In</th> <th>In</th>
<th>Out</th> <th>Out</th>
<th>In</th> <!-- /ko -->
<th>Out</th>
<th>In</th>
<th>Out</th>
<th>Sub-Total</th> <th>Sub-Total</th>
</tr> </tr>
</thead> </thead>
@ -222,17 +217,17 @@
<!-- ko foreach: TimeLogs--> <!-- ko foreach: TimeLogs-->
<tr> <tr>
<td class="valign" data-bind="text: DayOfWeek"></td> <td class="valign" data-bind="text: DayOfWeek"></td>
<td class="valign" data-bind="text: DailyTotal"></td> <!-- ko foreach: Logs -->
<td class="valign" data-bind="text: $root.convertToDisplayTime(EventTime)"></td>
<!-- /ko -->
<!-- ko foreach: new Array($parent.MaxDailyLogCount-LogCount)-->
<td class="valign"></td> <td class="valign"></td>
<td class="valign"></td> <!-- /ko -->
<td class="valign"></td> <td class="valign"data-bind="text: $root.convertToHours(DailyTotal)"></td>
<td class="valign"></td>
<td class="valign"></td>
<td class="valign">8</td>
</tr> </tr>
<!-- /ko --> <!-- /ko -->
<tr> <tr>
<td class="valign" colspan="7" for="monday">Weekly Total</td> <td class="valign" data-bind="attr:{colspan: MaxDailyLogCount+1}">Weekly Total</td>
<td class="valign" for="dailyHrsTotal" data-bind="text: $root.convertToHours(WeeklyTotal)"></td> <td class="valign" for="dailyHrsTotal" data-bind="text: $root.convertToHours(WeeklyTotal)"></td>
</tr> </tr>
</tbody> </tbody>

View File

@ -130,8 +130,16 @@
} }
}; };
self.convertToHours = function (value) { self.convertToHours = function (value) {
return value / 60; var hrs = value / 60;
if (hrs < 1) {
return value + " mins";
} }
return (value / 60)+" hrs";
};
self.convertToDisplayTime = function (dateValue) {
var date = new Date(dateValue);
return date.getHours() + ":" + (date.getMinutes() < 10 ? '0' : '') + date.getMinutes();
};
self.dismissAlert = function(data, event) { self.dismissAlert = function(data, event) {
self.errorData(null); self.errorData(null);
}; };
@ -156,7 +164,6 @@
value: pageNumber value: pageNumber
} }
]; ];
var url = self.createRequestUrl("users", args, false, false); var url = self.createRequestUrl("users", args, false, false);
location.hash = url; location.hash = url;
console.log(url); console.log(url);
@ -171,7 +178,6 @@
todayHighlight: true, todayHighlight: true,
calendarWeeks: true calendarWeeks: true
}); });
if (!selectedDate) { if (!selectedDate) {
selectedDate = new Date(); selectedDate = new Date();
} else { } else {
@ -190,7 +196,7 @@
// moment(kk).weeksInYear() // moment(kk).weeksInYear()
//); //);
self.selectedCalendarWeek(moment(kk).isoWeek()); self.selectedCalendarWeek(moment(kk).isoWeek());
self.goToTimeLogs(self.chosenTimeLogUserId, null, [{ key: "selectedDate", value: kk.toISOString() }]); self.goToTimeLogs(self.chosenTimeLogUserId, null, [{ key: "selectedDate", value: moment(kk).format("MM-DD-YYYY") }]);
}); });
} }
} }