Skip to content

Commit

Permalink
Clean up interview indexing logic (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
kharus authored Oct 28, 2024
1 parent 6b1474a commit 7629ec5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/components/TheMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export default {
data() {
return {
navigationLinks: [],
langs: this.$store.getters.langs,
langs: this.$store.getters.allLangs,
chosenLang: "",
showOptions: new Array(this.$store.getters.langs.length).fill(false),
showOptions: new Array(this.$store.getters.allLangs.length).fill(false),
selectedIndex: null,
};
},
Expand Down
10 changes: 4 additions & 6 deletions src/components/TheQuestion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="column is-one-fifth has-text-left is-size-4">
<Notification class="is-next-from-top clearEdges">
<div
v-for="(heading, index) in Object.keys(getTopLevelDecisions)"
v-for="(heading, index) in getTopLevelDecisions"
:key="heading"
class="vertical-container"
@click="changeQuestionPrompt(index)"
Expand All @@ -35,7 +35,6 @@ export default {
},
data() {
return {
whichPrompt: 0,
whichHeading: "",
};
},
Expand All @@ -49,7 +48,7 @@ export default {
return this.$store.getters.statements;
},
questionPrompt() {
return this.$store.getters.questionPrompt[this.whichPrompt];
return this.$store.getters.questionPrompt;
},
responseMsg() {
return {
Expand All @@ -66,13 +65,12 @@ export default {
}[this.questions.mark.value];
},
getTopLevelDecisions() {
return this.$store.getters.getTopLevelDecisions;
return this.$store.getters.getTopLevelDecisionKeys;
},
},
methods: {
changeQuestionPrompt(index) {
this.whichPrompt = index;
this.$store.commit("updateCurrentPrompt", this.whichPrompt);
this.$store.commit("updateCurrentPrompt", index);
},
},
};
Expand Down
26 changes: 14 additions & 12 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,30 @@ export function aaJsonLangs(aaJson) {
export default createStore({
state: {
marking: {},
interview: AaJson.default,
allInverviews: AaJson.default,
currentLang: 'nl4eng',
currentPrompt: 0,
},
getters: {
langs(state) {
return aaJsonLangs(state.interview);
allLangs(state) {
return aaJsonLangs(state.allInverviews);
},
questions(state) {
const topLevelDecisions = state.interview[state.currentLang][0]
const topLDBody = Object.values(topLevelDecisions)[state.currentPrompt];
return AnyAll.paint2(state.marking)(topLDBody);
questions(state, getters) {
const currentInterviewBody = Object.values(getters.currentInterview)[0];
return AnyAll.paint2(state.marking)(currentInterviewBody);
},
questionPrompt(state) {
return Object.keys(state.interview[state.currentLang][0]);
currentInterview(state) {
return state.allInverviews[state.currentLang][state.currentPrompt];
},
questionPrompt(state, getters) {
return Object.keys(getters.currentInterview)[0];
},
getMarkingField: (state) => (id) => {
return state.marking[id]
},
getTopLevelDecisions(state) {
return state.interview[state.currentLang][0];
},
getTopLevelDecisionKeys(state) {
return state.allInverviews[state.currentLang].flatMap((x) => Object.keys(x));
}
},
mutations: {
updateMarkingField(state, payload) {
Expand Down

0 comments on commit 7629ec5

Please sign in to comment.