From 8c7196ca1eda1f89bbac3e2f24219df739978776 Mon Sep 17 00:00:00 2001 From: Andy Rickert Date: Wed, 5 Aug 2020 00:07:59 -0400 Subject: lint --- src/client/views/EditableView.tsx | 12 ++--- .../views/collections/CollectionSchemaCells.tsx | 25 ++-------- .../views/collections/CollectionSchemaView.tsx | 4 +- src/client/views/collections/CollectionSubView.tsx | 2 +- .../views/nodes/formattedText/FormattedTextBox.tsx | 8 ++-- src/client/views/search/SearchBox.tsx | 56 +++++----------------- 6 files changed, 31 insertions(+), 76 deletions(-) (limited to 'src') 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 { } 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 { positions.forEach((num, cur) => { results.push({contents ? contents.slice(num, num + length) : this.props.placeholder?.valueOf()}); 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({contents ? contents.slice(num + length, end) : this.props.placeholder?.valueOf()}); } - ) + ); } 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 { // // // ); - 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 { 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 =
; const type = StrCast(doc.type); - console.log(StrCast(doc.type)); if (type === "pdf") { buttons =
+ ; } else if (type !== "rtf") { - console.log("sad"); buttons = undefined; } @@ -945,7 +931,6 @@ export class CollectionSchemaButtons extends CollectionSchemaCell { else { buttons = undefined; } - return (
{buttons}
); 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(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 { 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 SearchUtil.GetViewsOfDocument(doc); + getViews = (doc: Doc) => SearchUtil.GetViewsOfDocument(doc) @observable newsearchstring: string = ""; @@ -127,7 +127,6 @@ export class SearchBox extends ViewBoxBaseComponent { Doc.UnBrushDoc(result[0]); result[0].searchMatch = undefined; @@ -140,8 +139,7 @@ export class SearchBox extends ViewBoxBaseComponent { this.open = false }); + runInAction(() => { this.open = false; }); this._openNoResults = false; this._results = []; this._resultsSet.clear(); @@ -226,7 +224,6 @@ export class SearchBox extends ViewBoxBaseComponent 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(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(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 { console.log("Resubmitting search"); }, 60000); @@ -526,7 +515,6 @@ export class SearchBox extends ViewBoxBaseComponent 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(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(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 0) { - console.log("HIT"); newarray = []; docs.forEach((d) => { if (d.data !== undefined) { - console.log(d._searchDocs); d._searchDocs = new List(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 0) { - console.log("HIT"); newarray = []; docs.forEach((d) => { if (d.data !== undefined) { - console.log(d._searchDocs); d._searchDocs = new List(); - 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 0) { - console.log("HIT"); newarray = []; docs.forEach((d) => { if (d.data !== undefined) { - console.log(d._searchDocs); d._searchDocs = new List(); - 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 0) { - console.log("HIT"); newarray = []; docs.forEach((d) => { if (d.data !== undefined) { - console.log(d._searchDocs); d._searchDocs = new List(); - console.log(d); - console.log(d._searchDocs); - let newdocs = DocListCast(d.data); + const newdocs = DocListCast(d.data); newdocs.forEach((newdoc) => { newarray.push(newdoc); }); -- cgit v1.2.3-70-g09d2