aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusodhi <61431818+usodhi@users.noreply.github.com>2021-03-17 22:36:16 -0400
committerusodhi <61431818+usodhi@users.noreply.github.com>2021-03-17 22:36:16 -0400
commita8c02cba0bf96e435e062f2251890243ad8f49e0 (patch)
treed311cf983e609a094efc6c5606423b2ce2727331
parentc4ca83acf90676abf2f822b4b0ff455fe50c0ddb (diff)
made and/or a property of the document so it's saved with the filter
-rw-r--r--src/client/documents/Documents.ts4
-rw-r--r--src/client/util/CurrentUserUtils.ts5
-rw-r--r--src/client/views/PropertiesView.tsx3
-rw-r--r--src/client/views/nodes/FilterBox.tsx9
4 files changed, 12 insertions, 9 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 0d2f04569..ef6623f20 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -1040,7 +1040,7 @@ export namespace DocUtils {
return Field.toString(d[facetKey] as Field).includes(value);
});
// if we're ORing them together, the default return is false, and we return true for a doc if it satisfies any one set of criteria
- if (FilterBox._filterBoolean === "OR") {
+ if ((FilterBox.targetDoc.currentFilter as Doc).filterBoolean === "OR") {
if (satisfiesCheckFacets && !failsNotEqualFacets && satisfiesMatchFacets) return true;
}
// if we're ANDing them together, the default return is true, and we return false for a doc if it doesn't satisfy any set of criteria
@@ -1049,7 +1049,7 @@ export namespace DocUtils {
}
}
- return FilterBox._filterBoolean === "OR" ? false : true;
+ return (FilterBox.targetDoc.currentFilter as Doc).filterBoolean === "OR" ? false : true;
}) : childDocs;
const rangeFilteredDocs = filteredDocs.filter(d => {
for (let i = 0; i < docRangeFilters.length; i += 3) {
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 88bb1207f..157a88de7 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -810,8 +810,9 @@ export class CurrentUserUtils {
_lockedPosition: true, boxShadow: "0 0", childDontRegisterViews: true, targetDropAction: "same", system: true
});
const clearAll = ScriptField.MakeScript(`getProto(self).data = new List([])`);
- (doc.currentFilter as any as Doc).contextMenuScripts = new List<ScriptField>([clearAll!]);
- (doc.currentFilter as any as Doc).contextMenuLabels = new List<string>(["Clear All"]);
+ (doc.currentFilter as Doc).contextMenuScripts = new List<ScriptField>([clearAll!]);
+ (doc.currentFilter as Doc).contextMenuLabels = new List<string>(["Clear All"]);
+ (doc.currentFilter as Doc).filterBoolean = "AND";
}
}
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index c677478cb..b4e15b536 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -74,6 +74,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
@observable openTransform: boolean = true;
@observable openFilters: boolean = true; // should be false
+ /**
+ * autorun to set up the filter doc of a collection if that collection has been selected and the filters panel is open
+ */
private selectedDocListenerDisposer: Opt<Lambda>;
// @observable selectedUser: string = "";
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index d410d2b33..2ed3dc21f 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -44,7 +44,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
}
public static LayoutString(fieldKey: string) { return FieldView.LayoutString(FilterBox, fieldKey); }
- @observable static _filterBoolean = "AND";
@observable static _filterScope = "Current Dashboard";
public _filterSelected = false;
public _filterMatch = "matched";
@@ -279,11 +278,11 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
}
/**
- * Changes the value of the variable that determines whether filters are ANDed or ORed together
+ * Sets whether filters are ANDed or ORed together
*/
@action
changeBool = (e: any) => {
- FilterBox._filterBoolean = e.currentTarget.value;
+ (FilterBox.targetDoc.currentFilter as Doc).filterBoolean = e.currentTarget.value;
}
/**
@@ -388,8 +387,8 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
<div className="filterBox-select-bool">
<select className="filterBox-selection" onChange={this.changeBool}>
- <option value="AND" key="AND">AND</option>
- <option value="OR" key="OR">OR</option>
+ <option value="AND" key="AND" selected={(FilterBox.targetDoc.currentFilter as Doc).filterBoolean === "AND"}>AND</option>
+ <option value="OR" key="OR" selected={(FilterBox.targetDoc.currentFilter as Doc).filterBoolean === "OR"}>OR</option>
</select>
<div className="filterBox-select-text">filters in </div>
<select className="filterBox-selection" onChange={this.changeScope}>