From 7941773a61573db14cbf425d07ab0ff9b8ce5d33 Mon Sep 17 00:00:00 2001 From: anika Date: Wed, 27 Jan 2021 20:35:44 -0500 Subject: minor changes --- src/client/views/PropertiesView.tsx | 2 +- src/client/views/StyleProvider.tsx | 41 ++++++++++++++++++++++++++++++ src/client/views/nodes/FilterBox.scss | 6 +++++ src/client/views/nodes/FilterBox.tsx | 48 +++++++++++++++++++++++++++-------- 4 files changed, 86 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx index 2fb543224..4b65d01a4 100644 --- a/src/client/views/PropertiesView.tsx +++ b/src/client/views/PropertiesView.tsx @@ -28,7 +28,7 @@ import { PresBox } from "./nodes/PresBox"; import { PropertiesButtons } from "./PropertiesButtons"; import { PropertiesDocContextSelector } from "./PropertiesDocContextSelector"; import "./PropertiesView.scss"; -import { DefaultStyleProvider } from "./StyleProvider"; +import { DefaultStyleProvider, FilteringStyleProvider } from "./StyleProvider"; import { FilterBox } from "./nodes/FilterBox"; const higflyout = require("@hig/flyout"); export const { anchorPoints } = higflyout; diff --git a/src/client/views/StyleProvider.tsx b/src/client/views/StyleProvider.tsx index 101ecb9ad..85333eee9 100644 --- a/src/client/views/StyleProvider.tsx +++ b/src/client/views/StyleProvider.tsx @@ -16,6 +16,7 @@ import { DocumentViewProps } from "./nodes/DocumentView"; import { FieldViewProps } from './nodes/FieldView'; import "./StyleProvider.scss"; import "./collections/TreeView.scss"; +import "./nodes/FilterBox.scss"; import React = require("react"); import Color = require('color'); @@ -215,6 +216,46 @@ export function DashboardStyleProvider(doc: Opt, props: Opt runInAction(() => { + //e.stopPropagation(); + //doc.lockedPosition = doc.lockedPosition ? undefined : true; + }), "changeFilterBool"); +} + +function closeFilter(e: React.MouseEvent, doc: Doc) { + UndoManager.RunInBatch(() => runInAction(() => { + e.stopPropagation(); + //doc.lockedPosition = doc.lockedPosition ? undefined : true; + }), "closeFilter"); +} + + +/** + * add (to treeView) for filtering decorations + */ +export function FilteringStyleProvider(doc: Opt, props: Opt, property: string) { + switch (property.split(":")[0]) { + case StyleProp.Decorations: + if (doc) { + return doc._viewType === CollectionViewType.Docking || (Doc.IsSystem(doc)) ? (null) : + <> +
+ +
+
closeFilter(e, doc)}> + +
+ ; + } + default: return DefaultStyleProvider(doc, props, property); + + } +} + // // a preliminary semantic-"layering/grouping" mechanism for determining interactive properties of documents // currently, the provider tests whether the docuemnt's layer field matches the activeLayer field of the tab. diff --git a/src/client/views/nodes/FilterBox.scss b/src/client/views/nodes/FilterBox.scss index 144f161bc..fb1783ad4 100644 --- a/src/client/views/nodes/FilterBox.scss +++ b/src/client/views/nodes/FilterBox.scss @@ -33,6 +33,12 @@ // width: 100%; } +.filterBox-select { + width: 90%; + margin-top: 5px; + margin-bottom: 15px; +} + .filterBox-saveBookmark { background-color: #e9e9e9; diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx index 2db610e43..c7dc4c155 100644 --- a/src/client/views/nodes/FilterBox.tsx +++ b/src/client/views/nodes/FilterBox.tsx @@ -8,7 +8,7 @@ import { List } from "../../../fields/List"; import { RichTextField } from "../../../fields/RichTextField"; import { listSpec, makeInterface } from "../../../fields/Schema"; import { ComputedField, ScriptField } from "../../../fields/ScriptField"; -import { Cast } from "../../../fields/Types"; +import { Cast, StrCast } from "../../../fields/Types"; import { emptyFunction, emptyPath, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnOne, returnZero, returnTrue } from "../../../Utils"; import { Docs } from "../../documents/Documents"; import { DocumentType } from "../../documents/DocumentTypes"; @@ -27,6 +27,9 @@ export const { anchorPoints } = higflyout; export const Flyout = higflyout.default; import Select from "react-select"; import { UserOptions } from "../../util/GroupManager"; +import { DocumentViewProps } from "./DocumentView"; +import { DefaultStyleProvider, StyleProp } from "../StyleProvider"; +import { CollectionViewType } from "../collections/CollectionView"; type FilterBoxDocument = makeInterface<[typeof documentSchema]>; const FilterBoxDocument = makeInterface(documentSchema); @@ -206,6 +209,29 @@ export class FilterBox extends ViewBoxBaseComponent, props: Opt, property: string) { + switch (property.split(":")[0]) { + case StyleProp.Decorations: + if (doc) { + return doc._viewType === CollectionViewType.Docking || (Doc.IsSystem(doc)) ? (null) : + <> +
+ +
+
this.facetClick(StrCast(doc.title))}> + +
+ ; + } + default: return DefaultStyleProvider(doc, props, property); + + } + } + + render() { const facetCollection = this.props.Document; const flyout =
e.stopPropagation()}> @@ -286,7 +312,7 @@ export class FilterBox extends ViewBoxBaseComponent + add a filter
*/} - this.facetClick((val as UserOptions).value)} + value={null} + closeMenuOnSelect={false} + /> +
-- cgit v1.2.3-70-g09d2 From 5b0a4a154a6e68139d3d7e462ca421d3fbbdd224 Mon Sep 17 00:00:00 2001 From: anika Date: Thu, 28 Jan 2021 09:20:52 -0500 Subject: functionality for adding and removing filters --- src/client/util/CurrentUserUtils.ts | 2 +- src/client/views/nodes/FilterBox.tsx | 55 +++++++++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index f3fec9ae6..f869fe4f5 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -792,7 +792,7 @@ export class CurrentUserUtils { doc.currentFilter = new PrefetchProxy(Docs.Create.FilterDocument({ title: "FilterDoc", _height: 500, treeViewHideTitle: true, _xMargin: 5, _yMargin: 5, _gridGap: 5, forceActive: true, childDropAction: "none", - treeViewTruncateTitleWidth: 150, treeViewPreventOpen: false, ignoreClick: true, + treeViewTruncateTitleWidth: 90, treeViewPreventOpen: false, ignoreClick: true, lockedPosition: true, boxShadow: "0 0", dontRegisterChildViews: true, targetDropAction: "same", system: true })); const clearAll = ScriptField.MakeScript(`getProto(self).data = new List([])`); diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx index 61f5232ce..6b1cd793e 100644 --- a/src/client/views/nodes/FilterBox.tsx +++ b/src/client/views/nodes/FilterBox.tsx @@ -63,6 +63,7 @@ export class FilterBox extends ViewBoxBaseComponent key[0]).filter(key => key[0] === "#" || key.indexOf("lastModified") !== -1 || (key[0] === key[0].toUpperCase() && !key.startsWith("_")) || noviceFields.includes(key) || !Doc.UserDoc().noviceMode).sort(); } + /** * The current attributes selected to filter based on */ @@ -70,6 +71,10 @@ export class FilterBox extends ViewBoxBaseComponent StrCast(attribute.title)); + } + gatherFieldValues(dashboard: Doc, facetKey: string) { const childDocs = DocListCast((dashboard.data as any)[0].data); const valueSet = new Set(); @@ -102,28 +107,58 @@ export class FilterBox extends ViewBoxBaseComponent { + + public static removeFilter = (filterName: string) => { + console.log("remove filter"); const targetDoc = SelectionManager.Views()[0].Document; // CollectionDockingView.Instance.props.Document; - const found = this.activeAttributes.findIndex(doc => doc.title === facetHeader); + const filterDoc = Doc.UserDoc().currentFilter as any as Doc; + const attributes = DocListCast(filterDoc["data"]); + const found = attributes.findIndex(doc => doc.title === filterName); if (found !== -1) { - (this.dataDoc[this.props.fieldKey] as List).splice(found, 1); + (filterDoc["data"] as List).splice(found, 1); const docFilter = Cast(targetDoc._docFilters, listSpec("string")); if (docFilter) { let index: number; - while ((index = docFilter.findIndex(item => item.split(":")[0] === facetHeader)) !== -1) { + while ((index = docFilter.findIndex(item => item.split(":")[0] === filterName)) !== -1) { docFilter.splice(index, 1); } } const docRangeFilters = Cast(targetDoc._docRangeFilters, listSpec("string")); if (docRangeFilters) { let index: number; - while ((index = docRangeFilters.findIndex(item => item.split(":")[0] === facetHeader)) !== -1) { + while ((index = docRangeFilters.findIndex(item => item.split(":")[0] === filterName)) !== -1) { docRangeFilters.splice(index, 3); } } + } + } + + /** + * Responds to clicking the check box in the flyout menu + */ + facetClick = (facetHeader: string) => { + + console.log("facetClick: " + facetHeader); + console.log(this.props.fieldKey); + + const targetDoc = SelectionManager.Views()[0].Document; // CollectionDockingView.Instance.props.Document; + const found = this.activeAttributes.findIndex(doc => doc.title === facetHeader); + if (found !== -1) { + // (this.dataDoc[this.props.fieldKey] as List).splice(found, 1); + // const docFilter = Cast(targetDoc._docFilters, listSpec("string")); + // if (docFilter) { + // let index: number; + // while ((index = docFilter.findIndex(item => item.split(":")[0] === facetHeader)) !== -1) { + // docFilter.splice(index, 1); + // } + // } + // const docRangeFilters = Cast(targetDoc._docRangeFilters, listSpec("string")); + // if (docRangeFilters) { + // let index: number; + // while ((index = docRangeFilters.findIndex(item => item.split(":")[0] === facetHeader)) !== -1) { + // docRangeFilters.splice(index, 3); + // } + // } } else { const allCollectionDocs = DocListCast((targetDoc.data as any)[0].data); const facetValues = this.gatherFieldValues(targetDoc, facetHeader); @@ -221,7 +256,7 @@ export class FilterBox extends ViewBoxBaseComponentIs Not
-
this.facetClick(StrCast(doc.title))}> +
FilterBox.removeFilter(StrCast(doc.title))}>
; @@ -245,7 +280,7 @@ export class FilterBox extends ViewBoxBaseComponent !attributes.some(attribute => attribute.title === facet)).map(facet => ({ value: facet, label: facet })); - const options = this._allFacets.map(facet => ({ value: facet, label: facet })); + const options = this._allFacets.filter(facet => this.currentFacets.indexOf(facet) === -1).map(facet => ({ value: facet, label: facet })); return this.props.dontRegisterView ? (null) :
-- cgit v1.2.3-70-g09d2