Skip to content

Commit e9aafa8

Browse files
authored
Merge pull request #752 from citation-file-format/544-screen-level-validation
2 parents be0e043 + 60abfcf commit e9aafa8

13 files changed

Lines changed: 130 additions & 101 deletions

src/components/AuthorCardEditing.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,8 @@
160160

161161
<script lang="ts">
162162
import { byError, emailQueries, orcidQueries } from 'src/error-filtering'
163-
import { computed, defineComponent, onUpdated } from 'vue'
163+
import { computed, defineComponent } from 'vue'
164164
import InfoDialog from 'components/InfoDialog.vue'
165-
import { useStepperErrors } from 'src/store/stepper-errors'
166165
import { useValidation } from 'src/store/validation'
167166
168167
export default defineComponent({
@@ -205,10 +204,6 @@ export default defineComponent({
205204
}
206205
},
207206
setup (props) {
208-
onUpdated(() => {
209-
const { setErrorStateScreenAuthors } = useStepperErrors()
210-
setErrorStateScreenAuthors(document.getElementsByClassName('has-error').length > 0)
211-
})
212207
const { errors } = useValidation()
213208
const orcidErrors = computed(() => {
214209
return orcidQueries(props.index)

src/components/AuthorCardViewing.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@
5555
</template>
5656

5757
<script lang="ts">
58-
import { PropType, computed, defineComponent, onUpdated } from 'vue'
58+
import { PropType, computed, defineComponent } from 'vue'
5959
import { byError, duplicateAuthorQueries, duplicateMatcher, emailQueries, orcidQueries } from 'src/error-filtering'
6060
import { AuthorType } from 'src/types'
61-
import { useStepperErrors } from 'src/store/stepper-errors'
6261
import { useValidation } from 'src/store/validation'
6362
6463
export default defineComponent({
@@ -78,10 +77,6 @@ export default defineComponent({
7877
}
7978
},
8079
setup (props) {
81-
onUpdated(() => {
82-
const { setErrorStateScreenAuthors } = useStepperErrors()
83-
setErrorStateScreenAuthors(document.getElementsByClassName('has-error').length > 0)
84-
})
8580
const { errors } = useValidation()
8681
const emailErrors = computed(() => {
8782
return emailQueries(props.index)

src/components/ScreenAuthors.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,14 @@
6464

6565
<script lang="ts">
6666
import { authorsQueries, byError } from 'src/error-filtering'
67-
import { computed, defineComponent, nextTick, onUpdated, ref } from 'vue'
67+
import { computed, defineComponent, nextTick, ref } from 'vue'
6868
import { moveDown, moveUp } from 'src/updown'
6969
import AuthorCardEditing from 'components/AuthorCardEditing.vue'
7070
import AuthorCardViewing from 'components/AuthorCardViewing.vue'
7171
import { AuthorType } from 'src/types'
7272
import InfoDialog from 'components/InfoDialog.vue'
7373
import { scrollToBottom } from 'src/scroll-to-bottom'
7474
import { useCff } from 'src/store/cff'
75-
import { useStepperErrors } from 'src/store/stepper-errors'
7675
import { useValidation } from 'src/store/validation'
7776
7877
export default defineComponent({
@@ -83,10 +82,6 @@ export default defineComponent({
8382
InfoDialog
8483
},
8584
setup () {
86-
onUpdated(() => {
87-
const { setErrorStateScreenAuthors } = useStepperErrors()
88-
setErrorStateScreenAuthors(document.getElementsByClassName('has-error').length > 0)
89-
})
9085
const { authors, setAuthors } = useCff()
9186
const { errors } = useValidation()
9287
const editingId = ref(-1)

src/components/ScreenFinish.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ import DownloadButton from 'components/DownloadButton.vue'
6969
import { useApp } from 'src/store/app'
7070
import { useCff } from 'src/store/cff'
7171
import { useQuasar } from 'quasar'
72-
import { useStepperErrors } from 'src/store/stepper-errors'
7372
import { useValidation } from 'src/store/validation'
7473
7574
export default defineComponent({
@@ -80,7 +79,6 @@ export default defineComponent({
8079
setup () {
8180
const { setStepName, setShowAdvanced, showAdvanced } = useApp()
8281
const { reset: resetCffData } = useCff()
83-
const { reset: resetStepperErrorState } = useStepperErrors()
8482
const { errors } = useValidation()
8583
const q = useQuasar()
8684
return {
@@ -92,7 +90,6 @@ export default defineComponent({
9290
persistent: true
9391
}).onOk(async () => {
9492
resetCffData()
95-
resetStepperErrorState()
9693
setShowAdvanced(false)
9794
await setStepName('start')
9895
})

src/components/ScreenIdentifiers.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,13 @@
6666
<script lang="ts">
6767
import { IdentifierType, IdentifierTypeType } from 'src/types'
6868
import { byError, identifiersQueries } from 'src/error-filtering'
69-
import { computed, defineComponent, nextTick, onUpdated, ref } from 'vue'
69+
import { computed, defineComponent, nextTick, ref } from 'vue'
7070
import { moveDown, moveUp } from 'src/updown'
7171
import IdentifierCardEditing from 'components/IdentifierCardEditing.vue'
7272
import IdentifierCardViewing from 'components/IdentifierCardViewing.vue'
7373
import InfoDialog from 'components/InfoDialog.vue'
7474
import { scrollToBottom } from 'src/scroll-to-bottom'
7575
import { useCff } from 'src/store/cff'
76-
import { useStepperErrors } from 'src/store/stepper-errors'
7776
import { useValidation } from 'src/store/validation'
7877
7978
export default defineComponent({
@@ -84,10 +83,6 @@ export default defineComponent({
8483
IdentifierCardViewing
8584
},
8685
setup () {
87-
onUpdated(() => {
88-
const { setErrorStateScreenIdentifiers } = useStepperErrors()
89-
setErrorStateScreenIdentifiers(document.getElementsByClassName('has-error').length > 0)
90-
})
9186
const { identifiers, setIdentifiers } = useCff()
9287
const { errors } = useValidation()
9388
const editingId = ref(-1)

src/components/ScreenKeywords.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@
5050

5151
<script lang="ts">
5252
import { byError, keywordsQueries } from 'src/error-filtering'
53-
import { computed, defineComponent, nextTick, onUpdated } from 'vue'
53+
import { computed, defineComponent, nextTick } from 'vue'
5454
import { moveDown, moveUp } from 'src/updown'
5555
import InfoDialog from 'components/InfoDialog.vue'
5656
import Keyword from 'components/Keyword.vue'
5757
import { scrollToBottom } from 'src/scroll-to-bottom'
5858
import { useCff } from 'src/store/cff'
59-
import { useStepperErrors } from 'src/store/stepper-errors'
6059
import { useValidation } from 'src/store/validation'
6160
6261
export default defineComponent({
@@ -66,10 +65,6 @@ export default defineComponent({
6665
Keyword
6766
},
6867
setup () {
69-
onUpdated(() => {
70-
const { setErrorStateScreenKeywords } = useStepperErrors()
71-
setErrorStateScreenKeywords(document.getElementsByClassName('has-error').length > 0)
72-
})
7368
const { keywords, setKeywords } = useCff()
7469
const { errors } = useValidation()
7570
const addKeyword = async () => {

src/components/ScreenRelatedResources.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@
7474

7575
<script lang="ts">
7676
import { byError, repositoryArtifactQueries, repositoryCodeQueries, repositoryQueries, unique, urlQueries } from 'src/error-filtering'
77-
import { computed, defineComponent, onUpdated } from 'vue'
77+
import { computed, defineComponent } from 'vue'
7878
import InfoDialog from 'components/InfoDialog.vue'
7979
import { useCff } from 'src/store/cff'
80-
import { useStepperErrors } from 'src/store/stepper-errors'
8180
import { useValidation } from 'src/store/validation'
8281
8382
export default defineComponent({
@@ -86,10 +85,6 @@ export default defineComponent({
8685
InfoDialog
8786
},
8887
setup () {
89-
onUpdated(() => {
90-
const { setErrorStateScreenRelatedResources } = useStepperErrors()
91-
setErrorStateScreenRelatedResources(document.getElementsByClassName('has-error').length > 0)
92-
})
9388
const {
9489
repository, repositoryArtifact, repositoryCode, url,
9590
setRepository, setRepositoryArtifact, setRepositoryCode, setUrl

src/components/ScreenStart.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@
5050

5151
<script lang="ts">
5252
import { byError, messageQueries, titleQueries } from 'src/error-filtering'
53-
import { computed, defineComponent, onUpdated } from 'vue'
53+
import { computed, defineComponent } from 'vue'
5454
import InfoDialog from 'components/InfoDialog.vue'
5555
import { useCff } from 'src/store/cff'
56-
import { useStepperErrors } from 'src/store/stepper-errors'
5756
import { useValidation } from 'src/store/validation'
5857
5958
export default defineComponent({
@@ -62,10 +61,6 @@ export default defineComponent({
6261
InfoDialog
6362
},
6463
setup () {
65-
onUpdated(() => {
66-
const { setErrorStateScreenStart } = useStepperErrors()
67-
setErrorStateScreenStart(document.getElementsByClassName('has-error').length > 0)
68-
})
6964
const { message, title, type, setMessage, setTitle, setType } = useCff()
7065
const { errors } = useValidation()
7166
const messageErrors = computed(() => {

src/components/ScreenVersionSpecific.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@
8282

8383
<script lang="ts">
8484
import { byError, dateReleasedQueries } from 'src/error-filtering'
85-
import { computed, defineComponent, onUpdated } from 'vue'
85+
import { computed, defineComponent } from 'vue'
8686
import InfoDialog from 'components/InfoDialog.vue'
8787
import { useCff } from 'src/store/cff'
88-
import { useStepperErrors } from 'src/store/stepper-errors'
8988
import { useValidation } from 'src/store/validation'
9089
9190
export default defineComponent({
@@ -94,10 +93,6 @@ export default defineComponent({
9493
InfoDialog
9594
},
9695
setup () {
97-
onUpdated(() => {
98-
const { setErrorStateScreenVersionSpecific } = useStepperErrors()
99-
setErrorStateScreenVersionSpecific(document.getElementsByClassName('has-error').length > 0)
100-
})
10196
const initializeDate = () => {
10297
const today = new Date()
10398
const y = today.getFullYear()

src/components/Stepper.vue

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,27 +107,55 @@
107107

108108
<script lang="ts">
109109
110+
import {
111+
byError,
112+
instancePathStartsWithMatcher,
113+
screenAuthorQueries,
114+
screenIdentifiersQueries,
115+
screenKeywordsQueries,
116+
screenRelatedResourcesQueries,
117+
screenStartQueries,
118+
screenVersionSpecificQueries
119+
} from 'src/error-filtering'
120+
import { computed } from 'vue'
110121
import { useApp } from 'src/store/app'
111-
import { useStepperErrors } from 'src/store/stepper-errors'
122+
import { useValidation } from 'src/store/validation'
112123
113124
export default {
114125
setup () {
115126
const { showAdvanced, stepName, setStepName } = useApp()
116-
const {
117-
errorStateScreenAuthors,
118-
errorStateScreenIdentifiers,
119-
errorStateScreenKeywords,
120-
errorStateScreenRelatedResources,
121-
errorStateScreenStart,
122-
errorStateScreenVersionSpecific
123-
} = useStepperErrors()
127+
const { errors } = useValidation()
124128
return {
125-
errorStateScreenAuthors,
126-
errorStateScreenIdentifiers,
127-
errorStateScreenKeywords,
128-
errorStateScreenRelatedResources,
129-
errorStateScreenStart,
130-
errorStateScreenVersionSpecific,
129+
errorStateScreenAuthors: computed(() => {
130+
return screenAuthorQueries
131+
.filter(byError(errors.value, instancePathStartsWithMatcher))
132+
.length > 0
133+
}),
134+
errorStateScreenIdentifiers: computed(() => {
135+
return screenIdentifiersQueries
136+
.filter(byError(errors.value, instancePathStartsWithMatcher))
137+
.length > 0
138+
}),
139+
errorStateScreenKeywords: computed(() => {
140+
return screenKeywordsQueries
141+
.filter(byError(errors.value, instancePathStartsWithMatcher))
142+
.length > 0
143+
}),
144+
errorStateScreenRelatedResources: computed(() => {
145+
return screenRelatedResourcesQueries
146+
.filter(byError(errors.value, instancePathStartsWithMatcher))
147+
.length > 0
148+
}),
149+
errorStateScreenStart: computed(() => {
150+
return screenStartQueries
151+
.filter(byError(errors.value)) // One of the possible errors is instancePath == '', so we use a traditional approach here
152+
.length > 0
153+
}),
154+
errorStateScreenVersionSpecific: computed(() => {
155+
return screenVersionSpecificQueries
156+
.filter(byError(errors.value, instancePathStartsWithMatcher))
157+
.length > 0
158+
}),
131159
setStepName,
132160
showAdvanced,
133161
stepName

0 commit comments

Comments
 (0)