aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/search
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/search')
-rw-r--r--src/client/views/search/FilterBox.tsx44
-rw-r--r--src/client/views/search/IconButton.tsx2
-rw-r--r--src/client/views/search/NaviconButton.tsx22
-rw-r--r--src/client/views/search/SearchBox.tsx20
-rw-r--r--src/client/views/search/SearchItem.tsx26
-rw-r--r--src/client/views/search/ToggleBar.tsx3
6 files changed, 59 insertions, 58 deletions
diff --git a/src/client/views/search/FilterBox.tsx b/src/client/views/search/FilterBox.tsx
index 7812c9d97..12e1bc265 100644
--- a/src/client/views/search/FilterBox.tsx
+++ b/src/client/views/search/FilterBox.tsx
@@ -79,7 +79,7 @@ export class FilterBox extends React.Component {
acc[i].addEventListener("click", function (this: HTMLElement) {
this.classList.toggle("active");
- var panel = this.nextElementSibling as HTMLElement;
+ const panel = this.nextElementSibling as HTMLElement;
if (panel.style.maxHeight) {
panel.style.overflow = "hidden";
panel.style.maxHeight = "";
@@ -96,7 +96,7 @@ export class FilterBox extends React.Component {
}
});
- let el = acc[i] as HTMLElement;
+ const el = acc[i] as HTMLElement;
el.click();
}
});
@@ -105,14 +105,14 @@ export class FilterBox extends React.Component {
@action.bound
minimizeAll() {
$('document').ready(function () {
- var acc = document.getElementsByClassName('filter-header');
+ const acc = document.getElementsByClassName('filter-header');
// tslint:disable-next-line: prefer-for-of
for (var i = 0; i < acc.length; i++) {
- let classList = acc[i].classList;
+ const classList = acc[i].classList;
if (classList.contains("active")) {
acc[i].classList.toggle("active");
- var panel = acc[i].nextElementSibling as HTMLElement;
+ const panel = acc[i].nextElementSibling as HTMLElement;
panel.style.overflow = "hidden";
panel.style.maxHeight = "";
}
@@ -128,10 +128,10 @@ export class FilterBox extends React.Component {
}
basicRequireWords(query: string): string {
- let oldWords = query.split(" ");
- let newWords: string[] = [];
+ const oldWords = query.split(" ");
+ const newWords: string[] = [];
oldWords.forEach(word => {
- let newWrd = "+" + word;
+ const newWrd = "+" + word;
newWords.push(newWrd);
});
query = newWords.join(" ");
@@ -140,7 +140,7 @@ export class FilterBox extends React.Component {
}
basicFieldFilters(query: string, type: string): string {
- let oldWords = query.split(" ");
+ const oldWords = query.split(" ");
let mod = "";
if (type === Keys.AUTHOR) {
@@ -151,9 +151,9 @@ export class FilterBox extends React.Component {
mod = " title_t:";
}
- let newWords: string[] = [];
+ const newWords: string[] = [];
oldWords.forEach(word => {
- let newWrd = mod + word;
+ const newWrd = mod + word;
newWords.push(newWrd);
});
@@ -183,11 +183,11 @@ export class FilterBox extends React.Component {
//gets all of the collections of all the docviews that are selected
//if a collection is the only thing selected, search only in that collection (not its container)
getCurCollections(): Doc[] {
- let selectedDocs: DocumentView[] = SelectionManager.SelectedDocuments();
- let collections: Doc[] = [];
+ const selectedDocs: DocumentView[] = SelectionManager.SelectedDocuments();
+ const collections: Doc[] = [];
selectedDocs.forEach(async element => {
- let layout: string = StrCast(element.props.Document.layout);
+ const layout: string = StrCast(element.props.Document.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
@@ -229,14 +229,14 @@ export class FilterBox extends React.Component {
}
addCollectionFilter(query: string): string {
- let collections: Doc[] = this.getCurCollections();
- let oldWords = query.split(" ");
+ const collections: Doc[] = this.getCurCollections();
+ const oldWords = query.split(" ");
- let collectionString: string[] = [];
+ const collectionString: string[] = [];
collections.forEach(doc => {
- let proto = doc.proto;
- let protoId = (proto || doc)[Id];
- let colString: string = "{!join from=data_l to=id}id:" + protoId + " ";
+ const proto = doc.proto;
+ const protoId = (proto || doc)[Id];
+ const colString: string = "{!join from=data_l to=id}id:" + protoId + " ";
collectionString.push(colString);
});
@@ -254,9 +254,9 @@ export class FilterBox extends React.Component {
if (this._icons.length === 9) {
return docs;
}
- let finalDocs: Doc[] = [];
+ const finalDocs: Doc[] = [];
docs.forEach(doc => {
- let layoutresult = Cast(doc.type, "string");
+ const layoutresult = Cast(doc.type, "string");
if (layoutresult && this._icons.includes(layoutresult)) {
finalDocs.push(doc);
}
diff --git a/src/client/views/search/IconButton.tsx b/src/client/views/search/IconButton.tsx
index d2cfe7fad..f01508141 100644
--- a/src/client/views/search/IconButton.tsx
+++ b/src/client/views/search/IconButton.tsx
@@ -108,7 +108,7 @@ export class IconButton extends React.Component<IconButtonProps>{
@action.bound
onClick = () => {
- let newList: string[] = FilterBox.Instance.getIcons();
+ const newList: string[] = FilterBox.Instance.getIcons();
if (!this._isSelected) {
this._isSelected = true;
diff --git a/src/client/views/search/NaviconButton.tsx b/src/client/views/search/NaviconButton.tsx
index 3fa36b163..0fa4a0fca 100644
--- a/src/client/views/search/NaviconButton.tsx
+++ b/src/client/views/search/NaviconButton.tsx
@@ -4,7 +4,7 @@ import "./NaviconButton.scss";
import * as $ from 'jquery';
import { observable } from 'mobx';
-export interface NaviconProps{
+export interface NaviconProps {
onClick(): void;
}
@@ -13,19 +13,21 @@ export class NaviconButton extends React.Component<NaviconProps> {
@observable private _ref: React.RefObject<HTMLAnchorElement> = React.createRef();
componentDidMount = () => {
- let that = this;
- if(this._ref.current){this._ref.current.addEventListener("click", function(e) {
- e.preventDefault();
- if(that._ref.current){
- that._ref.current.classList.toggle('active');
- return false;
- }
- });}
+ const that = this;
+ if (this._ref.current) {
+ this._ref.current.addEventListener("click", function (e) {
+ e.preventDefault();
+ if (that._ref.current) {
+ that._ref.current.classList.toggle('active');
+ return false;
+ }
+ });
+ }
}
render() {
return (
- <a id="hamburger-icon" href="#" ref = {this._ref} title="Menu">
+ <a id="hamburger-icon" href="#" ref={this._ref} title="Menu">
<span className="line line-1"></span>
<span className="line line-2"></span>
<span className="line line-3"></span>
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index ff35542ed..c45fbe210 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -89,7 +89,7 @@ export class SearchBox extends React.Component {
public static async convertDataUri(imageUri: string, returnedFilename: string) {
try {
- let posting = Utils.prepend("/uploadURI");
+ const posting = Utils.prepend("/uploadURI");
const returnedUri = await rp.post(posting, {
body: {
uri: imageUri,
@@ -166,7 +166,7 @@ export class SearchBox extends React.Component {
const docs = await Promise.all(res.docs.map(async doc => (await Cast(doc.extendsDoc, Doc)) || doc));
const highlights: typeof res.highlighting = {};
docs.forEach((doc, index) => highlights[doc[Id]] = highlightList[index]);
- let filteredDocs = FilterBox.Instance.filterDocsByType(docs);
+ const filteredDocs = FilterBox.Instance.filterDocsByType(docs);
runInAction(() => {
// this._results.push(...filteredDocs);
filteredDocs.forEach(doc => {
@@ -198,8 +198,8 @@ export class SearchBox extends React.Component {
collectionRef = React.createRef<HTMLSpanElement>();
startDragCollection = async () => {
- let res = await this.getAllResults(FilterBox.Instance.getFinalQuery(this._searchString));
- let filtered = FilterBox.Instance.filterDocsByType(res.docs);
+ const res = await this.getAllResults(FilterBox.Instance.getFinalQuery(this._searchString));
+ const filtered = FilterBox.Instance.filterDocsByType(res.docs);
// console.log(this._results)
const docs = filtered.map(doc => {
const isProto = Doc.GetT(doc, "isPrototype", "boolean", true);
@@ -266,10 +266,10 @@ export class SearchBox extends React.Component {
@action
resultsScrolled = (e?: React.UIEvent<HTMLDivElement>) => {
- let scrollY = e ? e.currentTarget.scrollTop : this.resultsRef.current ? this.resultsRef.current.scrollTop : 0;
- let itemHght = 53;
- let startIndex = Math.floor(Math.max(0, scrollY / itemHght));
- let endIndex = Math.ceil(Math.min(this._numTotalResults - 1, startIndex + (this.resultsRef.current!.getBoundingClientRect().height / itemHght)));
+ const scrollY = e ? e.currentTarget.scrollTop : this.resultsRef.current ? this.resultsRef.current.scrollTop : 0;
+ const itemHght = 53;
+ const startIndex = Math.floor(Math.max(0, scrollY / itemHght));
+ const endIndex = Math.ceil(Math.min(this._numTotalResults - 1, startIndex + (this.resultsRef.current!.getBoundingClientRect().height / itemHght)));
this._endIndex = endIndex === -1 ? 12 : endIndex;
@@ -307,7 +307,7 @@ export class SearchBox extends React.Component {
this.getResults(this._searchString);
if (i < this._results.length) result = this._results[i];
if (result) {
- let highlights = Array.from([...Array.from(new Set(result[1]).values())]).filter(v => v !== "search_string");
+ const highlights = Array.from([...Array.from(new Set(result[1]).values())]).filter(v => v !== "search_string");
this._visibleElements[i] = <SearchItem doc={result[0]} query={this._searchString} key={result[0][Id]} lines={result[2]} highlighting={highlights} />;
this._isSearch[i] = "search";
}
@@ -315,7 +315,7 @@ export class SearchBox extends React.Component {
else {
result = this._results[i];
if (result) {
- let highlights = Array.from([...Array.from(new Set(result[1]).values())]).filter(v => v !== "search_string");
+ const highlights = Array.from([...Array.from(new Set(result[1]).values())]).filter(v => v !== "search_string");
this._visibleElements[i] = <SearchItem doc={result[0]} query={this._searchString} key={result[0][Id]} lines={result[2]} highlighting={highlights} />;
this._isSearch[i] = "search";
}
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index f1d825aa0..6ffff0562 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -52,7 +52,7 @@ export class SelectorContextMenu extends React.Component<SearchItemProps> {
}
async fetchDocuments() {
- let aliases = (await SearchUtil.GetViewsOfDocument(this.props.doc)).filter(doc => doc !== this.props.doc);
+ const aliases = (await SearchUtil.GetViewsOfDocument(this.props.doc)).filter(doc => doc !== this.props.doc);
const { docs } = await SearchUtil.Search("", true, { fq: `data_l:"${this.props.doc[Id]}"` });
const map: Map<Doc, Doc> = new Map;
const allDocs = await Promise.all(aliases.map(doc => SearchUtil.Search("", true, { fq: `data_l:"${doc[Id]}"` }).then(result => result.docs)));
@@ -82,7 +82,7 @@ export class SelectorContextMenu extends React.Component<SearchItemProps> {
<div className="parents">
<p className="contexts">Contexts:</p>
{[...this._docs, ...this._otherDocs].map(doc => {
- let item = React.createRef<HTMLDivElement>();
+ const item = React.createRef<HTMLDivElement>();
return <div className="collection" key={doc.col[Id] + doc.target[Id]} ref={item}>
<div className="collection-item" onPointerDown={
SetupDrag(item, () => doc.col, undefined, undefined, undefined, undefined, () => SearchBox.Instance.closeSearch())}>
@@ -146,11 +146,11 @@ export class SearchItem extends React.Component<SearchItemProps> {
//@computed
@action
public DocumentIcon() {
- let layoutresult = StrCast(this.props.doc.type);
+ const layoutresult = StrCast(this.props.doc.type);
if (!this._useIcons) {
- let returnXDimension = () => this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE);
- let returnYDimension = () => this._displayDim;
- let scale = () => returnXDimension() / NumCast(Doc.Layout(this.props.doc).nativeWidth, returnXDimension());
+ const returnXDimension = () => this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE);
+ const returnYDimension = () => this._displayDim;
+ const scale = () => returnXDimension() / NumCast(Doc.Layout(this.props.doc).nativeWidth, returnXDimension());
const docview = <div
onPointerDown={action(() => {
this._useIcons = !this._useIcons;
@@ -184,7 +184,7 @@ export class SearchItem extends React.Component<SearchItemProps> {
</div>;
return docview;
}
- let button = layoutresult.indexOf(DocumentType.PDF) !== -1 ? faFilePdf :
+ const button = layoutresult.indexOf(DocumentType.PDF) !== -1 ? faFilePdf :
layoutresult.indexOf(DocumentType.IMG) !== -1 ? faImage :
layoutresult.indexOf(DocumentType.TEXT) !== -1 ? faStickyNote :
layoutresult.indexOf(DocumentType.VID) !== -1 ? faFilm :
@@ -201,7 +201,7 @@ export class SearchItem extends React.Component<SearchItemProps> {
collectionRef = React.createRef<HTMLDivElement>();
startDocDrag = () => {
- let doc = this.props.doc;
+ const doc = this.props.doc;
const isProto = Doc.GetT(doc, "isPrototype", "boolean", true);
if (isProto) {
return Doc.MakeDelegate(doc);
@@ -218,7 +218,7 @@ export class SearchItem extends React.Component<SearchItemProps> {
nextHighlight = (e: React.PointerEvent) => {
e.preventDefault(); e.button === 0 && SearchBox.Instance.openSearch(e);
- let sstring = StrCast(this.props.doc.search_string);
+ const sstring = StrCast(this.props.doc.search_string);
this.props.doc.search_string = "";
setTimeout(() => this.props.doc.search_string = sstring, 0);
}
@@ -226,8 +226,8 @@ export class SearchItem extends React.Component<SearchItemProps> {
if (this.props.doc.type === DocumentType.LINK) {
if (this.props.doc.anchor1 && this.props.doc.anchor2) {
- let doc1 = Cast(this.props.doc.anchor1, Doc, null);
- let doc2 = Cast(this.props.doc.anchor2, Doc, null);
+ const doc1 = Cast(this.props.doc.anchor1, Doc, null);
+ const doc2 = Cast(this.props.doc.anchor2, Doc, null);
Doc.BrushDoc(doc1);
Doc.BrushDoc(doc2);
}
@@ -241,8 +241,8 @@ export class SearchItem extends React.Component<SearchItemProps> {
if (this.props.doc.type === DocumentType.LINK) {
if (this.props.doc.anchor1 && this.props.doc.anchor2) {
- let doc1 = Cast(this.props.doc.anchor1, Doc, null);
- let doc2 = Cast(this.props.doc.anchor2, Doc, null);
+ const doc1 = Cast(this.props.doc.anchor1, Doc, null);
+ const doc2 = Cast(this.props.doc.anchor2, Doc, null);
Doc.UnBrushDoc(doc1);
Doc.UnBrushDoc(doc2);
}
diff --git a/src/client/views/search/ToggleBar.tsx b/src/client/views/search/ToggleBar.tsx
index ed5ecd3ba..e4d7f2fd5 100644
--- a/src/client/views/search/ToggleBar.tsx
+++ b/src/client/views/search/ToggleBar.tsx
@@ -33,8 +33,7 @@ export class ToggleBar extends React.Component<ToggleBarProps>{
}
componentDidMount = () => {
-
- let totalWidth = 265;
+ const totalWidth = 265;
if (this._originalStatus) {
this._forwardTimeline.add({