aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/documents/Documents.ts4
-rw-r--r--src/client/views/nodes/QueryBox.tsx15
-rw-r--r--src/client/views/search/SearchBox.tsx37
3 files changed, 48 insertions, 8 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 247f7fa3e..948433bd1 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -146,7 +146,8 @@ export interface DocumentOptions {
selectedIndex?: number;
syntaxColor?: string; // can be applied to text for syntax highlighting all matches in the text
searchText?: string, //for searchbox
-
+ sq?: string,
+ fq?: string,
}
class EmptyBox {
@@ -459,6 +460,7 @@ export namespace Docs {
}
export function QueryDocument(options: DocumentOptions = {}) {
+ console.log("yuh");
return InstanceFromProto(Prototypes.get(DocumentType.QUERY), "", options);
}
diff --git a/src/client/views/nodes/QueryBox.tsx b/src/client/views/nodes/QueryBox.tsx
index 995effd1b..95ea3e099 100644
--- a/src/client/views/nodes/QueryBox.tsx
+++ b/src/client/views/nodes/QueryBox.tsx
@@ -3,7 +3,6 @@ import { library } from '@fortawesome/fontawesome-svg-core';
import { faArrowLeft, faArrowRight, faEdit, faMinus, faPlay, faPlus, faStop, faTimes } from '@fortawesome/free-solid-svg-icons';
import { IReactionDisposer, computed } from "mobx";
import { observer } from "mobx-react";
-import { FilterBox } from "../search/FilterBox";
import { FieldView, FieldViewProps } from './FieldView';
import "./PresBox.scss";
import { SearchBox } from "../search/SearchBox";
@@ -15,6 +14,7 @@ import { makeInterface, createSchema } from "../../../new_fields/Schema";
import { documentSchema } from "../../../new_fields/documentSchemas";
import { TraceMobx } from "../../../new_fields/util";
import { Id } from '../../../new_fields/FieldSymbols';
+import { StrCast } from "../../../new_fields/Types";
@@ -51,7 +51,18 @@ export class QueryBox extends DocAnnotatableComponent<FieldViewProps, QueryDocum
@computed get content() {
let key = this.props.Document[Id];
- return <SearchBox id={key}/>
+ let sq = StrCast(this.props.Document.sq);
+ let fq= StrCast(this.props.Document.fq);
+ if (this.props.Document.sq){
+ console.log("yes");
+ console.log(sq);
+ console.log(fq);
+ return <SearchBox id={key} sq={sq} fq={fq}/>
+ }
+ else {
+ console.log("no");
+ return <SearchBox id={key} />
+ }
}
contentFunc = () => [this.content];
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index ed9deff15..56b769396 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -27,6 +27,8 @@ library.add(faTimes);
export interface SearchProps {
id:string;
+ sq?:string;
+ fq?:string;
}
export enum Keys {
@@ -82,6 +84,16 @@ export class SearchBox extends React.Component<SearchProps> {
this._searchbarOpen = true;
});
}
+ if (this.props.sq && this.props.fq){
+ console.log(this.props.sq);
+ let sq= this.props.sq
+
+ let fq =this.props.fq;
+ runInAction(() => {
+ this._searchString=sq;
+ this.submitSearch();
+ });
+ }
}
@@ -223,6 +235,11 @@ export class SearchBox extends React.Component<SearchProps> {
return this._icons.length === 9 ? undefined : this._icons;
}
+ @action.bound
+ updateIcon(newArray: string[]) { this._icons = newArray; }
+
+ @action.bound
+ getIcons(): string[] { return this._icons; }
//TODO: basically all of this
//gets all of the collections of all the docviews that are selected
@@ -327,6 +344,7 @@ export class SearchBox extends React.Component<SearchProps> {
const includeDeleted = this.getDataStatus();
return "NOT baseProto_b:true" + (includeDeleted ? "" : " AND NOT deleted_b:true") + (types ? ` AND (${types.map(type => `({!join from=id to=proto_i}type_t:"${type}" AND NOT type_t:*) OR type_t:"${type}" OR type_t:"extension"`).join(" ")})` : "");
}
+
getDataStatus() { return this._deletedDocsStatus; }
@@ -417,9 +435,10 @@ export class SearchBox extends React.Component<SearchProps> {
y += 300;
}
}
+ console.log("create");
//return Docs.Create.TreeDocument(docs, { _width: 200, _height: 400, backgroundColor: "grey", title: `Search Docs: "${this._searchString}"` });
//return Docs.Create.SearchDocument(docs, { _width: 200, _height: 400, searchText: this._searchString, title: `Search Docs: "${this._searchString}"` });
- return Docs.Create.QueryDocument({_autoHeight: true, title: "-typed text-"
+ return Docs.Create.QueryDocument({_autoHeight: true, title: this._searchString, fq: this.filterQuery, sq: this._searchString,
});
}
@@ -633,9 +652,17 @@ export class SearchBox extends React.Component<SearchProps> {
// remove "height" from the element's inline styles, so it can return to its initial value
element.style.height="auto";
//element.style.height = undefined;
-
}
+ @action.bound
+ updateTitleStatus() { this._titleFieldStatus = !this._titleFieldStatus; }
+
+ @action.bound
+ updateAuthorStatus() { this._authorFieldStatus = !this._authorFieldStatus; }
+
+ @action.bound
+ updateDataStatus() { this._deletedDocsStatus = !this._deletedDocsStatus; }
+
render() {
return (
@@ -661,9 +688,9 @@ export class SearchBox extends React.Component<SearchProps> {
</div>
<div className="filter-key" id={`key${this.props.id}`} style={this._keyStatus ? { borderTop: "grey 1px solid" }: {borderTop: "0px"}}>
<div className="filter-keybar">
- <button className="filter-item" >Title</button>
- <button className="filter-item" >Deleted Docs</button>
- <button className="filter-item" >Author</button>
+ <button className="filter-item" style={this._titleFieldStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateTitleStatus}>Title</button>
+ <button className="filter-item" style={this._deletedDocsStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateDataStatus}>Deleted Docs</button>
+ <button className="filter-item" style={this._authorFieldStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateAuthorStatus}>Author</button>
</div>
</div>