mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
refactor(task-modal): enhance validation logic for concept tasks to support incomplete data
This commit is contained in:
1 parent
b70c0ceb8b
commit
415392eb9f
1 file changed
+29
-15
@@ -779,14 +779,21 @@ export default {
|
||||
this.$router.replace({ name: this.$route.name });
|
||||
},
|
||||
|
||||
async validateAllFields() {
|
||||
const employeesValid = await this._validateEmployees();
|
||||
const timeblocksValid = await this._validateTimeblocks();
|
||||
async validateAllFields(concept = false) {
|
||||
if (concept === false) {
|
||||
const employeesValid = await this._validateEmployees();
|
||||
const timeblocksValid = await this._validateTimeblocks();
|
||||
|
||||
if (!(await this.v$.$validate())) return;
|
||||
if (!employeesValid || !timeblocksValid) return;
|
||||
if (!(await this.v$.$validate())) return;
|
||||
if (!employeesValid || !timeblocksValid) return;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
} else {
|
||||
const employeesValid = await this._validateEmployees();
|
||||
if (!employeesValid) return;
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
async handleOnRemoveEmployee() {
|
||||
@@ -799,16 +806,18 @@ export default {
|
||||
|
||||
async save(concept = false) {
|
||||
this.wasFormValidationTriggered = true;
|
||||
if (!(await this.validateAllFields())) return;
|
||||
if (!(await this.validateAllFields(concept))) return;
|
||||
|
||||
this.subtask.description = this.$refs['description'].getHTML();
|
||||
this._mergeDeadlineTimeDate();
|
||||
|
||||
try {
|
||||
this.isSaving = true;
|
||||
this.subtask.deadline = moment(this.subtask.deadline).format(
|
||||
'YYYY-MM-DD HH:mm:SS',
|
||||
);
|
||||
|
||||
// Concept tasks may not have a deadline time set
|
||||
this.subtask.deadline = this.subtask.deadline
|
||||
? moment(this.subtask.deadline).format('YYYY-MM-DD HH:mm:SS')
|
||||
: null;
|
||||
|
||||
if (this.subtask?.id) {
|
||||
const timesheets = this.subtask.timesheets.map((timesheet) => {
|
||||
@@ -920,13 +929,18 @@ export default {
|
||||
},
|
||||
|
||||
_mergeDeadlineTimeDate() {
|
||||
const date = new Date(this.subtask.deadline);
|
||||
const timeParts = this.subtask._deadline_time.split(':');
|
||||
// Override for concept tasks which may not have a deadline time set (check for invalid date)
|
||||
if (isNaN(new Date(this.subtask.deadline).getTime())) {
|
||||
this.subtask.deadline = null;
|
||||
} else {
|
||||
const date = new Date(this.subtask.deadline);
|
||||
const timeParts = this.subtask._deadline_time.split(':');
|
||||
|
||||
date.setHours(parseInt(timeParts[0]));
|
||||
date.setMinutes(parseInt(timeParts[1]));
|
||||
date.setHours(parseInt(timeParts[0]));
|
||||
date.setMinutes(parseInt(timeParts[1]));
|
||||
|
||||
this.subtask.deadline = date;
|
||||
this.subtask.deadline = date;
|
||||
}
|
||||
},
|
||||
|
||||
_validateEmployees() {
|
||||
|
||||
Reference in new issue
Block a user