Skip to content

Commit

Permalink
Unique names for query parameters (re #164)
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Short authored and jezdez committed Jan 25, 2019
1 parent 23d6f7a commit 9614858
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions client/app/services/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class Parameter {
};
}
return {
[`p_${this.name}`]: this.value,
[`p_${this.name}_${this.queryId}`]: this.value,
};
}

Expand All @@ -158,7 +158,7 @@ class Parameter {
this.setValue([query[keyStart], query[keyEnd]]);
}
} else {
const key = `p_${this.name}`;
const key = `p_${this.name}_${this.queryId}`;
if (has(query, key)) {
this.setValue(query[key]);
}
Expand Down Expand Up @@ -221,7 +221,9 @@ class Parameters {
});

const parameterExists = p => includes(parameterNames, p.name);
this.query.options.parameters = this.query.options.parameters.filter(parameterExists).map(p => new Parameter(p));
this.query.options.parameters = this.query.options.parameters
.filter(parameterExists)
.map(p => new Parameter(Object.assign({ queryId: this.query.id }, p)));
}

initFromQueryString(query) {
Expand Down Expand Up @@ -486,7 +488,7 @@ function QueryResource(
params += '&';
}

params += `p_${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
params += `p_${encodeURIComponent(name)}_${this.id}=${encodeURIComponent(value)}`;
});
}

Expand Down

0 comments on commit 9614858

Please sign in to comment.