From 15ee40ea8da5140ba5db62185b4a26d36bf6255e Mon Sep 17 00:00:00 2001 From: Andy Rickert Date: Mon, 27 Apr 2020 15:44:43 -0700 Subject: refactored searchbox doctype out from querybox class to help with displaying search results as different collection types --- src/client/documents/DocumentTypes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/client/documents/DocumentTypes.ts') diff --git a/src/client/documents/DocumentTypes.ts b/src/client/documents/DocumentTypes.ts index de366763b..3c34ff1c8 100644 --- a/src/client/documents/DocumentTypes.ts +++ b/src/client/documents/DocumentTypes.ts @@ -13,7 +13,7 @@ export enum DocumentType { INK = "ink", // ink stroke SCREENSHOT = "screenshot", // view of a desktop application FONTICON = "fonticonbox", // font icon - QUERY = "query", // search query + SEARCH = "search", // search query LABEL = "label", // simple text label BUTTON = "button", // onClick button WEBCAM = "webcam", // webcam -- cgit v1.2.3-70-g09d2 From e4b7b54eecc307ec52f6105f92c3d87449458641 Mon Sep 17 00:00:00 2001 From: Andy Rickert Date: Tue, 28 Apr 2020 02:02:40 -0700 Subject: nested collection view now in search box, search item doc type cast over stacking view, but with bugs --- src/client/documents/DocumentTypes.ts | 1 + src/client/documents/Documents.ts | 8 +++ src/client/views/nodes/FieldView.tsx | 3 + src/client/views/nodes/QueryBox.tsx | 2 +- src/client/views/search/SearchBox.tsx | 40 ++++++++++--- src/client/views/search/SearchItem.tsx | 69 ++++++++++++---------- .../authentication/models/current_user_utils.ts | 3 + 7 files changed, 86 insertions(+), 40 deletions(-) (limited to 'src/client/documents/DocumentTypes.ts') diff --git a/src/client/documents/DocumentTypes.ts b/src/client/documents/DocumentTypes.ts index 3c34ff1c8..36d3e1c52 100644 --- a/src/client/documents/DocumentTypes.ts +++ b/src/client/documents/DocumentTypes.ts @@ -31,6 +31,7 @@ export enum DocumentType { COLOR = "color", // color picker (view of a color picker for a color string) YOUTUBE = "youtube", // youtube directory (view of you tube search results) DOCHOLDER = "docholder", // nested document (view of a document) + SEARCHITEM= "searchitem", LINKDB = "linkdb", // database of links ??? why do we have this RECOMMENDATION = "recommendation", // view of a recommendation diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 50326231c..e5b3c8a97 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -38,6 +38,7 @@ import { filterData} from "../views/search/SearchBox"; //import { PresBox } from "../views/nodes/PresBox"; //import { PresField } from "../../new_fields/PresField"; import { PresElementBox } from "../views/presentationview/PresElementBox"; +import { SearchItem } from "../views/search/SearchItem"; import { DashWebRTCVideo } from "../views/webcam/DashWebRTCVideo"; import { SearchBox } from "../views/search/SearchBox"; import { ColorBox } from "../views/nodes/ColorBox"; @@ -277,6 +278,9 @@ export namespace Docs { [DocumentType.PRESELEMENT, { layout: { view: PresElementBox, dataField: data } }], + [DocumentType.SEARCHITEM, { + layout: { view: SearchItem, dataField: data } + }], [DocumentType.INK, { layout: { view: InkingStroke, dataField: data }, options: { backgroundColor: "transparent" } @@ -671,6 +675,10 @@ export namespace Docs { return InstanceFromProto(Prototypes.get(DocumentType.PRESELEMENT), undefined, { ...(options || {}) }); } + export function SearchItemBoxDocument(options?: DocumentOptions) { + return InstanceFromProto(Prototypes.get(DocumentType.SEARCHITEM), undefined, { ...(options || {}) }); + } + export function DockDocument(documents: Array, config: string, options: DocumentOptions, id?: string) { const inst = InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _viewType: CollectionViewType.Docking, dockingConfig: config }, id); Doc.GetProto(inst).data = new List(documents); diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx index a3790d38b..6198212b5 100644 --- a/src/client/views/nodes/FieldView.tsx +++ b/src/client/views/nodes/FieldView.tsx @@ -51,6 +51,9 @@ export interface FieldViewProps { ContentScaling: () => number; ChromeHeight?: () => number; childLayoutTemplate?: () => Opt; + highlighting?: string[]; + lines?: string[]; + doc?: Doc; } @observer diff --git a/src/client/views/nodes/QueryBox.tsx b/src/client/views/nodes/QueryBox.tsx index eb57b98d2..fb47a01d7 100644 --- a/src/client/views/nodes/QueryBox.tsx +++ b/src/client/views/nodes/QueryBox.tsx @@ -34,7 +34,7 @@ export class QueryBox extends ViewBoxAnnotatableComponent e.stopPropagation()} > - + ; } } diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index 327617319..5ef71ca41 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -533,7 +533,6 @@ export class SearchBox extends ViewBoxBaseComponent(this._numTotalResults === -1 ? 0 : this._numTotalResults); this._visibleDocuments = Array(this._numTotalResults === -1 ? 0 : this._numTotalResults); - // indicates if things are placeholders this._isSearch = Array(this._numTotalResults === -1 ? 0 : this._numTotalResults); } @@ -555,7 +554,10 @@ export class SearchBox extends ViewBoxBaseComponent; + result[0].query=this._searchString; + this._visibleElements[i] = ; + Doc.AddDocToList(this.props.Document, undefined, result[0]) + this._visibleDocuments[i]= result[0]; this._isSearch[i] = "search"; } @@ -564,8 +566,10 @@ export class SearchBox extends ViewBoxBaseComponent; + result[0].query=this._searchString; + this._visibleElements[i] = ; this._visibleDocuments[i] = result[0]; + Doc.AddDocToList(this.props.Document, undefined, result[0]) this._isSearch[i] = "search"; } } @@ -729,7 +733,7 @@ export class SearchBox extends ViewBoxBaseComponent 100} @@ -767,7 +771,7 @@ export class SearchBox extends ViewBoxBaseComponent 100} @@ -805,7 +809,7 @@ export class SearchBox extends ViewBoxBaseComponent 100} @@ -889,7 +893,23 @@ export class SearchBox extends ViewBoxBaseComponent this.layoutDoc._viewType === CollectionViewType.Stacking ? Cast(Doc.UserDoc().presentationTemplate, Doc, null) : undefined; + childLayoutTemplate = () => this.layoutDoc._viewType === CollectionViewType.Stacking ? Cast(Doc.UserDoc().searchItemTemplate, Doc, null) : undefined; + getTransform = () => { + return this.props.ScreenToLocalTransform().translate(-5, -65);// listBox padding-left and pres-box-cont minHeight + } + panelHeight = () => { + return this.props.PanelHeight() - 50; + } + selectElement = (doc: Doc) => { + //this.gotoDocument(this.childDocs.indexOf(doc), NumCast(this.layoutDoc._itemIndex)); + } + + addDocument = (doc: Doc) => { + const newPinDoc = Doc.MakeAlias(doc); + newPinDoc.presentationTargetDoc = doc; + return Doc.AddDocToList(this.dataDoc, this.fieldKey, newPinDoc); + } + render() { return ( @@ -922,14 +942,16 @@ export class SearchBox extends ViewBoxBaseComponent - {/* */} + ScreenToLocalTransform={this.getTransform} />
{ } + +type SearchSchema = makeInterface<[typeof documentSchema]>; +const SearchDocument = makeInterface(documentSchema); + @observer -export class SearchItem extends React.Component { +export class SearchItem extends ViewBoxBaseComponent(SearchDocument) { + public static LayoutString(fieldKey: string) { return FieldView.LayoutString(SearchItem, fieldKey); } @observable _selected: boolean = false; onClick = () => { // I dont think this is the best functionality because clicking the name of the collection does that. Change it back if you'd like - DocumentManager.Instance.jumpToDocument(this.props.doc, false); + DocumentManager.Instance.jumpToDocument(this.props.doc!, false); } @observable _useIcons = true; @observable _displayDim = 50; componentDidMount() { - Doc.SetSearchQuery(this.props.query); - this.props.doc.searchMatch = true; + Doc.SetSearchQuery(StrCast(this.props.doc!.query)); + this.props.doc!.searchMatch = true; } componentWillUnmount() { - this.props.doc.searchMatch = undefined; + this.props.doc!.searchMatch = undefined; } //@computed @action public DocumentIcon() { - const layoutresult = StrCast(this.props.doc.type); + const layoutresult = StrCast(this.props.doc!.type); if (!this._useIcons) { const returnXDimension = () => this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE); const returnYDimension = () => this._displayDim; @@ -156,10 +165,10 @@ export class SearchItem extends React.Component { })} onPointerEnter={action(() => this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE))} > { nextHighlight = (e: React.PointerEvent) => { e.preventDefault(); e.button === 0 && SearchBox.Instance.openSearch(e); - this.props.doc.searchMatch = false; - setTimeout(() => this.props.doc.searchMatch = true, 0); + this.props.doc!.searchMatch = false; + setTimeout(() => this.props.doc!.searchMatch = true, 0); } highlightDoc = (e: React.PointerEvent) => { - if (this.props.doc.type === DocumentType.LINK) { - if (this.props.doc.anchor1 && this.props.doc.anchor2) { + if (this.props.doc!.type === DocumentType.LINK) { + if (this.props.doc!.anchor1 && this.props.doc!.anchor2) { - const doc1 = Cast(this.props.doc.anchor1, Doc, null); - const doc2 = Cast(this.props.doc.anchor2, Doc, null); + const doc1 = Cast(this.props.doc!.anchor1, Doc, null); + const doc2 = Cast(this.props.doc!.anchor2, Doc, null); Doc.BrushDoc(doc1); Doc.BrushDoc(doc2); } } else { - Doc.BrushDoc(this.props.doc); + Doc.BrushDoc(this.props.doc!); } e.stopPropagation(); } unHighlightDoc = (e: React.PointerEvent) => { - if (this.props.doc.type === DocumentType.LINK) { - if (this.props.doc.anchor1 && this.props.doc.anchor2) { + if (this.props.doc!.type === DocumentType.LINK) { + if (this.props.doc!.anchor1 && this.props.doc!.anchor2) { - const doc1 = Cast(this.props.doc.anchor1, Doc, null); - const doc2 = Cast(this.props.doc.anchor2, Doc, null); + const doc1 = Cast(this.props.doc!.anchor1, Doc, null); + const doc2 = Cast(this.props.doc!.anchor2, Doc, null); Doc.UnBrushDoc(doc1); Doc.UnBrushDoc(doc2); } } else { - Doc.UnBrushDoc(this.props.doc); + Doc.UnBrushDoc(this.props.doc!); } } @@ -236,7 +245,7 @@ export class SearchItem extends React.Component { ContextMenu.Instance.clearItems(); ContextMenu.Instance.addItem({ description: "Copy ID", event: () => { - Utils.CopyText(this.props.doc[Id]); + Utils.CopyText(this.props.doc![Id]); }, icon: "fingerprint" }); @@ -261,7 +270,7 @@ export class SearchItem extends React.Component { Math.abs(e.clientY - this._downY) > Utils.DRAG_THRESHOLD) { document.removeEventListener("pointermove", this.onPointerMoved); document.removeEventListener("pointerup", this.onPointerUp); - const doc = Doc.IsPrototype(this.props.doc) ? Doc.MakeDelegate(this.props.doc) : this.props.doc; + const doc = Doc.IsPrototype(this.props.doc!) ? Doc.MakeDelegate(this.props.doc!) : this.props.doc!; DragManager.StartDocumentDrag([this._target], new DragManager.DocumentDragData([doc]), e.clientX, e.clientY); } } @@ -272,29 +281,29 @@ export class SearchItem extends React.Component { @computed get contextButton() { - return CollectionDockingView.AddRightSplit(doc)} />; + return CollectionDockingView.AddRightSplit(doc)} />; } render() { - const doc1 = Cast(this.props.doc.anchor1, Doc); - const doc2 = Cast(this.props.doc.anchor2, Doc); + const doc1 = Cast(this.props.doc!.anchor1, Doc); + const doc2 = Cast(this.props.doc!.anchor2, Doc); return
-
{StrCast(this.props.doc.title)}
-
{this.props.highlighting.length ? "Matched fields:" + this.props.highlighting.join(", ") : this.props.lines.length ? this.props.lines[0] : ""}
- {this.props.lines.filter((m, i) => i).map((l, i) =>
`${l}`
)} +
{StrCast(this.props.doc!.title)}
+
{this.props.highlighting!.length ? "Matched fields:" + this.props.highlighting!.join(", ") : this.props.lines.length ? this.props.lines[0] : ""}
+ {this.props.lines!.filter((m, i) => i).map((l, i) =>
`${l}`
)}
{this.DocumentIcon()}
-
{this.props.doc.type ? this.props.doc.type : "Other"}
+
{this.props.doc!.type ? this.props.doc!.type : "Other"}
- {(doc1 instanceof Doc && doc2 instanceof Doc) && this.props.doc.type === DocumentType.LINK ? : + {(doc1 instanceof Doc && doc2 instanceof Doc) && this.props.doc!.type === DocumentType.LINK ? : this.contextButton}
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts index c03779002..3ca6b1b3a 100644 --- a/src/server/authentication/models/current_user_utils.ts +++ b/src/server/authentication/models/current_user_utils.ts @@ -251,6 +251,7 @@ export class CurrentUserUtils { // setup the Search button which will display the search panel. static setupSearchPanel(sidebarContainer: Doc) { + return Docs.Create.ButtonDocument({ _width: 50, _height: 25, title: "Search", fontSize: 10, letterSpacing: "0px", textTransform: "unset", borderRounding: "5px 5px 0px 0px", boxShadow: "3px 3px 0px rgb(34, 34, 34)", @@ -331,6 +332,8 @@ export class CurrentUserUtils { // the initial presentation Doc to use static setupDefaultPresentation(doc: Doc) { + doc.searchItemTemplate = new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" })); + doc.presentationTemplate = new PrefetchProxy(Docs.Create.PresElementBoxDocument({ title: "pres element template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" })); doc.curPresentation = Docs.Create.PresDocument(new List(), { title: "Presentation", _viewType: CollectionViewType.Stacking, _LODdisable: true, _chromeStatus: "replaced", _showTitle: "title", boxShadow: "0 0" }); } -- cgit v1.2.3-70-g09d2