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 });
|
this.$router.replace({ name: this.$route.name });
|
||||||
},
|
},
|
||||||
|
|
||||||
async validateAllFields() {
|
async validateAllFields(concept = false) {
|
||||||
const employeesValid = await this._validateEmployees();
|
if (concept === false) {
|
||||||
const timeblocksValid = await this._validateTimeblocks();
|
const employeesValid = await this._validateEmployees();
|
||||||
|
const timeblocksValid = await this._validateTimeblocks();
|
||||||
|
|
||||||
if (!(await this.v$.$validate())) return;
|
if (!(await this.v$.$validate())) return;
|
||||||
if (!employeesValid || !timeblocksValid) return;
|
if (!employeesValid || !timeblocksValid) return;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
const employeesValid = await this._validateEmployees();
|
||||||
|
if (!employeesValid) return;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async handleOnRemoveEmployee() {
|
async handleOnRemoveEmployee() {
|
||||||
@@ -799,16 +806,18 @@ export default {
|
|||||||
|
|
||||||
async save(concept = false) {
|
async save(concept = false) {
|
||||||
this.wasFormValidationTriggered = true;
|
this.wasFormValidationTriggered = true;
|
||||||
if (!(await this.validateAllFields())) return;
|
if (!(await this.validateAllFields(concept))) return;
|
||||||
|
|
||||||
this.subtask.description = this.$refs['description'].getHTML();
|
this.subtask.description = this.$refs['description'].getHTML();
|
||||||
this._mergeDeadlineTimeDate();
|
this._mergeDeadlineTimeDate();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.isSaving = true;
|
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) {
|
if (this.subtask?.id) {
|
||||||
const timesheets = this.subtask.timesheets.map((timesheet) => {
|
const timesheets = this.subtask.timesheets.map((timesheet) => {
|
||||||
@@ -920,13 +929,18 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_mergeDeadlineTimeDate() {
|
_mergeDeadlineTimeDate() {
|
||||||
const date = new Date(this.subtask.deadline);
|
// Override for concept tasks which may not have a deadline time set (check for invalid date)
|
||||||
const timeParts = this.subtask._deadline_time.split(':');
|
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.setHours(parseInt(timeParts[0]));
|
||||||
date.setMinutes(parseInt(timeParts[1]));
|
date.setMinutes(parseInt(timeParts[1]));
|
||||||
|
|
||||||
this.subtask.deadline = date;
|
this.subtask.deadline = date;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_validateEmployees() {
|
_validateEmployees() {
|
||||||
|
|||||||
Reference in new issue
Block a user