forked from hazza/dspace-angular
w2p-85346 Allow facets to be authority controlled and add test to verify
This commit is contained in:
@@ -24,6 +24,12 @@ export class FacetValue implements HALResource {
|
|||||||
@autoserialize
|
@autoserialize
|
||||||
count: number;
|
count: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Authority Value for this facet
|
||||||
|
*/
|
||||||
|
@autoserialize
|
||||||
|
authorityKey?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link HALLink}s for this FacetValue
|
* The {@link HALLink}s for this FacetValue
|
||||||
*/
|
*/
|
||||||
|
@@ -12,6 +12,7 @@ describe('Search Utils', () => {
|
|||||||
let facetValueWithSearchHref: FacetValue;
|
let facetValueWithSearchHref: FacetValue;
|
||||||
let facetValueWithoutSearchHref: FacetValue;
|
let facetValueWithoutSearchHref: FacetValue;
|
||||||
let searchFilterConfig: SearchFilterConfig;
|
let searchFilterConfig: SearchFilterConfig;
|
||||||
|
let facetValueWithSearchHrefAuthority: FacetValue;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
facetValueWithSearchHref = Object.assign(new FacetValue(), {
|
facetValueWithSearchHref = Object.assign(new FacetValue(), {
|
||||||
@@ -22,6 +23,11 @@ describe('Search Utils', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
facetValueWithSearchHrefAuthority = Object.assign(new FacetValue(), {
|
||||||
|
value: 'Value with search href',
|
||||||
|
authorityKey: 'uuid',
|
||||||
|
}
|
||||||
|
);
|
||||||
facetValueWithoutSearchHref = Object.assign(new FacetValue(), {
|
facetValueWithoutSearchHref = Object.assign(new FacetValue(), {
|
||||||
value: 'Value without search href'
|
value: 'Value without search href'
|
||||||
});
|
});
|
||||||
@@ -34,6 +40,10 @@ describe('Search Utils', () => {
|
|||||||
expect(getFacetValueForType(facetValueWithSearchHref, searchFilterConfig)).toEqual('Value with search href,operator');
|
expect(getFacetValueForType(facetValueWithSearchHref, searchFilterConfig)).toEqual('Value with search href,operator');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should retrieve the correct value from the Facet', () => {
|
||||||
|
expect(getFacetValueForType(facetValueWithSearchHrefAuthority, searchFilterConfig)).toEqual('uuid,authority');
|
||||||
|
});
|
||||||
|
|
||||||
it('should return the facet value with an equals operator by default', () => {
|
it('should return the facet value with an equals operator by default', () => {
|
||||||
expect(getFacetValueForType(facetValueWithoutSearchHref, searchFilterConfig)).toEqual('Value without search href,equals');
|
expect(getFacetValueForType(facetValueWithoutSearchHref, searchFilterConfig)).toEqual('Value without search href,equals');
|
||||||
});
|
});
|
||||||
|
@@ -16,6 +16,10 @@ export function getFacetValueForType(facetValue: FacetValue, searchFilterConfig:
|
|||||||
return values[1];
|
return values[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (facetValue.authorityKey) {
|
||||||
|
return addOperatorToFilterValue(facetValue.authorityKey, 'authority');
|
||||||
|
}
|
||||||
|
|
||||||
return addOperatorToFilterValue(facetValue.value, 'equals');
|
return addOperatorToFilterValue(facetValue.value, 'equals');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user