Skip to content

Commit

Permalink
Merge pull request #756 from SanDiegoCountySheriff/bug/favorites-filt…
Browse files Browse the repository at this point in the history
…ering

fix: check for null list before filtering favorite results
  • Loading branch information
jacobkellas authored Nov 15, 2023
2 parents 78d3df2 + bc6ab26 commit 4668e97
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 75 deletions.
162 changes: 88 additions & 74 deletions UI/src/components/features/RipaFormContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -411,102 +411,116 @@ export default {
result.version = 1
}
const updatedWarningCodes = result.result.warningCodes.filter(
code => {
return this.mappedFormStatutes.some(statute => {
return statute.code === code
})
},
)
if (result.result.warningCodes) {
const updatedWarningCodes = result.result.warningCodes.filter(
code => {
return this.mappedFormStatutes.some(statute => {
return statute.code === code
})
},
)
if (
updatedWarningCodes.length !== result.result.warningCodes.length
) {
result.favoritesCodeExpired = true
}
if (
updatedWarningCodes.length !==
result.result.warningCodes.length
) {
result.favoritesCodeExpired = true
}
result.result.warningCodes = updatedWarningCodes
result.result.warningCodes = updatedWarningCodes
}
const updatedVerbalWarningCodes =
result.result.verbalWarningCodes.filter(code => {
return this.mappedFormStatutes.some(statute => {
return statute.code === code
if (result.result.verbalWarningCodes) {
const updatedVerbalWarningCodes =
result.result.verbalWarningCodes.filter(code => {
return this.mappedFormStatutes.some(statute => {
return statute.code === code
})
})
})
if (
updatedVerbalWarningCodes.length !==
result.result.verbalWarningCodes.length
) {
result.favoritesCodeExpired = true
}
if (
updatedVerbalWarningCodes.length !==
result.result.verbalWarningCodes.length
) {
result.favoritesCodeExpired = true
}
result.result.verbalWarningCodes = updatedVerbalWarningCodes
result.result.verbalWarningCodes = updatedVerbalWarningCodes
}
const updatedWrittenWarningCodes =
result.result.writtenWarningCodes.filter(code => {
return this.mappedFormStatutes.some(statute => {
return statute.code === code
if (result.result.writtenWarningCodes) {
const updatedWrittenWarningCodes =
result.result.writtenWarningCodes.filter(code => {
return this.mappedFormStatutes.some(statute => {
return statute.code === code
})
})
})
if (
updatedWrittenWarningCodes.length !==
result.result.writtenWarningCodes.length
) {
result.favoritesCodeExpired = true
if (
updatedWrittenWarningCodes.length !==
result.result.writtenWarningCodes.length
) {
result.favoritesCodeExpired = true
}
result.result.writtenWarningCodes = updatedWrittenWarningCodes
}
result.result.writtenWarningCodes = updatedWrittenWarningCodes
if (result.result.citationCodes) {
const updatedCitationCodes = result.result.citationCodes.filter(
code => {
return this.mappedFormStatutes.some(statute => {
return statute.code === code
})
},
)
const updatedCitationCodes = result.result.citationCodes.filter(
code => {
return this.mappedFormStatutes.some(statute => {
return statute.code === code
})
},
)
if (
updatedCitationCodes.length !==
result.result.citationCodes.length
) {
result.favoritesCodeExpired = true
}
if (
updatedCitationCodes.length !==
result.result.citationCodes.length
) {
result.favoritesCodeExpired = true
result.result.citationCodes = updatedCitationCodes
}
result.result.citationCodes = updatedCitationCodes
if (result.result.infieldCodes) {
const updatedInfieldCodes = result.result.infieldCodes.filter(
code => {
return this.mappedFormStatutes.some(statute => {
return statute.code === code
})
},
)
const updatedInfieldCodes = result.result.infieldCodes.filter(
code => {
return this.mappedFormStatutes.some(statute => {
return statute.code === code
})
},
)
if (
updatedInfieldCodes.length !==
result.result.infieldCodes.length
) {
result.favoritesCodeExpired = true
}
if (
updatedInfieldCodes.length !== result.result.infieldCodes.length
) {
result.favoritesCodeExpired = true
result.result.infieldCodes = updatedInfieldCodes
}
result.result.infieldCodes = updatedInfieldCodes
const updatedCustodialArrestCodes =
result.result.custodialArrestCodes.filter(code => {
return this.mappedFormStatutes.some(statute => {
return statute.code === code
if (result.result.custodialArrestCodes) {
const updatedCustodialArrestCodes =
result.result.custodialArrestCodes.filter(code => {
return this.mappedFormStatutes.some(statute => {
return statute.code === code
})
})
})
if (
updatedCustodialArrestCodes.length !==
result.result.custodialArrestCodes.length
) {
result.favoritesCodeExpired = true
}
if (
updatedCustodialArrestCodes.length !==
result.result.custodialArrestCodes.length
) {
result.favoritesCodeExpired = true
}
result.result.custodialArrestCodes = updatedCustodialArrestCodes
result.result.custodialArrestCodes = updatedCustodialArrestCodes
}
return result
})
Expand Down
2 changes: 1 addition & 1 deletion UI/src/components/organisms/RipaFormWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ export default {
this.stepIndex = this.stepIndex - 2
} else if (this.model.stopVersion === 2) {
this.stepIndex = this.stepIndex - 1
} else if (!this.anyAgencyQuestions) {
} else if (!this.anyAgencyQuestions && this.stepIndex === 7) {
this.stepIndex = this.stepIndex - 2
} else {
this.stepIndex = this.stepIndex - 1
Expand Down

0 comments on commit 4668e97

Please sign in to comment.