Display error if created schedules are incomplete
@@ -824,7 +824,6 @@ export default {
})
},
createAndAddSchedule (restriction, schedule) {
- if (schedule.hourStart && schedule.hourEnd && schedule.scheduleDays) {
api
.request('post', '/schedules', this.$store.state.accessToken, {
'hourStart': schedule.hourStart,
@@ -839,7 +838,6 @@ export default {
this.handleError(error)
this.modalAlert = true
})
- }
},
addScheduleToRestriction (restriction, schedule) {
api
@@ -867,6 +865,7 @@ export default {
if (this.editMode) this.updateRestriction()
else if (this.modalStartDate && this.modalStartTime &&
((this.modalEndDate && this.modalEndTime) || this.infiniteRestriction)) {
+ if (this.verifyTempSchedules()) {
var formattedStart = moment(this.modalStartDate + 'T' + this.modalStartTime).toISOString()
var restrictionToCreate = {
name: this.modalRestrictionName,
@@ -910,11 +909,19 @@ export default {
this.handleError(error)
this.modalAlert = true
})
+ } else {
+ this.errorMessage = 'Specify details for all schedules you want to create'
+ this.modalAlert = true
+ }
} else {
this.errorMessage = 'Specify start and end date and time!'
this.modalAlert = true
}
},
+ verifyTempSchedules () {
+ if (this.tempSchedules.length === 0) return true
+ else return this.tempSchedules.every(s => s.hourStart && s.hourEnd && s.scheduleDays.length > 0)
+ },
removeRestriction () {
var restrictionId = this.restrictionId
api
@@ -954,6 +961,7 @@ export default {
updateRestriction () {
if (this.modalStartDate && this.modalStartTime &&
((this.modalEndDate && this.modalEndTime) || this.infiniteRestriction)) {
+ if (this.verifyTempSchedules()) {
var formattedStart = moment(this.modalStartDate + 'T' + this.modalStartTime).toISOString()
var formattedEnd = null
if (!this.infiniteRestriction) {
@@ -1034,6 +1042,10 @@ export default {
}
}
this.clearForm()
+ } else {
+ this.errorMessage = 'Specify details for every schedule'
+ this.modalAlert = true
+ }
} else {
this.errorMessage = 'Specify start and end date and time!'
this.modalAlert = true
