Skip to content

Commit 003d43b

Browse files
authored
Merge pull request #834 from citation-file-format/833-extra-cff-fields-error-feedback
2 parents 0ceae5d + e0eca03 commit 003d43b

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/components/Stepper.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
v-bind:caption="stepIndex < 2 ? 'required' : (step !== 'finish' ? 'optional' : '')"
2020
v-bind:data-cy="`step-${step}`"
2121
v-bind:done="screenVisited(step) && !errorPerStep[step].value"
22-
v-bind:error="currentStepIndex != stepIndex && screenVisited(step) && errorPerStep[step].value"
22+
v-bind:error="isScreenError(step)"
2323
v-bind:header-nav="stepIndex !== currentStepIndex && screenVisited(step) && !anyErrorBetween('start', step)"
2424
v-bind:key="step"
2525
v-bind:name="step"
@@ -87,6 +87,23 @@ export default {
8787
}
8888
},
8989
errorPerStep,
90+
isScreenError: (step: StepNameType) => {
91+
if (!screenVisited(step) || !errorPerStep[step].value || currentStepIndex.value === stepNames.indexOf(step)) {
92+
return false
93+
} else if (step === 'extra-cff-fields') {
94+
// If no other screen has error, then it must be the stepNames
95+
const otherScreensHaveErrors = stepNames.reduce((acc, step) => {
96+
if (step === 'extra-cff-fields') {
97+
return acc
98+
} else {
99+
return acc || errorPerStep[step].value
100+
}
101+
}, false)
102+
return !otherScreensHaveErrors
103+
} else {
104+
return true
105+
}
106+
},
90107
screenVisited,
91108
setStepName,
92109
stepName,

src/store/stepper-errors.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import {
99
screenVersionSpecificQueries
1010
} from 'src/error-filtering'
1111
import { computed } from 'vue'
12-
// import { StepNameType } from 'src/store/app'
12+
import { useCff } from 'src/store/cff'
1313
import { useValidation } from 'src/store/validation'
1414

1515
const { errors } = useValidation()
16+
const { extraCffFields } = useCff()
1617

1718
const errorStateScreenAuthors = computed(() => {
1819
return screenAuthorQueries
@@ -54,6 +55,6 @@ export const errorPerStep = {
5455
keywords: errorStateScreenKeywords,
5556
license: computed(() => false),
5657
'version-specific': errorStateScreenVersionSpecific,
57-
'extra-cff-fields': computed(() => errors.value.length > 0),
58+
'extra-cff-fields': computed(() => { return extraCffFields.value.length > 0 && errors.value.length > 0 }),
5859
finish: computed(() => false)
5960
}

0 commit comments

Comments
 (0)