aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndy Rickert <andrew_rickert@brown.edu>2020-06-25 17:23:43 -0400
committerAndy Rickert <andrew_rickert@brown.edu>2020-06-25 17:23:43 -0400
commit7a291cbffb9e609633759cfff8b459e1a32b4fc3 (patch)
treee43ec88857c1201b7e2b9c56353253ab9b1e09d4 /src
parenta8d9fb68b14a5c89a3186e49ff28bbfa2cd9978e (diff)
bugfixing search, refreshing docs, ghost buckets, etc.
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts1
-rw-r--r--src/client/util/CurrentUserUtils.ts6
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx15
-rw-r--r--src/client/views/search/SearchBox.tsx35
4 files changed, 35 insertions, 22 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index c32d187a0..ebdae1ce5 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -181,7 +181,6 @@ export interface DocumentOptions {
flexDirection?: "unset" | "row" | "column" | "row-reverse" | "column-reverse";
selectedIndex?: number;
syntaxColor?: string; // can be applied to text for syntax highlighting all matches in the text
- searchText?: string, //for searchbox
searchQuery?: string, // for quersyBox
filterQuery?: filterData,
linearViewIsExpanded?: boolean; // is linear view expanded
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index a7cb29815..0e0942496 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -42,10 +42,10 @@ export class CurrentUserUtils {
if (doc["template-button-query"] === undefined) {
const queryTemplate = Docs.Create.MulticolumnDocument(
[
- Docs.Create.SearchDocument({ _viewType: CollectionViewType.Stacking, title: "query", _height: 200 }),
+ Docs.Create.SearchDocument({ _viewType: CollectionViewType.Stacking, 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 }
+ { _width: 400, _height: 300, title: "queryView", _chromeStatus: "disabled", _xMargin: 3, _yMargin: 3, hideFilterView: true }
);
queryTemplate.isTemplateDoc = makeTemplate(queryTemplate);
doc["template-button-query"] = CurrentUserUtils.ficon({
@@ -628,7 +628,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({_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.Stacking, title: "sidebar search stack", })) as any as Doc,
searchFileTypes: new List<string>([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/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index 6b522f6d1..ca7db2cd4 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -261,20 +261,23 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
let tr = this._editorView.state.tr;
const flattened: TextSelection[] = [];
res.map(r => r.map(h => flattened.push(h)));
+
+
+ const lastSel = Math.min(flattened.length - 1, this._searchIndex);
+ flattened.forEach((h: TextSelection, ind: number) => tr = tr.addMark(h.from, h.to, ind === lastSel ? activeMark : mark));
+ this._searchIndex = ++this._searchIndex > flattened.length - 1 ? 0 : this._searchIndex;
+ this._editorView.dispatch(tr.setSelection(new TextSelection(tr.doc.resolve(flattened[lastSel].from), tr.doc.resolve(flattened[lastSel].to))).scrollIntoView());
+
+ console.log(this._searchIndex, length);
if (this._searchIndex>1){
this._searchIndex+=-2;
}
else if (this._searchIndex===1){
this._searchIndex=length-1;
}
- else if (this._searchIndex===0){
+ else if (this._searchIndex===0 && length!==1){
this._searchIndex=length-2;
}
-
- const lastSel = Math.min(flattened.length - 1, this._searchIndex);
- flattened.forEach((h: TextSelection, ind: number) => tr = tr.addMark(h.from, h.to, ind === lastSel ? activeMark : mark));
- this._searchIndex = ++this._searchIndex > flattened.length - 1 ? 0 : this._searchIndex;
- this._editorView.dispatch(tr.setSelection(new TextSelection(tr.doc.resolve(flattened[lastSel].from), tr.doc.resolve(flattened[lastSel].to))).scrollIntoView());
let index = this._searchIndex;
Doc.GetProto(this.dataDoc).searchIndex = index;
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 37d358b02..d1e1818c2 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -315,6 +315,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
console.log(selectedDocs);
selectedDocs.forEach(async element => {
const layout: string = StrCast(element.props.Document.layout);
+ console.log(layout);
//checks if selected view (element) is a collection. if it is, adds to list to search through
if (layout.indexOf("Collection") > -1) {
//makes sure collections aren't added more than once
@@ -391,13 +392,13 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
this._isSorted=[];
this._visibleElements = [];
this._visibleDocuments = [];
- console.log(this._timeout);
-
- if (this._timeout){clearTimeout(this._timeout); this._timeout=undefined};
- this._timeout= setTimeout(()=>{
- console.log("Resubmitting search");
- this.submitSearch();
- }, 10000);
+ if (StrCast(this.props.Document.searchQuery)){
+ if (this._timeout){clearTimeout(this._timeout); this._timeout=undefined};
+ this._timeout= setTimeout(()=>{
+ console.log("Resubmitting search");
+ this.submitSearch();
+ }, 60000);
+ }
if (query !== "") {
this._endIndex = 12;
@@ -442,7 +443,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
}
}
- let bucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: `default bucket`});
+ 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";
@@ -452,7 +453,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
this.bucketcount[0]=0;
if (this.firststring!==""){
- let firstbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: 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;
@@ -465,7 +466,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
}
if (this.secondstring!==""){
- let secondbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: 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;
@@ -475,21 +476,30 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
this.bucketcount[2]=0;
}
- let webbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: this.secondstring });
+ 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) => {
@@ -539,6 +549,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
const highlight = highlights[doc[Id]];
const line = lines.get(doc[Id]) || [];
const hlights = highlight ? Object.keys(highlight).map(key => key.substring(0, key.length - 2)) : [];
+ doc? console.log(Cast(doc.context, Doc)) : null;
if (this.findCommonElements(hlights)){
}
else{
@@ -619,7 +630,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
basicWordStatus: this._basicWordStatus,
icons: this._icons,
}
- return Docs.Create.SearchDocument({ _autoHeight: true, _viewType: CollectionViewType.Stacking , title: StrCast(this.layoutDoc._searchString), filterQuery: filter, searchQuery: StrCast(this.layoutDoc._searchString) });
+ return Docs.Create.SearchDocument({ _autoHeight: true, _viewType: CollectionViewType.Stacking , title: StrCast(this.layoutDoc._searchString), searchQuery: StrCast(this.layoutDoc._searchString) });
}
@action.bound