Skip to content

Commit

Permalink
refactor: improve maintainability
Browse files Browse the repository at this point in the history
  • Loading branch information
Seli0303 committed Jun 18, 2024
1 parent 12788f7 commit b7fb6d6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,6 @@ export default {
methods: {
vehicleColors,
vehicleIcon,
isEnabled (action) {
const disabled = this.disabledActions
return !disabled.includes(action)
},
// close editJobs dialog
closeEditModal () {
this.isEditOpen = false
Expand Down Expand Up @@ -212,7 +208,8 @@ export default {
for (const s of this.editSkills) {
editSkillIds.push(s.id)
}
for (const id of newSkillIds.sort((a,b) => a-b)) {
newSkillIds.sort((a,b) => a-b)
for (const id of newSkillIds) {
if (!editSkillIds.includes(id)) {
this.editSkills.push(new Skill(' Skill from imported ' + this.content.item + ' ' + id, id))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default {
}
const routes = []
for (const key in this.localMapViewData.routes) {
const route = Object.assign({}, this.localMapViewData.routes[key])
const route = {...this.localMapViewData.routes[key]}
if (!route.summary) {
route.summary = geoUtils.getHumanizedTimeAndDistance({distance: route.distance, duration:route.duration, unit: 'm'}, this.$t('global.units'))
this.parseSteps(route.steps)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default {
parsedInfos = this.parseCsvFile(fileContent)
} else if (type.indexOf('json') > -1 || type.indexOf('geojson') > -1) {
const parsedJson = JSON.parse(fileContent)
if (parsedJson && parsedJson.features) {
if (parsedJson?.features) {
parsedInfos = this.parseGeojsonFile(parsedJson)
} else {
parsedInfos= this.parseJsonFile(parsedJson)
Expand Down
2 changes: 1 addition & 1 deletion src/models/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class Job extends Place {
}
}

if (props.skills && props.skills.length) {
if (props.skills?.length) {
let skillIds = []
for (const skill of props.skills) {
skillIds.push(skill.id)
Expand Down
8 changes: 4 additions & 4 deletions src/support/app-modes/strategies/optimization-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ class OptimizationMode {
/**
* Build an optimization route
* @param {*} appRouteData
* @returns {Object} route like {name: 'MapDirections', params: {...} }
* @param options
* @returns {Object} route like {name: 'MapDirections', params: {...}}
*/
getRoute = (appRouteData, options = null) => {
options = options || appRouteData.options
const params = RouteUtils.buildRouteParams(appRouteData, options)
// Build and return the route object
const route = { name: 'MapOptimization', params: params }
return route
return {name: 'MapOptimization', params: params}
}

/**
Expand All @@ -50,7 +50,7 @@ class OptimizationMode {
// In the 'directions' mode, the options parameter may contain an options object
// that is expected to be used as the ORS API request options (avoid_polygons, avoid_features etc.)
// So, as they are stringified on the url, we try to parse them back to an object
if (appRouteData.options && appRouteData.options.options) {
if (appRouteData.options?.options) {
appRouteData.options.options = Utils.tryParseJson(appRouteData.options.options) || appRouteData.options.options
}

Expand Down

0 comments on commit b7fb6d6

Please sign in to comment.