aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/search/SearchBox.tsx18
-rw-r--r--src/client/views/search/SearchItem.tsx54
2 files changed, 35 insertions, 37 deletions
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index c38c4c1b9..525969565 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -80,9 +80,8 @@ const SearchBoxDocument = makeInterface(documentSchema, searchSchema);
@observer
export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDocument>(SearchBoxDocument) {
- // private get _searchString() { return this.rootDoc.searchQuery; }
- // private set _searchString(value) { this.rootDoc.setSearchQuery(value); }
- @observable _searchString: string ="";
+ @computed get _searchString() { return this.layoutDoc.searchQuery; }
+ @computed set _searchString(value) { this.layoutDoc.searchQuery=(value); }
@observable private _resultsOpen: boolean = false;
@observable private _searchbarOpen: boolean = false;
@observable private _results: [Doc, string[], string[]][] = [];
@@ -355,7 +354,12 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
@action
- submitSearch = async () => {
+ submitSearch = async (reset?:boolean) => {
+ console.log("yes");
+ if (reset){
+ this.layoutDoc._searchString="";
+ }
+ console.log(this.layoutDoc._searchString);
this.dataDoc[this.fieldKey] = new List<Doc>([]);
this.buckets=[];
this.new_buckets={};
@@ -660,10 +664,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
result[0].highlighting=highlights.join(", ");
this._visibleDocuments[i] = result[0];
- //<SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
result[0].targetDoc=result[0];
- //Doc.AddDocToList(this.buckets![Math.floor(i/3)], this.props.fieldKey, result[0]);
this._isSearch[i] = "search";
}
}
@@ -683,13 +685,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
result[0].query=StrCast(this.layoutDoc._searchString);
result[0].lines=new List<string>(result[2]);
result[0].highlighting=highlights.join(", ");
-
- //this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
if(i<this._visibleDocuments.length){
this._visibleDocuments[i]=result[0];
result[0].targetDoc=result[0];
-
- //Doc.AddDocToList(this.buckets![Math.floor(i/3)], this.props.fieldKey, result[0]);
this._isSearch[i] = "search";
}
}
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 103aa8017..a8d664ad8 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -248,32 +248,32 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
setTimeout(() => this.targetDoc!.searchMatch = true, 0);
}
highlightDoc = (e: React.PointerEvent) => {
- // if (this.targetDoc!.type === DocumentType.LINK) {
- // if (this.targetDoc!.anchor1 && this.targetDoc!.anchor2) {
-
- // const doc1 = Cast(this.targetDoc!.anchor1, Doc, null);
- // const doc2 = Cast(this.targetDoc!.anchor2, Doc, null);
- // Doc.BrushDoc(doc1);
- // Doc.BrushDoc(doc2);
- // }
- // } else {
- // Doc.BrushDoc(this.targetDoc!);
- // }
+ if (this.targetDoc!.type === DocumentType.LINK) {
+ if (this.targetDoc!.anchor1 && this.targetDoc!.anchor2) {
+
+ const doc1 = Cast(this.targetDoc!.anchor1, Doc, null);
+ const doc2 = Cast(this.targetDoc!.anchor2, Doc, null);
+ Doc.BrushDoc(doc1);
+ Doc.BrushDoc(doc2);
+ }
+ } else {
+ Doc.BrushDoc(this.targetDoc!);
+ }
e.stopPropagation();
}
unHighlightDoc = (e: React.PointerEvent) => {
- // if (this.targetDoc!.type === DocumentType.LINK) {
- // if (this.targetDoc!.anchor1 && this.targetDoc!.anchor2) {
-
- // const doc1 = Cast(this.targetDoc!.anchor1, Doc, null);
- // const doc2 = Cast(this.targetDoc!.anchor2, Doc, null);
- // Doc.UnBrushDoc(doc1);
- // Doc.UnBrushDoc(doc2);
- // }
- // } else {
- // Doc.UnBrushDoc(this.targetDoc!);
- // }
+ if (this.targetDoc!.type === DocumentType.LINK) {
+ if (this.targetDoc!.anchor1 && this.targetDoc!.anchor2) {
+
+ const doc1 = Cast(this.targetDoc!.anchor1, Doc, null);
+ const doc2 = Cast(this.targetDoc!.anchor2, Doc, null);
+ Doc.UnBrushDoc(doc1);
+ Doc.UnBrushDoc(doc2);
+ }
+ } else {
+ Doc.UnBrushDoc(this.targetDoc!);
+ }
}
onContextMenu = (e: React.MouseEvent) => {
@@ -345,13 +345,13 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
newsearch(){
runInAction(()=>{
SearchBox.Instance._searchString="";
- SearchBox.Instance.submitSearch();
+ SearchBox.Instance.submitSearch(true);
})
}
render() {
- // const doc1 = Cast(this.targetDoc!.anchor1, Doc);
- // const doc2 = Cast(this.targetDoc!.anchor2, Doc);
+ const doc1 = Cast(this.targetDoc!.anchor1, Doc);
+ const doc2 = Cast(this.targetDoc!.anchor2, Doc);
if (this.targetDoc.isBucket === true){
this.props.Document._viewType=CollectionViewType.Stacking;
this.props.Document._chromeStatus='disabled';
@@ -395,8 +395,8 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
</div>
</div>
<div className="searchItem-context" title="Drag as document">
- {/* {(doc1 instanceof Doc && doc2 instanceof Doc) && this.targetDoc!.type === DocumentType.LINK ? <LinkContextMenu doc1={doc1} doc2={doc2} /> :
- this.contextButton} */}
+ {(doc1 instanceof Doc && doc2 instanceof Doc) && this.targetDoc!.type === DocumentType.LINK ? <LinkContextMenu doc1={doc1} doc2={doc2} /> :
+ this.contextButton}
</div>
</div>
</div>;