aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Rickert <andrew_rickert@brown.edu>2020-08-05 00:07:59 -0400
committerAndy Rickert <andrew_rickert@brown.edu>2020-08-05 00:07:59 -0400
commit8c7196ca1eda1f89bbac3e2f24219df739978776 (patch)
treea50197ff35955d3bca3e8aa527027ec703449963
parent02f3d218aa084f00211ffa9e632ea0cdc4d2a531 (diff)
lint
-rw-r--r--src/client/views/EditableView.tsx12
-rw-r--r--src/client/views/collections/CollectionSchemaCells.tsx25
-rw-r--r--src/client/views/collections/CollectionSchemaView.tsx4
-rw-r--r--src/client/views/collections/CollectionSubView.tsx2
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx8
-rw-r--r--src/client/views/search/SearchBox.tsx56
6 files changed, 31 insertions, 76 deletions
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index a98ef97ea..a5628d5ee 100644
--- a/src/client/views/EditableView.tsx
+++ b/src/client/views/EditableView.tsx
@@ -187,13 +187,13 @@ export class EditableView extends React.Component<EditableProps> {
}
returnHighlights() {
- let results = [];
- let contents = this.props.bing!();
+ const results = [];
+ const contents = this.props.bing!();
if (contents !== undefined) {
if (this.props.positions !== undefined) {
- let positions = this.props.positions;
- let length = this.props.search!.length;
+ const positions = this.props.positions;
+ const length = this.props.search!.length;
// contents = String(this.props.contents.valueOf());
@@ -201,10 +201,10 @@ export class EditableView extends React.Component<EditableProps> {
positions.forEach((num, cur) => {
results.push(<span style={{ backgroundColor: "#FFFF00", fontStyle: this.props.fontStyle, fontSize: this.props.fontSize, color: this.props.contents ? "black" : "grey" }}>{contents ? contents.slice(num, num + length) : this.props.placeholder?.valueOf()}</span>);
let end = 0;
- cur === positions.length - 1 ? end = contents.length : end = positions[cur + 1];
+ cur === positions.length - 1 ? end = contents!.length : end = positions[cur + 1];
results.push(<span style={{ fontStyle: this.props.fontStyle, fontSize: this.props.fontSize, color: this.props.contents ? "black" : "grey" }}>{contents ? contents.slice(num + length, end) : this.props.placeholder?.valueOf()}</span>);
}
- )
+ );
}
return results;
}
diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index b02b4c86a..7a80f4484 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -241,7 +241,7 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
// <FontAwesomeIcon icon="expand" size="sm" />
// </div>
// );
- let positions = [];
+ const positions = [];
if (StrCast(this.props.Document._searchString) !== "") {
const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey]));
let term = "";
@@ -256,8 +256,8 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
term = String(NumCast(cfield));
}
}
- let search = StrCast(this.props.Document._searchString);
- let start = term.indexOf(search) as number;
+ const search = StrCast(this.props.Document._searchString);
+ let start = term.indexOf(search);
let tally = 0;
if (start !== -1) {
positions.push(start);
@@ -883,36 +883,27 @@ export class CollectionSchemaButtons extends CollectionSchemaCell {
// (!this.props.CollectionView || !this.props.CollectionView.props.isSelected() ? undefined :
// SetupDrag(reference, () => this._document, this.props.moveDocument, this.props.Document.schemaDoc ? "copy" : undefined)(e));
// };
- let doc = this.props.rowProps.original;
+ const doc = this.props.rowProps.original;
let buttons = <div style={{
paddingTop: 8,
paddingLeft: 3,
}}><button onClick={() => {
- console.log(doc);
- console.log(doc.searchMatch);
doc.searchMatch = false;
- console.log(doc.searchMatch);
setTimeout(() => doc.searchMatch = true, 0);
- console.log(doc.searchMatch);
doc.searchIndex = NumCast(doc.searchIndex);
}} style={{ padding: 2, left: 77 }}>
<FontAwesomeIcon icon="arrow-up" size="sm" />
</button>
<button onClick={() => {
{
- console.log(doc);
- console.log(doc.searchMatch2);
doc.searchMatch2 = false;
- console.log(doc.searchMatch2);
setTimeout(() => doc.searchMatch2 = true, 0);
- console.log(doc.searchMatch2);
doc.searchIndex = NumCast(doc.searchIndex);
}
}} style={{ padding: 2 }}>
<FontAwesomeIcon icon="arrow-down" size="sm" />
</button></div>;
const type = StrCast(doc.type);
- console.log(StrCast(doc.type));
if (type === "pdf") {
buttons = <div><button
style={{
@@ -923,19 +914,14 @@ export class CollectionSchemaButtons extends CollectionSchemaCell {
}}
onClick={() => {
- console.log(doc);
- console.log(doc.searchMatch);
doc.searchMatch = false;
- console.log(doc.searchMatch);
setTimeout(() => doc.searchMatch = true, 0);
- console.log(doc.searchMatch);
doc.searchIndex = NumCast(doc.searchIndex);
}}>
<FontAwesomeIcon icon="arrow-down" size="sm" />
- </button></div >
+ </button></div >;
}
else if (type !== "rtf") {
- console.log("sad");
buttons = undefined;
}
@@ -945,7 +931,6 @@ export class CollectionSchemaButtons extends CollectionSchemaCell {
else {
buttons = undefined;
}
-
return (
<div> {buttons}</div>
);
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index d47d41a1e..a003de0d3 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -329,14 +329,14 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
if (filter) {
Doc.setDocFilter(this.props.Document, newKey, filter, "match");
if (this.props.Document.selectedDoc !== undefined) {
- let doc = Cast(this.props.Document.selectedDoc, Doc) as Doc;
+ const doc = Cast(this.props.Document.selectedDoc, Doc) as Doc;
Doc.setDocFilter(doc, newKey, filter, "match");
}
}
else {
this.props.Document._docFilters = undefined;
if (this.props.Document.selectedDoc !== undefined) {
- let doc = Cast(this.props.Document.selectedDoc, Doc) as Doc;
+ const doc = Cast(this.props.Document.selectedDoc, Doc) as Doc;
doc._docFilters = undefined;
}
}
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 888f0b9e9..b896518ed 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -159,7 +159,7 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
newarray = [];
newdocs.forEach((t) => {
if (d.data !== undefined) {
- let newdocs = DocListCast(t.data);
+ const newdocs = DocListCast(t.data);
newdocs.forEach((newdoc) => {
newarray.push(newdoc);
});
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index b21596493..ab29f6889 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -298,7 +298,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
const mark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight);
const activeMark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight, { selected: true });
const res = terms.filter(t => t).map(term => this.findInNode(this._editorView!, this._editorView!.state.doc, term));
- let length = res[0].length;
+ const length = res[0].length;
let tr = this._editorView.state.tr;
const flattened: TextSelection[] = [];
res.map(r => r.map(h => flattened.push(h)));
@@ -318,7 +318,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
else if (this._searchIndex === 0 && length !== 1) {
this._searchIndex = length - 2;
}
- let index = this._searchIndex;
+ const index = this._searchIndex;
Doc.GetProto(this.dataDoc).searchIndex = index;
Doc.GetProto(this.dataDoc).length = length;
@@ -331,7 +331,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
const mark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight);
const activeMark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight, { selected: true });
const res = terms.filter(t => t).map(term => this.findInNode(this._editorView!, this._editorView!.state.doc, term));
- let length = res[0].length;
+ const length = res[0].length;
let tr = this._editorView.state.tr;
const flattened: TextSelection[] = [];
res.map(r => r.map(h => flattened.push(h)));
@@ -339,7 +339,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
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;
+ const index = this._searchIndex;
Doc.GetProto(this.dataDoc).searchIndex = index;
Doc.GetProto(this.dataDoc).length = length;
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 001792f41..097e6c4d9 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -94,7 +94,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
}
if (this.inputRef.current) {
this.inputRef.current.focus();
- runInAction(() => { this._searchbarOpen = true });
+ runInAction(() => { this._searchbarOpen = true; });
}
if (this.rootDoc.searchQuery && this.newAssign) {
const sq = this.rootDoc.searchQuery;
@@ -112,11 +112,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
this.submitSearch();
});
}
- };
+ }
@action
- getViews = (doc: Doc) => SearchUtil.GetViewsOfDocument(doc);
+ getViews = (doc: Doc) => SearchUtil.GetViewsOfDocument(doc)
@observable newsearchstring: string = "";
@@ -127,7 +127,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
if (e.target.value === "") {
- console.log(this._results);
this._results.forEach(result => {
Doc.UnBrushDoc(result[0]);
result[0].searchMatch = undefined;
@@ -140,8 +139,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
this.props.Document.selectedDoc = undefined;
}
- console.log("CLOSE");
- runInAction(() => { this.open = false });
+ runInAction(() => { this.open = false; });
this._openNoResults = false;
this._results = [];
this._resultsSet.clear();
@@ -226,7 +224,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
if (this._collectionStatus) {
query = this.addCollectionFilter(query);
query = query.replace(/\s+/g, ' ').trim();
- console.log(query)
}
return query;
@@ -253,8 +250,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
addCollectionFilter(query: string): string {
const collections: Doc[] = this.getCurCollections();
-
- console.log(collections);
const oldWords = query.split(" ");
const collectionString: string[] = [];
@@ -312,18 +307,16 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
}
let docs = DocListCast(selectedCollection.dataDoc[Doc.LayoutFieldKey(selectedCollection.dataDoc)]);
const found: [Doc, string[], string[]][] = [];
- const docsforFilter: Doc[] = []
+ const docsforFilter: Doc[] = [];
let newarray: Doc[] = [];
while (docs.length > 0) {
newarray = [];
docs.forEach((d) => {
- if (d.data != undefined) {
+ if (d.data !== undefined) {
newarray.push(...DocListCast(d.data));
}
-
- let hlights: string[] = [];
-
+ const hlights: string[] = [];
const protos = Doc.GetAllPrototypes(d);
protos.forEach(proto => {
Object.keys(proto).forEach(key => {
@@ -345,15 +338,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
selectedCollection.props.Document._searchDocs = new List<Doc>(docsforFilter);
docs = DocListCast(selectedCollection.dataDoc[Doc.LayoutFieldKey(selectedCollection.dataDoc)]);
while (docs.length > 0) {
- console.log("HIT");
newarray = [];
docs.forEach((d) => {
if (d.data !== undefined) {
- console.log(d._searchDocs);
d._searchDocs = new List<Doc>(docsforFilter);
- console.log(d);
- console.log(d._searchDocs);
- let newdocs = DocListCast(d.data);
+ const newdocs = DocListCast(d.data);
newdocs.forEach((newdoc) => {
newarray.push(newdoc);
});
@@ -449,7 +438,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
this._visibleElements = [];
this._visibleDocuments = [];
if (StrCast(this.props.Document.searchQuery)) {
- if (this._timeout) { clearTimeout(this._timeout); this._timeout = undefined };
+ if (this._timeout) { clearTimeout(this._timeout); this._timeout = undefined; }
this._timeout = setTimeout(() => {
console.log("Resubmitting search");
}, 60000);
@@ -526,7 +515,6 @@ 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)) : [];
- console.log(hlights);
doc ? console.log(Cast(doc.context, Doc)) : null;
if (this.findCommonElements(hlights)) {
}
@@ -683,7 +671,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
if (result) {
const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
const lines = new List<string>(result[2]);
- console.log(lines);
result[0].lines = lines;
result[0].highlighting = highlights.join(", ");
highlights.forEach((item) => headers.add(item));
@@ -701,7 +688,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
const lines = new List<string>(result[2]);
highlights.forEach((item) => headers.add(item));
- console.log(lines);
result[0].lines = lines;
result[0].highlighting = highlights.join(", ");
result[0].searchMatch = true;
@@ -796,15 +782,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
let docs: Doc[] = [];
docs = DocListCast(this.currentSelectedCollection.dataDoc[Doc.LayoutFieldKey(this.currentSelectedCollection.dataDoc)]);
while (docs.length > 0) {
- console.log("HIT");
newarray = [];
docs.forEach((d) => {
if (d.data !== undefined) {
- console.log(d._searchDocs);
d._searchDocs = new List<Doc>(this.docsforfilter);
- console.log(d);
- console.log(d._searchDocs);
- let newdocs = DocListCast(d.data);
+ const newdocs = DocListCast(d.data);
newdocs.forEach((newdoc) => {
newarray.push(newdoc);
});
@@ -821,15 +803,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
let docs: Doc[] = [];
docs = DocListCast(this.currentSelectedCollection.dataDoc[Doc.LayoutFieldKey(this.currentSelectedCollection.dataDoc)]);
while (docs.length > 0) {
- console.log("HIT");
newarray = [];
docs.forEach((d) => {
if (d.data !== undefined) {
- console.log(d._searchDocs);
d._searchDocs = new List<Doc>();
- console.log(d);
- console.log(d._searchDocs);
- let newdocs = DocListCast(d.data);
+ const newdocs = DocListCast(d.data);
newdocs.forEach((newdoc) => {
newarray.push(newdoc);
});
@@ -868,15 +846,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
let docs: Doc[] = [];
docs = DocListCast(this.currentSelectedCollection.dataDoc[Doc.LayoutFieldKey(this.currentSelectedCollection.dataDoc)]);
while (docs.length > 0) {
- console.log("HIT");
newarray = [];
docs.forEach((d) => {
if (d.data !== undefined) {
- console.log(d._searchDocs);
d._searchDocs = new List<Doc>();
- console.log(d);
- console.log(d._searchDocs);
- let newdocs = DocListCast(d.data);
+ const newdocs = DocListCast(d.data);
newdocs.forEach((newdoc) => {
newarray.push(newdoc);
});
@@ -906,15 +880,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
let docs: Doc[] = [];
docs = DocListCast(this.currentSelectedCollection.dataDoc[Doc.LayoutFieldKey(this.currentSelectedCollection.dataDoc)]);
while (docs.length > 0) {
- console.log("HIT");
newarray = [];
docs.forEach((d) => {
if (d.data !== undefined) {
- console.log(d._searchDocs);
d._searchDocs = new List<Doc>();
- console.log(d);
- console.log(d._searchDocs);
- let newdocs = DocListCast(d.data);
+ const newdocs = DocListCast(d.data);
newdocs.forEach((newdoc) => {
newarray.push(newdoc);
});