Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1074 from mbeard/scheduler-recurrance
Browse files Browse the repository at this point in the history
ensured the scheduler input checked attribute is being set, not just setting the active css class
  • Loading branch information
Christopher McCulloh committed Feb 12, 2015
2 parents 272a44d + 1ffa179 commit c1765c5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
10 changes: 5 additions & 5 deletions js/scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@
item.find('label').removeClass('active');
temp = recur.BYDAY.split(',');
for (i = 0, l = temp.length; i < l; i++) {
item.find('input[data-value="' + temp[i] + '"]').parent().addClass('active');
item.find('input[data-value="' + temp[i] + '"]').prop('checked',true).parent().addClass('active');
}
}

Expand All @@ -525,12 +525,12 @@
this.$element.find('.repeat-monthly label.radio-custom').removeClass('checked');
if (recur.BYMONTHDAY) {
temp = this.$element.find('.repeat-monthly-date');
temp.find('input').addClass('checked').attr('checked', 'checked');
temp.find('input').addClass('checked').prop('checked', true);
temp.find('label.radio-custom').addClass('checked');
temp.find('.selectlist').selectlist('selectByValue', recur.BYMONTHDAY);
} else if (recur.BYDAY) {
temp = this.$element.find('.repeat-monthly-day');
temp.find('input').addClass('checked').attr('checked', 'checked');
temp.find('input').addClass('checked').prop('checked', true);
temp.find('label.radio-custom').addClass('checked');
if (recur.BYSETPOS) {
temp.find('.month-day-pos').selectlist('selectByValue', recur.BYSETPOS);
Expand All @@ -545,7 +545,7 @@
this.$element.find('.repeat-yearly label.radio-custom').removeClass('checked');
if (recur.BYMONTHDAY) {
temp = this.$element.find('.repeat-yearly-date');
temp.find('input').addClass('checked').attr('checked', 'checked');
temp.find('input').addClass('checked').prop('checked', true);
temp.find('label.radio-custom').addClass('checked');
if (recur.BYMONTH) {
temp.find('.year-month').selectlist('selectByValue', recur.BYMONTH);
Expand All @@ -554,7 +554,7 @@
temp.find('.year-month-day').selectlist('selectByValue', recur.BYMONTHDAY);
} else if (recur.BYSETPOS) {
temp = this.$element.find('.repeat-yearly-day');
temp.find('input').addClass('checked').attr('checked', 'checked');
temp.find('input').addClass('checked').prop('checked', true);
temp.find('label.radio-custom').addClass('checked');
temp.find('.year-month-day-pos').selectlist('selectByValue', recur.BYSETPOS);
if (recur.BYDAY) {
Expand Down
25 changes: 25 additions & 0 deletions test/scheduler-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
define(function(require){
var $ = require('jquery');
var html = require('text!test/markup/scheduler-markup.html');
var templateHtml = html;

/* FOR DEV TESTING */
// html = require('text!index.html!strip');
html = $('<div>'+html+'</div>').find('#MyScheduler');
Expand Down Expand Up @@ -177,6 +179,11 @@ define(function(require){
test = (test.find('[data-value="MO"]').parent().hasClass('active') && test.find('[data-value="TH"]').parent().hasClass('active')) ? true : false;
ok(($repIntSelDrop.html()==='Weekly' && $repPanSpinbox.spinbox('value')==='7' && test), 'weekly recurrence set correctly');

$scheduler.scheduler('value', { recurrencePattern: 'FREQ=WEEKLY;BYDAY=MO,TH;' });
test = $scheduler.find('.repeat-days-of-the-week .btn-group');
ok(test.find('[data-value="MO"]').is(':checked'), 'weekly recurrence option set correctly with "checked" attribute');
ok(test.find('[data-value="TH"]').is(':checked'), 'weekly recurrence option set correctly with "checked" attribute');

$scheduler.scheduler('value', { recurrencePattern: 'FREQ=MONTHLY;INTERVAL=9;BYDAY=SA;BYSETPOS=4;' });
test = $scheduler.find('.repeat-monthly-day');
ok(($repIntSelDrop.html()==='Monthly' && $repPanSpinbox.spinbox('value')==='9' && test.find('div.radio input').hasClass('checked') &&
Expand Down Expand Up @@ -212,6 +219,24 @@ define(function(require){
// }
});

test('should set/get recurrence pattern properly', function() {
var schedule = {
startDateTime: '2014-03-31T03:23+02:00',
timeZone: {
offset: '+02:00'
},
recurrencePattern: 'FREQ=WEEKLY;BYDAY=WE;INTERVAL=1;'
};

// note: currently, the scheduler doesn't reset it's markup/state
// when setValue is called. so ensure we're starting with initial template markup
// that hasn't been altered by another unit test
var $scheduler = $('<div>'+templateHtml+'</div>').find('#MyScheduler').scheduler();
$scheduler.scheduler('value', schedule);

equal($scheduler.scheduler('value').recurrencePattern, schedule.recurrencePattern, 'schedule set correctly');
});

// TODO: need more end date test or dry out code where start and end use same methods

test('should initialize with end date provided', function() {
Expand Down

0 comments on commit c1765c5

Please sign in to comment.