Cleaned up task.jade file:

- moved ugly html newlines into the stylesheet
- renamed temporary var for datePicker’s ngmodel from _dateString to _tempDateForPicker
- renamed open -> openDatePicker, and have the function track datePicker’s open/closed state on a per task instead of global basis
This commit is contained in:
Allen Pan
2015-05-14 00:22:27 -07:00
parent 1ecf608408
commit a763a3a3da
5 changed files with 65 additions and 60 deletions

View File

@@ -4,10 +4,6 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
function($scope, $rootScope, $location, User, Notification, $http, ApiUrl, $timeout, Shared, Guide) {
$scope.obj = User.user; // used for task-lists
$scope.user = User.user;
// HACK: flagDict is for storing whether the datePicker popup is open or not. This should just be a boolean flag,
// but apparently due to angular bug need to put the bool in intermediate dict...
$scope.flagDict = {};
$scope.score = function(task, direction) {
switch (task.type) {
case 'reward':
@@ -136,15 +132,18 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
------------------------
*/
$scope.updateTaskStartDate = function(task) {
// TODO: Weirdness here...startDate should be a Date and _dateString
// should be a string, but the datePicker input fields sets _dateString
// to a Date even though input type="text"...
task.startDate = task._dateString;
/*
Keep startDate and _tempDateForPicker in sync. The reason for having both instead
of having startDate be the ngmodel for datePicker is that datePicker initializes with
an incorrect format when given a Date for an ngmodel; instead we initialize _tempDate
to be a string that datePicker then converts to a Date, which lets us control the format.
*/
task.startDate = task._tempDateForPicker;
};
$scope.open = function($event) {
$scope.openDatePicker = function($event, task) {
$event.stopPropagation();
$scope.flagDict['opened'] = !$scope.flagDict['opened'];
task._isDatePickerOpen = !task._isDatePickerOpen;
}