|
facetsFromParams() { |
|
if (this.facetString !== '') { |
|
const categoryArray = this.facetString.split(','); |
|
for (let i = 0; i < (categoryArray.length); i++) { |
|
const categorySplit = categoryArray[i].split('*'); |
|
const category = categorySplit[0]; |
|
const fieldsArr = categorySplit[1].split('+'); |
|
const params: { [facetValueLabel: string]: boolean } = {}; |
|
let hasSelections = false; |
|
let isAllMatch = false; |
|
let hasExcludeOption = false; |
|
let includeOptionsLength = 0; |
|
for (let j = 0; j < fieldsArr.length; j++) { |
|
const field = fieldsArr[j].split('.'); |
|
field[0] = decodeURIComponent(field[0]); |
|
if (field[0] === 'is_all_match') { |
|
isAllMatch = true; |
|
} else { |
|
if (field[1] === 'true') { |
|
params[field[0]] = true; |
|
hasSelections = true; |
|
includeOptionsLength++; |
|
} else if (field[1] === 'false') { |
|
params[field[0]] = false; |
|
hasSelections = true; |
|
hasExcludeOption = true; |
|
} |
|
} |
|
} |
|
if (hasSelections === true) { |
|
this.facetBuilder[category] = { params: params, hasSelections: true, isAllMatch: isAllMatch }; |
|
if (!hasExcludeOption && includeOptionsLength > 1) { |
|
this.facetBuilder[category].showAllMatchOption = true; |
|
} |
|
const paramsString = JSON.stringify(params); |
|
const newHash = this.utilsService.hashCode(paramsString, |
|
this.facetBuilder[category].isAllMatch.toString(), |
|
this.showDeprecated.toString()); |
|
this.facetBuilder[category].currentStateHash = newHash; |
|
} |
|
} |
|
this.privateFacetParams = this.facetBuilder; |
|
this.previousFacets.push(JSON.parse(JSON.stringify(this.privateFacetParams))); |
|
} |
|
} |
This section of the code ends up using "*", ",", "+", and "." in special ways. However, it's not uncommon for facet values to have any/each of these characters. There needs to be a strategy to encode them.
GSRSFrontend/src/app/core/facets-manager/facets-manager.component.ts
Lines 177 to 221 in ba13df3
This section of the code ends up using "*", ",", "+", and "." in special ways. However, it's not uncommon for facet values to have any/each of these characters. There needs to be a strategy to encode them.