aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/search
diff options
context:
space:
mode:
authorAndy Rickert <andrew_rickert@brown.edu>2020-07-31 18:25:39 -0400
committerAndy Rickert <andrew_rickert@brown.edu>2020-07-31 18:25:39 -0400
commita1950ec49c56f5f9e2612da7e60a1e2615209386 (patch)
tree56f4f5302c8c047e54cc8601f9e132c4ce084e12 /src/client/views/search
parent211beefca70ca5c869d6bf8a464fe41e94a7b4c3 (diff)
bugfix
Diffstat (limited to 'src/client/views/search')
-rw-r--r--src/client/views/search/SearchBox.tsx69
1 files changed, 50 insertions, 19 deletions
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index b17751d44..005f7d1af 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -40,6 +40,7 @@ import * as _ from "lodash";
import { checkIfStateModificationsAreAllowed } from 'mobx/lib/internal';
import { SchemaHeaderField } from '../../../fields/SchemaHeaderField';
import { indexOf } from 'lodash';
+import { protocol } from 'socket.io-client';
library.add(faTimes);
@@ -379,22 +380,42 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
let docs = DocListCast(selectedCollection.dataDoc[Doc.LayoutFieldKey(selectedCollection.dataDoc)]);
let found: [Doc, string[], string[]][] = [];
let docsforFilter: Doc[] = []
- docs.forEach((d) => {
- let hlights: string[] = [];
- const protos = Doc.GetAllPrototypes(d);
- let proto = protos[protos.length - 2];
- Object.keys(proto).forEach(key => {
- if (StrCast(d[key]).includes(query)) {
- console.log(key, d[key]);
- hlights.push(key);
+ let newarray: Doc[] = [];
+
+ while (docs.length > 0) {
+ console.log("iteration");
+ newarray = [];
+ docs.forEach((d) => {
+ console.log(d);
+ if (d.data != undefined) {
+ let newdocs = DocListCast(d.data);
+ newdocs.forEach((newdoc) => {
+ console.log(newdoc);
+ newarray.push(newdoc);
+
+ });
}
+
+
+ let hlights: string[] = [];
+
+ const protos = Doc.GetAllPrototypes(d);
+ let proto = protos[protos.length - 1];
+ protos.forEach(proto => {
+ Object.keys(proto).forEach(key => {
+ // console.log(key, d[key]);
+ if (StrCast(d[key]).includes(query) && !hlights.includes(key)) {
+ hlights.push(key);
+ }
+ })
+ });
+ if (hlights.length > 0) {
+ found.push([d, hlights, []]);
+ docsforFilter.push(d);
+ };
});
- if (hlights.length > 0) {
- found.push([d, hlights, []]);
- docsforFilter.push(d);
- };
- });
- console.log(found);
+ docs = newarray;
+ }
this._results = found;
this.docsforfilter = docsforFilter;
if (this.filter === true) {
@@ -408,6 +429,20 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
}
+
+ documentKeys(doc: Doc) {
+ const keys: { [key: string]: boolean } = {};
+ // bcz: ugh. this is untracked since otherwise a large collection of documents will blast the server for all their fields.
+ // then as each document's fields come back, we update the documents _proxies. Each time we do this, the whole schema will be
+ // invalidated and re-rendered. This workaround will inquire all of the document fields before the options button is clicked.
+ // then by the time the options button is clicked, all of the fields should be in place. If a new field is added while this menu
+ // is displayed (unlikely) it won't show up until something else changes.
+ //TODO Types
+ Doc.GetAllPrototypes(doc).map
+ (proto => Object.keys(proto).forEach(key => keys[key] = false));
+ return Array.from(Object.keys(keys));
+ }
+
applyBasicFieldFilters(query: string) {
let finalQuery = "";
@@ -669,7 +704,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
const endIndex = 30;
this._endIndex = endIndex === -1 ? 12 : endIndex;
this._endIndex = 30;
- let headers = new Set<string>(["title", "author", "creationDate"]);
+ let headers = new Set<string>(["title", "author", "lastModified"]);
if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
if (this.noresults === "") {
this.noresults = "No search results :(";
@@ -734,12 +769,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
if (i < this._visibleDocuments.length) {
this._visibleDocuments[i] = result[0];
this._isSearch[i] = "search";
- console.log("WHYYYY");
- console.log(result[0]);
-
Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
this.children++;
-
}
}
}