Updated event form to allow for time input

This commit is contained in:
Luke Vella 2015-02-01 23:35:15 +01:00
parent 47b60296eb
commit 6d81b21ed1
32 changed files with 456 additions and 88 deletions

View file

@ -15,7 +15,7 @@ angular.module('rallly')
event : '=',
form : '='
},
templateUrl : 'templates/directives/eventForm/userForm.html',
templateUrl : 'templates/form/userForm.html',
link : function(scope, el, attrs) {
scope.errors = {};
@ -37,7 +37,7 @@ angular.module('rallly')
event : '=',
form : '='
},
templateUrl : 'templates/directives/eventForm/eventForm.html',
templateUrl : 'templates/form/eventForm.html',
link : function(scope, el, attrs) {
scope.errors = {};
@ -58,7 +58,7 @@ angular.module('rallly')
event : '=',
form : '='
},
templateUrl : 'templates/directives/eventForm/dateForm.html'
templateUrl : 'templates/form/dateForm.html'
}
})
.directive('participantsForm', function(FormHelper){
@ -67,7 +67,7 @@ angular.module('rallly')
event : '=',
form : '='
},
templateUrl : 'templates/directives/eventForm/participantsForm.html',
templateUrl : 'templates/form/participantsForm.html',
link : function(scope, el, attrs){
scope.emailRegex = FormHelper.emailRegexString;
}
@ -79,7 +79,7 @@ angular.module('rallly')
event : '=',
form : '='
},
templateUrl : 'templates/directives/eventForm/settingsForm.html',
templateUrl : 'templates/form/settingsForm.html',
link : function(scope, el, attrs){
scope.deleteEvent = function(){
if (scope.deleteRequestSent) return;
@ -117,4 +117,53 @@ angular.module('rallly')
});
}
}
})
.directive('timeForm', function(DatePickerService){
return {
scope : {
event : '=',
form : '='
},
templateUrl : 'templates/form/timeForm.html',
link : function(scope, el, attrs){
var init = false;
var dateService;
var deregister = scope.$watch('event.dates', function(value){
if (value && !init) {
deregister();
}
init = true;
dateService = new DatePickerService(scope.event.dates);
scope.unsetDate = function(date){
dateService.removeDate(date);
}
});
}
}
})
.directive('timePicker', function(){
return {
scope : {
model : '=ngModel'
},
require : 'ngModel',
link : function(scope, el, attrs, ngModel){
ngModel.$viewChangeListeners.push(function(){
scope.model = Date.parse(ngModel.$modelValue);
ngModel.$setViewValue(scope.model.toString("hh:mm tt"));
ngModel.$render();
});
ngModel.$validators.time = function(modelValue, viewValue){
if (ngModel.$isEmpty(modelValue)) return true;
var time = Date.parse(modelValue);
if (time) {
ngModel.$setViewValue(time.toString("hh:mm tt"));
ngModel.$render();
return true;
}
return false;
}
}
}
});