Skip to content

Commit

Permalink
Merge pull request #3 from emcniece/master
Browse files Browse the repository at this point in the history
Fixing day-schedule config/storage
  • Loading branch information
bitwit authored Oct 18, 2016
2 parents 70e87e6 + 0149287 commit 6800f6a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
10 changes: 7 additions & 3 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,22 @@ app.controller('SchedulerCtrl', ['$scope', function ($scope) {
$scope.toggleDaySelection = function (day) {
for (var i = 0; i < $scope.config.daySelection.length; i++) {
var obj = $scope.config.daySelection[i];
if (day.value === obj.value) {
if (day.value === obj) {
$scope.config.daySelection.splice(i, 1);
return;
}
}
$scope.config.daySelection.push(day);
$scope.config.daySelection.push(day.value);
};

$scope.isDaySelected = function (day) {
if(!$scope.config.daySelection){
$scope.config.daySelection = [];
}

for (var i = 0; i < $scope.config.daySelection.length; i++) {
var obj = $scope.config.daySelection[i];
if (day.value === obj.value) {
if (day.value === obj) {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var utils ={
getNextScheduledTime: function getNextScheduledTime(branchConfig){
var frequency = branchConfig.frequency
, time = moment(branchConfig.time)
, days = _.flatten(branchConfig.daySelection, 'value')
, days = branchConfig.daySelection
, now = utils.getNow()
, timeMinutes = time.minutes()
, timeHours = time.hours()
Expand Down
Binary file modified static/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions test/utils_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe("utils", function() {
time: moment("1976-10-01 4:30 +0000", "YYYY-MM-DD HH:mm Z"),
daySelection:[
// Wednedays only
{key: 'Wednesday', value:3}
3
]
};
var time = utils.getNextScheduledTime(config);
Expand All @@ -64,7 +64,7 @@ describe("utils", function() {
time: moment("1976-10-01 4:30 +0000", "YYYY-MM-DD HH:mm Z"),
daySelection:[
// Sundays only, but the time above has passed already
{key: 'Sunday', value:0}
0
]
};
var time = utils.getNextScheduledTime(config);
Expand All @@ -81,8 +81,8 @@ describe("utils", function() {
frequency: 60 * 60 * 1000 * 24, //daily
time: moment("1976-10-01 4:30 +0000", "YYYY-MM-DD HH:mm Z"),
daySelection:[
{key: 'Friday', value:5},
{key: 'Tuesday', value:2}
5,
2
]
};
var time = utils.getNextScheduledTime(config);
Expand All @@ -99,7 +99,7 @@ describe("utils", function() {
frequency: 60 * 60 * 1000 * 24, //daily
time: moment('2014-10-13T01:48:26.433Z'), //format as expected from JSON objects
daySelection:[
{key: 'Wednesday', value:3}
3
]
};
var time = utils.getNextScheduledTime(config);
Expand Down

0 comments on commit 6800f6a

Please sign in to comment.