Skip to content

Commit 13511fa

Browse files
committed
Merge branch 'master' into stable
2 parents c2a139d + f4cd8c4 commit 13511fa

File tree

4 files changed

+81
-21
lines changed

4 files changed

+81
-21
lines changed

eform-client/cypress/e2e/plugins/time-planning-pn/b/dashboard-edit-b.spec.cy.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ const secondUpdateActualTexts = [
118118
{ date: nextWeekDates[2], start1StartedAt: '07:15', stop1StoppedAt: '16:00', pause1Id: '01:00', start2StartedAt: '17:00', stop2StoppedAt: '20:00', pause2Id: '00:30', plannedHours: '8:00', flexBalanceToDate: 'swap_vert97.03', flexToDate: '97.03', flexIncludingToday: '97.03', nettoHours: '10.25', todaysFlex: '0.00', paidOutFlex: 0, calculatedHours: '10.25' },
119119
{ date: nextWeekDates[3], start1StartedAt: '06:00', stop1StoppedAt: '12:00', pause1Id: '00:30', start2StartedAt: '18:00', stop2StoppedAt: '20:00', pause2Id: '00:30', plannedHours: '8:00', flexBalanceToDate: 'swap_vert97.03', flexToDate: '97.03', flexIncludingToday: '97.03', nettoHours: '7.00', todaysFlex: '0.00', paidOutFlex: 0, calculatedHours: '7' },
120120
{ date: nextWeekDates[4], start1StartedAt: '06:00', stop1StoppedAt: '12:00' , pause1Id: '01:50' , start2StartedAt: '18:00' , stop2StoppedAt: '20:00' , pause2Id: '01:50' , plannedHours: '8.0' , flexBalanceToDate: 'swap_vert94.70' , flexToDate: '97.03' , flexIncludingToday: '94.70' , nettoHours: '4.33' , todaysFlex: '-2.33' , paidOutFlex : 0, calculatedHours : 6.666666666666667 },
121-
{ date : nextWeekDates[5] , start1StartedAt : '00:00' , stop1StoppedAt : '00:00' , pause1Id : '00:00' , start2StartedAt : '00:00' , stop2StoppedAt : '00:00' , pause2Id : '00:00' , plannedHours : '' , flexBalanceToDate : 'swap_vert88.36' , flexToDate : '94.70' , flexIncludingToday : '88.36' , nettoHours : '0.00' , todaysFlex : '-6.33' , paidOutFlex : 0 , calculatedHours : 6.333333333333333 },
122-
{ date : lastWeekDates[6] , start1StartedAt : '06:00' , stop1StoppedAt : '14:00' , pause1Id : '00:30' , start2StartedAt : '00:00' , stop2StoppedAt : '00:00' , pause2Id : '00:00' , plannedHours : '8:00' , flexBalanceToDate : 'swap_vert88.36' , flexToDate : '88.36' , flexIncludingToday : '88.36' , nettoHours : '7.50' , todaysFlex : '0.00' , paidOutFlex : 0 , calculatedHours : '7.5' }
121+
{ date : nextWeekDates[5] , start1StartedAt : '' , stop1StoppedAt : '' , pause1Id : '' , start2StartedAt : '' , stop2StoppedAt : '' , pause2Id : '' , plannedHours : '' , flexBalanceToDate : 'swap_vert88.36' , flexToDate : '94.70' , flexIncludingToday : '88.36' , nettoHours : '0.00' , todaysFlex : '-6.33' , paidOutFlex : 0 , calculatedHours : 6.333333333333333 },
122+
{ date : lastWeekDates[6] , start1StartedAt : '06:00' , stop1StoppedAt : '14:00' , pause1Id : '00:30' , start2StartedAt : '' , stop2StoppedAt : '' , pause2Id : '' , plannedHours : '8:00' , flexBalanceToDate : 'swap_vert88.36' , flexToDate : '88.36' , flexIncludingToday : '88.36' , nettoHours : '7.50' , todaysFlex : '0.00' , paidOutFlex : 0 , calculatedHours : '7.5' }
123123
];
124124

125125
describe('Dashboard edit values', () => {
@@ -144,7 +144,7 @@ describe('Dashboard edit values', () => {
144144
cy.get(cellId).click();
145145
cy.get('#planHours').should('be.visible');
146146

147-
if (secondUpdateActualTexts[i].start1StartedAt !== '') {
147+
if (secondUpdateActualTexts[i].start1StartedAt !== '' && secondUpdateActualTexts[i].start1StartedAt !== '00:00') {
148148
cy.get(`#start1StartedAt`).click();
149149
// eslint-disable-next-line max-len
150150
let degrees0 = 360 / 12 * parseInt(secondUpdateActualTexts[i].start1StartedAt.split(':')[0]);
@@ -165,7 +165,7 @@ describe('Dashboard edit values', () => {
165165
}
166166
cy.get('#start1StartedAt').should('have.value', secondUpdateActualTexts[i].start1StartedAt);
167167

168-
if (secondUpdateActualTexts[i].stop1StoppedAt !== '') {
168+
if (secondUpdateActualTexts[i].stop1StoppedAt !== '' && secondUpdateActualTexts[i].stop1StoppedAt !== '00:00') {
169169
cy.get(`#stop1StoppedAt`).click();
170170
// eslint-disable-next-line max-len
171171
let degrees1 = 360 / 12 * parseInt(secondUpdateActualTexts[i].stop1StoppedAt.split(':')[0]);
@@ -189,7 +189,7 @@ describe('Dashboard edit values', () => {
189189
}
190190
cy.get('#stop1StoppedAt').should('have.value', secondUpdateActualTexts[i].stop1StoppedAt);
191191

192-
if (secondUpdateActualTexts[i].pause1Id !== '' || secondUpdateActualTexts[i].pause1Id !== '00:00') {
192+
if (secondUpdateActualTexts[i].pause1Id !== '' && secondUpdateActualTexts[i].pause1Id !== '00:00') {
193193
cy.get(`#pause1Id`).click();
194194
// eslint-disable-next-line max-len
195195
let degrees2 = 360 / 12 * parseInt(secondUpdateActualTexts[i].pause1Id.split(':')[0]);
@@ -212,10 +212,10 @@ describe('Dashboard edit values', () => {
212212
cy.get('.timepicker-button span').contains('Ok').click();
213213
cy.get('#pause1Id').should('have.value', secondUpdateActualTexts[i].pause1Id);
214214
} else {
215-
cy.get('#pause1Id').should('have.value', '00:00');
215+
cy.get('#pause1Id').should('have.value', '');
216216
}
217217

218-
if (secondUpdateActualTexts[i].start2StartedAt !== '' || secondUpdateActualTexts[i].start2StartedAt !== '00:00') {
218+
if (secondUpdateActualTexts[i].start2StartedAt !== '' && secondUpdateActualTexts[i].start2StartedAt !== '00:00') {
219219
cy.get(`#start2StartedAt`).click();
220220
// eslint-disable-next-line max-len
221221
let degrees3 = 360 / 12 * parseInt(secondUpdateActualTexts[i].start2StartedAt.split(':')[0]);
@@ -239,7 +239,7 @@ describe('Dashboard edit values', () => {
239239
}
240240
cy.get('#start2StartedAt').should('have.value', secondUpdateActualTexts[i].start2StartedAt);
241241

242-
if (secondUpdateActualTexts[i].stop2StoppedAt !== '' || secondUpdateActualTexts[i].stop2StoppedAt !== '00:00' ) {
242+
if (secondUpdateActualTexts[i].stop2StoppedAt !== '' && secondUpdateActualTexts[i].stop2StoppedAt !== '00:00' ) {
243243
cy.get(`#stop2StoppedAt`).click();
244244
// eslint-disable-next-line max-len
245245
let degrees4 = 360 / 12 * parseInt(secondUpdateActualTexts[i].stop2StoppedAt.split(':')[0]);
@@ -263,7 +263,7 @@ describe('Dashboard edit values', () => {
263263
}
264264
cy.get('#stop2StoppedAt').should('have.value', secondUpdateActualTexts[i].stop2StoppedAt);
265265

266-
if (secondUpdateActualTexts[i].pause2Id !== '' || secondUpdateActualTexts[i].pause2Id !== '00:00') {
266+
if (secondUpdateActualTexts[i].pause2Id !== '' && secondUpdateActualTexts[i].pause2Id !== '00:00') {
267267
cy.get(`#pause2Id`).click();
268268
// eslint-disable-next-line max-len
269269
let degrees5 = 360 / 12 * parseInt(secondUpdateActualTexts[i].pause2Id.split(':')[0]);

eform-client/cypress/e2e/plugins/time-planning-pn/f/dashboard-edit-a.spec.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ describe('Dashboard edit values', () => {
7373

7474
it('should show an error when planned break is longer than the shift duration', () => {
7575
setTimepickerValue('#plannedStartOfShift1', '1', '00');
76-
setTimepickerValue('#plannedBreakOfShift1', '9', '00');
7776
setTimepickerValue('#plannedEndOfShift1', '10', '00');
77+
setTimepickerValue('#plannedBreakOfShift1', '9', '00');
7878
assertInputError('plannedBreakOfShift1-Error', 'Break cannot be equal or longer than shift duration');
7979
});
8080

eform-client/src/app/plugins/modules/time-planning-pn/components/plannings/time-planning-actions/workday-entity/workday-entity-dialog.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@
763763
{{ 'Cancel' | translate }}
764764
</button>
765765

766+
<!-- [disabled]="workdayForm.invalid"-->
767+
766768
<button
767769
id="saveButton"
768770
mat-raised-button

eform-client/src/app/plugins/modules/time-planning-pn/components/plannings/time-planning-actions/workday-entity/workday-entity-dialog.component.ts

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,14 @@ export class WorkdayEntityDialogComponent implements OnInit {
550550
}
551551
}
552552

553+
// Disallow pause = 00:00
554+
if (breakMin === 0) {
555+
setError(pauseControl, 'invalidPause', 'Pause cannot be 00:00');
556+
} else {
557+
removeError(pauseControl, 'invalidPause');
558+
}
559+
560+
553561
if (duration > 24 * 60) {
554562
setError(group, 'shiftTooLong', 'Shift duration cannot exceed 24 hours');
555563
} else {
@@ -655,6 +663,24 @@ export class WorkdayEntityDialogComponent implements OnInit {
655663
const prevEnd = this.parseTimeToMinutes(prevShift.get('stop')?.value);
656664
const currStart = this.parseTimeToMinutes(currShift.get('start')?.value);
657665

666+
// Disallow 00:00 as start for shifts > 1
667+
if (i > 0 && currStart === 0) {
668+
currShift.get('start')?.setErrors({
669+
...(currShift.get('start')?.errors || {}),
670+
invalidStart: `Start time 00:00 is not allowed for ${label} Shift ${i + 1}`,
671+
});
672+
673+
if (!formError) {
674+
formError = `${label} Shift ${i + 1} cannot start at 00:00`;
675+
}
676+
} else {
677+
const errors = currShift.get('start')?.errors;
678+
if (errors && errors['invalidStart']) {
679+
delete errors['invalidStart'];
680+
currShift.get('start')?.setErrors(Object.keys(errors).length ? errors : null);
681+
}
682+
}
683+
658684
if (prevEnd !== null && (currStart !== null && currStart !== 0)) {
659685
if (currStart < prevEnd) {
660686
currShift.get('start')?.setErrors({
@@ -990,24 +1016,24 @@ export class WorkdayEntityDialogComponent implements OnInit {
9901016
const s2 = this.workdayForm.get('planned.shift2') as FormGroup;
9911017
switch (number) {
9921018
case 1:
993-
s1.patchValue({start: '00:00', break: '00:00', stop: '00:00'});
994-
s2.patchValue({start: '00:00', break: '00:00', stop: '00:00'});
1019+
s1.patchValue({start: null, break: null, stop: null});
1020+
s2.patchValue({start: null, break: null, stop: null});
9951021
break;
9961022
case 2:
997-
s1.patchValue({break: '00:00'});
1023+
s1.patchValue({break: null});
9981024
break;
9991025
case 3:
1000-
s1.patchValue({break: '00:00', stop: '00:00'});
1001-
s2.patchValue({start: '00:00', break: '00:00', stop: '00:00'});
1026+
s1.patchValue({break: null, stop: null});
1027+
s2.patchValue({start: null, break: null, stop: null});
10021028
break;
10031029
case 4:
1004-
s2.patchValue({start: '00:00', break: '00:00', stop: '00:00'});
1030+
s2.patchValue({start: null, break: null, stop: null});
10051031
break;
10061032
case 5:
1007-
s2.patchValue({break: '00:00'});
1033+
s2.patchValue({break: null});
10081034
break;
10091035
case 6:
1010-
s2.patchValue({break: '00:00', stop: '00:00'});
1036+
s2.patchValue({break: null, stop: null});
10111037
break;
10121038
}
10131039
this.calculatePlanHours();
@@ -1053,8 +1079,8 @@ export class WorkdayEntityDialogComponent implements OnInit {
10531079
const p4 = this.workdayForm.get('planned.shift4')?.value as { start: string; break: string; stop: string };
10541080
const p5 = this.workdayForm.get('planned.shift5')?.value as { start: string; break: string; stop: string };
10551081

1056-
this.data.planningPrDayModels.plannedStartOfShift1 = this.convertTimeToMinutes(p1?.start);
1057-
this.data.planningPrDayModels.plannedEndOfShift1 = this.convertTimeToMinutes(p1?.stop);
1082+
this.data.planningPrDayModels.plannedStartOfShift1 = this.convertTimeToMinutes(p1?.start ?? '00:00');
1083+
this.data.planningPrDayModels.plannedEndOfShift1 = this.convertTimeToMinutes(p1?.stop ?? '00:00');
10581084
this.data.planningPrDayModels.plannedBreakOfShift1 = this.convertTimeToMinutes(p1?.break ?? '00:00');
10591085

10601086
this.data.planningPrDayModels.plannedStartOfShift2 = this.convertTimeToMinutes(p2?.start ?? '00:00');
@@ -1124,7 +1150,39 @@ export class WorkdayEntityDialogComponent implements OnInit {
11241150
// Rens paidOutFlex
11251151
this.data.planningPrDayModels.paidOutFlex =
11261152
this.data.planningPrDayModels.paidOutFlex === null ? 0 : this.data.planningPrDayModels.paidOutFlex;
1127-
this.data.planningPrDayModels.commentOffice = this.workdayForm.get('commentOffice')?.value;
1153+
}
1154+
1155+
private getPlannedShiftMinutes(
1156+
start: number | null,
1157+
end: number | null,
1158+
breakMinutes: number | null
1159+
): number {
1160+
if (start === null || end === null || start === end) {
1161+
return 0;
1162+
}
1163+
1164+
let duration = end - start;
1165+
1166+
if (end <= start) {
1167+
duration = (1440 - start) + end;
1168+
}
1169+
1170+
if (breakMinutes) {
1171+
duration -= breakMinutes;
1172+
}
1173+
1174+
return Math.max(0, duration);
1175+
}
1176+
1177+
markAllAsTouched(control: AbstractControl) {
1178+
if (control instanceof FormControl) {
1179+
control.markAsTouched({ onlySelf: true });
1180+
} else if (control instanceof FormGroup) {
1181+
Object.values(control.controls).forEach((c) => this.markAllAsTouched(c));
1182+
control.markAsTouched({ onlySelf: true });
1183+
} else if (control instanceof FormArray) {
1184+
control.controls.forEach((c) => this.markAllAsTouched(c));
1185+
}
11281186
}
11291187

11301188
private getPlannedShiftMinutes(

0 commit comments

Comments
 (0)