diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-04 10:23:03 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-04 10:23:03 +0100 |
commit | de021bcaf9cb7c64bc0c24783886cfa9ad6a970e (patch) | |
tree | 542bc96a83b7c7aa03d79ddb92772e33632b6f89 | |
parent | 93f22add195215bc561bf39141fe1375372e061e (diff) |
Fix birthday field - fixes #112
-rw-r--r-- | js/components/parsers/dateModel_directive.js | 14 | ||||
-rw-r--r-- | js/public/script.js | 65 | ||||
-rw-r--r-- | templates/detailItems/date.html | 2 |
3 files changed, 55 insertions, 26 deletions
diff --git a/js/components/parsers/dateModel_directive.js b/js/components/parsers/dateModel_directive.js new file mode 100644 index 00000000..1a014822 --- /dev/null +++ b/js/components/parsers/dateModel_directive.js @@ -0,0 +1,14 @@ +app.directive('dateModel', ['$filter', function($filter){ + return{ + restrict: 'A', + require: 'ngModel', + link: function(scope, element, attr, ngModel) { + ngModel.$formatters.push(function(value) { + return new Date(value); + }); + ngModel.$parsers.push(function(value) { + return $filter('date')(value, 'yyyy-MM-dd'); + }); + } + }; +}]); diff --git a/js/public/script.js b/js/public/script.js index 53be43de..59a0e6ac 100644 --- a/js/public/script.js +++ b/js/public/script.js @@ -193,31 +193,6 @@ app.directive('addressbooklist', function() { }; }); -app.controller('contactCtrl', ['$route', '$routeParams', function($route, $routeParams) { - var ctrl = this; - - ctrl.openContact = function() { - $route.updateParams({ - gid: $routeParams.gid, - uid: ctrl.contact.uid()}); - }; - - console.log("Contact: ",ctrl.contact); - -}]); - -app.directive('contact', function() { - return { - scope: {}, - controller: 'contactCtrl', - controllerAs: 'ctrl', - bindToController: { - contact: '=data' - }, - templateUrl: OC.linkTo('contacts', 'templates/contact.html') - }; -}); - app.controller('contactdetailsCtrl', ['ContactService', 'AddressBookService', 'vCardPropertiesService', '$routeParams', '$scope', function(ContactService, AddressBookService, vCardPropertiesService, $routeParams, $scope) { var ctrl = this; @@ -305,6 +280,31 @@ app.directive('contactdetails', function() { }; }); +app.controller('contactCtrl', ['$route', '$routeParams', function($route, $routeParams) { + var ctrl = this; + + ctrl.openContact = function() { + $route.updateParams({ + gid: $routeParams.gid, + uid: ctrl.contact.uid()}); + }; + + console.log("Contact: ",ctrl.contact); + +}]); + +app.directive('contact', function() { + return { + scope: {}, + controller: 'contactCtrl', + controllerAs: 'ctrl', + bindToController: { + contact: '=data' + }, + templateUrl: OC.linkTo('contacts', 'templates/contact.html') + }; +}); + app.controller('contactlistCtrl', ['$scope', '$filter', '$route', '$routeParams', 'ContactService', function($scope, $filter, $route, $routeParams, ContactService) { var ctrl = this; @@ -526,6 +526,21 @@ app.directive('grouplist', function() { }; }); +app.directive('dateModel', ['$filter', function($filter){ + return{ + restrict: 'A', + require: 'ngModel', + link: function(scope, element, attr, ngModel) { + ngModel.$formatters.push(function(value) { + return new Date(value); + }); + ngModel.$parsers.push(function(value) { + return $filter('date')(value, 'yyyy-MM-dd'); + }); + } + }; +}]); + app.directive('telModel', function(){ return{ restrict: 'A', diff --git a/templates/detailItems/date.html b/templates/detailItems/date.html index bc8bf3b7..cab0a9e0 100644 --- a/templates/detailItems/date.html +++ b/templates/detailItems/date.html @@ -1,6 +1,6 @@ <label for="details-{{ctrl.name}}">{{ctrl.meta.readableName}}</label> <input type="date" id="details-{{ctrl.name}}" name="{{ctrl.name}}" - ng-model="ctrl.data.value" ng-model-options="{ debounce: 500 }" + ng-model="ctrl.data.value" date-model ng-model-options="{ debounce: 500 }" ng-change="ctrl.model.updateContact()" value="" focus-expression="$parent.ctrl.focus === ctrl.name" /> |