Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/controller/summer-camp-challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ app.controller('SummerCampChallengeController', function ($scope, $routeParams,
// Check if the difference in the route params and the current day of summercamp is greater than 1
// Check if the id in the route params is either greater than or equal to the progress challenge number.
// If both are true, then redirect the user to the summercamp calendar
console.log($scope.id, progressNo, diff);
if (!config.TEST_MODE && ($scope.id - diff) > 1 && $scope.id >= progressNo) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woah! Is this on master? We missed it!

$location.path('/summercamp');
}
Expand Down
26 changes: 25 additions & 1 deletion lib/controller/summer-camp.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,27 @@ app.controller('SummerCampController', function ($interval, $timeout, $scope, $r
$scope.selectedSummerChallengeDay = startDate.date() + day;
$scope.selectedSummerChallenge = selectedChallenge;
$scope.selectedSummerChallengeObj = challenges[selectedChallenge];
$scope.isFutureChallenge = (day > currentDayIndex()) ? true : false;
$scope.isFutureChallenge = isFutureChallenge(day);
analytics.track('Viewed Challenge ' + day, {
category : 'Viewed Summer Camp Challenge'
});
countDownToNext();
};

/*
* Open a challenge by double-clicking and check if it's unlocked and not a future
* challenge.
*
* @param {Number} day
* @return void
*/
$scope.openChallenge = function (day) {
if (!$scope.isLocked(day) && !isFutureChallenge(day)) {
day = day + 1;
$location.path('/summercamp/challenge/' + day);
}
};

/*
* Deselect a challenge and close challenge modal
*
Expand Down Expand Up @@ -181,6 +195,16 @@ app.controller('SummerCampController', function ($interval, $timeout, $scope, $r
return index === (now.getDay() || 7) - 1;
}

/*
* Returns true if challenge is a future challenge
*
* @param {Number} day
* @return {Boolean}
*/
function isFutureChallenge(day) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arifshanji @rcocetta I've just refactored the isFutureChallenge into a function. Is this better?

return (day > currentDayIndex()) ? true : false;
};

function currentDayIndex() {
var today = moment(),
diff = today.diff(startDate),
Expand Down
1 change: 1 addition & 0 deletions views/summer-camp-calendar.jade
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
ul.calendar
li.day(ng-repeat='day in range(21)')
a(
ng-dblClick='openChallenge(day)',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you use the same code we already use to open challenges?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rcocetta the only way to open a challenge from the calendar before was through an href.
So I had to create the function for double clicking

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

ng-click='selectChallenge(day)',
ng-class='{ locked: isLocked(day) && !currentDay(day), completed: isCompleted(day), current: isCurrent(day), unlocked: currentDay(day) }',
)
Expand Down