Skip to content

Commit

Permalink
Merge pull request Marklogic-retired#207 in PROD/explorer-ui from ~SV…
Browse files Browse the repository at this point in the history
…ISHAKA/explorer-ui:DHFPROD-4259 to develop

* commit 'db9aa6fc0a4d3487895e3556f3d9f7d799c64838':
  removed extra for loop
  duplicate facets fix
  • Loading branch information
Bruce An authored and Bruce An committed Jan 31, 2020
2 parents e85e99f + db9aa6f commit 22b7854
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
9 changes: 6 additions & 3 deletions src/components/facet/facet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ const Facet: React.FC<Props> = (props) => {

const checkFacetValues = (checkedValues) => {
let updatedChecked = [...checked];
props.addFacetValues(props.constraint, checkedValues, props.facetType, props.facetCategory);
updatedChecked.push(...checkedValues);
for(let value of checkedValues){
if(updatedChecked.indexOf(value) === -1)
updatedChecked.push(value);
}
setChecked(updatedChecked);
props.addFacetValues(props.constraint, updatedChecked, props.facetType, props.facetCategory);
toggleApply(true);
}

Expand Down Expand Up @@ -165,7 +168,7 @@ const Facet: React.FC<Props> = (props) => {
onClick={() => showMore()}
data-cy="show-more"
>{(more) ? '<< less' : 'more >>'}</div>
{props.facetType === 'xs:string' &&
{props.facetType === 'xs:string' && props.facetValues.length >= 25 &&
<div className={styles.searchValues}>
<PopOverSearch
name={props.name}
Expand Down
17 changes: 8 additions & 9 deletions src/components/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ const Sidebar: React.FC<Props> = (props) => {
let additionalFacetVals = vals.map(item => {
return { name: item, count: 0, value: item }
});

if (!newAllSelectedfacets.hasOwnProperty(constraint)) {
// facet value doesn't exist
newAllSelectedfacets = {
...newAllSelectedfacets,
Expand All @@ -174,14 +172,15 @@ const Sidebar: React.FC<Props> = (props) => {
[valueKey]: vals
}
}
// TODO duplicate facet is added if additional facet vals contains
// existing value
newEntityFacets[index]['facetValues'].unshift(...additionalFacetVals);
} else {
// add facet vals to selected facet
newAllSelectedfacets[constraint][valueKey].push(...vals)
for (let i = 0; i < additionalFacetVals.length; i++) {
for (let j = 0; j < newEntityFacets[index]['facetValues'].length; j++) {
if (additionalFacetVals[i].name === newEntityFacets[index]['facetValues'][j].name) {
newEntityFacets[index]['facetValues'].splice(j, 1);
break;
}
}
newEntityFacets[index]['facetValues'].unshift(additionalFacetVals[i]);
}

}
setEntityFacets(newEntityFacets);
} else if (facetCategory === 'hub') {
Expand Down

0 comments on commit 22b7854

Please sign in to comment.