Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(datepicker): properly handle showWeeks config option
Browse files Browse the repository at this point in the history
Closes #1132
  • Loading branch information
mme-private authored and pkozlowski-opensource committed Oct 27, 2013
1 parent 253c49f commit 570dba9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/datepicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.position'])
appendToBody: false
})

.directive('datepickerPopup', ['$compile', '$parse', '$document', '$position', 'dateFilter', 'datepickerPopupConfig',
function ($compile, $parse, $document, $position, dateFilter, datepickerPopupConfig) {
.directive('datepickerPopup', ['$compile', '$parse', '$document', '$position', 'dateFilter', 'datepickerPopupConfig', 'datepickerConfig',
function ($compile, $parse, $document, $position, dateFilter, datepickerPopupConfig, datepickerConfig) {
return {
restrict: 'EA',
require: 'ngModel',
Expand Down Expand Up @@ -406,7 +406,7 @@ function ($compile, $parse, $document, $position, dateFilter, datepickerPopupCon
if (attrs.showWeeks) {
addWatchableAttribute(attrs.showWeeks, 'showWeeks', 'show-weeks');
} else {
scope.showWeeks = true;
scope.showWeeks = datepickerConfig.showWeeks;
datepickerEl.attr('show-weeks', 'showWeeks');
}
if (attrs.dateDisabled) {
Expand Down
24 changes: 24 additions & 0 deletions src/datepicker/test/datepicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,30 @@ describe('datepicker directive', function () {
expect(elm.children().length).toEqual(1);
});
});

describe('with setting datepickerConfig.showWeeks to false', function() {
var originalConfig = {};
beforeEach(inject(function(datepickerConfig) {
angular.extend(originalConfig, datepickerConfig);
datepickerConfig.showWeeks = false;

var wrapElement = $compile('<div><input ng-model="date" datepicker-popup><div>')($rootScope);
$rootScope.$digest();
assignElements(wrapElement);
}));
afterEach(inject(function(datepickerConfig) {
// return it to the original state
angular.extend(datepickerConfig, originalConfig);
}));

it('changes initial visibility for weeks', function() {
expect(getLabelsRow().find('th').eq(0).css('display')).toBe('none');
var tr = element.find('tbody').find('tr');
for (var i = 0; i < 5; i++) {
expect(tr.eq(i).find('td').eq(0).css('display')).toBe('none');
}
});
});
});
});

Expand Down

1 comment on commit 570dba9

@kpgarrod
Copy link

Choose a reason for hiding this comment

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

From what I can see this change has been regressed in 0.11. Specifiying "show-weeks='false'" on a datepicker-popup does not hide the week numbers. I don't see these changes to the source in 0.11.

Please sign in to comment.