From d995b381343c9f286c80b5c8268e3697c05c2566 Mon Sep 17 00:00:00 2001 From: andy temp Date: Tue, 21 Jul 2020 18:04:16 -0400 Subject: search bar on topnpm start --- src/client/views/MainView.tsx | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/client/views/MainView.tsx') diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index f6db1af66..c65c90afb 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -59,6 +59,7 @@ import { DocumentManager } from '../util/DocumentManager'; import { DocumentLinksButton } from './nodes/DocumentLinksButton'; import { LinkMenu } from './linking/LinkMenu'; import { LinkDocPreview } from './nodes/LinkDocPreview'; +import { SearchBox } from './search/SearchBox'; @observer export class MainView extends React.Component { @@ -79,6 +80,8 @@ export class MainView extends React.Component { @computed private get mainContainer() { return this.userDoc ? FieldValue(Cast(this.userDoc.activeWorkspace, Doc)) : CurrentUserUtils.GuestWorkspace; } @computed public get mainFreeform(): Opt { return (docs => (docs && docs.length > 1) ? docs[1] : undefined)(DocListCast(this.mainContainer!.data)); } @computed public get sidebarButtonsDoc() { return Cast(this.userDoc["tabs-buttons"], Doc) as Doc; } + @computed public get searchDoc() { return Cast(this.userDoc["search-panel"], Doc) as Doc; } + public isPointerDown = false; @@ -300,6 +303,39 @@ export class MainView extends React.Component { } } } + + @computed get search() { + return ; + } + + + + + @computed get mainDocView() { return ; } + @computed get dockingContent() { TraceMobx(); const mainContainer = this.mainContainer; @@ -461,6 +498,10 @@ export class MainView extends React.Component { @computed get mainContent() { const sidebar = this.userDoc?.["tabs-panelContainer"]; return !this.userDoc || !(sidebar instanceof Doc) ? (null) : ( +
+
+ {this.search} +
{this.dockingContent}
+
); } -- cgit v1.2.3-70-g09d2 From d4ff3975ee3b72a7869535bf8d9fc78039203aed Mon Sep 17 00:00:00 2001 From: andy temp 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/MainView.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: Thu, 23 Jul 2020 13:51:21 -0400 Subject: test --- src/client/views/MainView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/client/views/MainView.tsx') diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index fce3707a7..0a7964cea 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -164,7 +164,7 @@ export class MainView extends React.Component { if (targets && targets.length && SearchBox.Instance._searchbarOpen){ let check = false; targets.forEach((thing)=>{ - if (thing.className.toString()==="collectionSchemaView-table" || thing.className.toString()==="beta") { + if (thing.className.toString()==="collectionSchemaView-table" || thing.className.toString()==="beta"|| thing.className.toString()==="collectionSchemaView-menuOptions-wrapper") { check=true; } }); -- cgit v1.2.3-70-g09d2 From 3bbabb64695650fc632fdf88286094f457adb838 Mon Sep 17 00:00:00 2001 From: bobzel Date: Mon, 3 Aug 2020 23:50:22 -0400 Subject: starting to cleanup search --- src/client/util/CurrentUserUtils.ts | 33 ++-------- src/client/util/SearchUtil.ts | 1 - src/client/views/MainView.tsx | 70 ---------------------- .../views/collections/CollectionSchemaCells.tsx | 9 --- .../views/collections/CollectionSchemaHeaders.tsx | 10 ---- .../views/collections/CollectionSchemaView.tsx | 24 +++----- src/client/views/collections/CollectionSubView.tsx | 3 - src/client/views/nodes/LabelBox.tsx | 1 - src/client/views/nodes/WebBox.tsx | 2 +- src/client/views/pdf/PDFViewer.tsx | 3 - 10 files changed, 16 insertions(+), 140 deletions(-) (limited to 'src/client/views/MainView.tsx') diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index 12e48ae13..048b5fe76 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -414,9 +414,9 @@ export class CurrentUserUtils { doc.emptyButton = Docs.Create.ButtonDocument({ _width: 150, _height: 50, _xPadding: 10, _yPadding: 10, title: "Button" }); } if (doc.emptyDocHolder === undefined) { - // doc.emptyDocHolder = Docs.Create.DocumentDocument( - // ComputedField.MakeFunction("selectedDocs(this,this.excludeCollections,[_last_])?.[0]") as any, - // { _width: 250, _height: 250, title: "container" }); + doc.emptyDocHolder = Docs.Create.DocumentDocument( + ComputedField.MakeFunction("selectedDocs(this,this.excludeCollections,[_last_])?.[0]") as any, + { _width: 250, _height: 250, title: "container" }); } if (doc.emptyWebpage === undefined) { doc.emptyWebpage = Docs.Create.WebDocument("", { title: "webpage", _nativeWidth: 850, _nativeHeight: 962, _width: 600, UseCors: true }); @@ -647,7 +647,7 @@ export class CurrentUserUtils { // setup the Creator button which will display the creator panel. This panel will include the drag creators and the color picker. // when clicked, this panel will be displayed in the target container (ie, sidebarContainer) - static async setupToolsBtnPanel(doc: Doc, sidebarContainer: Doc) { + static async setupToolsBtnPanel(doc: Doc) { // setup a masonry view of all he creators const creatorBtns = await CurrentUserUtils.setupCreatorButtons(doc); const templateBtns = CurrentUserUtils.setupUserTemplateButtons(doc); @@ -746,20 +746,7 @@ export class CurrentUserUtils { } } - // setup the Search button which will display the search panel. - static setupSearchBtnPanel(doc: Doc, sidebarContainer: Doc) { - if (doc["tabs-button-search"] === undefined) { - doc["tabs-button-search"] = new PrefetchProxy(Docs.Create.ButtonDocument({ - _width: 50, _height: 25, title: "Search", _fontSize: "10pt", - letterSpacing: "0px", textTransform: "unset", borderRounding: "5px 5px 0px 0px", boxShadow: "3px 3px 0px rgb(34, 34, 34)", - sourcePanel: new PrefetchProxy(Docs.Create.SearchDocument({ ignoreClick: true, childDropAction: "alias", lockedPosition: true, _viewType: CollectionViewType.Schema, title: "sidebar search stack", })) as any as Doc, - searchFileTypes: new List([DocumentType.RTF, DocumentType.IMG, DocumentType.PDF, DocumentType.VID, DocumentType.WEB, DocumentType.SCRIPTING]), - targetContainer: new PrefetchProxy(sidebarContainer) as any as Doc, - lockedPosition: true, - onClick: ScriptField.MakeScript("this.targetContainer.proto = this.sourcePanel") - })); - } - } + static setupUserDoc(doc: Doc) { if (doc["sidebar-userDoc"] === undefined) { doc.treeViewOpen = true; @@ -784,15 +771,7 @@ export class CurrentUserUtils { // setup the list of sidebar mode buttons which determine what is displayed in the sidebar static async setupSidebarButtons(doc: Doc) { - const sidebarContainer = CurrentUserUtils.setupSidebarContainer(doc); - const toolsBtn = await CurrentUserUtils.setupToolsBtnPanel(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, _chromeStatus: "disabled", title: "sidebar search stack", })) as any as Doc; - } - - - await CurrentUserUtils.setupToolsBtnPanel(doc, sidebarContainer); + await CurrentUserUtils.setupToolsBtnPanel(doc); CurrentUserUtils.setupWorkspaces(doc); CurrentUserUtils.setupCatalog(doc); CurrentUserUtils.setupRecentlyClosed(doc); diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts index f54e13197..7b2c601fe 100644 --- a/src/client/util/SearchUtil.ts +++ b/src/client/util/SearchUtil.ts @@ -4,7 +4,6 @@ import { Doc } from '../../fields/Doc'; import { Id } from '../../fields/FieldSymbols'; import { Utils } from '../../Utils'; import { DocumentType } from '../documents/DocumentTypes'; -import { StringMap } from 'libxmljs'; export namespace SearchUtil { export type HighlightingResult = { [id: string]: { [key: string]: string[] } }; diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index 03f624038..923036eae 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -80,7 +80,6 @@ export class MainView extends React.Component { @computed private get userDoc() { return Doc.UserDoc(); } @computed private get mainContainer() { return this.userDoc ? FieldValue(Cast(this.userDoc.activeWorkspace, Doc)) : CurrentUserUtils.GuestWorkspace; } @computed public get mainFreeform(): Opt { return (docs => (docs && docs.length > 1) ? docs[1] : undefined)(DocListCast(this.mainContainer!.data)); } - @computed public get sidebarButtonsDoc() { return Cast(this.userDoc["tabs-buttons"], Doc) as Doc; } @computed public get searchDoc() { return Cast(this.userDoc["search-panel"], Doc) as Doc; } @@ -356,38 +355,6 @@ export class MainView extends React.Component { } } - // @computed get search() { - // return ; - // } - - - - - @computed get mainDocView() { return - //
- // {this.search} - //
- //
- //
- //
- //
- // - //
- //
- // {this.flyout} - // {this.expandButton} - //
- //
- // {this.dockingContent} - //
- //
- //
); const pinned = FormatShapePane.Instance?.Pinned; const innerContent = this.mainInnerContent; return !this.userDoc ? (null) : ( diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx index e50f95dca..ecd20eb06 100644 --- a/src/client/views/collections/CollectionSchemaCells.tsx +++ b/src/client/views/collections/CollectionSchemaCells.tsx @@ -32,7 +32,6 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import DatePicker from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; import { DateField } from "../../../fields/DateField"; -import { indexOf } from "lodash"; const path = require('path'); library.add(faExpand); @@ -292,9 +291,6 @@ export class CollectionSchemaCell extends React.Component { maxHeight={Number(MAX_ROW_HEIGHT)} placeholder={"enter value"} bing={() => { - // if (type === "number" && (contents === 0 || contents === "0")) { - // return "0"; - // } else { const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey])); if (cfield !== undefined) { if (cfield.Text !== undefined) { @@ -307,11 +303,6 @@ export class CollectionSchemaCell extends React.Component { return String(NumCast(cfield)); } } - // console.log(cfield.Text); - // console.log(StrCast(cfield)); - // return StrCast(cfield); - // } - }} GetValue={() => { if (type === "number" && (contents === 0 || contents === "0")) { diff --git a/src/client/views/collections/CollectionSchemaHeaders.tsx b/src/client/views/collections/CollectionSchemaHeaders.tsx index a979f9838..5d7ab2c61 100644 --- a/src/client/views/collections/CollectionSchemaHeaders.tsx +++ b/src/client/views/collections/CollectionSchemaHeaders.tsx @@ -78,14 +78,6 @@ export class CollectionSchemaAddColumnHeader extends React.Component { @undoBatch onKeyDown = (e: React.KeyboardEvent): void => { - //if (this._key !==) - if (e.key === "Enter") { const keyOptions = this._searchTerm === "" ? this.props.possibleKeys : this.props.possibleKeys.filter(key => key.toUpperCase().indexOf(this._searchTerm.toUpperCase()) > -1); if (keyOptions.length) { diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx index b93a7f7b8..869be2b03 100644 --- a/src/client/views/collections/CollectionSchemaView.tsx +++ b/src/client/views/collections/CollectionSchemaView.tsx @@ -4,27 +4,26 @@ import { faCog, faPlus, faSortDown, faSortUp, faTable } from '@fortawesome/free- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { action, computed, observable, untracked } from "mobx"; import { observer } from "mobx-react"; +import Measure from "react-measure"; import { Resize } from "react-table"; import "react-table/react-table.css"; -import { Doc, DocCastAsync } from "../../../fields/Doc"; +import { Doc } from "../../../fields/Doc"; import { List } from "../../../fields/List"; import { listSpec } from "../../../fields/Schema"; -import { SchemaHeaderField, PastelSchemaPalette } from "../../../fields/SchemaHeaderField"; -import { Cast, NumCast, StrCast } from "../../../fields/Types"; -import { Docs, DocumentOptions } from "../../documents/Documents"; +import { PastelSchemaPalette, SchemaHeaderField } from "../../../fields/SchemaHeaderField"; +import { Cast, NumCast } from "../../../fields/Types"; +import { TraceMobx } from "../../../fields/util"; +import { emptyFunction, returnFalse, returnOne, returnZero, setupMoveUpEvents } from "../../../Utils"; +import { SnappingManager } from "../../util/SnappingManager"; import { Transform } from "../../util/Transform"; import { undoBatch } from "../../util/UndoManager"; import { COLLECTION_BORDER_WIDTH } from '../../views/globalCssVariables.scss'; import '../DocumentDecorations.scss'; +import { ContentFittingDocumentView } from "../nodes/ContentFittingDocumentView"; import { KeysDropdown } from "./CollectionSchemaHeaders"; import "./CollectionSchemaView.scss"; import { CollectionSubView } from "./CollectionSubView"; -import { ContentFittingDocumentView } from "../nodes/ContentFittingDocumentView"; -import { setupMoveUpEvents, emptyFunction, returnZero, returnOne, returnFalse } from "../../../Utils"; -import { SnappingManager } from "../../util/SnappingManager"; -import Measure from "react-measure"; import { SchemaTable } from "./SchemaTable"; -import { TraceMobx } from "../../../fields/util"; library.add(faCog, faPlus, faSortUp, faSortDown); library.add(faTable); @@ -170,9 +169,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { @action setColumnSort = (columnField: SchemaHeaderField, descending: boolean | undefined) => { const columns = this.columns; - columns.forEach(col => { - col.setDesc(undefined); - }) + columns.forEach(col => col.setDesc(undefined)); const index = columns.findIndex(c => c.heading === columnField.heading); const column = columns[index]; @@ -330,8 +327,6 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { columns[index] = column; this.columns = columns; if (filter) { - console.log(newKey); - console.log(filter); Doc.setDocFilter(this.props.Document, newKey, filter, "match"); if (this.props.Document.selectedDoc !== undefined) { let doc = Cast(this.props.Document.selectedDoc, Doc) as Doc; @@ -462,7 +457,6 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { this.props.select(false); } } - console.log("yeeeet"); } @computed diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx index ab28e1904..88241f519 100644 --- a/src/client/views/collections/CollectionSubView.tsx +++ b/src/client/views/collections/CollectionSubView.tsx @@ -130,10 +130,7 @@ export function CollectionSubView(schemaCtor: (doc: Doc) => T, moreProps?: let childDocs = viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs; const searchDocs = DocListCast(this.props.Document._searchDocs); - console.log(this.props.Document); - console.log(searchDocs); if (searchDocs !== undefined && searchDocs.length > 0) { - console.log("yes"); childDocs = searchDocs; } const docFilters = this.docFilters(); diff --git a/src/client/views/nodes/LabelBox.tsx b/src/client/views/nodes/LabelBox.tsx index 983470f9d..302d66cc5 100644 --- a/src/client/views/nodes/LabelBox.tsx +++ b/src/client/views/nodes/LabelBox.tsx @@ -69,7 +69,6 @@ export class LabelBox extends ViewBoxBaseComponent !this.paramsDoc[p]); params?.map(p => DocListCast(this.paramsDoc[p])); // bcz: really hacky form of prefetching ... - console.log(this.backColor); return (
runInAction(() => { this.clicked = !this.clicked; this.clicked ? this.backColor = StrCast(this.layoutDoc.hovercolor) : this.backColor = "unset" })} onMouseLeave={() => runInAction(() => { !this.clicked ? this.backColor = "unset" : null })} onMouseOver={() => runInAction(() => { this.backColor = StrCast(this.layoutDoc.hovercolor); })} ref={this.createDropTarget} onContextMenu={this.specificContextMenu} diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx index 1313bded7..646a94aa7 100644 --- a/src/client/views/nodes/WebBox.tsx +++ b/src/client/views/nodes/WebBox.tsx @@ -139,7 +139,7 @@ export class WebBox extends ViewBoxAnnotatableComponent { - console.log(this.Index); this.Index = Math.max(this.Index - 1, 0); - console.log(this.Index); - console.log(this.allAnnotations); this.scrollToAnnotation(this.allAnnotations.sort((a, b) => NumCast(a.y) - NumCast(b.y))[this.Index]); } -- cgit v1.2.3-70-g09d2 From 4931f089160d6de5f34d8956c6106b6be1ec7d6f Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 4 Aug 2020 11:21:44 -0400 Subject: fixed click behavior on filter icon in search bar. --- src/client/views/MainView.tsx | 2 +- src/client/views/search/SearchBox.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/client/views/MainView.tsx') diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index 923036eae..c6cebc9ab 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -195,7 +195,7 @@ export class MainView extends React.Component { if (targets && targets.length && SearchBox.Instance._searchbarOpen) { let check = false; targets.forEach((thing) => { - if (thing.className.toString() === "collectionSchemaView-table" || thing.className.toString() === "beta" || thing.className.toString() === "collectionSchemaView-menuOptions-wrapper") { + if (thing.className.toString() === "collectionSchemaView-table" || (thing as any)?.dataset["icon"] === "filter" || thing.className.toString() === "beta" || thing.className.toString() === "collectionSchemaView-menuOptions-wrapper") { check = true; } }); diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index 2cb910f8b..b7f7af244 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -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; -- cgit v1.2.3-70-g09d2 From 7d296bf47dd373c5cb74eecda149ba1aa608acbc Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 4 Aug 2020 15:51:10 -0400 Subject: clean up labelBox --- src/client/views/DocComponent.tsx | 1 - src/client/views/MainView.tsx | 1 - src/client/views/nodes/LabelBox.tsx | 10 +++++++--- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/client/views/MainView.tsx') diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx index 149586c67..804c7a8d4 100644 --- a/src/client/views/DocComponent.tsx +++ b/src/client/views/DocComponent.tsx @@ -170,7 +170,6 @@ export function ViewBoxAnnotatableComponent

doc.context = this.props.Document); (targetDataDoc[this.annotationKey] as List).push(...added); targetDataDoc[this.annotationKey + "-lastModified"] = new DateField(new Date(Date.now())); - } } } diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index 7cf993d83..119fa3451 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -187,7 +187,6 @@ 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(); diff --git a/src/client/views/nodes/LabelBox.tsx b/src/client/views/nodes/LabelBox.tsx index ccdd088d3..826ccd340 100644 --- a/src/client/views/nodes/LabelBox.tsx +++ b/src/client/views/nodes/LabelBox.tsx @@ -57,7 +57,8 @@ export class LabelBox extends ViewBoxBaseComponent m + ":").join(" ") + ")") @@ -66,8 +67,11 @@ export class LabelBox extends ViewBoxBaseComponent !this.paramsDoc[p]); params?.map(p => DocListCast(this.paramsDoc[p])); // bcz: really hacky form of prefetching ... return ( -

runInAction(() => { this.clicked = !this.clicked; this.clicked ? this.backColor = StrCast(this.layoutDoc.hovercolor) : this.backColor = "unset" })} onMouseLeave={() => runInAction(() => { !this.clicked ? this.backColor = "unset" : null })} - onMouseOver={() => runInAction(() => { this.backColor = StrCast(this.layoutDoc.hovercolor); })} ref={this.createDropTarget} onContextMenu={this.specificContextMenu} +
this.clicked = !this.clicked)} + onMouseLeave={action(() => this._mouseOver = false)} + onMouseOver={action(() => this._mouseOver = true)} + ref={this.createDropTarget} onContextMenu={this.specificContextMenu} style={{ boxShadow: this.layoutDoc.opacity ? StrCast(this.layoutDoc.boxShadow) : "" }}>
Date: Wed, 5 Aug 2020 01:17:28 -0400 Subject: lint --- src/client/util/CurrentUserUtils.ts | 1 - src/client/views/EditableView.tsx | 4 +- src/client/views/MainView.tsx | 9 +- .../views/collections/CollectionSchemaCells.tsx | 11 +- src/client/views/collections/CollectionSubView.tsx | 4 +- src/client/views/linking/LinkMenuItem.tsx | 1 - src/client/views/nodes/DocumentLinksButton.tsx | 2 +- .../views/nodes/formattedText/FormattedTextBox.tsx | 3 +- .../views/nodes/formattedText/RichTextMenu.tsx | 3 +- src/client/views/search/FieldFilters.scss | 12 - src/client/views/search/FieldFilters.tsx | 41 -- src/client/views/search/FilterBox.scss | 178 --------- src/client/views/search/FilterBox.tsx | 431 --------------------- src/server/websocket.ts | 8 +- 14 files changed, 25 insertions(+), 683 deletions(-) delete mode 100644 src/client/views/search/FieldFilters.scss delete mode 100644 src/client/views/search/FieldFilters.tsx delete mode 100644 src/client/views/search/FilterBox.scss delete mode 100644 src/client/views/search/FilterBox.tsx (limited to 'src/client/views/MainView.tsx') diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index ea701ec33..53d187aa0 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -771,7 +771,6 @@ export class CurrentUserUtils { // setup the list of sidebar mode buttons which determine what is displayed in the sidebar static async setupSidebarButtons(doc: Doc) { - this.setupSidebarContainer(doc); await CurrentUserUtils.setupToolsBtnPanel(doc); CurrentUserUtils.setupWorkspaces(doc); CurrentUserUtils.setupCatalog(doc); diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx index a5628d5ee..ec3e754fb 100644 --- a/src/client/views/EditableView.tsx +++ b/src/client/views/EditableView.tsx @@ -197,11 +197,11 @@ export class EditableView extends React.Component { // contents = String(this.props.contents.valueOf()); - results.push({contents ? contents.slice(0, this.props.positions![0]) : this.props.placeholder?.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; - cur === positions.length - 1 ? end = contents!.length : end = positions[cur + 1]; + cur === positions.length - 1 ? end = contents.length : end = positions[cur + 1]; results.push({contents ? contents.slice(num + length, end) : this.props.placeholder?.valueOf()}); } ); diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index 119fa3451..1b2dd1c44 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -82,8 +82,8 @@ export class MainView extends React.Component { @computed public get mainFreeform(): Opt { return (docs => (docs && docs.length > 1) ? docs[1] : undefined)(DocListCast(this.mainContainer!.data)); } @computed public get searchDoc() { return Cast(this.userDoc["search-panel"], Doc) as Doc; } - - @observable public sidebarContent: any = this.userDoc?.["sidebar"]; + sidebar: string = "sidebar"; + @observable public sidebarContent: any = this.userDoc?.[this.sidebar]; @observable public panelContent: string = "none"; @observable public showProperties: boolean = false; public isPointerDown = false; @@ -193,8 +193,9 @@ export class MainView extends React.Component { } if (targets && targets.length && SearchBox.Instance._searchbarOpen) { let check = false; + const icon = "icon"; targets.forEach((thing) => { - if (thing.className.toString() === "collectionSchemaView-table" || (thing as any)?.dataset["icon"] === "filter" || thing.className.toString() === "beta" || thing.className.toString() === "collectionSchemaView-menuOptions-wrapper") { + if (thing.className.toString() === "collectionSchemaView-table" || (thing as any)?.dataset[icon] === "filter" || thing.className.toString() === "beta" || thing.className.toString() === "collectionSchemaView-menuOptions-wrapper") { check = true; } }); @@ -731,7 +732,7 @@ export class MainView extends React.Component { @computed get search() { return
{/*
{Doc.CurrentUserEmail}
*/} -
{ bing={() => { const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey])); if (cfield !== undefined) { - if (cfield.Text !== undefined) { - return (cfield.Text); + console.log(typeof (cfield)); + // if (typeof(cfield)===RichTextField) + const a = cfield as RichTextField; + if (a.Text !== undefined) { + return (a.Text); } else if (StrCast(cfield)) { return StrCast(cfield); @@ -884,7 +888,8 @@ export class CollectionSchemaButtons extends CollectionSchemaCell { // SetupDrag(reference, () => this._document, this.props.moveDocument, this.props.Document.schemaDoc ? "copy" : undefined)(e)); // }; const doc = this.props.rowProps.original; - let buttons =
-
-
-
-
-
Filter by type of node
-
-
-
-
-
-
Filter by Basic Keys
-
-
-
-
-
- - -
-
- ) : - undefined} -
- ); - } -} \ No newline at end of file diff --git a/src/server/websocket.ts b/src/server/websocket.ts index cdce41a3a..2c8ec090a 100644 --- a/src/server/websocket.ts +++ b/src/server/websocket.ts @@ -286,16 +286,16 @@ export namespace WebSocket { dynfield = true; const val = docfield[key]; key = key.substring(7); - if (key==="_height"){ - Object.values(suffixMap).forEach(suf => {update[key] = { set: null };}); + if (key === "_height") { + Object.values(suffixMap).forEach(suf => { update[key] = { set: null }; }); } else { - Object.values(suffixMap).forEach(suf => {update[key + getSuffix(suf)] = { set: null };}); + Object.values(suffixMap).forEach(suf => { update[key + getSuffix(suf)] = { set: null }; }); } const term = ToSearchTerm(val); if (term !== undefined) { const { suffix, value } = term; - if (key==="_height"){ + if (key === "_height") { update[key] = { set: value }; } update[key + suffix] = { set: value }; -- cgit v1.2.3-70-g09d2