11import MapViewData from '@/models/map-view-data'
22import constants from '@/resources/constants'
33import Place from '@/models/place'
4+ import Job from '@/models/job'
5+ import Vehicle from '@/models/vehicle'
46import store from '@/store/store'
57import lodash from 'lodash'
68/**
@@ -22,9 +24,9 @@ class JsonImporter {
2224 return new Promise ( ( resolve , reject ) => {
2325 let mapViewData = new MapViewData ( )
2426 const parsingResult = context . parseFileContentToMapViewData ( )
27+
2528 if ( parsingResult ) {
26- mapViewData = parsingResult
27- mapViewData = context . setMode ( mapViewData )
29+ mapViewData = context . setMode ( parsingResult )
2830
2931 // Make sure that the mode defined
3032 // in the imported file/object is valid
@@ -93,6 +95,10 @@ class JsonImporter {
9395 } else {
9496 if ( key === 'places' ) {
9597 mapViewData . places = this . parsePlaces ( content )
98+ } else if ( key === 'jobs' ) {
99+ mapViewData . jobs = this . parseJobs ( content )
100+ } else if ( key === 'vehicles' ) {
101+ mapViewData . vehicles = this . parseVehicles ( content )
96102 } else if ( content [ key ] ) {
97103 mapViewData [ key ] = content [ key ]
98104 }
@@ -118,6 +124,22 @@ class JsonImporter {
118124 return places
119125 }
120126
127+ parseJobs = ( content ) => {
128+ const jobs = [ ]
129+ for ( const job of content . jobs ) {
130+ jobs . push ( Job . fromObject ( job ) )
131+ }
132+ return jobs
133+ }
134+
135+ parseVehicles = ( content ) => {
136+ const vehicles = [ ]
137+ for ( const v of content . vehicles ) {
138+ vehicles . push ( Vehicle . fromObject ( v ) )
139+ }
140+ return vehicles
141+ }
142+
121143 /**
122144 * Adjust summary data
123145 */
0 commit comments