@@ -389,9 +389,6 @@ export default {
389389 return jobProps
390390 } ,
391391 parseProps ( jobProps ) {
392- if ( ! jobProps ) {
393- return undefined
394- }
395392 let parsedProps = [ ]
396393 for ( const j of jobProps ) {
397394 let parsedJobProps = { id : j . id }
@@ -400,19 +397,21 @@ export default {
400397 parsedJobProps [ prop ] = j [ prop ]
401398 }
402399 }
403- let propSkills = [ ]
404- for ( const s of j . skills ) {
405- let skillIds = [ ]
406- for ( const skill of this . skills ) {
407- skillIds . push ( skill . id )
408- }
409- if ( skillIds . includes ( s ) ) {
410- propSkills . push ( this . skills [ s - 1 ] )
411- } else {
412- propSkills . push ( new Skill ( 'Skill from added ' + this . $t ( 'optimization.job' ) + ' ' + j . id , s ) )
400+ if ( j . skills ) {
401+ let propSkills = [ ]
402+ for ( const s of j . skills ) {
403+ let skillIds = [ ]
404+ for ( const skill of this . skills ) {
405+ skillIds . push ( skill . id )
406+ }
407+ if ( skillIds . includes ( s ) ) {
408+ propSkills . push ( this . skills [ s - 1 ] )
409+ } else {
410+ propSkills . push ( new Skill ( 'Skill from added ' + this . $t ( 'optimization.job' ) + ' ' + j . id , s ) )
411+ }
413412 }
413+ parsedJobProps . skills = propSkills
414414 }
415- parsedJobProps . skills = propSkills
416415
417416 parsedProps . push ( parsedJobProps )
418417 }
@@ -534,14 +533,19 @@ export default {
534533 // places from the appRoute without changing the
535534 // object reference because it is a prop
536535 const defaultJobs = this . jobs
537- const jobProps = this . parseProps ( this . $store . getters . appRouteData . options . jobProps )
538536 const places = this . $store . getters . appRouteData . places
537+ const propData = this . $store . getters . appRouteData . options . jobProps
539538 let storedJobs = localStorage . getItem ( 'jobs' )
540539 const jobs = [ ]
541- if ( places . length > 0 ) {
540+ if ( propData && places . length === propData . length ) {
541+ const jobProps = this . parseProps ( propData )
542542 for ( const [ i , place ] of places . entries ( ) ) {
543543 jobs . push ( new Job ( place . lng , place . lat , place . placeName , jobProps [ i ] ) )
544544 }
545+ } else if ( places . length > 0 ) {
546+ for ( const [ i , place ] of places . entries ( ) ) {
547+ jobs . push ( new Job ( place . lng , place . lat , place . placeName , { id : i + 1 } ) )
548+ }
545549 } else if ( this . jobs === undefined && storedJobs ) {
546550 for ( const job of JSON . parse ( storedJobs ) ) {
547551 jobs . push ( Job . fromObject ( job ) )
0 commit comments