From 4fd53320c87313c9add8f551154f8df3e2522b5f Mon Sep 17 00:00:00 2001 From: madelinegr Date: Tue, 4 Jun 2019 18:15:54 -0400 Subject: end of day 6/4 --- src/client/util/SearchUtil.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/client/util') diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts index 28ec8ca14..27d27a3b8 100644 --- a/src/client/util/SearchUtil.ts +++ b/src/client/util/SearchUtil.ts @@ -23,4 +23,8 @@ export namespace SearchUtil { return Search(`proto_i:"${protoId}"`, true); // return Search(`{!join from=id to=proto_i}id:${protoId}`, true); } + + export async function GetViewsOfDocument(doc: Doc): Promise { + return Search(`proto_i:"${doc[Id]}"`, true); + } } \ No newline at end of file -- cgit v1.2.3-70-g09d2 From e65fba03470cc38bc610baf4ff77fcc13cc08b74 Mon Sep 17 00:00:00 2001 From: madelinegr Date: Tue, 11 Jun 2019 16:47:15 -0400 Subject: lint errors fixed --- src/client/northstar/dash-nodes/HistogramBox.tsx | 2 +- src/client/util/DocumentManager.ts | 2 +- src/client/util/DragManager.ts | 3 +- src/client/views/ContextMenu.tsx | 4 +-- src/client/views/DocumentDecorations.tsx | 2 +- src/client/views/MainOverlayTextBox.tsx | 2 +- src/client/views/MainView.tsx | 2 +- src/client/views/PresentationView.tsx | 4 +-- .../views/collections/CollectionBaseView.tsx | 2 +- .../views/collections/CollectionDockingView.tsx | 3 +- .../views/collections/CollectionSchemaView.tsx | 11 ++++--- .../views/collections/CollectionStackingView.tsx | 4 +-- .../views/collections/CollectionTreeView.tsx | 10 +++---- .../CollectionFreeFormLinksView.tsx | 2 +- .../collectionFreeForm/CollectionFreeFormView.tsx | 2 +- .../collections/collectionFreeForm/MarqueeView.tsx | 2 +- src/client/views/nodes/DocumentView.tsx | 6 ++-- src/client/views/nodes/ImageBox.tsx | 4 +-- src/client/views/nodes/PDFBox.tsx | 6 ++-- src/client/views/search/IconBar.tsx | 35 +++++++++++----------- src/client/views/search/SearchBox.tsx | 8 ++--- src/client/views/search/ToggleBar.tsx | 4 +-- 22 files changed, 59 insertions(+), 61 deletions(-) (limited to 'src/client/util') diff --git a/src/client/northstar/dash-nodes/HistogramBox.tsx b/src/client/northstar/dash-nodes/HistogramBox.tsx index d7732ee86..ce678a9d2 100644 --- a/src/client/northstar/dash-nodes/HistogramBox.tsx +++ b/src/client/northstar/dash-nodes/HistogramBox.tsx @@ -126,7 +126,7 @@ export class HistogramBox extends React.Component { brush.backgroundColor = StyleConstants.BRUSH_COLORS[i % StyleConstants.BRUSH_COLORS.length]; let brushed = DocListCast(brush.brushingDocs); if (!brushed.length) - return null; + {return null;} return { l: brush, b: brushed[0][Id] === proto[Id] ? brushed[1] : brushed[0] }; }); runInAction(() => this.HistoOp.BrushLinks.splice(0, this.HistoOp.BrushLinks.length, ...mapped.filter(m => m) as { l: Doc, b: Doc }[])); diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts index ff0c1560b..76ca4b99b 100644 --- a/src/client/util/DocumentManager.ts +++ b/src/client/util/DocumentManager.ts @@ -35,7 +35,7 @@ export class DocumentManager { let toReturn: DocumentView | null = null; let passes = preferredCollection ? [preferredCollection, undefined] : [undefined]; - for (let i = 0; i < passes.length; i++) { + for(let i = 0; i < passes.length; i++) { DocumentManager.Instance.DocumentViews.map(view => { if (view.props.Document[Id] === id && (!passes[i] || view.props.ContainingCollectionView === preferredCollection)) { toReturn = view; diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts index 8ee1ad2af..475bb9237 100644 --- a/src/client/util/DragManager.ts +++ b/src/client/util/DragManager.ts @@ -246,11 +246,12 @@ export namespace DragManager { // } // } let set = dragElement.getElementsByTagName('*'); - for (let i = 0; i < set.length; i++) + for (let i = 0; i < set.length; i++) { if (set[i].hasAttribute("style")) { let s = set[i]; (s as any).style.pointerEvents = "none"; } + } dragDiv.appendChild(dragElement); diff --git a/src/client/views/ContextMenu.tsx b/src/client/views/ContextMenu.tsx index da374455e..eb1937683 100644 --- a/src/client/views/ContextMenu.tsx +++ b/src/client/views/ContextMenu.tsx @@ -1,8 +1,8 @@ import React = require("react"); import { ContextMenuItem, ContextMenuProps } from "./ContextMenuItem"; import { observable, action } from "mobx"; -import { observer } from "mobx-react" -import "./ContextMenu.scss" +import { observer } from "mobx-react"; +import "./ContextMenu.scss"; import { library } from '@fortawesome/fontawesome-svg-core'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faSearch, faCircle } from '@fortawesome/free-solid-svg-icons'; diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index 7260b00cf..5ac02a78d 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -430,7 +430,7 @@ export class DocumentDecorations extends React.Component<{}, { value: string }> SelectionManager.SelectedDocuments().forEach(element => { const rect = element.ContentDiv ? element.ContentDiv.getBoundingClientRect() : new DOMRect(); - if (rect.width !== 0 && (dX != 0 || dY != 0 || dW != 0 || dH != 0)) { + if (rect.width !== 0 && (dX !== 0 || dY !== 0 || dW !== 0 || dH !== 0)) { let doc = PositionDocument(element.props.Document); let nwidth = doc.nativeWidth || 0; let nheight = doc.nativeHeight || 0; diff --git a/src/client/views/MainOverlayTextBox.tsx b/src/client/views/MainOverlayTextBox.tsx index a0359419b..8f6d16e1f 100644 --- a/src/client/views/MainOverlayTextBox.tsx +++ b/src/client/views/MainOverlayTextBox.tsx @@ -34,7 +34,7 @@ export class MainOverlayTextBox extends React.Component this.TextDoc = box.props.Document; let sxf = Utils.GetScreenTransform(box ? box.CurrentDiv : undefined); let xf = () => { box.props.ScreenToLocalTransform(); return new Transform(-sxf.translateX, -sxf.translateY, 1 / sxf.scale); }; - this.setTextDoc(box.props.fieldKey, box.CurrentDiv, xf) + this.setTextDoc(box.props.fieldKey, box.CurrentDiv, xf); } else { this.TextDoc = undefined; diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index 307f23df1..f30755711 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -344,7 +344,7 @@ export class MainView extends React.Component { this.globalDisplayFlags.jumpToVisible = true; break; case "escape": - _.mapValues(this.globalDisplayFlags, () => false) + _.mapValues(this.globalDisplayFlags, () => false); break; case "f": this.isSearchVisible = !this.isSearchVisible; diff --git a/src/client/views/PresentationView.tsx b/src/client/views/PresentationView.tsx index b0c93ee26..db689e1b6 100644 --- a/src/client/views/PresentationView.tsx +++ b/src/client/views/PresentationView.tsx @@ -41,8 +41,8 @@ class PresentationViewList extends React.Component { //this doc is selected className += " presentationView-selected"; } - let onEnter = (e: React.PointerEvent) => { document.libraryBrush = true; } - let onLeave = (e: React.PointerEvent) => { document.libraryBrush = false; } + let onEnter = (e: React.PointerEvent) => { document.libraryBrush = true; }; + let onLeave = (e: React.PointerEvent) => { document.libraryBrush = false; }; return (
{ @action.bound removeDocument(doc: Doc): boolean { - let docView = DocumentManager.Instance.getDocumentView(doc, this.props.ContainingCollectionView) + let docView = DocumentManager.Instance.getDocumentView(doc, this.props.ContainingCollectionView); docView && SelectionManager.DeselectDoc(docView); const props = this.props; //TODO This won't create the field if it doesn't already exist diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx index 51e29cb54..2bce6103b 100644 --- a/src/client/views/collections/CollectionDockingView.tsx +++ b/src/client/views/collections/CollectionDockingView.tsx @@ -419,8 +419,7 @@ export class DockedFrameRenderer extends React.Component { @observable private _document: Opt; get _stack(): any { let parent = (this.props as any).glContainer.parent.parent; - if (this._document && this._document.excludeFromLibrary && parent.parent && parent.parent.contentItems.length > 1) - return parent.parent.contentItems[1]; + if (this._document && this._document.excludeFromLibrary && parent.parent && parent.parent.contentItems.length > 1) { return parent.parent.contentItems[1]; } return parent; } constructor(props: any) { diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx index b9e5a5b65..c886d0f35 100644 --- a/src/client/views/collections/CollectionSchemaView.tsx +++ b/src/client/views/collections/CollectionSchemaView.tsx @@ -90,8 +90,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { let columnDocs = DocListCast(schemaDoc.data); if (columnDocs) { let ddoc = columnDocs.find(doc => doc.title === columnName); - if (ddoc) - return ddoc; + if (ddoc) { return ddoc; } } } return this.props.Document; @@ -288,7 +287,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { } getPreviewTransform = (): Transform => this.props.ScreenToLocalTransform().translate( - - this.borderWidth - this.DIVIDER_WIDTH - this.tableWidth, - this.borderWidth); + - this.borderWidth - this.DIVIDER_WIDTH - this.tableWidth, - this.borderWidth) get documentKeysCheckList() { @@ -337,7 +336,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { columns={this.tableColumns} column={{ ...ReactTableDefaults.column, Cell: this.renderCell, }} getTrProps={this.getTrProps} - /> + />; } @computed @@ -362,7 +361,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { addDocTab={this.props.addDocTab} setPreviewScript={this.setPreviewScript} previewScript={this.previewScript} - /> + />; } @action setPreviewScript = (script: string) => { @@ -410,7 +409,7 @@ export class CollectionSchemaPreview extends React.Component this.nativeWidth * this.contentScaling(); private PanelHeight = () => this.nativeHeight * this.contentScaling(); - private getTransform = () => this.props.getTransform().translate(-this.centeringOffset, 0).scale(1 / this.contentScaling()) + private getTransform = () => this.props.getTransform().translate(-this.centeringOffset, 0).scale(1 / this.contentScaling()); get centeringOffset() { return (this.props.width() - this.nativeWidth * this.contentScaling()) / 2; } @action onPreviewScriptChange = (e: React.ChangeEvent) => { diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx index cad7cd50c..0c5d42769 100644 --- a/src/client/views/collections/CollectionStackingView.tsx +++ b/src/client/views/collections/CollectionStackingView.tsx @@ -116,7 +116,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) { let childFocus = (doc: Doc) => { doc.libraryBrush = true; this.props.focus(this.props.Document); // just focus on this collection, not the underlying document because the API doesn't support adding an offset to focus on and we can't pan zoom our contents to be centered. - } + }; return (
doc) { collapseToPoint={this.collapseToPoint} />
); - }) + }); } onContextMenu = (e: React.MouseEvent): void => { if (!e.isPropagationStopped() && this.props.Document[Id] !== "mainDoc") { // need to test this because GoldenLayout causes a parallel hierarchy in the React DOM for its children and the main document view7 diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx index 8a6764c58..f83fa3b4b 100644 --- a/src/client/views/collections/CollectionTreeView.tsx +++ b/src/client/views/collections/CollectionTreeView.tsx @@ -67,8 +67,8 @@ class TreeView extends React.Component { @undoBatch delete = () => this.props.deleteDoc(this.props.document); @undoBatch openRight = async () => this.props.addDocTab(this.props.document, "openRight"); - @action onMouseEnter = () => { this._isOver = true; } - @action onMouseLeave = () => { this._isOver = false; } + @action onMouseEnter = () => { this._isOver = true; }; + @action onMouseLeave = () => { this._isOver = false; }; onPointerEnter = (e: React.PointerEvent): void => { this.props.active() && (this.props.document.libraryBrush = true); @@ -89,8 +89,8 @@ class TreeView extends React.Component { let bounds = this.props.ScreenToLocalTransform().transformPoint(rect.left, rect.top + rect.height / 2); let before = x[1] < bounds[1]; let inside = x[0] > bounds[0] + 75 || (!before && this._bulletType === BulletType.Collapsible); - this._header!.current!.className = "treeViewItem-header" - if (inside && this._bulletType != BulletType.List) this._header!.current!.className = "treeViewItem-header-inside"; + this._header!.current!.className = "treeViewItem-header"; + if (inside && this._bulletType !== BulletType.List) this._header!.current!.className = "treeViewItem-header-inside"; else if (before) this._header!.current!.className = "treeViewItem-header-above"; else if (!before) this._header!.current!.className = "treeViewItem-header-below"; e.stopPropagation(); @@ -191,7 +191,7 @@ class TreeView extends React.Component { if (inside) { let docList = Cast(this.props.document.data, listSpec(Doc)); if (docList !== undefined) { - addDoc = (doc: Doc) => { docList && docList.push(doc); return true; } + addDoc = (doc: Doc) => { docList && docList.push(doc); return true; }; } } let added = false; diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx index c4dd534ed..be75c6c5c 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx @@ -109,7 +109,7 @@ export class CollectionFreeFormLinksView extends React.Component [ , ...this.views - ]; + ] render() { const containerName = `collectionfreeformview${this.isAnnotationOverlay ? "-overlay" : "-container"}`; const easing = () => this.props.Document.panTransformType === "Ease"; diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx index b6c566964..b93b90c72 100644 --- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx +++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx @@ -312,7 +312,7 @@ export class MarqueeView extends React.Component summary.imageSummary = imageSummary; this.props.addDocument(imageSummary, false); } - }) + }); newCollection.proto!.summaryDoc = summary; selected = [newCollection]; newCollection.x = bounds.left + bounds.width; diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 19f5c7d36..71bb3a8dc 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -312,8 +312,8 @@ export class DocumentView extends DocComponent(Docu this._lastTap = Date.now(); } - deleteClicked = (): void => { this.props.removeDocument && this.props.removeDocument(this.props.Document); } - fieldsClicked = (): void => { this.props.addDocTab(Docs.KVPDocument(this.props.Document, { width: 300, height: 300 }), "onRight") }; + deleteClicked = (): void => { this.props.removeDocument && this.props.removeDocument(this.props.Document); }; + fieldsClicked = (): void => { this.props.addDocTab(Docs.KVPDocument(this.props.Document, { width: 300, height: 300 }), "onRight"); }; makeBtnClicked = (): void => { let doc = Doc.GetProto(this.props.Document); doc.isButton = !BoolCast(doc.isButton, false); @@ -442,7 +442,7 @@ export class DocumentView extends DocComponent(Docu onPointerLeave = (e: React.PointerEvent): void => { this.props.Document.libraryBrush = false; }; isSelected = () => SelectionManager.IsSelected(this); - @action select = (ctrlPressed: boolean) => { this.selectOnLoad = false; SelectionManager.SelectDoc(this, ctrlPressed); } + @action select = (ctrlPressed: boolean) => { this.selectOnLoad = false; SelectionManager.SelectDoc(this, ctrlPressed); }; @observable selectOnLoad: boolean = false; @computed get nativeWidth() { return this.Document.nativeWidth || 0; } diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx index 0d19508fa..c93b84949 100644 --- a/src/client/views/nodes/ImageBox.tsx +++ b/src/client/views/nodes/ImageBox.tsx @@ -88,7 +88,7 @@ export class ImageBox extends DocComponent(ImageD onPointerDown = (e: React.PointerEvent): void => { if (e.shiftKey && e.ctrlKey) - e.stopPropagation(); + {e.stopPropagation();} // if (Date.now() - this._lastTap < 300) { // if (e.buttons === 1) { // this._downX = e.clientX; @@ -189,7 +189,7 @@ export class ImageBox extends DocComponent(ImageD @action onError = () => { let timeout = this._curSuffix === "_s" ? this._smallRetryCount : this._curSuffix === "_m" ? this._mediumRetryCount : this._largeRetryCount; if (timeout < 10) - setTimeout(this.retryPath, Math.min(10000, timeout * 5)); + { setTimeout(this.retryPath, Math.min(10000, timeout * 5));} } _curSuffix = "_m"; render() { diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx index 05088f688..1fb3090b8 100644 --- a/src/client/views/nodes/PDFBox.tsx +++ b/src/client/views/nodes/PDFBox.tsx @@ -262,7 +262,7 @@ export class PDFBox extends DocComponent(PdfDocumen this.props.Document.thumbnail = new ImageField(new URL(url)); } runInAction(() => this._renderAsSvg = true); - }) + }); })) .catch(function (error: any) { console.error('oops, something went wrong!', error); @@ -336,7 +336,7 @@ export class PDFBox extends DocComponent(PdfDocumen choosePath(url: URL) { if (url.protocol === "data" || url.href.indexOf(window.location.origin) === -1) - return url.href; + {return url.href;} let ext = path.extname(url.href); return url.href.replace(ext, this._curSuffix + ext); } @@ -351,7 +351,7 @@ export class PDFBox extends DocComponent(PdfDocumen @action onError = () => { let timeout = this._curSuffix === "_s" ? this._smallRetryCount : this._curSuffix === "_m" ? this._mediumRetryCount : this._largeRetryCount; if (timeout < 10) - setTimeout(this.retryPath, Math.min(10000, timeout * 5)); + {setTimeout(this.retryPath, Math.min(10000, timeout * 5));} } _curSuffix = "_m"; diff --git a/src/client/views/search/IconBar.tsx b/src/client/views/search/IconBar.tsx index 3f5d11d8f..3f77d64eb 100644 --- a/src/client/views/search/IconBar.tsx +++ b/src/client/views/search/IconBar.tsx @@ -95,6 +95,7 @@ export class IconBar extends React.Component { @action.bound unselectAllRefs() { + this.allRefs.forEach(element => { if (element.current) { element.current.setAttribute("data-selected", "false"); @@ -105,16 +106,16 @@ export class IconBar extends React.Component { @action.bound alternateRef(ref: any) { if (ref.getAttribute("data-selected") === "true") { - ref.setAttribute("data-selected", "false") + ref.setAttribute("data-selected", "false"); } else { - ref.setAttribute("data-selected", "true") + ref.setAttribute("data-selected", "true"); } } @action.bound onClick = (value: string) => { - let icons: string[] = this.props.getIcons() + let icons: string[] = this.props.getIcons(); let ref = this.getRef(value); this.alternateRef(ref); if (value === DocTypes.NONE) { @@ -150,15 +151,13 @@ export class IconBar extends React.Component { } getInitialStatus = (type: string) => { - console.log(this.getRef(type)) if (this.originalFilteredNodes.includes(type)) { - return "true" + return "true"; } - return "false" + return "false"; } render() { - console.log("rendering") return (
Filter by type of node
@@ -167,7 +166,7 @@ export class IconBar extends React.Component {
{ this.onClick(DocTypes.NONE) }}> + onClick={() => { this.onClick(DocTypes.NONE); }}>
Clear
@@ -176,7 +175,7 @@ export class IconBar extends React.Component {
{ this.onClick(DocTypes.PDF) }}> + onClick={() => { this.onClick(DocTypes.PDF); }}>
PDF
@@ -185,7 +184,7 @@ export class IconBar extends React.Component {
{ this.onClick(DocTypes.HIST) }}> + onClick={() => { this.onClick(DocTypes.HIST); }}>
Histogram
@@ -194,7 +193,7 @@ export class IconBar extends React.Component {
{ this.onClick(DocTypes.COL) }}> + onClick={() => { this.onClick(DocTypes.COL); }}>
Collection
@@ -203,7 +202,7 @@ export class IconBar extends React.Component {
{ this.onClick(DocTypes.IMG) }}> + onClick={() => { this.onClick(DocTypes.IMG); }}>
Image
@@ -212,7 +211,7 @@ export class IconBar extends React.Component {
{ this.onClick(DocTypes.VID) }}> + onClick={() => { this.onClick(DocTypes.VID); }}>
Video
@@ -221,7 +220,7 @@ export class IconBar extends React.Component {
{ this.onClick(DocTypes.WEB) }}> + onClick={() => { this.onClick(DocTypes.WEB); }}>
Web
@@ -230,7 +229,7 @@ export class IconBar extends React.Component {
{ this.onClick(DocTypes.LINK) }}> + onClick={() => { this.onClick(DocTypes.LINK); }}>
Link
@@ -239,7 +238,7 @@ export class IconBar extends React.Component {
{ this.onClick(DocTypes.AUDIO) }}> + onClick={() => { this.onClick(DocTypes.AUDIO); }}>
Audio
@@ -248,13 +247,13 @@ export class IconBar extends React.Component {
{ this.onClick(DocTypes.TEXT) }}> + onClick={() => { this.onClick(DocTypes.TEXT); }}>
Text
- ) + ); } } diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index e9146a6d1..deeb56762 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -47,14 +47,14 @@ export class SearchBox extends React.Component { if(!this._wordStatus){ let oldWords = query.split(" "); let newWords: string[] = []; - console.log(oldWords) + console.log(oldWords); oldWords.forEach(word => { let newWrd = "+" + word; newWords.push(newWrd); - }) - console.log(newWords) + }); + console.log(newWords); - query = newWords.join(" ") + query = newWords.join(" "); } //gets json result into a list of documents that can be used diff --git a/src/client/views/search/ToggleBar.tsx b/src/client/views/search/ToggleBar.tsx index 7dbb3b767..e7fd86d30 100644 --- a/src/client/views/search/ToggleBar.tsx +++ b/src/client/views/search/ToggleBar.tsx @@ -64,7 +64,7 @@ export class ToggleBar extends React.Component{ translateX: -totalWidth, easing: "easeInOutQuad", duration: 500 - }) + }); } } @@ -88,5 +88,5 @@ export class ToggleBar extends React.Component{ ); - }; + } } \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 09e40959ec0d47ae3bff2e9f1797ea2b0cbc1034 Mon Sep 17 00:00:00 2001 From: madelinegr Date: Wed, 12 Jun 2019 22:45:20 -0400 Subject: end of day 6/12 --- src/client/documents/Documents.ts | 6 +++--- src/client/util/DocumentManager.ts | 26 +++++++++++++++++++++++++- src/client/views/MainView.tsx | 4 ++-- src/client/views/search/IconBar.scss | 15 ++++++++++++++- src/client/views/search/IconBar.tsx | 16 +++++++++++++++- src/client/views/search/SearchBox.tsx | 25 +++++++++++++++++-------- src/client/views/search/SearchItem.tsx | 22 +++++++++++++++++----- src/client/views/search/ToggleBar.tsx | 16 ++++++++++++++-- 8 files changed, 107 insertions(+), 23 deletions(-) (limited to 'src/client/util') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 9d83f0e36..2da5eed43 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -89,11 +89,13 @@ export namespace DocUtils { let protoSrc = source.proto ? source.proto : source; let protoTarg = target.proto ? target.proto : target; UndoManager.RunInBatch(() => { - let linkDoc = Docs.TextDocument({ width: 100, height: 30, borderRounding: -1 }); + let linkDoc = Docs.TextDocument({ width: 100, height: 30, borderRounding: -1}); + // linkDoc.type = DocTypes.LINK; let linkDocProto = Doc.GetProto(linkDoc); linkDocProto.title = source.title + " to " + target.title; linkDocProto.linkDescription = ""; linkDocProto.linkTags = "Default"; + linkDocProto.type = DocTypes.LINK; linkDocProto.linkedTo = target; linkDocProto.linkedFrom = source; @@ -110,8 +112,6 @@ export namespace DocUtils { return linkDoc; }, "make link"); } - - } export namespace Docs { diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts index 76ca4b99b..40928ecae 100644 --- a/src/client/util/DocumentManager.ts +++ b/src/client/util/DocumentManager.ts @@ -30,12 +30,36 @@ export class DocumentManager { // this.DocumentViews = new Array(); } + //gets all views + public getDocumentViewsById(id: string) { + let toReturn: DocumentView[] = []; + DocumentManager.Instance.DocumentViews.map(view => { + if (view.props.Document[Id] === id) { + toReturn.push(view); + } + }); + if (toReturn.length === 0) { + DocumentManager.Instance.DocumentViews.map(view => { + let doc = view.props.Document.proto; + if (doc && doc[Id]) { + if(doc[Id] === id) + {toReturn.push(view);} + } + }); + } + return toReturn; + } + + public getAllDocumentViews(doc: Doc){ + return this.getDocumentViewsById(doc[Id]); + } + public getDocumentViewById(id: string, preferredCollection?: CollectionView | CollectionPDFView | CollectionVideoView): DocumentView | null { let toReturn: DocumentView | null = null; let passes = preferredCollection ? [preferredCollection, undefined] : [undefined]; - for(let i = 0; i < passes.length; i++) { + for (let i = 0; i < passes.length; i++) { DocumentManager.Instance.DocumentViews.map(view => { if (view.props.Document[Id] === id && (!passes[i] || view.props.ContainingCollectionView === preferredCollection)) { toReturn = view; diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index f30755711..c612d4b00 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -10,7 +10,7 @@ import * as request from 'request'; import { CurrentUserUtils } from '../../server/authentication/models/current_user_utils'; import { RouteStore } from '../../server/RouteStore'; import { emptyFunction, returnTrue, Utils, returnOne, returnZero } from '../../Utils'; -import { Docs } from '../documents/Documents'; +import { Docs, DocTypes } from '../documents/Documents'; import { SetupDrag, DragManager } from '../util/DragManager'; import { Transform } from '../util/Transform'; import { UndoManager } from '../util/UndoManager'; @@ -243,7 +243,7 @@ export class MainView extends React.Component { let audiourl = "http://techslides.com/demos/samples/sample.mp3"; let videourl = "http://techslides.com/demos/sample-videos/small.mp4"; - let addTextNode = action(() => Docs.TextDocument({ borderRounding: -1, width: 200, height: 200, title: "a text note" })); + let addTextNode = action(() => Docs.TextDocument({ borderRounding: -1, width: 200, height: 200, title: "a text note", type: DocTypes.TEXT })); let addColNode = action(() => Docs.FreeformDocument([], { width: this.pwidth * .7, height: this.pheight, title: "a freeform collection" })); let addSchemaNode = action(() => Docs.SchemaDocument(["title"], [], { width: 200, height: 200, title: "a schema collection" })); let addTreeNode = action(() => CurrentUserUtils.UserDocument); diff --git a/src/client/views/search/IconBar.scss b/src/client/views/search/IconBar.scss index 98b4e50a6..e08e09702 100644 --- a/src/client/views/search/IconBar.scss +++ b/src/client/views/search/IconBar.scss @@ -34,10 +34,12 @@ .type-icon.selected { background-color: $alt-accent; + opacity: 1; } .type-icon.not-selected { background-color: transparent; + opacity: .4; } .fontawesome-icon { @@ -45,9 +47,20 @@ width: 28px; } -.type-icon:hover { +.type-icon.filter:hover { transform: scale(1.1); background-color: $alt-accent; + opacity: 1; + + +.filter-description { + opacity: 1; + } +} + +.type-icon.none:hover { + transform: scale(1.1); + // background-color: $alt-accent; + opacity: 1; +.filter-description { opacity: 1; diff --git a/src/client/views/search/IconBar.tsx b/src/client/views/search/IconBar.tsx index f3741a5de..8fb7d0959 100644 --- a/src/client/views/search/IconBar.tsx +++ b/src/client/views/search/IconBar.tsx @@ -31,6 +31,8 @@ export interface IconBarProps { @observer export class IconBar extends React.Component { + static Instance: IconBar; + @observable noneRef = React.createRef(); @observable colRef = React.createRef(); @observable imgRef = React.createRef(); @@ -45,11 +47,23 @@ export class IconBar extends React.Component { @observable originalFilteredNodes: string[] = this.props.getIcons(); + constructor(props: IconBarProps){ + super(props); + IconBar.Instance = this; + } + componentDidMount = () => { //i KNOW this is bad i just can't get this to re render eeeeeeeek this.forceUpdate(); } + @action.bound + resetIconFilters = () => { + this.unselectAllRefs(); + // lmao sorry + this.forceUpdate(); + } + //gets ref associated with given string @action.bound getRef = (value: string) => { @@ -163,7 +177,7 @@ export class IconBar extends React.Component {
Filter by type of node
-
{ this.onClick(DocTypes.NONE); }}> diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index 319573adf..622fa27f0 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -53,6 +53,14 @@ export class SearchBox extends React.Component { }); } + @action.bound + resetFilters = () => { + ToggleBar.Instance.resetToggle(); + IconBar.Instance.resetIconFilters(); + // this._wordStatus = true; + this._icons = []; + } + @action.bound onChange(e: React.ChangeEvent) { this._searchString = e.target.value; @@ -66,22 +74,24 @@ export class SearchBox extends React.Component { @action submitSearch = async () => { let query = this._searchString; + let results: Doc[]; if (!this._wordStatus) { let oldWords = query.split(" "); let newWords: string[] = []; - console.log(oldWords); oldWords.forEach(word => { let newWrd = "+" + word; newWords.push(newWrd); }); - console.log(newWords); - query = newWords.join(" "); } - //gets json result into a list of documents that can be used - const results = await this.getResults(query); + if(query === ""){ + results = []; + } + else{ + //gets json result into a list of documents that can be used + results = await this.getResults(query);} runInAction(() => { this._resultsOpen = true; @@ -151,6 +161,7 @@ export class SearchBox extends React.Component { closeSearch = () => { this._open = false; this._resultsOpen = false; + this._results = []; } @action @@ -227,14 +238,12 @@ export class SearchBox extends React.Component { stopProp = (e: React.PointerEvent) => { e.stopPropagation(); - console.log('stopping prop') this._pointerTime = e.timeStamp; } @action.bound openSearch(e: React.PointerEvent) { e.stopPropagation(); - this._results = []; this._openNoResults = false; this._open = false; this._resultsOpen = true; @@ -285,7 +294,7 @@ export class SearchBox extends React.Component { temp for filtering where in doc the keywords are found
- +
) : undefined} diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx index 65f4dfd31..fb0eade4b 100644 --- a/src/client/views/search/SearchItem.tsx +++ b/src/client/views/search/SearchItem.tsx @@ -3,7 +3,7 @@ import { library } from '@fortawesome/fontawesome-svg-core'; import { faCaretUp, faFilePdf, faFilm, faImage, faObjectGroup, faStickyNote, faMusic, faLink, faChartBar, faGlobeAsia } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Cast, NumCast } from "../../../new_fields/Types"; -import { observable, runInAction, computed } from "mobx"; +import { observable, runInAction, computed, action } from "mobx"; import { listSpec } from "../../../new_fields/Schema"; import { Doc } from "../../../new_fields/Doc"; import { DocumentManager } from "../../util/DocumentManager"; @@ -16,6 +16,7 @@ import "./SearchItem.scss"; import { CollectionViewType } from "../collections/CollectionBaseView"; import { DocTypes } from "../../documents/Documents"; import { SearchBox } from "./SearchBox"; +import { DocumentView } from "../nodes/DocumentView"; export interface SearchItemProps { doc: Doc; @@ -84,11 +85,8 @@ export class SelectorContextMenu extends React.Component { export class SearchItem extends React.Component { @observable _selected: boolean = false; - @observable hover = false; onClick = () => { - // DocumentManager.Instance.jumpToDocument(this.props.doc); - console.log(Cast(this.props.doc.type, "string", "")) CollectionDockingView.Instance.AddRightSplit(this.props.doc); } @@ -138,10 +136,24 @@ export class SearchItem extends React.Component { SearchBox.Instance.openSearch(e); } + highlightDoc = (e: React.PointerEvent) => { + let docViews: DocumentView[] = DocumentManager.Instance.getAllDocumentViews(this.props.doc); + docViews.forEach(element => { + element.props.Document.libraryBrush = true; + }); + } + + unHighlightDoc = (e: React.PointerEvent) => { + let docViews: DocumentView[] = DocumentManager.Instance.getAllDocumentViews(this.props.doc); + docViews.forEach(element => { + element.props.Document.libraryBrush = false; + }); + } + render() { return (
-
{ +
{ this.pointerDown; SetupDrag(this.collectionRef, this.startDocDrag);}} >
diff --git a/src/client/views/search/ToggleBar.tsx b/src/client/views/search/ToggleBar.tsx index e7fd86d30..32f7a63dd 100644 --- a/src/client/views/search/ToggleBar.tsx +++ b/src/client/views/search/ToggleBar.tsx @@ -15,6 +15,7 @@ export interface ToggleBarProps { @observer export class ToggleBar extends React.Component{ + static Instance: ToggleBar; @observable forwardTimeline: anime.AnimeTimelineInstance; @observable _toggleButton: React.RefObject; @@ -23,6 +24,7 @@ export class ToggleBar extends React.Component{ constructor(props: ToggleBarProps) { super(props); + ToggleBar.Instance = this; this._toggleButton = React.createRef(); this.forwardTimeline = anime.timeline({ loop: false, @@ -76,12 +78,22 @@ export class ToggleBar extends React.Component{ this.props.changeStatus(); } + @action.bound + public resetToggle = () => { + if (!this._curStatus) { + this.forwardTimeline.play() + this.forwardTimeline.reverse(); + this.props.changeStatus(); + this._curStatus = true; + } + } + render() { return (
-
{this.props.optionOne}
-
{this.props.optionTwo}
+
{this.props.optionOne}
+
{this.props.optionTwo}
-- cgit v1.2.3-70-g09d2