aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormadelinegr <monika_hedman@brown.edu>2019-06-12 22:45:20 -0400
committermadelinegr <monika_hedman@brown.edu>2019-06-12 22:45:20 -0400
commit09e40959ec0d47ae3bff2e9f1797ea2b0cbc1034 (patch)
tree0bf827c0393086ac62f57b69827c3a26bb477650 /src
parent95dbea8f51b0f5835d6caf9adf2cecdfb51d35f7 (diff)
end of day 6/12
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts6
-rw-r--r--src/client/util/DocumentManager.ts26
-rw-r--r--src/client/views/MainView.tsx4
-rw-r--r--src/client/views/search/IconBar.scss15
-rw-r--r--src/client/views/search/IconBar.tsx16
-rw-r--r--src/client/views/search/SearchBox.tsx25
-rw-r--r--src/client/views/search/SearchItem.tsx22
-rw-r--r--src/client/views/search/ToggleBar.tsx16
8 files changed, 107 insertions, 23 deletions
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<DocumentView>();
}
+ //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<IconBarProps> {
+ static Instance: IconBar;
+
@observable noneRef = React.createRef<HTMLDivElement>();
@observable colRef = React.createRef<HTMLDivElement>();
@observable imgRef = React.createRef<HTMLDivElement>();
@@ -45,11 +47,23 @@ export class IconBar extends React.Component<IconBarProps> {
@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<IconBarProps> {
<div className="filter icon-title">Filter by type of node</div>
<div className="filter icon-bar">
<div className="filter type-outer">
- <div className={"type-icon filter none"}
+ <div className={"type-icon none not-selected"}
ref={this.noneRef}
data-selected={"false"}
onClick={() => { 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
@@ -54,6 +54,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<HTMLInputElement>) {
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
</div>
</div>
- <button className="reset-filter">Reset Filters</button>
+ <button className="reset-filter" onClick = {this.resetFilters}>Reset Filters</button>
</div>
) : undefined}
</div>
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<SearchItemProps> {
export class SearchItem extends React.Component<SearchItemProps> {
@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<SearchItemProps> {
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 (
<div className="search-overview" onPointerDown = {this.pointerDown}>
- <div className="search-item" ref={this.collectionRef} id="result" onClick={this.onClick} onPointerDown={ () => {
+ <div className="search-item" onPointerEnter={this.highlightDoc} onPointerLeave={this.unHighlightDoc} ref={this.collectionRef} id="result" onClick={this.onClick} onPointerDown={ () => {
this.pointerDown;
SetupDrag(this.collectionRef, this.startDocDrag);}} >
<div className="main-search-info">
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<ToggleBarProps>{
+ static Instance: ToggleBar;
@observable forwardTimeline: anime.AnimeTimelineInstance;
@observable _toggleButton: React.RefObject<HTMLDivElement>;
@@ -23,6 +24,7 @@ export class ToggleBar extends React.Component<ToggleBarProps>{
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<ToggleBarProps>{
this.props.changeStatus();
}
+ @action.bound
+ public resetToggle = () => {
+ if (!this._curStatus) {
+ this.forwardTimeline.play()
+ this.forwardTimeline.reverse();
+ this.props.changeStatus();
+ this._curStatus = true;
+ }
+ }
+
render() {
return (
<div>
<div className="toggle-title">
- <div className="toggle-option" style = {{ opacity: (this._curStatus ? 1:.4)}}>{this.props.optionOne}</div>
- <div className="toggle-option" style = {{ opacity: (this._curStatus ? .4:1)}}>{this.props.optionTwo}</div>
+ <div className="toggle-option" style={{ opacity: (this._curStatus ? 1 : .4) }}>{this.props.optionOne}</div>
+ <div className="toggle-option" style={{ opacity: (this._curStatus ? .4 : 1) }}>{this.props.optionTwo}</div>
</div>
<div className="toggle-bar" id="toggle-bar" style={{ flexDirection: (this._originalStatus ? "row" : "row-reverse") }}>
<div className="toggle-button" id="toggle-button" ref={this._toggleButton} onClick={this.onclick} />