X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/45ee419ff7952fc722a139666c327a321a92cc81..796a3ce005800d37ef5711b367c926ac720577d5:/src/models/vocabulary.ts?ds=sidebyside diff --git a/src/models/vocabulary.ts b/src/models/vocabulary.ts index 158d8058..ebef70f0 100644 --- a/src/models/vocabulary.ts +++ b/src/models/vocabulary.ts @@ -50,6 +50,14 @@ export const getTagValueID = (tagKeyID:string, tagValueLabel:string, vocabulary: l => l.label === tagValueLabel) !== undefined) || '' : ''; +export const getTagValueLabel = (tagKeyID:string, tagValueID:string, vocabulary: Vocabulary) => + vocabulary.tags[tagKeyID] && + vocabulary.tags[tagKeyID].values && + vocabulary.tags[tagKeyID].values![tagValueID] && + vocabulary.tags[tagKeyID].values![tagValueID].labels.length > 0 + ? vocabulary.tags[tagKeyID].values![tagValueID].labels[0].label + : tagValueID; + const compare = (a: PropFieldSuggestion, b: PropFieldSuggestion) => { if (a.label < b.label) {return -1;} if (a.label > b.label) {return 1;} @@ -86,4 +94,10 @@ export const getTags = ({ tags }: Vocabulary) => { export const getTagKeyID = (tagKeyLabel:string, vocabulary: Vocabulary) => Object.keys(vocabulary.tags).find( k => vocabulary.tags[k].labels.find( - l => l.label === tagKeyLabel) !== undefined) || ''; + l => l.label === tagKeyLabel) !== undefined + ) || ''; + +export const getTagKeyLabel = (tagKeyID:string, vocabulary: Vocabulary) => + vocabulary.tags[tagKeyID] && vocabulary.tags[tagKeyID].labels.length > 0 + ? vocabulary.tags[tagKeyID].labels[0].label + : tagKeyID;