Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly initialize starting category trace + removing #246

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/components/BeslisboomForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ function reset() {
}

function back() {
questionStore.revertAnswer(previousSubCategory.value)
categoryStore.revertCurrentCategory()
questionStore.revertAnswer(previousSubCategory.value)
}

function backButtonConclusion() {
Expand Down
24 changes: 12 additions & 12 deletions frontend/src/stores/CategoryStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export const useCategoryStore = defineStore('category', () => {
const initialPreviousSubCategory = localStorage.getItem('previousSubCategory') ?? startSubCategory
const initialCurrentCategory = localStorage.getItem('currentCategory') ?? startCategory
const initialCurrentSubCategory = localStorage.getItem('currentSubCategory') ?? startSubCategory
const initialCategoryTrace = JSON.parse(localStorage.getItem('categoryTrace') ?? '[]')
const initialSubCategoryTrace = JSON.parse(localStorage.getItem('subCategoryTrace') ?? '[]')
const initialCategoryTrace = JSON.parse(localStorage.getItem('categoryTrace') ?? '["AI verordening van toepassing?"]')
const initialSubCategoryTrace = JSON.parse(localStorage.getItem('subCategoryTrace') ?? '["Soort toepassing"]')
const initialCategoryStateString = `{
"ai_act_applicable_state": "doing",
"risk_group_state": "incomplete"
Expand Down Expand Up @@ -99,28 +99,28 @@ export const useCategoryStore = defineStore('category', () => {
*/
// Categories section
revertCategoryState()
if(categoryTrace.value.length - 2 > 0){
currentCategory.value = categoryTrace.value[categoryTrace.value.length - 2]
if(categoryTrace.value.length - 1 > 0){
currentCategory.value = categoryTrace.value[categoryTrace.value.length - 1]
}else{
currentCategory.value = startCategory
}
categoryTrace.value.pop()

if(categoryTrace.value.length - 2 > 0) {
previousCategory.value = categoryTrace.value[categoryTrace.value.length - 2]
if(categoryTrace.value.length - 1 > 0) {
previousCategory.value = categoryTrace.value[categoryTrace.value.length - 1]
} else {
previousCategory.value = startCategory
}
// Subcategories section
if(subCategoryTrace.value.length - 2 > 0){
currentSubCategory.value = subCategoryTrace.value[subCategoryTrace.value.length - 2]
if(subCategoryTrace.value.length - 1 > 0){
currentSubCategory.value = subCategoryTrace.value[subCategoryTrace.value.length - 1]
}else{
currentSubCategory.value = startSubCategory
}
subCategoryTrace.value.pop()

if(subCategoryTrace.value.length - 2 > 0) {
previousSubCategory.value = subCategoryTrace.value[subCategoryTrace.value.length - 2]
if(subCategoryTrace.value.length - 1 > 0) {
previousSubCategory.value = subCategoryTrace.value[subCategoryTrace.value.length - 1]
} else {
previousSubCategory.value = startSubCategory
}
Expand All @@ -139,8 +139,8 @@ export const useCategoryStore = defineStore('category', () => {
previousCategory.value = startCategory
previousSubCategory.value = startSubCategory
categoryState.value = JSON.parse(initialCategoryStateString)
categoryTrace.value = []
subCategoryTrace.value = []
categoryTrace.value = [startCategory]
subCategoryTrace.value = [startSubCategory]
localStorage.removeItem('currentCategory')
localStorage.removeItem('currentSubCategory')
localStorage.removeItem('previousCategory')
Expand Down