diff options
| author | bob <bcz@cs.brown.edu> | 2019-08-19 10:11:59 -0400 |
|---|---|---|
| committer | bob <bcz@cs.brown.edu> | 2019-08-19 10:11:59 -0400 |
| commit | e37bf9124c952aa26c3e29deb9e4faa01cad1a7e (patch) | |
| tree | be44ae9bd5e2eb6c5ce392383d41505b5863d061 /src/client/views/SearchItem.tsx | |
| parent | 07482c3bf435748140addfd4fd338fc668657798 (diff) | |
| parent | b037aa89fb564812f880994453ce002054a0ad82 (diff) | |
Merge branch 'master' into presentation_f
Diffstat (limited to 'src/client/views/SearchItem.tsx')
| -rw-r--r-- | src/client/views/SearchItem.tsx | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/client/views/SearchItem.tsx b/src/client/views/SearchItem.tsx new file mode 100644 index 000000000..fd4b2420d --- /dev/null +++ b/src/client/views/SearchItem.tsx @@ -0,0 +1,67 @@ +import React = require("react"); +import { library } from '@fortawesome/fontawesome-svg-core'; +import { faCaretUp, faFilePdf, faFilm, faImage, faObjectGroup, faStickyNote } from '@fortawesome/free-solid-svg-icons'; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { Doc } from "../../new_fields/Doc"; +import { DocumentManager } from "../util/DocumentManager"; +import { SetupDrag } from "../util/DragManager"; + + +export interface SearchProps { + doc: Doc; +} + +library.add(faCaretUp); +library.add(faObjectGroup); +library.add(faStickyNote); +library.add(faFilePdf); +library.add(faFilm); + +export class SearchItem extends React.Component<SearchProps> { + + onClick = () => { + DocumentManager.Instance.jumpToDocument(this.props.doc, false); + } + + //needs help + // @computed get layout(): string { const field = Cast(this.props.doc[fieldKey], IconField); return field ? field.icon : "<p>Error loading icon data</p>"; } + + + public static DocumentIcon(layout: string) { + let button = layout.indexOf("PDFBox") !== -1 ? faFilePdf : + layout.indexOf("ImageBox") !== -1 ? faImage : + layout.indexOf("Formatted") !== -1 ? faStickyNote : + layout.indexOf("Video") !== -1 ? faFilm : + layout.indexOf("Collection") !== -1 ? faObjectGroup : + faCaretUp; + return <FontAwesomeIcon icon={button} className="documentView-minimizedIcon" />; + } + onPointerEnter = (e: React.PointerEvent) => { + Doc.BrushDoc(this.props.doc); + } + onPointerLeave = (e: React.PointerEvent) => { + Doc.UnBrushDoc(this.props.doc); + } + + collectionRef = React.createRef<HTMLDivElement>(); + startDocDrag = () => { + let doc = this.props.doc; + const isProto = Doc.GetT(doc, "isPrototype", "boolean", true); + if (isProto) { + return Doc.MakeDelegate(doc); + } else { + return Doc.MakeAlias(doc); + } + } + render() { + return ( + <div className="search-item" ref={this.collectionRef} id="result" + onPointerEnter={this.onPointerEnter} onPointerLeave={this.onPointerLeave} + onClick={this.onClick} onPointerDown={SetupDrag(this.collectionRef, this.startDocDrag)} > + <div className="search-title" id="result" >title: {this.props.doc.title}</div> + {/* <div className="search-type" id="result" >Type: {this.props.doc.layout}</div> */} + {/* <div className="search-type" >{SearchItem.DocumentIcon(this.layout)}</div> */} + </div> + ); + } +}
\ No newline at end of file |
