From f7d53d005542541dd60d72855448ec42f5a33302 Mon Sep 17 00:00:00 2001 From: Emma Hegarty Date: Mon, 27 May 2024 12:14:07 +0200 Subject: [PATCH] wip: jobProps --- .../components/optimization/optimization.js | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/fragments/forms/map-form/components/optimization/optimization.js b/src/fragments/forms/map-form/components/optimization/optimization.js index dd91dc226..4d5c83a5f 100644 --- a/src/fragments/forms/map-form/components/optimization/optimization.js +++ b/src/fragments/forms/map-form/components/optimization/optimization.js @@ -382,12 +382,39 @@ export default { jobProps.skills = skillIds } for (const prop of ['service', 'priority', 'delivery', 'pickup', 'time_windows']) { - if (job[prop].length) { + if (job[prop].length && job[prop][0] !== 0) { jobProps[prop] = job[prop] } } return jobProps }, + parseProps(jobProps) { + let parsedProps = [] + for (const j in jobProps) { + let [parsedJobProps] = {id: j.id} + for (const prop of ['service', 'priority', 'delivery', 'pickup', 'time_windows']) { + if (j[prop].length && j[prop][0] !== 0) { + parsedJobProps[prop] = j[prop] + } + } + let propSkills = [] + for (const s in j.skills) { + let skillIds = [] + for (const skill in this.skills) { + skillIds.push(skill.id) + } + if (skillIds.includes(s)) { + propSkills.push(this.skills[s-1]) + } else { + propSkills.push(new Skill('Skill from added ' + this.$t('optimization.job') + ' ' + j.id, s)) + } + } + parsedJobProps.skills = propSkills + + parsedProps.push(parsedJobProps) + } + return parsedProps + }, /** * Request and draw a route based on the value of multiples places input * @returns {Promise} @@ -468,7 +495,7 @@ export default { // object reference because it is a prop const defaultJobs = this.jobs const defaultVehicles = this.vehicles - const jobProps = this.$store.getters.appRouteData.options.jobProps + const jobProps = this.parseProps(this.$store.getters.appRouteData.options.jobProps) const urlVehicles = this.$store.getters.appRouteData.options.vehicles const places = this.$store.getters.appRouteData.places let storedJobs = localStorage.getItem('jobs')