File tree Expand file tree Collapse file tree 1 file changed +35
-9
lines changed
src/components/ShaclForm/Editor Expand file tree Collapse file tree 1 file changed +35
-9
lines changed Original file line number Diff line number Diff line change 33 class =" input-field"
44 :value =" toInputValue(value)"
55 @input =" onInput"
6+ :key =" resolvedCounter"
67 >
78 <option :value =" null" >
89 - select -
910 </option >
1011 <option
11- v-for =" option in createOptions() "
12- :key =" option. key"
13- :value =" option. key"
12+ v-for =" key in keys "
13+ :key =" key"
14+ :value =" key"
1415 >
15- {{ option.value }}
16+ {{ values[key] }}
1617 </option >
1718 </select >
1819</template >
@@ -21,6 +22,8 @@ import * as $rdf from 'rdflib'
2122import _ from ' lodash'
2223import { Component , Prop , Vue } from ' vue-property-decorator'
2324import rdfUtils from ' @/rdf/utils'
25+ import api from ' @/api'
26+ import { SHACL } from ' @/rdf/namespaces'
2427
2528@Component ({})
2629export default class EnumSelectEditor extends Vue {
@@ -30,11 +33,34 @@ export default class EnumSelectEditor extends Vue {
3033 @Prop ({ required: true })
3134 readonly value: any
3235
33- createOptions() {
34- return _ .get (this .field , ' in' , []).map ((val ) => ({
35- key: val ,
36- value: rdfUtils .pathTerm (val ),
37- }))
36+ keys : any
37+
38+ values : any
39+
40+ resolvedCounter : number = 0
41+
42+ created(): void {
43+ this .keys = []
44+ this .values = {}
45+
46+ _ .get (this .field , ' in' , []).forEach ((key ) => {
47+ this .keys .push (key )
48+ this .values [key ] = rdfUtils .pathTerm (key )
49+
50+ if (this .field .nodeKind === SHACL (' IRI' ).value ) {
51+ this .resolveValue (key )
52+ }
53+ })
54+ }
55+
56+ async resolveValue(key : string ): Promise <void > {
57+ try {
58+ const label = await api .label .getLabel (key )
59+ this .values [key ] = label .data .label
60+ this .resolvedCounter += 1
61+ } catch {
62+ // nothing could be fetched, keep default label
63+ }
3864 }
3965
4066 onInput(e ) {
You can’t perform that action at this time.
0 commit comments