|
|
|
@ -43,7 +43,7 @@ Object.defineProperty(tree.Filterset.prototype, 'clone', {
|
|
|
|
|
Object.defineProperty(tree.Filterset.prototype, 'cloneWith', {
|
|
|
|
|
enumerable: false,
|
|
|
|
|
value: function(other) {
|
|
|
|
|
var additions;
|
|
|
|
|
var additions = [];
|
|
|
|
|
for (var id in other) {
|
|
|
|
|
var status = this.addable(other[id]);
|
|
|
|
|
if (status === false) {
|
|
|
|
@ -51,14 +51,13 @@ Object.defineProperty(tree.Filterset.prototype, 'cloneWith', {
|
|
|
|
|
}
|
|
|
|
|
if (status === true) {
|
|
|
|
|
// Adding the filter will override another value.
|
|
|
|
|
if (!additions) additions = [];
|
|
|
|
|
additions.push(other[id]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Adding the other filters doesn't make this filterset invalid, but it
|
|
|
|
|
// doesn't add anything to it either.
|
|
|
|
|
if (!additions) return null;
|
|
|
|
|
if (!additions.length) return null;
|
|
|
|
|
|
|
|
|
|
// We can successfully add all filters. Now clone the filterset and add the
|
|
|
|
|
// new rules.
|
|
|
|
@ -79,13 +78,11 @@ Object.defineProperty(tree.Filterset.prototype, 'cloneWith', {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns true when the new filter can be added, false otherwise.
|
|
|
|
|
*/
|
|
|
|
|
// Returns true when the new filter can be added, false otherwise.
|
|
|
|
|
Object.defineProperty(tree.Filterset.prototype, 'addable', {
|
|
|
|
|
enumerable: false,
|
|
|
|
|
value: function(filter) {
|
|
|
|
|
var key = filter.key, value = filter.val;
|
|
|
|
|
var key = filter.key.toString(), value = filter.val;
|
|
|
|
|
|
|
|
|
|
switch (filter.op) {
|
|
|
|
|
case '=':
|
|
|
|
@ -141,13 +138,11 @@ Object.defineProperty(tree.Filterset.prototype, 'addable', {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Only call this function for filters that have been cleared by .addable().
|
|
|
|
|
*/
|
|
|
|
|
// Only call this function for filters that have been cleared by .addable().
|
|
|
|
|
Object.defineProperty(tree.Filterset.prototype, 'add', {
|
|
|
|
|
enumerable: false,
|
|
|
|
|
value: function(filter) {
|
|
|
|
|
var key = filter.key;
|
|
|
|
|
var key = filter.key.toString();
|
|
|
|
|
|
|
|
|
|
switch (filter.op) {
|
|
|
|
|
case '=':
|
|
|
|
|