Skip to content

Commit ab2173e

Browse files
committed
add type for link info
1 parent 0122df1 commit ab2173e

2 files changed

Lines changed: 36 additions & 23 deletions

File tree

src/components/IdentifierCardEditing.vue

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313
v-bind:error-message="typeError.messages.join(', ')"
1414
v-bind:model-value="type"
1515
v-bind:options="typeOptions"
16-
v-on:update:modelValue="
17-
$emit('updateType', 'type', $event)
18-
"
16+
v-on:update:modelValue="$emit('updateType', 'type', $event)"
1917
/>
2018
</div>
2119
<div class="q-gutter-md q-mt-md items-center no-wrap">
2220
<p class="question">
23-
What is the value of the {{getLinkLabel}}?
24-
<SchemaGuideLink :anchor="getLinkUrl" />
21+
What is the value of the {{ getLinkLabel }}?
22+
<SchemaGuideLink v-bind:anchor="getLinkUrl" />
2523
</p>
2624
<q-input
2725
bg-color="white"
@@ -32,14 +30,12 @@
3230
v-bind:error="valueError.hasError"
3331
v-bind:error-message="valueError.messages.join(', ')"
3432
v-bind:model-value="value"
35-
v-on:update:modelValue="
36-
$emit('updateValue', 'value', $event)
37-
"
33+
v-on:update:modelValue="$emit('updateValue', 'value', $event)"
3834
/>
3935
</div>
4036
<div class="q-gutter-md q-mt-md items-center no-wrap">
4137
<p class="question">
42-
What is the description for the {{getLinkLabel}}?
38+
What is the description for the {{ getLinkLabel }}?
4339
<SchemaGuideLink anchor="#definitionsidentifier-description" />
4440
</p>
4541
<q-input
@@ -51,9 +47,7 @@
5147
v-bind:error="descriptionError.hasError"
5248
v-bind:error-message="descriptionError.messages.join(', ')"
5349
v-bind:model-value="description"
54-
v-on:update:modelValue="
55-
$emit('updateDescription', 'description', $event)
56-
"
50+
v-on:update:modelValue="$emit('updateDescription', 'description', $event)"
5751
/>
5852
</div>
5953
</q-card-section>
@@ -92,12 +86,11 @@
9286
</template>
9387

9488
<script lang="ts">
95-
import {ref} from 'vue'
96-
import { IdentifierTypeType } from '../types'
89+
import { IdentifierTypeType, linkInfoType } from '../types'
9790
import { computed, defineComponent, PropType } from 'vue'
9891
import { getMyErrors } from 'src/store/validator'
9992
import { identifierErrors } from 'src/identifier-errors'
100-
import SchemaGuideLink from "components/SchemaGuideLink.vue";
93+
import SchemaGuideLink from 'components/SchemaGuideLink.vue'
10194
10295
export default defineComponent({
10396
name: 'IdentifierCardEditing',
@@ -127,11 +120,13 @@ export default defineComponent({
127120
SchemaGuideLink
128121
},
129122
setup (props) {
130-
131-
const linkInfo: any = {
123+
const linkInfo: linkInfoType = {
132124
doi: { linkLabel: 'DOI', linkUrl: '#definitionsdoi' },
133125
url: { linkLabel: 'URL', linkUrl: '#definitionsurl' },
134-
swh: { linkLabel: 'Software Heritage identifier', linkUrl: '#definitionsswh-identifier' },
126+
swh: {
127+
linkLabel: 'Software Heritage identifier',
128+
linkUrl: '#definitionsswh-identifier'
129+
},
135130
other: { linkLabel: 'identifier', linkUrl: '#definitionsidentifier-description' }
136131
}
137132
@@ -143,25 +138,41 @@ export default defineComponent({
143138
{ label: 'Other', value: 'other' }
144139
],
145140
getLinkLabel: computed(() => {
141+
// console.log("label props:", props.type);
142+
// return "Label"
146143
return linkInfo[props.type].linkLabel
147144
}),
148145
getLinkUrl: computed(() => {
146+
// let reallyString = <string>props.type;
147+
// console.log("url props:", props.type);
148+
// console.log("reallyString:", reallyString);
149+
// return "Url"
149150
return linkInfo[props.type].linkUrl
150151
}),
151152
typeError: computed(() => getMyErrors(`/identifiers/${props.index}/type`)),
152153
valueError: computed(() => getMyErrors(`/identifiers/${props.index}/value`)),
153-
descriptionError: computed(() => getMyErrors(`/identifiers/${props.index}/description`)),
154+
descriptionError: computed(() =>
155+
getMyErrors(`/identifiers/${props.index}/description`)
156+
),
154157
identifierErrors: computed(() => identifierErrors(props.index)),
155158
SchemaGuideLink
156159
}
157160
},
158-
emits: ['closePressed', 'removePressed', 'updateType', 'updateValue', 'updateDescription', 'moveUp', 'moveDown']
161+
emits: [
162+
'closePressed',
163+
'removePressed',
164+
'updateType',
165+
'updateValue',
166+
'updateDescription',
167+
'moveUp',
168+
'moveDown'
169+
]
159170
})
160171
</script>
161172
<style scoped>
162173
.row {
163-
display: flex;
164-
flex-direction: row;
165-
column-gap: 10px;
174+
display: flex;
175+
flex-direction: row;
176+
column-gap: 10px;
166177
}
167178
</style>

src/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export type IdentifiersType = Array<IdentifierType> | undefined
2121

2222
export type KeywordsType = Array<string> | undefined
2323

24+
export type linkInfoType = Record<string, Record<string, string>>
25+
2426
export type TypeType = 'software' | 'dataset'
2527

2628
export type CffType = {

0 commit comments

Comments
 (0)