Use select instead of an input for cds

This commit is contained in:
Blade Barringer
2015-09-06 09:36:29 -05:00
parent 085a785e4d
commit f1224bc6be
3 changed files with 25 additions and 53 deletions

View File

@@ -31,27 +31,6 @@ describe('Settings Controller', function() {
sandbox.stub(window, 'alert'); sandbox.stub(window, 'alert');
}); });
context('failures', function() {
var tests = {
'blank': '',
'not a whole number': 5.3,
'not a number': 'foo',
'less than 0': -5,
'more than 24': 25
};
for (var test in tests) {
it('returns with an alert if number is ' + test, function() {
scope.openDayStartModal(tests[test]);
expect(rootScope.openModal).to.not.be.called;
expect(window.alert).to.be.calledOnce;
expect(window.alert).to.be.calledWith(env.t('enterNumber'));
});
}
});
context('success', function() {
it('opens the day start modal', function() { it('opens the day start modal', function() {
scope.openDayStartModal(5); scope.openDayStartModal(5);
@@ -87,12 +66,10 @@ describe('Settings Controller', function() {
expect(scope.nextCron).to.eq(expectedTime); expect(scope.nextCron).to.eq(expectedTime);
}); });
}); });
});
describe('#saveDayStart', function() { describe('#saveDayStart', function() {
it('updates user\'s custom day start and last cron', function() { it('updates user\'s custom day start and last cron', function() {
var fakeCurrentTime = new Date(2013, 3, 1, 8, 12).getTime(); var fakeCurrentTime = new Date(2013, 3, 1, 8, 12).getTime();
var expectedTime = fakeCurrentTime; var expectedTime = fakeCurrentTime;
sandbox.useFakeTimers(fakeCurrentTime); sandbox.useFakeTimers(fakeCurrentTime);

View File

@@ -66,12 +66,6 @@ habitrpg.controller('SettingsCtrl',
$scope.openDayStartModal = function(dayStart) { $scope.openDayStartModal = function(dayStart) {
$scope.dayStart = +dayStart; $scope.dayStart = +dayStart;
var flooredDayStart = Math.floor($scope.dayStart);
if ($scope.dayStart !== flooredDayStart || $scope.dayStart < 0 || $scope.dayStart > 24 ) {
return alert(window.env.t('enterNumber'));
}
$scope.nextCron = _calculateNextCron(); $scope.nextCron = _calculateNextCron();
$rootScope.openModal('change-day-start', { scope: $scope }); $rootScope.openModal('change-day-start', { scope: $scope });

View File

@@ -97,9 +97,10 @@ script(type='text/ng-template', id='partials/options.settings.settings.html')
select.form-control(ng-model='dayStart') select.form-control(ng-model='dayStart')
- var number = 0 - var number = 0
while number < 24 while number < 24
- var hour = number++ % 12 - var value = number
- var meridian = number < 12 ? 'AM' : 'PM' - var meridian = number < 12 ? 'AM' : 'PM'
option(value=number) #{hour ? hour : 12}:00 #{meridian} - var hour = number++ % 12
option(value=value) #{hour ? hour : 12}:00 #{meridian}
.col-sm-5 .col-sm-5
br.visible-xs br.visible-xs