From 0c18866dfb11742ba5d60684b1bc3e7e3537aaa5 Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Fri, 7 May 2021 15:58:01 -0400 Subject: [PATCH 1/4] Directly force database name into short synonym field --- src/client/components/element-info/entity-info.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/client/components/element-info/entity-info.js b/src/client/components/element-info/entity-info.js index 2a2c72a8e..7e56125bf 100644 --- a/src/client/components/element-info/entity-info.js +++ b/src/client/components/element-info/entity-info.js @@ -373,6 +373,16 @@ class EntityInfo extends DataComponent { assoc = null; } + // Add association 'name' as a (short) synonym, if different than input + if( assoc ) { + const { name: assocName } = assoc; + if( assocName !== s.name ){ + const shortSynonyms = _.get( assoc, 'shortSynonyms', [] ); + const updatedSynonyms = _.uniq( _.concat( assocName, shortSynonyms ) ); + _.set( assoc, 'shortSynonyms', updatedSynonyms ); + } + } + let targetFromAssoc = (m, complete = false, showRefinement = false) => { let highlight = !complete; let searchStr = highlight ? s.name : null; From 66c991619dccd5b6695009db09af226956eafafe Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Mon, 10 May 2021 16:50:09 -0400 Subject: [PATCH 2/4] Add (remove) the name to (from) the match --- .../components/element-info/entity-info.js | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/client/components/element-info/entity-info.js b/src/client/components/element-info/entity-info.js index 7e56125bf..8ae6b6043 100644 --- a/src/client/components/element-info/entity-info.js +++ b/src/client/components/element-info/entity-info.js @@ -148,6 +148,21 @@ class EntityInfo extends DataComponent { delete match.typeOfGene; // n.b. the model overrides via this field } + if( s.name !== match.name ) { + // Add 'name' to shortSynonyms + let shortSyns = _.get( match, 'shortSynonyms', [] ); + let newShortSyns = _.uniq( _.concat( match.name, shortSyns ) ); + _.set( match, 'shortSynonyms', newShortSyns ); + } + + const assoc = el.association(); + if( assoc ) { + // Drop 'name' from shortSynonyms + let shortSyns = _.get( assoc, 'shortSynonyms', [] ); + let newShortSyns = _.without( shortSyns, assoc.name ); + _.set( assoc, 'shortSynonyms', newShortSyns ); + } + el.associate( match ); el.complete(); @@ -373,16 +388,6 @@ class EntityInfo extends DataComponent { assoc = null; } - // Add association 'name' as a (short) synonym, if different than input - if( assoc ) { - const { name: assocName } = assoc; - if( assocName !== s.name ){ - const shortSynonyms = _.get( assoc, 'shortSynonyms', [] ); - const updatedSynonyms = _.uniq( _.concat( assocName, shortSynonyms ) ); - _.set( assoc, 'shortSynonyms', updatedSynonyms ); - } - } - let targetFromAssoc = (m, complete = false, showRefinement = false) => { let highlight = !complete; let searchStr = highlight ? s.name : null; From 0bb39d57cc60cd06b44ffbe767ba6e727df20440 Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Mon, 10 May 2021 19:02:11 -0400 Subject: [PATCH 3/4] Comments describing logic for dealing with match name --- src/client/components/element-info/entity-info.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/client/components/element-info/entity-info.js b/src/client/components/element-info/entity-info.js index 8ae6b6043..997112175 100644 --- a/src/client/components/element-info/entity-info.js +++ b/src/client/components/element-info/entity-info.js @@ -148,16 +148,18 @@ class EntityInfo extends DataComponent { delete match.typeOfGene; // n.b. the model overrides via this field } - if( s.name !== match.name ) { - // Add 'name' to shortSynonyms - let shortSyns = _.get( match, 'shortSynonyms', [] ); - let newShortSyns = _.uniq( _.concat( match.name, shortSyns ) ); + // If label is different from match 'name', add latter to shortSynonyms + const label = s.name; + let matchShortSyns = _.get( match, 'shortSynonyms', [] ); + let inputNotMatchName = label !== match.name; + if ( inputNotMatchName ) { + let newShortSyns = _.uniq( _.concat( match.name, matchShortSyns ) ); _.set( match, 'shortSynonyms', newShortSyns ); } + // Remove the match 'name' from the current association, if exists const assoc = el.association(); if( assoc ) { - // Drop 'name' from shortSynonyms let shortSyns = _.get( assoc, 'shortSynonyms', [] ); let newShortSyns = _.without( shortSyns, assoc.name ); _.set( assoc, 'shortSynonyms', newShortSyns ); From d2a00eff1aefc9e86127d478ad8b3f9c80adeb31 Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Wed, 12 May 2021 13:21:26 -0400 Subject: [PATCH 4/4] Compare label to match names in a case-insensitive manner --- src/client/components/element-info/entity-info.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/client/components/element-info/entity-info.js b/src/client/components/element-info/entity-info.js index 997112175..3e4659020 100644 --- a/src/client/components/element-info/entity-info.js +++ b/src/client/components/element-info/entity-info.js @@ -149,9 +149,8 @@ class EntityInfo extends DataComponent { } // If label is different from match 'name', add latter to shortSynonyms - const label = s.name; let matchShortSyns = _.get( match, 'shortSynonyms', [] ); - let inputNotMatchName = label !== match.name; + let inputNotMatchName = _.toLower( s.name ) !== _.toLower( match.name ); if ( inputNotMatchName ) { let newShortSyns = _.uniq( _.concat( match.name, matchShortSyns ) ); _.set( match, 'shortSynonyms', newShortSyns );