aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusodhi <61431818+usodhi@users.noreply.github.com>2021-03-17 21:56:31 -0400
committerusodhi <61431818+usodhi@users.noreply.github.com>2021-03-17 21:56:31 -0400
commit9c612838c775a6fa9737963618aeebbc427e794c (patch)
tree1d5e89a2f0d101c5d7ae8ceec71d45b09bd8e715
parent7c6ccf0c6dce1b778163f03ae271b3c17896a560 (diff)
converted dockingview.instance to dashboard + started commenting
-rw-r--r--src/client/views/PropertiesView.tsx11
-rw-r--r--src/client/views/nodes/FilterBox.tsx73
2 files changed, 61 insertions, 23 deletions
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 8bffb0778..c677478cb 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -51,7 +51,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
@computed get selectedDoc() { return SelectionManager.SelectedSchemaDoc() || this.selectedDocumentView?.rootDoc; }
@computed get filterDoc() {
- return FilterBox._filterScope === "Current Collection" ? this.selectedDoc || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+ return FilterBox.targetDoc;
}
@computed get selectedDocumentView() {
if (SelectionManager.Views().length) return SelectionManager.Views()[0];
@@ -59,8 +59,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
return undefined;
}
@computed get isPres(): boolean {
- if (this.selectedDoc?.type === DocumentType.PRES) return true;
- return false;
+ return this.selectedDoc?.type === DocumentType.PRES;
}
@computed get dataDoc() { return this.selectedDoc?.[DataSym]; }
@@ -934,7 +933,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
}
@computed get filtersSubMenu() {
- return <div className="propertiesView-filters">
+ return !this.filterDoc?.currentFilter ? (null) : <div className="propertiesView-filters">
<div className="propertiesView-filters-title"
onPointerDown={action(() => this.openFilters = !this.openFilters)}
style={{ backgroundColor: this.openFilters ? "black" : "" }}>
@@ -944,7 +943,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
</div>
</div>
{
- !this.openFilters || !this.filterDoc.currentFilter ? (null) :
+ !this.openFilters ? (null) :
<div className="propertiesView-filters-content">
<DocumentView
Document={this.filterDoc.currentFilter as Doc}
@@ -1100,7 +1099,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
{this.sharingSubMenu}
- {this.selectedDoc.type === DocumentType.COL && this.filtersSubMenu}
+ {this.filtersSubMenu}
{this.inkSubMenu}
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index 541693cdf..d410d2b33 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -40,7 +40,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
constructor(props: Readonly<FieldViewProps>) {
super(props);
const targetDoc = FilterBox.targetDoc;
- if (!targetDoc) CurrentUserUtils.setupFilterDocs(targetDoc);
+ if (targetDoc && !targetDoc.currentFilter) CurrentUserUtils.setupFilterDocs(targetDoc);
}
public static LayoutString(fieldKey: string) { return FieldView.LayoutString(FilterBox, fieldKey); }
@@ -49,11 +49,43 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
public _filterSelected = false;
public _filterMatch = "matched";
+ @computed static get currentContainingCollectionDoc() {
+ let docView: any = SelectionManager.Views()[0];
+ let doc = docView.Document;
+
+ while (docView && doc && doc.type !== "collection") {
+ doc = docView.props.ContainingCollectionDoc;
+ docView = docView.props.ContainingCollectionView;
+ }
+
+ return doc;
+ }
+
+ // /**
+ // * @returns the relevant doc according to the value of FilterBox._filterScope i.e. either the Current Dashboard or the Current Collection
+ // */
+
+
+ // trying to get this to work rather than the version below this
+
+ // @computed static get targetDoc() {
+ // console.log(FilterBox.currentContainingCollectionDoc.type);
+ // if (FilterBox._filterScope === "Current Collection") {
+ // return FilterBox.currentContainingCollectionDoc;
+ // }
+ // else return CollectionDockingView.Instance.props.Document;
+ // // return FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+ // }
+
+
/**
- * @returns the relevant doc according to the value of FilterBox._filterScope i.e. either the Current Dashboard or the Current Collection
- */
+ * @returns the relevant doc according to the value of FilterBox._filterScope i.e. either the Current Dashboard or the Current Collection
+ */
@computed static get targetDoc() {
- return FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+ if (FilterBox._filterScope === "Current Collection") {
+ return SelectionManager.Views()[0].Document.type === "collection" ? SelectionManager.Views()[0].Document : SelectionManager.Views()[0].props.ContainingCollectionDoc!;
+ }
+ else return CurrentUserUtils.ActiveDashboard;
}
@observable _loaded = false;
@@ -70,7 +102,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
const allDocs = new Set<Doc>();
const targetDoc = FilterBox.targetDoc;
if (this._loaded && targetDoc) {
- // if (targetDoc) {
const activeTabs = DocListCast(targetDoc.data);
SearchBox.foreachRecursiveDoc(activeTabs, (doc: Doc) => allDocs.add(doc));
setTimeout(() => targetDoc.allDocuments = new List<Doc>(Array.from(allDocs)));
@@ -247,20 +278,30 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
return script ? () => script : undefined;
}
+ /**
+ * Changes the value of the variable that determines whether filters are ANDed or ORed together
+ */
@action
changeBool = (e: any) => {
FilterBox._filterBoolean = e.currentTarget.value;
}
+ /**
+ * Changes the value of the variable that determines whether the filters should apply to the dashboard or the collection
+ */
@action
changeScope = (e: any) => {
FilterBox._filterScope = e.currentTarget.value;
}
+ /**
+ * Changes whether to select matched or unmatched documents
+ */
@action
changeMatch = (e: any) => {
this._filterMatch = e.currentTarget.value;
}
+
@action
changeSelected = () => {
if (this._filterSelected) {
@@ -296,19 +337,26 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
suppressChildClick = () => ScriptField.MakeScript("")!;
+ /**
+ * Adds a filterDoc to the list of saved filters
+ */
saveFilter = () => {
Doc.AddDocToList(Doc.UserDoc(), "savedFilters", this.props.Document);
- console.log("saved filter");
}
+ /**
+ * Changes the title of the filterDoc
+ */
onTitleValueChange = (val: string) => {
- this.props.Document.title = val || `FilterDoc for ${SelectionManager.Views()[0].Document.title}`;
+ this.props.Document.title = val || `FilterDoc for ${FilterBox.targetDoc.title}`;
return true;
}
+ /**
+ * The flyout from which you can select a saved filter to apply
+ */
@computed get flyoutPanel() {
return DocListCast(Doc.UserDoc().savedFilters).map(doc => {
- // console.log("mapping");
return <>
<div className="filterBox-tempFlyout" onWheel={e => e.stopPropagation()} style={{ height: 50, border: "2px" }} onPointerDown={() => this.props.updateFilterDoc?.(doc)}>
{StrCast(doc.title)}
@@ -320,15 +368,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
render() {
const facetCollection = this.props.Document;
- // const flyout = DocListCast(Doc.UserDoc().savedFilters).map(doc => {
- // // console.log("mapping");
- // return <>
- // <div className="filterBox-tempFlyout" onWheel={e => e.stopPropagation()} style={{ height: 50, border: "2px" }} onPointerDown={() => this.props.updateFilterDoc?.(doc)}>
- // {StrCast(doc.title)}
- // </div>
- // </>;
- // }
- // );
// TODO uncomment the line below when the treeview x works
// const options = this._allFacets.filter(facet => this.currentFacets.indexOf(facet) === -1).map(facet => ({ value: facet, label: facet }));