From 195dde9364bf7b294d74b95e70c8c9a9dd19f891 Mon Sep 17 00:00:00 2001 From: Andy Rickert Date: Fri, 3 Jul 2020 16:06:07 -0400 Subject: search works with schema, fixed sorting...stil a lot of bugs --- src/client/util/CurrentUserUtils.ts | 4 +- .../views/collections/CollectionSchemaView.scss | 2 +- .../views/collections/CollectionSchemaView.tsx | 4 + src/client/views/collections/SchemaTable.tsx | 14 +- src/client/views/search/SearchBox.tsx | 172 +++------------------ 5 files changed, 35 insertions(+), 161 deletions(-) (limited to 'src') diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index 276ad4c90..c152a4a64 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -42,7 +42,7 @@ export class CurrentUserUtils { if (doc["template-button-query"] === undefined) { const queryTemplate = Docs.Create.MulticolumnDocument( [ - Docs.Create.SearchDocument({ _viewType: CollectionViewType.Stacking, ignoreClick: true, forceActive: true, lockedPosition: true, title: "query", _height: 200 }), + Docs.Create.SearchDocument({ _viewType: CollectionViewType.Schema, ignoreClick: true, forceActive: true, lockedPosition: true, title: "query", _height: 200 }), Docs.Create.FreeformDocument([], { title: "data", _height: 100, _LODdisable: true }) ], { _width: 400, _height: 300, title: "queryView", _chromeStatus: "disabled", _xMargin: 3, _yMargin: 3, hideFilterView: true } @@ -631,7 +631,7 @@ export class CurrentUserUtils { doc["tabs-button-search"] = new PrefetchProxy(Docs.Create.ButtonDocument({ _width: 50, _height: 25, title: "Search", _fontSize: 10, 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.Stacking, title: "sidebar search stack", })) as any as Doc, + 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, diff --git a/src/client/views/collections/CollectionSchemaView.scss b/src/client/views/collections/CollectionSchemaView.scss index 5226a60f1..688099b6c 100644 --- a/src/client/views/collections/CollectionSchemaView.scss +++ b/src/client/views/collections/CollectionSchemaView.scss @@ -6,7 +6,7 @@ border-style: solid; border-radius: $border-radius; box-sizing: border-box; - position: absolute; + position: relative; top: 0; width: 100%; height: 100%; diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx index 9722f8f26..688313951 100644 --- a/src/client/views/collections/CollectionSchemaView.tsx +++ b/src/client/views/collections/CollectionSchemaView.tsx @@ -170,6 +170,10 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { @action setColumnSort = (columnField: SchemaHeaderField, descending: boolean | undefined) => { const columns = this.columns; + columns.forEach(col => { + col.setDesc(undefined); + }) + const index = columns.findIndex(c => c.heading === columnField.heading); const column = columns[index]; column.setDesc(descending); diff --git a/src/client/views/collections/SchemaTable.tsx b/src/client/views/collections/SchemaTable.tsx index 695965cb4..5a73e7501 100644 --- a/src/client/views/collections/SchemaTable.tsx +++ b/src/client/views/collections/SchemaTable.tsx @@ -128,7 +128,7 @@ export class SchemaTable extends React.Component { } @computed get sorted(): SortingRule[] { return this.props.columns.reduce((sorted, shf) => { - shf.desc && sorted.push({ id: shf.heading, desc: shf.desc }); + shf.desc !== undefined && sorted.push({ id: shf.heading, desc: shf.desc }); return sorted; }, [] as SortingRule[]); } @@ -209,7 +209,7 @@ export class SchemaTable extends React.Component { }}> {col.heading}; - const sortIcon = col.desc === undefined ? "circle" : col.desc === true ? "caret-down" : "caret-up"; + const sortIcon = col.desc === undefined ? "caret-right" : col.desc === true ? "caret-down" : "caret-up"; const header =
{ className="collectionSchemaView-menuOptions-wrapper" style={{ background: col.color, padding: "2px", - display: "flex" + display: "flex", cursor: "default" }}> {/*
{ {keysDropdown} {/*
*/}
this.changeSorting(col)} - style={{ paddingRight: "6px", display: "inline", zIndex: 1, background: "inherit" }}> - + style={{ width: 21, padding: 1, display: "inline", zIndex: 1, background: "inherit" }}> +
-
this.props.openHeader(col, e.clientX, e.clientY)} + {/*
this.props.openHeader(col, e.clientX, e.clientY)} style={{ float: "right", paddingRight: "6px", zIndex: 1, background: "inherit" }}> -
+
*/}
; return { diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index 5960a0502..d51d1bf0c 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -132,21 +132,21 @@ export class SearchBox extends ViewBoxBaseComponent { @@ -422,86 +422,6 @@ export class SearchBox extends ViewBoxBaseComponent([]); - for (var key in this.new_buckets) { - if (this.new_buckets[key] > highcount) { - secondcount === highcount; - this.secondstring = this.firststring; - highcount = this.new_buckets[key]; - this.firststring = key; - } - else if (this.new_buckets[key] > secondcount) { - secondcount = this.new_buckets[key]; - this.secondstring = key; - } - } - - let bucket = Docs.Create.StackingDocument([], { _viewType: CollectionViewType.Stacking, ignoreClick: true, forceActive: true, lockedPosition: true, title: `default bucket` }); - bucket._viewType === CollectionViewType.Stacking; - bucket._height = 185; - bucket.bucketfield = "results"; - bucket.isBucket = true; - Doc.AddDocToList(this.dataDoc, this.props.fieldKey, bucket); - this.buckets!.push(bucket); - this.bucketcount[0] = 0; - - if (this.firststring !== "") { - let firstbucket = Docs.Create.StackingDocument([], { _viewType: CollectionViewType.Stacking, ignoreClick: true, forceActive: true, lockedPosition: true, title: this.firststring }); - firstbucket._height = 185; - - firstbucket._viewType === CollectionViewType.Stacking; - firstbucket.bucketfield = this.firststring; - firstbucket.isBucket = true; - Doc.AddDocToList(this.dataDoc, this.props.fieldKey, firstbucket); - this.buckets!.push(firstbucket); - this.bucketcount[1] = 0; - - } - - if (this.secondstring !== "") { - let secondbucket = Docs.Create.StackingDocument([], { _viewType: CollectionViewType.Stacking, ignoreClick: true, forceActive: true, lockedPosition: true, title: this.secondstring }); - secondbucket._height = 185; - secondbucket._viewType === CollectionViewType.Stacking; - secondbucket.bucketfield = this.secondstring; - secondbucket.isBucket = true; - Doc.AddDocToList(this.dataDoc, this.props.fieldKey, secondbucket); - this.buckets!.push(secondbucket); - this.bucketcount[2] = 0; - } - - let webbucket = Docs.Create.StackingDocument([], { _viewType: CollectionViewType.Stacking, childDropAction: "alias", ignoreClick: true, lockedPosition: true, title: this.secondstring }); - webbucket._height = 185; - webbucket._viewType === CollectionViewType.Stacking; - webbucket.bucketfield = "webs"; - webbucket.isBucket = true; - let old = Cast(this.props.Document.webbucket, Doc) as Doc; - let old2 = Cast(this.props.Document.bing, Doc) as Doc; - if (old) { - console.log("Cleanup"); - Doc.RemoveDocFromList(old, this.props.fieldKey, old2); - } - const textDoc = Docs.Create.WebDocument(`https://bing.com/search?q=${this.layoutDoc._searchString}`, { - _width: 200, _nativeHeight: 962, _nativeWidth: 800, isAnnotating: false, - title: "bing", UseCors: true - }); - this.props.Document.bing = textDoc; - this.props.Document.webbucket = webbucket; - Doc.AddDocToList(this.dataDoc, this.props.fieldKey, webbucket); - Doc.AddDocToList(webbucket, this.props.fieldKey, textDoc); - - - } - - @observable buckets: Doc[] | undefined; getAllResults = async (query: string) => { @@ -521,7 +441,6 @@ export class SearchBox extends ViewBoxBaseComponent; getResults = async (query: string) => { @@ -581,9 +500,7 @@ export class SearchBox extends ViewBoxBaseComponent 3 && this.expandedBucket === false) { - this.makenewbuckets(); - } + this.resultsScrolled(); res(); }); @@ -632,7 +549,7 @@ export class SearchBox extends ViewBoxBaseComponent 3 && this.expandedBucket === false) { - - if (StrCast(result[0].type) === this.firststring) { - if (this.bucketcount[1] < 3) { - result[0].parent = this.buckets![1]; - Doc.AddDocToList(this.buckets![1], this.props.fieldKey, result[0]); - this.bucketcount[1] += 1; - } - } - else if (StrCast(result[0].type) === this.secondstring) { - if (this.bucketcount[2] < 3) { - result[0].parent = this.buckets![2]; - Doc.AddDocToList(this.buckets![2], this.props.fieldKey, result[0]); - this.bucketcount[2] += 1; - } - } - else if (this.bucketcount[0] < 3) { - //Doc.AddDocToList(this.buckets![0], this.props.fieldKey, result[0]); - //this.bucketcount[0]+=1; - Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]); - } - } - else { - Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]); - } + Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]); + } } } } } } - if (this._numTotalResults > 3 && this.expandedBucket === false) { - if (this.buckets![0]) { - this.buckets![0]._height = this.bucketcount[0] * 55 + 25; - } - if (this.buckets![1]) { - this.buckets![1]._height = this.bucketcount[1] * 55 + 25; - } - if (this.buckets![2]) { - this.buckets![2]._height = this.bucketcount[2] * 55 + 25; - } - } if (this._maxSearchIndex >= this._numTotalResults) { this._visibleElements.length = this._results.length; this._visibleDocuments.length = this._results.length; @@ -1214,12 +1097,11 @@ export class SearchBox extends ViewBoxBaseComponent this.layoutDoc._viewType === CollectionViewType.Stacking ? this.searchItemTemplate : undefined; getTransform = () => { return this.props.ScreenToLocalTransform().translate(-5, -65);// listBox padding-left and pres-box-cont minHeight } panelHeight = () => { - return this.props.PanelHeight() - 50; + return this.props.PanelHeight(); } selectElement = (doc: Doc) => { //this.gotoDocument(this.childDocs.indexOf(doc), NumCasst(this.layoutDoc._itemIndex)); @@ -1230,17 +1112,9 @@ export class SearchBox extends ViewBoxBaseComponent -
StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} ref={this.collectionRef} title="Drag Results as Collection"> @@ -1263,11 +1137,7 @@ export class SearchBox extends ViewBoxBaseComponent 400} - childLayoutTemplate={this.childLayoutTemplate} - addDocument={undefined} removeDocument={returnFalse} focus={this.selectElement} ScreenToLocalTransform={Transform.Identity} /> @@ -1284,7 +1154,7 @@ export class SearchBox extends ViewBoxBaseComponent