@@ -42,6 +42,8 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
4242 activities : Activity [ ] = [ ] ;
4343 goingToWorkOnThis = false ;
4444 shouldRestartEntry = false ;
45+ starDateValue ;
46+ endDateValue ;
4547
4648 constructor ( private formBuilder : FormBuilder , private store : Store < Merged > ,
4749 private actionsSubject$ : ActionsSubject , private toastrService : ToastrService ) {
@@ -139,6 +141,8 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
139141 uri : this . entryToEdit . uri ,
140142 technology : '' ,
141143 } ) ;
144+ this . starDateValue = formatDate ( get ( this . entryToEdit , 'start_date' , '00:00' ) , 'HH:mm' , 'en' ) ;
145+ this . endDateValue = formatDate ( get ( this . entryToEdit , 'end_date' , '00:00' ) , 'HH:mm' , 'en' ) ;
142146 } else {
143147 this . cleanForm ( ) ;
144148 }
@@ -204,13 +208,20 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
204208 }
205209 const startDate = this . entryForm . value . start_date ;
206210 const endDate = this . entryForm . value . end_date ;
211+ this . starDateValue = this . entryForm . value . start_hour === this . starDateValue ?
212+ this . entryToEdit . start_date :
213+ new Date ( `${ startDate } T${ this . entryForm . value . start_hour . trim ( ) } ` ) . toISOString ( ) ;
214+ this . endDateValue = this . entryForm . value . end_hour === this . endDateValue ?
215+ this . entryToEdit . end_date :
216+ new Date ( `${ endDate } T${ this . entryForm . value . end_hour . trim ( ) } ` ) . toISOString ( ) ;
217+
207218 const entry = {
208219 project_id : this . entryForm . value . project_id ,
209220 activity_id : this . entryForm . value . activity_id ,
210221 technologies : get ( this , 'selectedTechnologies' , [ ] ) ,
211222 description : this . entryForm . value . description ,
212- start_date : new Date ( ` ${ startDate } T ${ this . entryForm . value . start_hour . trim ( ) } ` ) . toISOString ( ) ,
213- end_date : new Date ( ` ${ endDate } T ${ this . entryForm . value . end_hour . trim ( ) } ` ) . toISOString ( ) ,
223+ start_date : this . starDateValue ,
224+ end_date : this . endDateValue ,
214225 uri : this . entryForm . value . uri ,
215226 timezone_offset : new Date ( ) . getTimezoneOffset ( ) ,
216227 } ;
0 commit comments