forked from MapComplete/MapComplete
Improve the precise input element, normalize 'and' to check if it is empty (and to check if no filter is active)
This commit is contained in:
parent
475b89a794
commit
a4f4365d71
10 changed files with 262 additions and 28 deletions
|
@ -5,7 +5,19 @@ export class And extends TagsFilter {
|
|||
|
||||
constructor(and: TagsFilter[]) {
|
||||
super();
|
||||
this.and = and;
|
||||
this.and = and
|
||||
}
|
||||
|
||||
normalize(){
|
||||
const ands = []
|
||||
for (const c of this.and) {
|
||||
if(c instanceof And){
|
||||
ands.push(...c.and)
|
||||
}else{
|
||||
ands.push(c)
|
||||
}
|
||||
}
|
||||
return new And(ands)
|
||||
}
|
||||
|
||||
private static combine(filter: string, choices: string[]): string[] {
|
||||
|
@ -64,17 +76,6 @@ export class And extends TagsFilter {
|
|||
return false;
|
||||
}
|
||||
|
||||
for (const selfTag of this.and) {
|
||||
let matchFound = false;
|
||||
for (let i = 0; i < other.and.length && !matchFound; i++) {
|
||||
let otherTag = other.and[i];
|
||||
matchFound = selfTag.isEquivalent(otherTag);
|
||||
}
|
||||
if (!matchFound) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (const selfTag of this.and) {
|
||||
let matchFound = false;
|
||||
for (const otherTag of other.and) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue