export class HashiDatePickerController { public static NAME: string = "HashiDatePickerController"; public static NAME_AS = `${HashiDatePickerController.NAME} as controller`; public static $inject: string[] = ["$scope"]; public dateWithParts: HashidevDashboardCore.IDateWithParts; private lastSavedDate: Date; public isRequired: boolean; private funcitonForNotification: Function; constructor( $scope: ng.IScope) { this.funcitonForNotification = $scope["onChange"]; this.dateWithParts = $scope["dateWithParts"] as HashidevDashboardCore.IDateWithParts; this.dateWithParts.onChange(); this.snapAsLastSaved(); this.isRequired = $scope["isRequired"]; } public get isDirty(): boolean { return this.lastSavedDate !== this.dateWithParts.fullDate; } private snapAsLastSaved() { this.lastSavedDate = this.dateWithParts.fullDate; } public valuesHaveChanged() { this.dateWithParts.onChange(); } public onRemoveClicked() { this.dateWithParts.clear(); this.snapAsLastSaved(); this.funcitonForNotification(null); } public onSaveClicked() { this.dateWithParts.onChange(); this.snapAsLastSaved(); this.funcitonForNotification(this.dateWithParts.fullDate); } }