aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusodhi <61431818+usodhi@users.noreply.github.com>2021-03-03 11:18:47 -0500
committerusodhi <61431818+usodhi@users.noreply.github.com>2021-03-03 11:18:47 -0500
commit59044880fcf0eb5ed4ca164de4c533fb7e6378a7 (patch)
tree96bf224ed29a6fa2164978db5fbb8ff7deb0d80a
parent76da783c2174cba248a058d5bcac5651c29541cd (diff)
minor changes
-rw-r--r--src/client/util/CurrentUserUtils.ts4
-rw-r--r--src/client/views/nodes/FilterBox.tsx20
2 files changed, 13 insertions, 11 deletions
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index a2f59e48f..0f7c2571b 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -809,9 +809,9 @@ export class CurrentUserUtils {
if (doc.currentFilter === undefined) {
doc.currentFilter = Docs.Create.FilterDocument({
title: "FilterDoc", _height: 20,
- treeViewHideTitle: true, _xMargin: 5, _yMargin: 5, _gridGap: 5, _yPadding: 10, forceActive: true, childDropAction: "none",
+ treeViewHideTitle: true, _xMargin: 5, _yMargin: 5, _gridGap: 5, _yPadding: 10, _forceActive: true, childDropAction: "none",
treeViewTruncateTitleWidth: 90, treeViewPreventOpen: false, ignoreClick: true,
- lockedPosition: true, boxShadow: "0 0", dontRegisterChildViews: true, targetDropAction: "same", system: true
+ _lockedPosition: true, boxShadow: "0 0", dontRegisterChildViews: 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!]);
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index b25d78a1e..a4ae0b5a3 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -43,7 +43,8 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
constructor(props: Readonly<FieldViewProps>) {
super(props);
FilterBox.Instance = this;
- if (!CollectionDockingView.Instance.props.Document.currentFilter) CurrentUserUtils.setupFilterDocs(CollectionDockingView.Instance.props.Document);
+ const targetDoc = FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+ if (!targetDoc) CurrentUserUtils.setupFilterDocs(targetDoc);
}
public static LayoutString(fieldKey: string) { return FieldView.LayoutString(FilterBox, fieldKey); }
@@ -51,16 +52,20 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
@observable public static _filterScope = "Current Dashboard";
public _filterSelected = false;
public _filterMatch = "matched";
- // private myFiltersRef = React.createRef<HTMLDivElement>();
@observable private showFilterDialog = false;
+ @computed get targetDoc() {
+ return FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+ }
+
@computed get allDocs() {
const allDocs = new Set<Doc>();
- if (CollectionDockingView.Instance) {
- const activeTabs = DocListCast(CollectionDockingView.Instance.props.Document.data);
+ const targetDoc = FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+ if (targetDoc) {
+ const activeTabs = DocListCast(targetDoc.data);
SearchBox.foreachRecursiveDoc(activeTabs, (doc: Doc) => allDocs.add(doc));
- setTimeout(() => CollectionDockingView.Instance.props.Document.allDocuments = new List<Doc>(Array.from(allDocs)));
+ setTimeout(() => targetDoc.allDocuments = new List<Doc>(Array.from(allDocs)));
}
return allDocs;
}
@@ -123,8 +128,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
public removeFilter = (filterName: string) => {
console.log("remove filter");
const targetDoc = FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
- // const targetDoc = SelectionManager.Views()[0].props.Document;
- // const targetDoc = SelectionManager.Views()[0].Document; // CollectionDockingView.Instance.props.Document;
const filterDoc = targetDoc.currentFilter as Doc;
const attributes = DocListCast(filterDoc["data"]);
const found = attributes.findIndex(doc => doc.title === filterName);
@@ -175,7 +178,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
// }
// }
} else {
- // const allCollectionDocs = DocListCast((targetDoc.data as any)[0].data);
+ const allCollectionDocs = DocListCast((targetDoc.data as any)[0].data);
const facetValues = this.gatherFieldValues(targetDoc, facetHeader);
let nonNumbers = 0;
@@ -245,7 +248,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
this._filterMatch = e.currentTarget.value;
console.log(this._filterMatch);
}
- // CHANGE SO DOCKINGVIEW HAS ITS OWN FILTERDOC
@action
changeSelected = () => {
if (this._filterSelected) {