import {DateTimeController, DateTimeControllerScope} from '../../../src/components/renderers/controls/datetime/datetime.directive'; import {Testers, schemaTypeIs, schemaTypeMatches} from '../../../src/components/renderers/testers'; class DateTimeDirective implements ng.IDirective { restrict = 'E'; templateUrl = 'datetimeBootstrap.html'; controller = DateTimeBootstrapController; controllerAs = 'vm'; } class DateTimeBootstrapController extends DateTimeController { static $inject = ['$scope', 'PathResolver']; private isOpen: boolean = false; constructor(scope: DateTimeControllerScope) { super(scope); } public openDate() { this.isOpen = true; if (this.dt == null) { this.dt = new Date(); this.triggerChangeEvent(); } } protected updateDateObject() { let value = this.resolvedData[this.fragment]; if (value) { this.dt = new Date(value); } else { this.dt = null; } } } const datetimeTemplate = `
`; export default angular .module('jsonforms-bootstrap.renderers.controls.datetime', ['jsonforms-bootstrap.renderers.controls']) .directive('datetimeBootstrapControl', () => new DateTimeDirective()) .run(['RendererService', RendererService => RendererService.register('datetime-bootstrap-control', Testers.and( schemaTypeIs('string'), schemaTypeMatches(el => _.has(el, 'format') && el['format'] === 'date') ), 10) ]) .run(['$templateCache', $templateCache => { $templateCache.put('datetimeBootstrap.html', datetimeTemplate); }]) .name;