Skip to content

Commit

Permalink
fix: vehicle time window
Browse files Browse the repository at this point in the history
  • Loading branch information
blackbirdem committed May 10, 2024
1 parent 1391066 commit 9822675
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<v-item-group v-if="vehiclesBox" style="margin: 10px 15px 0 0; border: solid lightgray 1px; padding: 10px">
<v-layout class="profile-options-wrapper">
<v-item v-for="profile in profilesMapping" :key="profile.slug">
<v-flex style="min-width:45px">
<v-flex style="min-width: 48px">
<profile-selector-option @profileSelected="profileSelected" :profile="profile"
:active-profile-slug="vehicleProfile(i)" :active-vehicle-type="editData[i].profile"
:is-vehicle="true">
Expand All @@ -83,8 +83,11 @@
</v-item-group>
<v-text-field v-if="vehiclesBox" v-model.number="editData[i].capacity[0]" type="number" style="width: 50%" :persistent-hint="true" :hint="'Capacity'"></v-text-field>
</v-layout>
<v-text-field v-if="jobsBox" v-model.number="editData[i].service" :persistent-hint="true" :hint="'Service time (in seconds)'"></v-text-field>
<v-text-field v-if="vehiclesBox" v-model="editData[i].time_window" :persistent-hint="true" :hint="'Working time window (in seconds passed since 00:00 or timestamp)'"></v-text-field>
<v-text-field v-if="jobsBox" v-model.number="editData[i].service" :persistent-hint="true" :hint="$t('editDialog.service')"></v-text-field>
<v-layout row-wrap>
<v-text-field v-if="vehiclesBox" v-model.number="editData[i].time_window[0]" style="padding-right: 10px" :persistent-hint="true" :hint="$t('editDialog.start') + $t('editDialog.timeWindow')"></v-text-field>
<v-text-field v-if="vehiclesBox" v-model.number="editData[i].time_window[1]" style="padding-right: 10px" :persistent-hint="true" :hint="$t('editDialog.end') + $t('editDialog.timeWindow')"></v-text-field>
</v-layout>

<v-select v-model="editData[i].skills" :items="editSkills" :item-text="'name'" :item-value="'id'" return-object chips deletable-chips
:persistent-hint="true" :hint="content.skills" multiple :menu-props="{'closeOnContentClick':true}">
Expand All @@ -99,7 +102,7 @@
</div>
</v-card-text>
</v-card>
<v-alert v-if="editData.length >= content.maxLength" :value="true" type="warning" style="color:black" >
<v-alert v-if="editData.length > content.maxLength" :value="true" type="warning" style="color:black" >
{{ content.maxWarning }}
</v-alert>
<v-layout row :wrap="$lowResolution">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default {
item: 'Job',
class: Job,
maxLength: 50,
maxWarning: this.$t('optimization.maxWarning') + '50' + this.$t('optimization.jobs'),
maxWarning: this.$t('optimization.maxWarning') + '50 ' + this.$t('optimization.jobs'),
import: this.$t('optimization.import') + this.$t('optimization.jobs'),
edit: this.$t('optimization.edit') + this.$t('optimization.job'),
add: this.$t('optimization.add') + this.$t('optimization.job'),
Expand All @@ -91,7 +91,7 @@ export default {
item: 'Vehicle',
class: Vehicle,
maxLength: 3,
maxWarning: this.$t('optimization.maxWarning') + '3' + this.$t('optimization.vehicles'),
maxWarning: this.$t('optimization.maxWarning') + '3 ' + this.$t('optimization.vehicles'),
import: this.$t('optimization.import') + this.$t('optimization.vehicles'),
edit: this.$t('optimization.edit') + this.$t('optimization.vehicle'),
add: this.$t('optimization.add') + this.$t('optimization.vehicle'),
Expand All @@ -118,6 +118,15 @@ export default {
const id = this.editId - 1
return this.editData[id].start[0] === this.editData[id].end[0] && this.editData[id].start[1] === this.editData[id].end[1]
},
// check if one of the items does not have a location
hasEmptyLocation () {
for (let item of this.editData) {
if (item.location === null || item.start === null) {
return true
}
}
return false
},
profilesMapping () {
const filter = OrsFilterUtil.getFilterRefByName(constants.profileFilterName)
return filter.mapping
Expand Down Expand Up @@ -210,18 +219,22 @@ export default {
this.isImportOpen = false
},

// check if one of the jobs does not have a location
hasEmptyLocation () {
for (let item of this.editData) {
if (item.location === null || item.start === null) {
return true
// check if vehicle has only a time window start and no time window end
validateTimeWindow () {
for (let index in this.editData) {
if (this.editData[index].time_window[0] === '') {
this.editData[index].time_window = []
} else if (this.editData[index].time_window.length === 1 || this.editData[index].time_window[1] === '') {
this.editData[index].time_window[1] = this.editData[index].time_window[0] + 3600
}
}
return false
},
// save items and close the edit box, show error if one or more of them has an empty location
saveItems () {
if (this.hasEmptyLocation()) {
if (this.content.item === 'Vehicle') {
this.validateTimeWindow()
}
if (this.hasEmptyLocation) {
this.showError(this.content.emptyLoc, {timeout: 3000})
} else {
this.$emit(this.content.changedEvent, this.editData)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export default {
editDialog: {
keepEdits: 'Keep edits',
service: 'Service time (in seconds)',
timeWindow: ' of time window (in seconds passed since 00:00 or timestamp)',
start: 'Start',
end: 'End'
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export default {
editDialog: {
keepEdits: 'Keep edits',
service: 'Service time (in seconds)',
timeWindow: ' of time window (in seconds passed since 00:00 or timestamp)',
start: 'Start',
end: 'End'
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export default {
editDialog: {
keepEdits: 'Keep edits',
service: 'Service time (in seconds)',
timeWindow: ' of time window (in seconds passed since 00:00 or timestamp)',
start: 'Start',
end: 'End'
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export default {
editDialog: {
keepEdits: 'Keep edits',
service: 'Service time (in seconds)',
timeWindow: ' of time window (in seconds passed since 00:00 or timestamp)',
start: 'Start',
end: 'End'
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export default {
editDialog: {
keepEdits: 'Keep edits',
service: 'Service time (in seconds)',
timeWindow: ' of time window (in seconds passed since 00:00 or timestamp)',
start: 'Start',
end: 'End'
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export default {
editDialog: {
keepEdits: 'Keep edits',
service: 'Service time (in seconds)',
timeWindow: ' of time window (in seconds passed since 00:00 or timestamp)',
start: 'Start',
end: 'End'
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export default {
editDialog: {
keepEdits: 'Keep edits',
service: 'Service time (in seconds)',
timeWindow: ' of time window (in seconds passed since 00:00 or timestamp)',
start: 'Start',
end: 'End'
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export default {
editDialog: {
keepEdits: 'Keep edits',
service: 'Service time (in seconds)',
timeWindow: ' of time window (in seconds passed since 00:00 or timestamp)',
start: 'Start',
end: 'End'
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export default {
editDialog: {
keepEdits: 'Keep edits',
service: 'Service time (in seconds)',
timeWindow: ' of time window (in seconds passed since 00:00 or timestamp)',
start: 'Start',
end: 'End'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<v-card-title style="padding-bottom: 0;"><v-icon :color="vehicleColors(v.id)" style="padding: 0 5px 0 0">{{vehicleIcon(v.profile)}}</v-icon><b>Vehicle {{v.id}} ({{v.profile}})</b></v-card-title>
<v-card-text>
<template v-for="prop in ['capacity','skills','time_window']">
<v-chip v-if="v[prop] && prop === 'time_window' && v[prop].length" style="flex: auto">{{ $t(`optimization.${prop}`) }}: {{ v[prop] }}</v-chip>
<v-chip v-if="v[prop] && prop === 'time_window' && v[prop][0] > 0 " style="flex: auto">{{ $t(`optimization.${prop}`) }}: {{ v[prop][0] }} - {{ v[prop][1] }}</v-chip>
<v-chip v-else-if="v[prop] && prop === 'capacity'" style="flex: auto">{{ $t(`optimization.${prop}`) }}: {{ v[prop][0] }}</v-chip>
<v-chip v-else-if="v[prop] && prop === 'skills' && v[prop].length" style="flex: auto">
{{ $t(`optimization.${prop}`) }}: {{ skillIds(v) }}
Expand Down

0 comments on commit 9822675

Please sign in to comment.