<commit_before>angular.module('app').directive('uxdDatePickerWrapper', () => {
    return {
        restrict: 'E',
        controller: 'DatePickerCtrl as vm',
        template: require('./date-picker-wrapper.directive.html'),
        scope: true
    };
});

angular.module('app').controller('DatePickerCtrl', DatePickerCtrl);

function DatePickerCtrl($scope: angular.IScope) {
    var vm = this;

    vm.$onDestroy = function() {
       $scope.$destroy();
    };

    vm.date = new Date();
    vm.opened = false;

    vm.open = function($event: any) {
        $event.preventDefault();
        $event.stopPropagation();
        vm.opened = true;
    };

    vm.openKey = function($event: any) {
        if ($event.which === 13) {
            $event.preventDefault();
            $event.stopPropagation();
            vm.opened = true;
        }
    };

    vm.change = function() {
        var customdate = new Date(vm.date);

        if (isNaN(customdate as any)) {
            vm.date = new Date();
        } else if(vm.date !== vm.prevdate) {
            vm.date = new Date(vm.date);
            vm.prevdate = vm.date;
        }
    };
}<commit_msg>EL-2380 - Fixing issue with date picker<commit_after>angular.module('app').directive('uxdDatePickerWrapper', () => {
    return {
        restrict: 'E',
        controller: 'DatePickerCtrl as vm',
        template: require('./date-picker-wrapper.directive.html'),
        scope: true
    };
});

angular.module('app').controller('DatePickerCtrl', ['$scope', DatePickerCtrl]);

function DatePickerCtrl($scope: angular.IScope) {
    var vm = this;

    vm.$onDestroy = function() {
       $scope.$destroy();
    };

    vm.date = new Date();
    vm.opened = false;

    vm.open = function($event: any) {
        $event.preventDefault();
        $event.stopPropagation();
        vm.opened = true;
    };

    vm.openKey = function($event: any) {
        if ($event.which === 13) {
            $event.preventDefault();
            $event.stopPropagation();
            vm.opened = true;
        }
    };

    vm.change = function() {
        var customdate = new Date(vm.date);

        if (isNaN(customdate as any)) {
            vm.date = new Date();
        } else if(vm.date !== vm.prevdate) {
            vm.date = new Date(vm.date);
            vm.prevdate = vm.date;
        }
    };
}
{'fraction_non_alphanumeric': 0.15982905982905982, 'fraction_numerical': 0.003418803418803419, 'mean_word_length': 2.0561357702349867, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6894980', 'n_tokens_mistral': 718, 'n_tokens_neox': 704, 'n_words': 138}