@@ -712,7 +712,7 @@ export class WorkdayEntityDialogComponent implements OnInit {
712712 const p2Start = this . getCtrl ( 'planned.shift2.start' ) . value as string | null ;
713713 const p2Stop = this . getCtrl ( 'planned.shift2.stop' ) . value as string | null ;
714714
715- const isSet = ( time : string | null ) => ! ! time && time !== '00:00' ;
715+ const isSet = ( time : string | null ) => ! ! time ; // && time !== '00:00';
716716
717717 // Plan hours enabled only if shift 1 start & stop are empty or 00:00
718718 if ( ( ! p1Start && ! p1Stop ) || ( p1Start === '00:00' && p1Stop === '00:00' ) ) {
@@ -730,7 +730,11 @@ export class WorkdayEntityDialogComponent implements OnInit {
730730
731731 if ( isSet ( p1Stop ) ) {
732732 this . setDisabled ( 'planned.shift1.break' , false ) ;
733- this . setDisabled ( 'planned.shift2.start' , false ) ;
733+ if ( p1Stop !== '00:00' ) {
734+ this . setDisabled ( 'planned.shift2.start' , false ) ;
735+ } else {
736+ this . setDisabled ( 'planned.shift2.start' , true ) ;
737+ }
734738 } else {
735739 this . setDisabled ( 'planned.shift1.break' , true ) ;
736740 this . setDisabled ( 'planned.shift2.start' , true ) ;
@@ -745,30 +749,41 @@ export class WorkdayEntityDialogComponent implements OnInit {
745749
746750 if ( isSet ( p2Stop ) ) {
747751 this . setDisabled ( 'planned.shift2.break' , false ) ;
748- if ( this . data . assignedSiteModel . thirdShiftActive )
749- { this . setDisabled ( 'planned.shift3.start' , false ) ; }
752+ if ( this . data . assignedSiteModel . thirdShiftActive && p2Stop !== '00:00' ) {
753+ this . setDisabled ( 'planned.shift3.start' , false ) ;
754+ } else {
755+ this . setDisabled ( 'planned.shift3.start' , true ) ;
756+ }
750757 } else {
751758 this . setDisabled ( 'planned.shift2.break' , true ) ;
752- if ( this . data . assignedSiteModel . thirdShiftActive )
753- { this . setDisabled ( 'planned.shift3.start' , true ) ; }
759+ if ( this . data . assignedSiteModel . thirdShiftActive ) {
760+ this . setDisabled ( 'planned.shift3.start' , true ) ;
761+ }
754762 }
755763
756764 // Shift 3
757765 if ( this . data . assignedSiteModel . thirdShiftActive ) {
758766 const p3Start = this . getCtrl ( 'planned.shift3.start' ) . value as string | null ;
759767 const p3Stop = this . getCtrl ( 'planned.shift3.stop' ) . value as string | null ;
760768
761- if ( isSet ( p3Start ) ) { this . setDisabled ( 'planned.shift3.stop' , false ) ; }
762- else { this . setDisabled ( 'planned.shift3.stop' , true ) ; }
769+ if ( isSet ( p3Start ) ) {
770+ this . setDisabled ( 'planned.shift3.stop' , false ) ;
771+ } else {
772+ this . setDisabled ( 'planned.shift3.stop' , true ) ;
773+ }
763774
764775 if ( isSet ( p3Stop ) ) {
765776 this . setDisabled ( 'planned.shift3.break' , false ) ;
766- if ( this . data . assignedSiteModel . fourthShiftActive )
767- { this . setDisabled ( 'planned.shift4.start' , false ) ; }
777+ if ( this . data . assignedSiteModel . fourthShiftActive && p3Stop !== '00:00' ) {
778+ this . setDisabled ( 'planned.shift4.start' , false ) ;
779+ } else {
780+ this . setDisabled ( 'planned.shift4.start' , true ) ;
781+ }
768782 } else {
769783 this . setDisabled ( 'planned.shift3.break' , true ) ;
770- if ( this . data . assignedSiteModel . fourthShiftActive )
771- { this . setDisabled ( 'planned.shift4.start' , true ) ; }
784+ if ( this . data . assignedSiteModel . fourthShiftActive ) {
785+ this . setDisabled ( 'planned.shift4.start' , true ) ;
786+ }
772787 }
773788 }
774789
@@ -777,17 +792,24 @@ export class WorkdayEntityDialogComponent implements OnInit {
777792 const p4Start = this . getCtrl ( 'planned.shift4.start' ) . value as string | null ;
778793 const p4Stop = this . getCtrl ( 'planned.shift4.stop' ) . value as string | null ;
779794
780- if ( isSet ( p4Start ) ) { this . setDisabled ( 'planned.shift4.stop' , false ) ; }
781- else { this . setDisabled ( 'planned.shift4.stop' , true ) ; }
795+ if ( isSet ( p4Start ) ) {
796+ this . setDisabled ( 'planned.shift4.stop' , false ) ;
797+ } else {
798+ this . setDisabled ( 'planned.shift4.stop' , true ) ;
799+ }
782800
783801 if ( isSet ( p4Stop ) ) {
784802 this . setDisabled ( 'planned.shift4.break' , false ) ;
785- if ( this . data . assignedSiteModel . fifthShiftActive )
786- { this . setDisabled ( 'planned.shift5.start' , false ) ; }
803+ if ( this . data . assignedSiteModel . fifthShiftActive && p4Stop !== '00:00' ) {
804+ this . setDisabled ( 'planned.shift5.start' , false ) ;
805+ } else {
806+ this . setDisabled ( 'planned.shift5.start' , true ) ;
807+ }
787808 } else {
788809 this . setDisabled ( 'planned.shift4.break' , true ) ;
789- if ( this . data . assignedSiteModel . fifthShiftActive )
790- { this . setDisabled ( 'planned.shift5.start' , true ) ; }
810+ if ( this . data . assignedSiteModel . fifthShiftActive ) {
811+ this . setDisabled ( 'planned.shift5.start' , true ) ;
812+ }
791813 }
792814 }
793815
@@ -796,11 +818,17 @@ export class WorkdayEntityDialogComponent implements OnInit {
796818 const p5Start = this . getCtrl ( 'planned.shift5.start' ) . value as string | null ;
797819 const p5Stop = this . getCtrl ( 'planned.shift5.stop' ) . value as string | null ;
798820
799- if ( isSet ( p5Start ) ) { this . setDisabled ( 'planned.shift5.stop' , false ) ; }
800- else { this . setDisabled ( 'planned.shift5.stop' , true ) ; }
821+ if ( isSet ( p5Start ) ) {
822+ this . setDisabled ( 'planned.shift5.stop' , false ) ;
823+ } else {
824+ this . setDisabled ( 'planned.shift5.stop' , true ) ;
825+ }
801826
802- if ( isSet ( p5Stop ) ) { this . setDisabled ( 'planned.shift5.break' , false ) ; }
803- else { this . setDisabled ( 'planned.shift5.break' , true ) ; }
827+ if ( isSet ( p5Stop ) ) {
828+ this . setDisabled ( 'planned.shift5.break' , false ) ;
829+ } else {
830+ this . setDisabled ( 'planned.shift5.break' , true ) ;
831+ }
804832 }
805833
806834 // Actual
@@ -844,7 +872,11 @@ export class WorkdayEntityDialogComponent implements OnInit {
844872
845873 if ( a2Stop ) {
846874 this . setDisabled ( 'actual.shift2.pause' , false ) ;
847- this . setDisabled ( 'actual.shift3.start' , false ) ;
875+ if ( this . data . assignedSiteModel . thirdShiftActive && a2Stop !== '00:00' ) {
876+ this . setDisabled ( 'actual.shift3.start' , false ) ;
877+ } else {
878+ this . setDisabled ( 'actual.shift3.start' , true ) ;
879+ }
848880 }
849881
850882 if ( this . data . assignedSiteModel . thirdShiftActive ) {
@@ -857,7 +889,11 @@ export class WorkdayEntityDialogComponent implements OnInit {
857889 }
858890 if ( a3Stop ) {
859891 this . setDisabled ( 'actual.shift3.pause' , false ) ;
860- this . setDisabled ( 'actual.shift4.start' , false ) ;
892+ if ( this . data . assignedSiteModel . fourthShiftActive && a3Stop !== '00:00' ) {
893+ this . setDisabled ( 'actual.shift4.start' , false ) ;
894+ } else {
895+ this . setDisabled ( 'actual.shift4.start' , true ) ;
896+ }
861897 }
862898 }
863899
@@ -871,7 +907,11 @@ export class WorkdayEntityDialogComponent implements OnInit {
871907 }
872908 if ( a4Stop ) {
873909 this . setDisabled ( 'actual.shift4.pause' , false ) ;
874- this . setDisabled ( 'actual.shift5.start' , false ) ;
910+ if ( this . data . assignedSiteModel . fifthShiftActive && a4Stop !== '00:00' ) {
911+ this . setDisabled ( 'actual.shift5.start' , false ) ;
912+ } else {
913+ this . setDisabled ( 'actual.shift5.start' , true ) ;
914+ }
875915 }
876916 }
877917
@@ -886,7 +926,6 @@ export class WorkdayEntityDialogComponent implements OnInit {
886926 this . setDisabled ( 'actual.shift5.pause' , false ) ;
887927 }
888928 }
889-
890929 }
891930
892931 // ===== UI-hjælpere (samme logik som tidligere, men brugt af form) =====
@@ -1039,6 +1078,7 @@ export class WorkdayEntityDialogComponent implements OnInit {
10391078 const s5 = this . workdayForm . get ( 'planned.shift5' ) as FormGroup ;
10401079 switch ( number ) {
10411080 case 1 :
1081+ this . workdayForm . get ( 'planHours' ) ?. setValue ( 0 , { emitEvent : false } ) ;
10421082 s1 . patchValue ( { start : null , break : null , stop : null } ) ;
10431083 s2 . patchValue ( { start : null , break : null , stop : null } ) ;
10441084 s3 . patchValue ( { start : null , break : null , stop : null } ) ;
@@ -1275,7 +1315,7 @@ export class WorkdayEntityDialogComponent implements OnInit {
12751315 }
12761316
12771317
1278- private getPlannedShiftMinutes (
1318+ private getPlannedShiftMinutes (
12791319 start : number | null ,
12801320 end : number | null ,
12811321 breakMinutes : number | null
@@ -1299,10 +1339,10 @@ private getPlannedShiftMinutes(
12991339
13001340 markAllAsTouched ( control : AbstractControl ) {
13011341 if ( control instanceof FormControl ) {
1302- control . markAsTouched ( { onlySelf : true } ) ;
1342+ control . markAsTouched ( { onlySelf : true } ) ;
13031343 } else if ( control instanceof FormGroup ) {
13041344 Object . values ( control . controls ) . forEach ( ( c ) => this . markAllAsTouched ( c ) ) ;
1305- control . markAsTouched ( { onlySelf : true } ) ;
1345+ control . markAsTouched ( { onlySelf : true } ) ;
13061346 } else if ( control instanceof FormArray ) {
13071347 control . controls . forEach ( ( c ) => this . markAllAsTouched ( c ) ) ;
13081348 }
0 commit comments