From e4b7b54eecc307ec52f6105f92c3d87449458641 Mon Sep 17 00:00:00 2001 From: Andy Rickert Date: Tue, 28 Apr 2020 02:02:40 -0700 Subject: nested collection view now in search box, search item doc type cast over stacking view, but with bugs --- src/client/views/nodes/FieldView.tsx | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/client/views/nodes/FieldView.tsx') diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx index a3790d38b..6198212b5 100644 --- a/src/client/views/nodes/FieldView.tsx +++ b/src/client/views/nodes/FieldView.tsx @@ -51,6 +51,9 @@ export interface FieldViewProps { ContentScaling: () => number; ChromeHeight?: () => number; childLayoutTemplate?: () => Opt; + highlighting?: string[]; + lines?: string[]; + doc?: Doc; } @observer -- cgit v1.2.3-70-g09d2 From fd741cddf64fe1b068b7a1de5bc3840798afe75d Mon Sep 17 00:00:00 2001 From: andy temp Date: Wed, 22 Jul 2020 14:42:32 -0400 Subject: search results open and close as panel under bar --- src/client/util/CurrentUserUtils.ts | 2 +- .../views/collections/CollectionSchemaView.tsx | 2 +- src/client/views/collections/CollectionView.tsx | 2 +- src/client/views/nodes/FieldView.tsx | 2 ++ src/client/views/search/SearchBox.scss | 2 +- src/client/views/search/SearchBox.tsx | 28 ++++++++++++++++++---- 6 files changed, 29 insertions(+), 9 deletions(-) (limited to 'src/client/views/nodes/FieldView.tsx') diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index 582cc2d5c..f16ef399c 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -658,7 +658,7 @@ export class CurrentUserUtils { const libraryBtn = CurrentUserUtils.setupLibraryPanel(doc, sidebarContainer); const searchBtn = CurrentUserUtils.setupSearchBtnPanel(doc, sidebarContainer); if (doc["search-panel"] === undefined) { - doc["search-panel"] = new PrefetchProxy(Docs.Create.SearchDocument({ ignoreClick: true, childDropAction: "alias", lockedPosition: true, _viewType: CollectionViewType.Schema, title: "sidebar search stack", })) as any as Doc; + doc["search-panel"] = new PrefetchProxy(Docs.Create.SearchDocument({_width: 500, _height: 400, backgroundColor: "dimGray", ignoreClick: true, childDropAction: "alias", lockedPosition: true, _viewType: CollectionViewType.Schema, title: "sidebar search stack", })) as any as Doc; } // Finally, setup the list of buttons to display in the sidebar if (doc["tabs-buttons"] === undefined) { diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx index 50eea5059..be4f7c888 100644 --- a/src/client/views/collections/CollectionSchemaView.tsx +++ b/src/client/views/collections/CollectionSchemaView.tsx @@ -631,7 +631,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { return
{this.showIsTagged()} -
+
{this.collectionViewType !== undefined ? this.SubView(this.collectionViewType, props) : (null)}
{this.lightbox(DocListCast(this.props.Document[this.props.fieldKey]).filter(d => d.type === DocumentType.IMG).map(d => diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx index 3aabd5d6b..8b83a29b2 100644 --- a/src/client/views/nodes/FieldView.tsx +++ b/src/client/views/nodes/FieldView.tsx @@ -48,10 +48,12 @@ export interface FieldViewProps { ignoreAutoHeight?: boolean; PanelWidth: () => number; PanelHeight: () => number; + PanelPosition: string; NativeHeight: () => number; NativeWidth: () => number; setVideoBox?: (player: VideoBox) => void; ContentScaling: () => number; + ChromeHeight?: () => number; childLayoutTemplate?: () => Opt; highlighting?: string[]; diff --git a/src/client/views/search/SearchBox.scss b/src/client/views/search/SearchBox.scss index 4d057f782..8cd2f00b4 100644 --- a/src/client/views/search/SearchBox.scss +++ b/src/client/views/search/SearchBox.scss @@ -17,7 +17,7 @@ .searchBox-bar { height: 32px; display: flex; - justify-content: flex-end; + justify-content: center; align-items: center; background-color: black; .searchBox-barChild { diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index 884aa6a68..21f476ea4 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -199,13 +199,26 @@ export class SearchBox extends ViewBoxBaseComponent { if (e.key === "Enter") { - if (this._icons !== this._allIcons) { - runInAction(() => { this.expandedBucket = false }); + // if (this._icons !== this._allIcons) { + // runInAction(() => { this.expandedBucket = false }); + // } + console.log(StrCast(this.layoutDoc._searchString)); + if (StrCast(this.layoutDoc._searchString)!==""){ + console.log("OPEN"); + runInAction(()=>{this.open=true}); + } + else { + console.log("CLOSE"); + runInAction(()=>{this.open=false}); + } this.submitSearch(); } } + @observable open: boolean = false; + + public static async convertDataUri(imageUri: string, returnedFilename: string) { try { const posting = Utils.prepend("/uploadURI"); @@ -377,7 +390,6 @@ export class SearchBox extends ViewBoxBaseComponent { this.checkIcons(); @@ -1109,7 +1121,7 @@ export class SearchBox extends ViewBoxBaseComponent */} + style={{ width: this._searchbarOpen ? "200px" : "200px" }} /> {/* */}
0 ? { overflow: "visible" } : { overflow: "hidden" }}> @@ -1123,12 +1135,18 @@ export class SearchBox extends ViewBoxBaseComponent
+
{this.headerscale > 0 ? 200 :()=>0} + PanelWidth={this.open===true? ()=>600 : ()=>0} + PanelPosition={"absolute"} focus={this.selectElement} - ScreenToLocalTransform={Transform.Identity} /> : undefined} + ScreenToLocalTransform={Transform.Identity} + /> : undefined} +
Date: Wed, 22 Jul 2020 22:39:44 -0400 Subject: search --- src/client/util/CurrentUserUtils.ts | 2 +- src/client/views/EditableView.tsx | 5 +- src/client/views/MainView.tsx | 14 ++++ .../views/collections/CollectionSchemaCells.tsx | 10 +-- .../views/collections/CollectionSchemaHeaders.tsx | 42 +++++++++- .../views/collections/CollectionSchemaView.tsx | 5 +- src/client/views/collections/SchemaTable.tsx | 6 +- src/client/views/nodes/FieldView.tsx | 4 +- src/client/views/search/SearchBox.tsx | 91 +++++++++++++++++----- 9 files changed, 135 insertions(+), 44 deletions(-) (limited to 'src/client/views/nodes/FieldView.tsx') diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index f16ef399c..c7cdf8545 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -658,7 +658,7 @@ export class CurrentUserUtils { const libraryBtn = CurrentUserUtils.setupLibraryPanel(doc, sidebarContainer); const searchBtn = CurrentUserUtils.setupSearchBtnPanel(doc, sidebarContainer); if (doc["search-panel"] === undefined) { - doc["search-panel"] = new PrefetchProxy(Docs.Create.SearchDocument({_width: 500, _height: 400, backgroundColor: "dimGray", ignoreClick: true, childDropAction: "alias", lockedPosition: true, _viewType: CollectionViewType.Schema, title: "sidebar search stack", })) as any as Doc; + doc["search-panel"] = new PrefetchProxy(Docs.Create.SearchDocument({_width: 500, _height: 400, backgroundColor: "dimGray", ignoreClick: true, childDropAction: "alias", lockedPosition: true, _viewType: CollectionViewType.Schema, _chromeStatus: "disabled", title: "sidebar search stack", })) as any as Doc; } // Finally, setup the list of buttons to display in the sidebar if (doc["tabs-buttons"] === undefined) { diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx index 4c2d2f0a9..b78ed6fee 100644 --- a/src/client/views/EditableView.tsx +++ b/src/client/views/EditableView.tsx @@ -195,15 +195,13 @@ export class EditableView extends React.Component { if (this.props.positions!==undefined){ let positions = this.props.positions; let length = this.props.search!.length; - console.log(contents); - console.log(this.props.contents?.valueOf()); + // contents = String(this.props.contents.valueOf()); results.push({contents ? contents.slice(0, this.props.positions![0]) : this.props.placeholder?.valueOf()}); positions.forEach((num, cur) => { results.push({contents ? contents.slice(num, num + length) : this.props.placeholder?.valueOf()}); let end = 0; - console.log cur === positions.length-1? end = contents.length: end = positions[cur + 1]; results.push({contents ? contents.slice(num + length, end) : this.props.placeholder?.valueOf()}); } @@ -217,7 +215,6 @@ else{ } render() { - console.log(this.props.highlight === undefined); if (this._editing && this.props.GetValue() !== undefined) { return this.props.sizeToContent ?
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index c65c90afb..fce3707a7 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -156,10 +156,24 @@ export class MainView extends React.Component { const targets = document.elementsFromPoint(e.x, e.y); if (targets && targets.length && targets[0].className.toString().indexOf("contextMenu") === -1) { ContextMenu.Instance.closeMenu(); + //SearchBox.Instance.closeSearch(); } if (targets && (targets.length && targets[0].className.toString() !== "timeline-menu-desc" && targets[0].className.toString() !== "timeline-menu-item" && targets[0].className.toString() !== "timeline-menu-input")) { TimelineMenu.Instance.closeMenu(); } + if (targets && targets.length && SearchBox.Instance._searchbarOpen){ + let check = false; + targets.forEach((thing)=>{ + if (thing.className.toString()==="collectionSchemaView-table" || thing.className.toString()==="beta") { + check=true; + } + }); + if (check===false){ + SearchBox.Instance.closeSearch(); + } + } + + }); globalPointerUp = () => this.isPointerDown = false; diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx index b1c3705ca..11f0edf23 100644 --- a/src/client/views/collections/CollectionSchemaCells.tsx +++ b/src/client/views/collections/CollectionSchemaCells.tsx @@ -246,7 +246,6 @@ export class CollectionSchemaCell extends React.Component { trace(); let positions = []; if (StrCast(this.props.Document._searchString) !== "") { - console.log(StrCast(this.props.Document._searchString)); const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey])); let term = ""; if (cfield!==undefined){ @@ -262,7 +261,6 @@ export class CollectionSchemaCell extends React.Component { } let search = StrCast(this.props.Document._searchString) let start = term.indexOf(search) as number; - console.log(start); let tally = 0; if (start!==-1){ positions.push(start); @@ -277,7 +275,6 @@ export class CollectionSchemaCell extends React.Component { positions.pop(); } } - console.log(positions.length); return (
@@ -299,18 +296,14 @@ export class CollectionSchemaCell extends React.Component { // return "0"; // } else { const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey])); - console.log(cfield); if (cfield!==undefined){ if (cfield.Text!==undefined){ - console.log - return(cfield.Text) + return(cfield.Text); } else if (StrCast(cfield)){ - console.log("strcast"); return StrCast(cfield); } else { - console.log("numcast"); return String(NumCast(cfield)); } } @@ -325,7 +318,6 @@ export class CollectionSchemaCell extends React.Component { return "0"; } else { const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey])); - console.log(cfield); if (type === "number") { return StrCast(cfield); } diff --git a/src/client/views/collections/CollectionSchemaHeaders.tsx b/src/client/views/collections/CollectionSchemaHeaders.tsx index 4a9bd4aa6..ec8605215 100644 --- a/src/client/views/collections/CollectionSchemaHeaders.tsx +++ b/src/client/views/collections/CollectionSchemaHeaders.tsx @@ -9,6 +9,8 @@ import { ColumnType } from "./CollectionSchemaView"; import { faFile } from "@fortawesome/free-regular-svg-icons"; import { SchemaHeaderField, PastelSchemaPalette } from "../../../fields/SchemaHeaderField"; import { undoBatch } from "../../util/UndoManager"; +import { Doc } from "../../../fields/Doc"; +import { StrCast } from "../../../fields/Types"; const higflyout = require("@hig/flyout"); export const { anchorPoints } = higflyout; export const Flyout = higflyout.default; @@ -291,6 +293,7 @@ export interface KeysDropdownProps { onSelect: (oldKey: string, newKey: string, addnew: boolean, filter?: string) => void; setIsEditing: (isEditing: boolean) => void; width?: string; + docs?: Doc[]; } @observer export class KeysDropdown extends React.Component { @@ -309,7 +312,6 @@ export class KeysDropdown extends React.Component { if (key.slice(0, this._key.length) === this._key && this._key !== key) { let filter = key.slice(this._key.length - key.length); this.props.onSelect(this._key, this._key, this.props.addNew, filter); - console.log("YEE"); } else { this.props.onSelect(this._key, key, this.props.addNew); @@ -319,6 +321,13 @@ export class KeysDropdown extends React.Component { } } + @action + onSelect2 = (key: string): void => { + this._searchTerm=this._searchTerm.slice(0,this._key.length) +key; + this._isOpen = false; + + } + @undoBatch onKeyDown = (e: React.KeyboardEvent): void => { //if (this._key !==) @@ -394,7 +403,35 @@ export class KeysDropdown extends React.Component { return options; } + renderFilterOptions = (): JSX.Element[] | JSX.Element => { + console.log("HEHEHE") + if (!this._isOpen) return <>; + + const keyOptions:string[]=[]; + console.log(this._searchTerm.slice(this._key.length)) + let temp = this._searchTerm.slice(this._key.length); + this.props.docs?.forEach((doc)=>{ + let key = StrCast(doc[this._key]); + if (keyOptions.includes(key)===false && key.includes(temp)){ + keyOptions.push(key); + } + }); + + + const options = keyOptions.map(key => { + return
e.stopPropagation()} onClick={() => { this.onSelect2(key); }}>{key}
; + }); + + return options; + } + + render() { + console.log(this.props.docs); return (
{this._key === this._searchTerm.slice(0, this._key.length) ? @@ -414,7 +451,8 @@ export class KeysDropdown extends React.Component { width: this.props.width, maxWidth: this.props.width, }} onPointerEnter={this.onPointerEnter} onPointerLeave={this.onPointerOut}> - {this.renderOptions()} + {this._key === this._searchTerm.slice(0, this._key.length) ? + this.renderFilterOptions():this.renderOptions()}
); diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx index be4f7c888..0b3d8e20d 100644 --- a/src/client/views/collections/CollectionSchemaView.tsx +++ b/src/client/views/collections/CollectionSchemaView.tsx @@ -609,7 +609,6 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { onKeyPress = (e: React.KeyboardEvent) => { - console.log("yeet2"); } render() { TraceMobx(); @@ -631,10 +630,10 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { return
this.props.active(true) && e.stopPropagation()} diff --git a/src/client/views/collections/SchemaTable.tsx b/src/client/views/collections/SchemaTable.tsx index 2b60bef1b..c820cb661 100644 --- a/src/client/views/collections/SchemaTable.tsx +++ b/src/client/views/collections/SchemaTable.tsx @@ -189,7 +189,7 @@ export class SchemaTable extends React.Component { addNew={false} onSelect={this.props.changeColumns} setIsEditing={this.props.setHeaderIsEditing} - + docs={this.props.childDocs} // try commenting this out width={"100%"} />; @@ -451,10 +451,8 @@ export class SchemaTable extends React.Component { //@ts-ignore expandedRowsList.forEach(row => expanded[row] = true); const rerender = [...this.textWrappedRows]; // TODO: get component to rerender on text wrap change without needign to console.log :(((( - let overflow = "auto"; - StrCast(this.props.Document.type) === "search" ? overflow = "overlay" : "auto"; return void; ignoreAutoHeight?: boolean; - PanelWidth: () => number; - PanelHeight: () => number; + PanelWidth: () => number|string; + PanelHeight: () => number|string; PanelPosition: string; NativeHeight: () => number; NativeWidth: () => number; diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index 21f476ea4..ee85375e3 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -73,7 +73,7 @@ export class SearchBox extends ViewBoxBaseComponent SearchUtil.GetViewsOfDocument(doc) + + @observable newsearchstring: string =""; @action.bound onChange(e: React.ChangeEvent) { - this.layoutDoc._searchString = e.target.value; - + //this.layoutDoc._searchString = e.target.value; + this.newsearchstring= e.target.value; + if (e.target.value===""){ + console.log("CLOSE"); + runInAction(()=>{this.open=false}); + } this._openNoResults = false; this._results = []; this._resultsSet.clear(); @@ -199,10 +205,11 @@ export class SearchBox extends ViewBoxBaseComponent { if (e.key === "Enter") { + console.log(this.newsearchstring) + this.layoutDoc._searchString=this.newsearchstring; // if (this._icons !== this._allIcons) { // runInAction(() => { this.expandedBucket = false }); // } - console.log(StrCast(this.layoutDoc._searchString)); if (StrCast(this.layoutDoc._searchString)!==""){ console.log("OPEN"); runInAction(()=>{this.open=true}); @@ -392,11 +399,15 @@ export class SearchBox extends ViewBoxBaseComponent { + this.checkIcons(); if (reset) { this.layoutDoc._searchString = ""; } + this.noresults= false; this.dataDoc[this.fieldKey] = new List([]); + this.headercount=0; + this.children=0; this.buckets = []; this.new_buckets = {}; const query = StrCast(this.layoutDoc._searchString); @@ -519,7 +530,7 @@ export class SearchBox extends ViewBoxBaseComponent(); startDragCollection = async () => { const res = await this.getAllResults(this.getFinalQuery(StrCast(this.layoutDoc._searchString))); @@ -591,6 +602,7 @@ export class SearchBox extends ViewBoxBaseComponent) => { if (!this._resultsRef.current) return; @@ -604,11 +616,7 @@ export class SearchBox extends ViewBoxBaseComponent(); if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) { - this._visibleElements = [
No Search Results
]; - //this._visibleDocuments= Docs.Create. - let noResult = Docs.Create.TextDocument("", { title: "noResult" }) - noResult.isBucket = false; - Doc.AddDocToList(this.dataDoc, this.props.fieldKey, noResult); + this.noresults=true; return; } @@ -653,6 +661,7 @@ export class SearchBox extends ViewBoxBaseComponent schemaheaders.push(new SchemaHeaderField(item, "#f1efeb"))) + this.headercount= schemaheaders.length; this.props.Document._schemaHeaders = new List(schemaheaders); if (this._maxSearchIndex >= this._numTotalResults) { this._visibleElements.length = this._results.length; @@ -688,7 +699,7 @@ export class SearchBox extends ViewBoxBaseComponent 3 ? length = 650 : length = length * 205 + 51; + let height = this.children; + height > 8 ? height = 31+31*8: height = 31*height+ 31; return (
{/* StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} ref={this.collectionRef} title="Drag Results as Collection"> */} - {Doc.CurrentUserEmail}
+ + + style={{ paddingLeft:23, width: this._searchbarOpen ? "200px" : "200px" }} /> {/* */}
0 ? { overflow: "visible" } : { overflow: "hidden" }}> @@ -1135,18 +1154,52 @@ export class SearchBox extends ViewBoxBaseComponent
-
- {this.headerscale > 0 ? + {this._searchbarOpen === true ? +
+
0?length: 251, + height: 25, + borderColor: "#9c9396", + border: "1px solid", + borderRadius:"0.3em", + borderBottom:this.open===false?"1px solid":"none", + position: "absolute", + background: "rgb(241, 239, 235)", + top:29}}> +
+ +
+
+ + {this.noresults===false?
200 :()=>0} - PanelWidth={this.open===true? ()=>600 : ()=>0} + PanelHeight={this.open===true?()=> height:()=>0} + PanelWidth={this.open===true? ()=>length : ()=>0} PanelPosition={"absolute"} focus={this.selectElement} ScreenToLocalTransform={Transform.Identity} - /> : undefined} -
+ />
:
+
No search results :(
+
} +
: undefined} +
Date: Tue, 28 Jul 2020 17:03:53 -0400 Subject: filter and other small features --- .../views/collections/CollectionSchemaView.scss | 1 - .../views/collections/CollectionSchemaView.tsx | 1 + src/client/views/nodes/FieldView.tsx | 5 +- src/client/views/search/SearchBox.tsx | 194 +++------------------ 4 files changed, 28 insertions(+), 173 deletions(-) (limited to 'src/client/views/nodes/FieldView.tsx') diff --git a/src/client/views/collections/CollectionSchemaView.scss b/src/client/views/collections/CollectionSchemaView.scss index 83fe54c82..93878d799 100644 --- a/src/client/views/collections/CollectionSchemaView.scss +++ b/src/client/views/collections/CollectionSchemaView.scss @@ -25,7 +25,6 @@ .collectionSchemaView-tableContainer { width: 100%; height: 100%; - overflow: auto; } .collectionSchemaView-dividerDragger { diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx index 4ecc7ba60..d3c975e5d 100644 --- a/src/client/views/collections/CollectionSchemaView.tsx +++ b/src/client/views/collections/CollectionSchemaView.tsx @@ -628,6 +628,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
; return
diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx index 732a254fe..c9fc99a31 100644 --- a/src/client/views/nodes/FieldView.tsx +++ b/src/client/views/nodes/FieldView.tsx @@ -46,9 +46,10 @@ export interface FieldViewProps { dontRegisterView?: boolean; focus: (doc: Doc) => void; ignoreAutoHeight?: boolean; - PanelWidth: () => number|string; - PanelHeight: () => number|string; + PanelWidth: () => number | string; + PanelHeight: () => number | string; PanelPosition: string; + overflow?: boolean; NativeHeight: () => number; NativeWidth: () => number; setVideoBox?: (player: VideoBox) => void; diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index 7601ea12e..73932896b 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -452,39 +452,22 @@ export class SearchBox extends ViewBoxBaseComponent { - // let hlights: string[] = []; - // const protos = Doc.GetAllPrototypes(d); - // let proto = protos[protos.length - 2]; - // Object.keys(proto).forEach(key => { - // console.log(key); - // console.log(StrCast(this.layoutDoc._searchString)); - // Doc.setDocFilter(selectedCollection.props.Document, key, StrCast(this.layoutDoc._searchString), "match"); - - // // if (StrCast(d[key]).includes(query)) { - // // console.log(key, d[key]); - // // hlights.push(key); - // // } - // }); - // // if (hlights.length > 0) { - // // found.push([d, hlights, []]); - // // }; - // }); - // console.log(found); - // this._results = found; - // this._numTotalResults = found.length; + let doc = undefined; + if (this.scale === false) { + doc = SelectionManager.SelectedDocuments()[0].props.Document; + } + console.log(this.scale); + if (this.scale === true) { + doc = Cast(Doc.UserDoc().myWorkspaces, Doc) as Doc; + doc = DocListCast(doc.data)[0]; + } + if (doc !== undefined) { + console.log(StrCast(doc.title)); + Doc.setDocFilter(doc, key, values, "match"); } else { this.noresults = "No collection selected :("; } - - //Doc.setDocFilter(this.props.Document, newKey, filter, "match"); } @action @@ -512,7 +495,6 @@ export class SearchBox extends ViewBoxBaseComponent { console.log("Resubmitting search"); - }, 60000); } @@ -708,7 +690,7 @@ export class SearchBox extends ViewBoxBaseComponent(); + let headers = new Set(["title", "author", "creationDate"]); if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) { if (this.noresults === "") { this.noresults = "No search results :("; @@ -986,125 +968,6 @@ export class SearchBox extends ViewBoxBaseComponent Doc.RemoveDocFromList(CurrentUserUtils.UserDocument.expandingButtons as Doc, "data", doc); moveButtonDoc = (doc: Doc, targetCollection: Doc | undefined, addDocument: (document: Doc) => boolean) => this.remButtonDoc(doc) && addDocument(doc); - @computed get docButtons() { - const nodeBtns = this.props.Document.nodeButtons; - let width = () => NumCast(this.props.Document._width); - // if (StrCast(this.props.Document.title)==="sidebar search stack"){ - width = MainView.Instance.flyoutWidthFunc; - - // } - if (nodeBtns instanceof Doc) { - return
- 100} - renderDepth={0} - backgroundColor={returnEmptyString} - focus={emptyFunction} - parentActive={returnTrue} - whenActiveChanged={emptyFunction} - bringToFront={emptyFunction} - ContainingCollectionView={undefined} - ContainingCollectionDoc={undefined} - NativeHeight={() => 100} - NativeWidth={width} - /> -
; - } - return (null); - } - - @computed get keyButtons() { - const nodeBtns = this.props.Document.keyButtons; - let width = () => NumCast(this.props.Document._width); - // if (StrCast(this.props.Document.title)==="sidebar search stack"){ - width = MainView.Instance.flyoutWidthFunc; - // } - if (nodeBtns instanceof Doc) { - return
- 100} - renderDepth={0} - backgroundColor={returnEmptyString} - focus={emptyFunction} - parentActive={returnTrue} - whenActiveChanged={emptyFunction} - bringToFront={emptyFunction} - ContainingCollectionView={undefined} - ContainingCollectionDoc={undefined} - NativeHeight={() => 100} - NativeWidth={width} - /> -
; - } - return (null); - } - - @computed get defaultButtons() { - const defBtns = this.props.Document.defaultButtons; - let width = () => NumCast(this.props.Document._width); - // if (StrCast(this.props.Document.title)==="sidebar search stack"){ - width = MainView.Instance.flyoutWidthFunc; - // } - if (defBtns instanceof Doc) { - return
- 100} - renderDepth={0} - backgroundColor={returnEmptyString} - focus={emptyFunction} - parentActive={returnTrue} - whenActiveChanged={emptyFunction} - bringToFront={emptyFunction} - ContainingCollectionView={undefined} - ContainingCollectionDoc={undefined} - NativeHeight={() => 100} - NativeWidth={width} - /> -
; - } - return (null); - } - @action.bound updateIcon = async (icon: string) => { if (this._icons.includes(icon)) { @@ -1223,15 +1086,17 @@ export class SearchBox extends ViewBoxBaseComponent 3 ? length = 650 : length = length * 205 + 51; - let height = this.children; - height > 8 ? height = 31 + 31 * 8 : height = 31 * height + 31; + let cols = Cast(this.props.Document._schemaHeaders, listSpec(SchemaHeaderField), []).length; + let length = 0; + cols > 5 ? length = 1076 : length = cols * 205 + 51; + let height = 0; + let rows = this.children; + rows > 8 ? height = 31 + 31 * 8 : height = 31 * rows + 31; return (
@@ -1239,28 +1104,16 @@ export class SearchBox extends ViewBoxBaseComponent */}
{Doc.CurrentUserEmail}
- + StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} icon={"search"} size="lg" style={{ position: "relative", left: 24, padding: 1 }} /> - {/* */} -
-
0 ? { overflow: "visible" } : { overflow: "hidden" }}> -
- {this.defaultButtons} -
-
- {this.docButtons} -
-
- {this.keyButtons} -
{this._searchbarOpen === true ?
0 ? length : 253, + width: cols > 0 ? length : 253, height: 25, borderColor: "#9c9396", border: "1px solid", @@ -1315,9 +1168,10 @@ export class SearchBox extends ViewBoxBaseComponent height : () => 0} PanelWidth={this.open === true ? () => length : () => 0} PanelPosition={"absolute"} + overflow={cols > 5 || rows > 8 ? true : false} focus={this.selectElement} ScreenToLocalTransform={Transform.Identity} - />
:
+ />
:
{this.noresults}
}
: undefined} -- cgit v1.2.3-70-g09d2 From a59bcec29efb9b5ea0ba8ddfb4b9977b904c10b8 Mon Sep 17 00:00:00 2001 From: Andy Rickert Date: Tue, 4 Aug 2020 12:18:16 -0400 Subject: cleaning up --- src/client/views/nodes/FieldView.tsx | 2 +- src/client/views/search/SearchBox.tsx | 6 +- src/client/views/search/SearchItem.tsx | 272 +++++++++++++++++---------------- 3 files changed, 141 insertions(+), 139 deletions(-) (limited to 'src/client/views/nodes/FieldView.tsx') diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx index 2cbfcdb0b..34b07f351 100644 --- a/src/client/views/nodes/FieldView.tsx +++ b/src/client/views/nodes/FieldView.tsx @@ -48,7 +48,7 @@ export interface FieldViewProps { ignoreAutoHeight?: boolean; PanelWidth: () => number; PanelHeight: () => number; - PanelPosition: string; + PanelPosition?: string; overflow?: boolean; NativeHeight: () => number; NativeWidth: () => number; diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index b7f7af244..b76955815 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -54,7 +54,7 @@ const SearchBoxDocument = makeInterface(documentSchema, searchSchema); @observer export class SearchBox extends ViewBoxBaseComponent(SearchBoxDocument) { - @computed get _searchString() { return this.layoutDoc.searchQuery; } + get _searchString() { return this.layoutDoc.searchQuery; } @computed set _searchString(value) { this.layoutDoc.searchQuery = (value); } @observable private _resultsOpen: boolean = false; @observable _searchbarOpen: boolean = false; @@ -691,7 +691,7 @@ export class SearchBox extends ViewBoxBaseComponent(["title", "author", "text", "lastModified"]); if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) { @@ -1039,7 +1039,7 @@ export class SearchBox extends ViewBoxBaseComponent { e.stopPropagation(); SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined); }} onClick={action(() => { this.filter = !this.filter && !this.scale; diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx index 6b06289c4..b61ed450f 100644 --- a/src/client/views/search/SearchItem.tsx +++ b/src/client/views/search/SearchItem.tsx @@ -143,13 +143,13 @@ const SearchDocument = makeInterface(documentSchema); @observer export class SearchItem extends ViewBoxBaseComponent(SearchDocument) { - + public static LayoutString(fieldKey: string) { return FieldView.LayoutString(SearchItem, fieldKey); } - constructor(props:any){ + constructor(props: any) { super(props); //this.rootDoc._viewType= CollectionViewType.Stacking; - this.props.Document._height=46; + this.props.Document._height = 46; if (!this.searchItemTemplate) { // create exactly one presElmentBox template to use by any and all presentations. Doc.UserDoc().searchItemTemplate = new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" })); // this script will be called by each presElement to get rendering-specific info that the PresBox knows about but which isn't written to the PresElement @@ -175,44 +175,46 @@ export class SearchItem extends ViewBoxBaseComponent this._useIcons, - el=> { - if (this.rootDoc.parent){ + el => { + if (this.rootDoc.parent) { parent = Cast(this.rootDoc.parent, Doc, null) as Doc; - height=(NumCast(parent._height)); + height = (NumCast(parent._height)); }; console.log(height); console.log(this._oldHeight); - setTimeout(() =>{this._mainRef.current?.getBoundingClientRect()? this.props.Document._height= this._mainRef.current?.getBoundingClientRect().height : null; - parent!==undefined? this._mainRef.current?.getBoundingClientRect()? parent._height= -this._oldHeight + height +this._mainRef.current?.getBoundingClientRect().height : null: null; - this._mainRef.current?.getBoundingClientRect()? this._oldHeight= this._mainRef.current?.getBoundingClientRect().height : null; - // this._oldHeight 55? this._oldHeight =55:null; - }, 1); - } + setTimeout(() => { + this._mainRef.current?.getBoundingClientRect() ? this.props.Document._height = this._mainRef.current?.getBoundingClientRect().height : null; + parent !== undefined ? this._mainRef.current?.getBoundingClientRect() ? parent._height = -this._oldHeight + height + this._mainRef.current?.getBoundingClientRect().height : null : null; + this._mainRef.current?.getBoundingClientRect() ? this._oldHeight = this._mainRef.current?.getBoundingClientRect().height : null; + // this._oldHeight 55? this._oldHeight =55:null; + }, 1); + } ); this._reactionDisposer3 = reaction( () => this._displayLines, - el=> { - if (this.rootDoc.parent){ + el => { + if (this.rootDoc.parent) { parent = Cast(this.rootDoc.parent, Doc, null) as Doc; - height=(NumCast(parent._height)); + height = (NumCast(parent._height)); }; - setTimeout(() =>{this._mainRef.current?.getBoundingClientRect()? this.props.Document._height= this._mainRef.current?.getBoundingClientRect().height : null; - parent!==undefined? this._mainRef.current?.getBoundingClientRect()? parent._height= -this._oldHeight + height +this._mainRef.current?.getBoundingClientRect().height : null: null; - this._mainRef.current?.getBoundingClientRect()? this._oldHeight= this._mainRef.current?.getBoundingClientRect().height : null; - }, 1); - } + setTimeout(() => { + this._mainRef.current?.getBoundingClientRect() ? this.props.Document._height = this._mainRef.current?.getBoundingClientRect().height : null; + parent !== undefined ? this._mainRef.current?.getBoundingClientRect() ? parent._height = -this._oldHeight + height + this._mainRef.current?.getBoundingClientRect().height : null : null; + this._mainRef.current?.getBoundingClientRect() ? this._oldHeight = this._mainRef.current?.getBoundingClientRect().height : null; + }, 1); + } ); Doc.SetSearchQuery(this.query); @@ -225,14 +227,14 @@ export class SearchItem extends ViewBoxBaseComponent
{ this._useIcons = false; this._displayDim = Number(SEARCH_THUMBNAIL_SIZE); })} >
-
{this.rootDoc.type ? this.rootDoc.type : "Other"}
+
{this.rootDoc.type ? this.rootDoc.type : "Other"}
- ; + ; } collectionRef = React.createRef(); @@ -304,8 +306,8 @@ export class SearchItem extends ViewBoxBaseComponent this.rootDoc!.searchMatch = true, 0); - this.rootDoc.searchIndex=NumCast(this.rootDoc.searchIndex); - this.length=NumCast(this.rootDoc!.length); + this.rootDoc.searchIndex = NumCast(this.rootDoc.searchIndex); + this.length = NumCast(this.rootDoc!.length); } @action @@ -317,12 +319,12 @@ export class SearchItem extends ViewBoxBaseComponent this.rootDoc!.searchMatch2 = true, 0); - this.rootDoc.searchIndex=NumCast(this.rootDoc.searchIndex); + this.rootDoc.searchIndex = NumCast(this.rootDoc.searchIndex); - this.length=NumCast(this.rootDoc!.length); + this.length = NumCast(this.rootDoc!.length); } - @observable length:number|undefined = 0; + @observable length: number | undefined = 0; highlightDoc = (e: React.PointerEvent) => { if (this.rootDoc!.type === DocumentType.LINK) { @@ -402,9 +404,9 @@ export class SearchItem extends ViewBoxBaseComponent this.layoutDoc._viewType === CollectionViewType.Stacking ? this.searchItemTemplate: undefined; + childLayoutTemplate = () => this.layoutDoc._viewType === CollectionViewType.Stacking ? this.searchItemTemplate : undefined; getTransform = () => { - return this.props.ScreenToLocalTransform().translate(-5, -65);// listBox padding-left and pres-box-cont minHeight + return this.props.ScreenToLocalTransform().translate(-5, -65);// listBox padding-left and pres-box-cont minHeight } panelHeight = () => { return this.props.PanelHeight(); @@ -413,60 +415,60 @@ export class SearchItem extends ViewBoxBaseComponent{ - if (StrCast(this.rootDoc.bucketfield)!=="results"){ - SearchBox.Instance._icons=[StrCast(this.rootDoc.bucketfield)]; - SearchBox.Instance._icons=SearchBox.Instance._icons; - } - else{ - SearchBox.Instance._icons=SearchBox.Instance._allIcons; - } - SearchBox.Instance.expandedBucket= true; - SearchBox.Instance.submitSearch(); - }) + newsearch() { + runInAction(() => { + if (StrCast(this.rootDoc.bucketfield) !== "results") { + SearchBox.Instance._icons = [StrCast(this.rootDoc.bucketfield)]; + SearchBox.Instance._icons = SearchBox.Instance._icons; + } + else { + SearchBox.Instance._icons = SearchBox.Instance._allIcons; + } + SearchBox.Instance.submitSearch(); + }) } - + @action - returnLines(){ - if ((Cast(this.rootDoc.lines, listSpec("string")))!.length>1){ - if (!this._displayLines) { - console.log(Cast(this.rootDoc.lines, listSpec("string"))); - return
{ - this._displayLines = !this._displayLines; - //this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE); - })} - //onPointerEnter={action(() => this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE))} - > - {Cast(this.rootDoc.lines, listSpec("string"))!.filter((m, i) => i).map((l, i) =>
{l}
)} -
;; + returnLines() { + if ((Cast(this.rootDoc.lines, listSpec("string")))!.length > 1) { + if (!this._displayLines) { + console.log(Cast(this.rootDoc.lines, listSpec("string"))); + return
{ + this._displayLines = !this._displayLines; + //this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE); + })} + //onPointerEnter={action(() => this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE))} + > + {Cast(this.rootDoc.lines, listSpec("string"))!.filter((m, i) => i).map((l, i) =>
{l}
)} +
;; + } } } - } - + //this._displayDim = Number(SEARCH_THUMBNAIL_SIZE); @observable _displayLines: boolean = true; - returnButtons(){ + returnButtons() { return
-
{ this.rootDoc!.type === DocumentType.PDF? this._displayLines = !this._displayLines : null; - })}> - {this.rootDoc!.type === DocumentType.PDF?"Expand Lines": null} - {NumCast(this.rootDoc!.length)>1?`Instance ${NumCast(this.rootDoc.searchIndex)===0? NumCast(this.rootDoc.length):NumCast(this.rootDoc.searchIndex) } of ${NumCast(this.rootDoc.length)}`: null} - - -
-
-
- {this.returnLines()} -
-
+
{ + this.rootDoc!.type === DocumentType.PDF ? this._displayLines = !this._displayLines : null; + })}> + {this.rootDoc!.type === DocumentType.PDF ? "Expand Lines" : null} + {NumCast(this.rootDoc!.length) > 1 ? `Instance ${NumCast(this.rootDoc.searchIndex) === 0 ? NumCast(this.rootDoc.length) : NumCast(this.rootDoc.searchIndex)} of ${NumCast(this.rootDoc.length)}` : null} + + +
+
+
+ {this.returnLines()} +
+
} @@ -476,79 +478,79 @@ export class SearchItem extends ViewBoxBaseComponent - +
} - if (this.rootDoc.isBucket === true){ - this.props.Document._viewType=CollectionViewType.Stacking; - this.props.Document._chromeStatus='disabled'; - this.props.Document._height=this.rootDoc._height; + if (this.rootDoc.isBucket === true) { + this.props.Document._viewType = CollectionViewType.Stacking; + this.props.Document._chromeStatus = 'disabled'; + this.props.Document._height = this.rootDoc._height; return
- -
} - else if (this.rootDoc.isBucket === false){ - this.props.Document._chromeStatus='disabled'; - return
+ else if (this.rootDoc.isBucket === false) { + this.props.Document._chromeStatus = 'disabled'; + return
-
-
No Search Results
-
+
+
No Search Results
+
} else { - return
-
-
-
-
{StrCast(this.rootDoc.title)}
-
- {this.rootDoc.highlighting? StrCast(this.rootDoc.highlighting).length ? "Matched fields:" + StrCast(this.rootDoc.highlighting) : Cast(this.rootDoc.lines, listSpec("string"))!.length ? Cast(this.rootDoc.lines, listSpec("string"))![0] : "":null}
-
- {NumCast(this.rootDoc.length) > 1 || this.rootDoc!.type === DocumentType.PDF?this.returnButtons(): null} + return
+
+
+
+
{StrCast(this.rootDoc.title)}
+
+ {this.rootDoc.highlighting ? StrCast(this.rootDoc.highlighting).length ? "Matched fields:" + StrCast(this.rootDoc.highlighting) : Cast(this.rootDoc.lines, listSpec("string"))!.length ? Cast(this.rootDoc.lines, listSpec("string"))![0] : "" : null}
+
+ {NumCast(this.rootDoc.length) > 1 || this.rootDoc!.type === DocumentType.PDF ? this.returnButtons() : null} +
+
+
+
+
{this.DocumentIcon()}
-
-
-
-
{this.DocumentIcon()}
-
- {/*
+ {/*
{(doc1 instanceof Doc && doc2 instanceof Doc) && this.rootDoc!.type === DocumentType.LINK ? : this.contextButton}
*/} -
-
; +
+
; } } } \ No newline at end of file -- cgit v1.2.3-70-g09d2