From 9c612838c775a6fa9737963618aeebbc427e794c Mon Sep 17 00:00:00 2001 From: usodhi <61431818+usodhi@users.noreply.github.com> Date: Wed, 17 Mar 2021 21:56:31 -0400 Subject: converted dockingview.instance to dashboard + started commenting --- src/client/views/PropertiesView.tsx | 11 +++--- src/client/views/nodes/FilterBox.tsx | 73 +++++++++++++++++++++++++++--------- 2 files changed, 61 insertions(+), 23 deletions(-) (limited to 'src') 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 { @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 { 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 { } @computed get filtersSubMenu() { - return
+ return !this.filterDoc?.currentFilter ? (null) :
this.openFilters = !this.openFilters)} style={{ backgroundColor: this.openFilters ? "black" : "" }}> @@ -944,7 +943,7 @@ export class PropertiesView extends React.Component {
{ - !this.openFilters || !this.filterDoc.currentFilter ? (null) : + !this.openFilters ? (null) :
{ {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) { 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(); 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(Array.from(allDocs))); @@ -247,20 +278,30 @@ export class FilterBox extends ViewBoxBaseComponent 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 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 <>
e.stopPropagation()} style={{ height: 50, border: "2px" }} onPointerDown={() => this.props.updateFilterDoc?.(doc)}> {StrCast(doc.title)} @@ -320,15 +368,6 @@ export class FilterBox extends ViewBoxBaseComponent { - // // console.log("mapping"); - // return <> - //
e.stopPropagation()} style={{ height: 50, border: "2px" }} onPointerDown={() => this.props.updateFilterDoc?.(doc)}> - // {StrCast(doc.title)} - //
- // ; - // } - // ); // 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 })); -- cgit v1.2.3-70-g09d2