From b2aa0b80843e6e58f737e2937c45351d653255fa Mon Sep 17 00:00:00 2001
From: Sam Wilkins <samwilkins333@gmail.com>
Date: Mon, 27 Jan 2020 04:18:01 -0500
Subject: pivot field box and proper AND/OR behavior of facets

---
 .../views/collections/CollectionPivotView.tsx      | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

(limited to 'src/client/views/collections/CollectionPivotView.tsx')

diff --git a/src/client/views/collections/CollectionPivotView.tsx b/src/client/views/collections/CollectionPivotView.tsx
index a44f990e1..98fc54b3b 100644
--- a/src/client/views/collections/CollectionPivotView.tsx
+++ b/src/client/views/collections/CollectionPivotView.tsx
@@ -16,6 +16,8 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
 import { List } from "../../../new_fields/List";
 import { Set } from "typescript-collections";
 import { PrefetchProxy } from "../../../new_fields/Proxy";
+import { EditableView } from "../EditableView";
+import { listSpec } from "../../../new_fields/Schema";
 
 @observer
 export class CollectionPivotView extends CollectionSubView(doc => doc) {
@@ -76,6 +78,13 @@ export class CollectionPivotView extends CollectionSubView(doc => doc) {
             const found = DocListCast(facetCollection.data).findIndex(doc => doc.title === facetHeader);
             if (found !== -1) {
                 (facetCollection.data as List<Doc>).splice(found, 1);
+                const docFilter = Cast(this.props.Document._docFilter, listSpec("string"));
+                if (docFilter) {
+                    let index: number;
+                    while ((index = docFilter.findIndex(item => item === facetHeader)) !== -1) {
+                        docFilter.splice(index, 3);
+                    }
+                }
             } else {
                 const newFacet = Docs.Create.TreeDocument([], { title: facetHeader, treeViewOpen: true, isFacetFilter: true });
                 const capturedVariables = { layoutDoc: this.props.Document, dataDoc: this.dataDoc };
@@ -129,6 +138,19 @@ export class CollectionPivotView extends CollectionSubView(doc => doc) {
         );
         return !facetCollection ? (null) :
             <div className="collectionPivotView">
+                <div className={"pivotKeyEntry"}>
+                    <EditableView
+                        contents={this.props.Document.pivotField}
+                        GetValue={() => StrCast(this.props.Document.pivotField)}
+                        SetValue={value => {
+                            if (value && value.length) {
+                                this.props.Document.pivotField = value;
+                                return true;
+                            }
+                            return false;
+                        }}
+                    />
+                </div>
                 <div className="collectionPivotView-dragger" key="dragger" onPointerDown={this.onPointerDown} style={{ transform: `translate(${this._facetWidth}px, 0px)` }} >
                     <span title="library View Dragger" style={{ width: "5px", position: "absolute", top: "0" }} />
                 </div>
-- 
cgit v1.2.3-70-g09d2

