1313 vertical
1414 >
1515 <q-step
16- data-cy =" step-start"
17- name =" start"
18- aria-label =" Start"
19- title =" Start"
20- v-bind:active-icon =" errorStateScreenStart ? 'warning' : 'edit'"
21- v-bind:error =" errorStateScreenStart"
22- v-bind:order =" 0"
23- v-on:click =" setStepName('start')"
24- />
25-
26- <q-step
27- data-cy =" step-authors"
28- name =" authors"
29- aria-label =" Authors"
30- title =" Authors"
31- v-bind:active-icon =" errorStateScreenAuthors ? 'warning' : 'edit'"
32- v-bind:error =" errorStateScreenAuthors"
33- v-bind:order =" 1"
34- v-on:click =" setStepName('authors')"
35- />
36-
37- <q-step
38- data-cy =" step-identifiers"
39- name =" identifiers"
40- aria-label =" Identifiers"
41- title =" Identifiers"
42- v-bind:active-icon =" errorStateScreenIdentifiers ? 'warning' : 'edit'"
43- v-bind:error =" errorStateScreenIdentifiers"
44- v-bind:order =" 2"
45- v-if =" showAdvanced"
46- v-on:click =" setStepName('identifiers')"
47- />
48-
49- <q-step
50- data-cy =" step-related-resources"
51- name =" related-resources"
52- aria-label =" Related resources"
53- title =" Related resources"
54- v-bind:active-icon =" errorStateScreenRelatedResources ? 'warning' : 'edit'"
55- v-bind:error =" errorStateScreenRelatedResources"
56- v-bind:order =" 3"
57- v-if =" showAdvanced"
58- v-on:click =" setStepName('related-resources')"
59- />
60-
61- <q-step
62- data-cy =" step-abstract"
63- name =" abstract"
64- aria-label =" Abstract"
65- title =" Abstract"
66- v-bind:order =" 4"
67- v-if =" showAdvanced"
68- v-on:click =" setStepName('abstract')"
69- />
70-
71- <q-step
72- data-cy =" step-keywords"
73- name =" keywords"
74- aria-label =" Keywords"
75- title =" Keywords"
76- v-bind:active-icon =" errorStateScreenKeywords ? 'warning' : 'edit'"
77- v-bind:error =" errorStateScreenKeywords"
78- v-bind:order =" 5"
79- v-if =" showAdvanced"
80- v-on:click =" setStepName('keywords')"
81- />
82-
83- <q-step
84- data-cy =" step-license"
85- name =" license"
86- aria-label =" License"
87- title =" License"
88- v-bind:order =" 6"
89- v-if =" showAdvanced"
90- v-on:click =" setStepName('license')"
91- />
92-
93- <q-step
94- data-cy =" step-version-specific"
95- name =" version-specific"
96- aria-label =" Version specific"
97- title =" Version specific"
98- v-bind:active-icon =" errorStateScreenVersionSpecific ? 'warning' : 'edit'"
99- v-bind:error =" errorStateScreenVersionSpecific"
100- v-bind:order =" 7"
101- v-if =" showAdvanced"
102- v-on:click =" setStepName('version-specific')"
103- />
104-
105- <q-step
106- active-icon =" navigate_next"
107- data-cy =" step-finish"
108- name =" finish"
109- aria-label =" Finish"
110- title =" Finish"
111- v-bind:order =" showAdvanced ? 8 : 2"
112- v-on:click =" setStepName('finish')"
16+ v-for =" (step, stepIndex) in stepNames"
17+ v-bind:active-icon =" activeIcon(errorPerStep[step].value, step)"
18+ v-bind:aria-label =" toLabel(step)"
19+ v-bind:data-cy =" `step-${step}`"
20+ v-bind:done =" currentStepIndex > stepIndex"
21+ v-bind:error =" errorPerStep[step].value"
22+ v-bind:key =" step"
23+ v-bind:name =" step"
24+ v-bind:order =" stepIndex"
25+ v-bind:title =" toLabel(step)"
26+ v-on:click =" setStepName(step)"
27+ v-on:keyup.enter =" setStepName(step)"
11328 />
11429 </q-stepper >
11530 </nav >
11631</template >
11732
11833<script lang="ts">
11934
35+ import { ComputedRef , computed } from ' vue'
36+ import { StepNameType , useApp } from ' src/store/app'
12037import {
12138 byError ,
12239 instancePathStartsWithMatcher ,
@@ -127,53 +44,73 @@ import {
12744 screenStartQueries ,
12845 screenVersionSpecificQueries
12946} from ' src/error-filtering'
130- import { computed } from ' vue'
131- import { useApp } from ' src/store/app'
13247import { useValidation } from ' src/store/validation'
13348
13449export default {
13550 setup () {
136- const { showAdvanced , stepName, setStepName } = useApp ()
51+ const { currentStepIndex , stepName, setStepName, stepNames } = useApp ()
13752 const { errors } = useValidation ()
53+ const toLabel = (name : string ) => {
54+ return name .split (' -' ).map ((s ) => s .slice (0 , 1 ).toUpperCase () + s .slice (1 )).join (' ' )
55+ }
56+ const errorStateScreenAuthors = computed (() => {
57+ return screenAuthorQueries
58+ .filter (byError (errors .value , instancePathStartsWithMatcher ))
59+ .length > 0
60+ })
61+ const errorStateScreenIdentifiers = computed (() => {
62+ return screenIdentifiersQueries
63+ .filter (byError (errors .value , instancePathStartsWithMatcher ))
64+ .length > 0
65+ })
66+ const errorStateScreenKeywords = computed (() => {
67+ return screenKeywordsQueries
68+ .filter (byError (errors .value , instancePathStartsWithMatcher ))
69+ .length > 0
70+ })
71+ const errorStateScreenRelatedResources = computed (() => {
72+ return screenRelatedResourcesQueries
73+ .filter (byError (errors .value , instancePathStartsWithMatcher ))
74+ .length > 0
75+ })
76+ const errorStateScreenStart = computed (() => {
77+ return screenStartQueries
78+ .filter (byError (errors .value )) // One of the possible errors is instancePath == '', so we use a traditional approach here
79+ .length > 0
80+ })
81+ const errorStateScreenVersionSpecific = computed (() => {
82+ return screenVersionSpecificQueries
83+ .filter (byError (errors .value , instancePathStartsWithMatcher ))
84+ .length > 0
85+ })
86+ const errorPerStep: Record <StepNameType , ComputedRef <boolean >> = {
87+ start: errorStateScreenStart ,
88+ authors: errorStateScreenAuthors ,
89+ identifiers: errorStateScreenIdentifiers ,
90+ ' related-resources' : errorStateScreenRelatedResources ,
91+ abstract: computed (() => false ),
92+ keywords: errorStateScreenKeywords ,
93+ license: computed (() => false ),
94+ ' version-specific' : errorStateScreenVersionSpecific ,
95+ finish: computed (() => false )
96+ }
13897 return {
139- errorStateScreenAuthors: computed (() => {
140- return screenAuthorQueries
141- .filter (byError (errors .value , instancePathStartsWithMatcher ))
142- .length > 0
143- }),
144- errorStateScreenIdentifiers: computed (() => {
145- return screenIdentifiersQueries
146- .filter (byError (errors .value , instancePathStartsWithMatcher ))
147- .length > 0
148- }),
149- errorStateScreenKeywords: computed (() => {
150- return screenKeywordsQueries
151- .filter (byError (errors .value , instancePathStartsWithMatcher ))
152- .length > 0
153- }),
154- errorStateScreenRelatedResources: computed (() => {
155- return screenRelatedResourcesQueries
156- .filter (byError (errors .value , instancePathStartsWithMatcher ))
157- .length > 0
158- }),
159- errorStateScreenStart: computed (() => {
160- return screenStartQueries
161- .filter (byError (errors .value )) // One of the possible errors is instancePath == '', so we use a traditional approach here
162- .length > 0
163- }),
164- errorStateScreenVersionSpecific: computed (() => {
165- return screenVersionSpecificQueries
166- .filter (byError (errors .value , instancePathStartsWithMatcher ))
167- .length > 0
168- }),
98+ activeIcon : (hasError : boolean , step : StepNameType ) => {
99+ if (hasError ) {
100+ return ' warning'
101+ } else if (step === ' finish' && errors .value .length === 0 ) {
102+ return ' done'
103+ } else {
104+ return ' edit'
105+ }
106+ },
107+ currentStepIndex ,
108+ errorPerStep ,
169109 setStepName ,
170- showAdvanced ,
171- stepName
110+ stepName ,
111+ stepNames ,
112+ toLabel
172113 }
173114 }
174115}
175116 </script >
176-
177- <style scoped>
178-
179- </style >
0 commit comments