7575</template >
7676
7777<script lang="ts">
78+ import { authorsQueries , byError } from ' src/error-filtering'
7879import { computed , defineComponent , nextTick , onUpdated , ref } from ' vue'
79- import SchemaGuideLink from ' components/SchemaGuideLink.vue'
80- import Stepper from ' components/Stepper.vue'
81- import StepperActions from ' components/StepperActions.vue'
80+ import { moveDown , moveUp } from ' src/updown'
8281import AuthorCardEditing from ' components/AuthorCardEditing.vue'
8382import AuthorCardViewing from ' components/AuthorCardViewing.vue'
8483import { AuthorType } from ' src/types'
85- import { moveDown , moveUp } from ' ../updown'
84+ import SchemaGuideLink from ' components/SchemaGuideLink.vue'
85+ import Stepper from ' components/Stepper.vue'
86+ import StepperActions from ' components/StepperActions.vue'
87+ import { scrollToBottom } from ' src/scroll-to-bottom'
8688import { useCff } from ' src/store/cff'
87- import { scrollToBottom } from ' ../scroll-to-bottom'
88- import { useValidation } from ' src/store/validation'
89- import { byError , authorsQueries } from ' src/error-filtering'
9089import { useStepperErrors } from ' src/store/stepper-errors'
90+ import { useValidation } from ' src/store/validation'
9191
9292export default defineComponent ({
9393 name: ' ScreenAuthors' ,
@@ -107,40 +107,27 @@ export default defineComponent({
107107 const { errors } = useValidation ()
108108 const editingId = ref (- 1 )
109109 const addAuthor = async () => {
110- let newAuthors: AuthorType []
111110 const newAuthor: AuthorType = {}
112- if (authors .value === undefined ) {
113- newAuthors = [newAuthor ]
114- } else {
115- newAuthors = [... authors .value , newAuthor ]
116- }
111+ const newAuthors = [... authors .value , newAuthor ]
117112 setAuthors (newAuthors )
118113 editingId .value = newAuthors .length - 1
119114 // await the DOM update that resulted from updating the authors list
120115 await nextTick ()
121116 scrollToBottom ()
122117 }
123118 const removeAuthor = () => {
124- if (authors .value !== undefined ) {
125- const newAuthors = [... authors .value ]
126- newAuthors .splice (editingId .value , 1 )
127- setAuthors (newAuthors )
128- editingId .value = - 1
129- if (Array .isArray (newAuthors ) && newAuthors .length === 0 ) {
130- setAuthors ([])
131- }
132- }
119+ const newAuthors = [... authors .value ]
120+ newAuthors .splice (editingId .value , 1 )
121+ setAuthors (newAuthors )
122+ editingId .value = - 1
133123 }
134124 const setAuthorField = (field : keyof AuthorType , value : string ) => {
135- if (authors .value !== undefined ) {
136- const author = { ... authors .value [editingId .value ] }
137- author [field ] = value === ' ' ? undefined : value
138- authors .value [editingId .value ] = author
139- setAuthors (authors .value )
140- }
125+ const newAuthor = { ... authors .value [editingId .value ] }
126+ newAuthor [field ] = value === ' ' ? undefined : value
127+ authors .value [editingId .value ] = newAuthor
128+ setAuthors (authors .value )
141129 }
142130 const moveAuthorUp = (index : number ) => {
143- if (authors .value === undefined ) return
144131 moveUp (index , authors .value , setAuthors )
145132 if (editingId .value === index && index > 0 ) {
146133 editingId .value = editingId .value - 1
@@ -149,7 +136,6 @@ export default defineComponent({
149136 }
150137 }
151138 const moveAuthorDown = (index : number ) => {
152- if (authors .value === undefined ) return
153139 moveDown (index , authors .value , setAuthors )
154140 if (editingId .value === index && index < authors .value .length - 1 ) {
155141 editingId .value = editingId .value + 1
0 commit comments