Skip to content

Commit

Permalink
Prevent timesheet overlaps.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeburg committed Sep 3, 2024
1 parent 091c505 commit 9987f84
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
16 changes: 14 additions & 2 deletions app/components/person/timesheet-manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,25 @@ export default class PersonTimesheetManageComponent extends Component {
*/

_saveCheckTimes(model) {
if (model.review_status !== STATUS_REJECTED && (model._changes['position_id'] || model._changes['on_duty'] || model._changes['off_duty'])) {
this.shiftManage.checkDateTime(model.position_id, model.on_duty, model.off_duty, () => this._checkForOverlaps(model));
if (model._changes['position_id'] || model._changes['on_duty'] || model._changes['off_duty']) {
if (model.review_status === STATUS_REJECTED) {
model.rollbackProperty('position_id');
model.rollbackProperty('on_duty');
model.rollbackProperty('off_duty');
this.modal.info('Correction Rejected - Position and times not changed',
`You changed position and/or times while corrections were rejected. The new positions and/or times have NOT be saved.`, this._saveCheckTimesCommon(model));
} else {
this._saveCheckTimesCommon(model);
}
} else {
this._saveCommon(model);
}
}

_saveCheckTimesCommon(model) {
this.shiftManage.checkDateTime(model.position_id, model.on_duty, model.off_duty, () => this._checkForOverlaps(model));
}

_checkForOverlaps(model) {
this.shiftManage.checkForOverlap(this.args.person.id, model.on_duty, model.off_duty, model.id, () => this._saveCommon(model));
}
Expand Down
2 changes: 2 additions & 0 deletions app/constants/positions.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export const TRAINER_UBER = 95;
export const TRAINING = 13;
export const TRAINING_RADIO_PRACTICE = 179;
export const TROUBLESHOOTER = 91;
export const TROUBLESHOOTER_LEAL = 147;
export const TROUBLESHOOTER_LEAL_PRE_EVENT = 148;
export const TROUBLESHOOTER_MENTEE = 127;
export const TROUBLESHOOTER_MENTOR = 128;
export const TROUBLESHOOTER_TRAINING = 94;
Expand Down
6 changes: 3 additions & 3 deletions app/services/shift-manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,15 @@ export default class ShiftManageService extends Service {
return callback();
}

let message = `<p>The time overlaps with the following timesheet entries:<ul>`;
let message = `<p class="text-danger">The time overlaps with the following timesheet entries:<ul>`;

timesheets.forEach((entry) => {
message += `<li>${entry.position.title} ${shiftFormat([entry.on_duty, entry.off_duty], {})}</li>`
});

message += '</ul>Use the Cancel button to correct the dates, or use Confirm to indicate the dates are correct.';
message += '</ul>The entries may not overlap. Double-check the times are correct. Update the status to Correction Rejected if this is a correction request.';

this.modal.confirm('Overlapping Timesheet Entries', message, callback);
this.modal.info('Overlapping Timesheet Entries', message);
}

}

0 comments on commit 9987f84

Please sign in to comment.