瀏覽代碼

rewrite Filter._getMongoSelecto to not include Empty Filter.

IgnatzHome 7 年之前
父節點
當前提交
39974c9532
共有 1 個文件被更改,包括 10 次插入12 次删除
  1. 10 12
      client/lib/filter.js

+ 10 - 12
client/lib/filter.js

@@ -248,18 +248,16 @@ Filter = {
 
 
     const exceptionsSelector = {_id: {$in: this._exceptions}};
     const exceptionsSelector = {_id: {$in: this._exceptions}};
     this._exceptionsDep.depend();
     this._exceptionsDep.depend();
-    console.log("Final Filter:");
-    console.log({
-      $or: [filterSelector, exceptionsSelector, this.advanced._getMongoSelector()],
-    });
-    if (includeEmptySelectors)
-      return {
-        $or: [filterSelector, exceptionsSelector, this.advanced._getMongoSelector(), emptySelector],
-      };
-    else
-      return {
-        $or: [filterSelector, exceptionsSelector, this.advanced._getMongoSelector()],
-      };
+
+    const selectors = [exceptionsSelector];
+
+    if (_.any(this._fields, (fieldName) => {
+      return this[fieldName]._isActive();
+    })) selectors.push(filterSelector);
+    if (includeEmptySelectors) selectors.push(emptySelector);
+    if (this.advanced._isActive()) selectors.push(this.advanced._getMongoSelector());
+
+    return {$or: selectors};
   },
   },
 
 
   mongoSelector(additionalSelector) {
   mongoSelector(additionalSelector) {