Skip to content

Commit

Permalink
Change how sub-property filter works
Browse files Browse the repository at this point in the history
We used camelCase to determine subEntities that generate incongruences with properties like 'usageYear'
Instead now we use dash '-' to determine nesting
  • Loading branch information
manelcecs committed Jan 22, 2024
1 parent 2bfa08c commit 95988e6
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/domain-services/flows/flow-search-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,11 @@ export class FlowSearchService {
orderBy.column = struct[2];
orderBy.direction = struct[1] as FlowNestedDirection;

// We need to look after the capitalized letter
// that will indicate the entity
// and the whole word will be the subEntity
// Capitalized letter will never be the first letter
const entity = this.getSubstringUntilCapital(struct[0]);
// We need to look after the '-' character
// [0] will indicate the entity
// and [1] will be the subEntity
const splitted = struct[0].split('-');
const entity = splitted[0];
orderBy.entity = entity;

if (entity === struct[0]) {
Expand All @@ -442,15 +442,6 @@ export class FlowSearchService {
return orderBy;
}

getSubstringUntilCapital(inputString: string): string {
for (let i = 0; i < inputString.length; i++) {
if (inputString[i] === inputString[i].toUpperCase()) {
return inputString.substring(0, i);
}
}
return inputString; // Return inputString if no capital letter is found
}

prepareFlowConditions(flowFilters: SearchFlowsFilters): any {
let flowConditions = {};

Expand Down

0 comments on commit 95988e6

Please sign in to comment.