18866: Fixes the bug. 18866-property-editor-bugfix
authorLucas Di Pentima <lucas.dipentima@curii.com>
Tue, 15 Mar 2022 17:21:51 +0000 (14:21 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Tue, 15 Mar 2022 17:21:51 +0000 (14:21 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

src/models/vocabulary.ts

index 6c6290597c6e85d571e19b73d1a07404ac14011b..c913bd65124544b475d7816a73db6d5728104535 100644 (file)
@@ -45,12 +45,17 @@ export const isStrictTag = (tagKeyID: string, vocabulary: Vocabulary) => {
     return tag ? tag.strict : false;
 };
 
-export const getTagValueID = (tagKeyID:string, tagValueLabel:string, vocabulary: Vocabulary) =>
-    (tagKeyID && vocabulary.tags[tagKeyID] && vocabulary.tags[tagKeyID].values)
-    ? Object.keys(vocabulary.tags[tagKeyID].values!).find(
-        k => vocabulary.tags[tagKeyID].values![k].labels.find(
-            l => l.label.toLowerCase() === tagValueLabel.toLowerCase()) !== undefined) || ''
-    : '';
+export const getTagValueID = (tagKeyID:string, tagValueLabel:string, vocabulary: Vocabulary) => {
+    if (tagKeyID && vocabulary.tags[tagKeyID] && vocabulary.tags[tagKeyID].values) {
+        const values = vocabulary.tags[tagKeyID].values!;
+        return Object.keys(values).find(k =>
+            (k.toLowerCase() === tagValueLabel.toLowerCase())
+            || values[k].labels.find(
+                l => l.label.toLowerCase() === tagValueLabel.toLowerCase()) !== undefined)
+            || '';
+    };
+    return '';
+};
 
 export const getTagValueLabel = (tagKeyID:string, tagValueID:string, vocabulary: Vocabulary) =>
     vocabulary.tags[tagKeyID] &&
@@ -130,11 +135,11 @@ export const getPreferredTags = ({ tags }: Vocabulary, withMatch?: string): Prop
         : [];
 };
 
-export const getTagKeyID = (tagKeyLabel:string, vocabulary: Vocabulary) =>
-    Object.keys(vocabulary.tags).find(
-        k => vocabulary.tags[k].labels.find(
-            l => l.label.toLowerCase() === tagKeyLabel.toLowerCase()) !== undefined
-        || '';
+export const getTagKeyID = (tagKeyLabel: string, vocabulary: Vocabulary) =>
+    Object.keys(vocabulary.tags).find(k => (k.toLowerCase() === tagKeyLabel.toLowerCase())
+        || vocabulary.tags[k].labels.find(
+            l => l.label.toLowerCase() === tagKeyLabel.toLowerCase()) !== undefined)
+        || '';
 
 export const getTagKeyLabel = (tagKeyID:string, vocabulary: Vocabulary) =>
     vocabulary.tags[tagKeyID] && vocabulary.tags[tagKeyID].labels.length > 0