22 <q-card
33 flat
44 bordered
5- class =" bg-formcard"
5+ v-bind: class =" [' bg-formcard', 'q-pa-md', identifierErrors.hasError ? 'red-border' : ''] "
66 >
77 <q-card-section >
88 <div class =" row items-center no-wrap" >
99 <q-option-group
1010 inline
1111 type =" radio"
12+ v-bind:error =" typeError.hasError"
13+ v-bind:error-message =" typeError.messages.join(', ')"
1214 v-bind:model-value =" type"
1315 v-bind:options =" typeOptions"
1416 v-on:update:modelValue ="
2325 outlined
2426 standout
2527 dense
28+ v-bind:error =" valueError.hasError"
29+ v-bind:error-message =" valueError.messages.join(', ')"
2630 v-bind:model-value =" value"
2731 v-on:update:modelValue ="
2832 $emit('updateValue', 'value', $event)
3640 outlined
3741 standout
3842 dense
43+ v-bind:error =" descriptionError.hasError"
44+ v-bind:error-message =" descriptionError.messages.join(', ')"
3945 v-bind:model-value =" description"
4046 v-on:update:modelValue ="
4147 $emit('updateDescription', 'description', $event)
7985
8086<script lang="ts">
8187import { IdentifierTypeType } from ' ../types'
82- import { defineComponent , PropType } from ' vue'
88+ import { computed , defineComponent , PropType } from ' vue'
89+ import { getMyErrors } from ' src/store/validator'
90+ import { identifierErrors } from ' src/identifier-errors'
8391
8492export default defineComponent ({
8593 name: ' IdentifierCardEditing' ,
@@ -105,23 +113,18 @@ export default defineComponent({
105113 default: 0
106114 }
107115 },
108- setup () {
109- // validating of value depends on type
110- // const valueValidators: Record<IdentifierTypeType, (val: unknown) => true | string > = {
111- // doi: makeFieldValidator('/definitions/identifier/anyOf/0/properties/value'),
112- // url: makeFieldValidator('/definitions/identifier/anyOf/1/properties/value'),
113- // swh: makeFieldValidator('/definitions/identifier/anyOf/2/properties/value'),
114- // other: makeFieldValidator('/definitions/identifier/anyOf/3/properties/value')
115- // }
116+ setup (props ) {
116117 return {
117- // validateValue: (val: string) => valueValidators[props.type as IdentifierTypeType](val),
118- // validateDescription: makeOptionalFieldValidator('/definitions/identifier-description'),
119118 typeOptions: [
120119 { label: ' DOI' , value: ' doi' },
121120 { label: ' URL' , value: ' url' },
122121 { label: ' Software Heritage' , value: ' swh' },
123122 { label: ' Other' , value: ' other' }
124- ]
123+ ],
124+ typeError: computed (() => getMyErrors (` /identifiers/${props .index }/type ` )),
125+ valueError: computed (() => getMyErrors (` /identifiers/${props .index }/value ` )),
126+ descriptionError: computed (() => getMyErrors (` /identifiers/${props .index }/description ` )),
127+ identifierErrors: computed (() => identifierErrors (props .index ))
125128 }
126129 },
127130 emits: [' closePressed' , ' removePressed' , ' updateType' , ' updateValue' , ' updateDescription' , ' moveUp' , ' moveDown' ]
0 commit comments