From a59bcec29efb9b5ea0ba8ddfb4b9977b904c10b8 Mon Sep 17 00:00:00 2001 From: Andy Rickert Date: Tue, 4 Aug 2020 12:18:16 -0400 Subject: cleaning up --- src/client/views/nodes/FieldView.tsx | 2 +- src/client/views/search/SearchBox.tsx | 6 +- src/client/views/search/SearchItem.tsx | 272 +++++++++++++++++---------------- 3 files changed, 141 insertions(+), 139 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx index 2cbfcdb0b..34b07f351 100644 --- a/src/client/views/nodes/FieldView.tsx +++ b/src/client/views/nodes/FieldView.tsx @@ -48,7 +48,7 @@ export interface FieldViewProps { ignoreAutoHeight?: boolean; PanelWidth: () => number; PanelHeight: () => number; - PanelPosition: string; + PanelPosition?: string; overflow?: boolean; NativeHeight: () => number; NativeWidth: () => number; diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index b7f7af244..b76955815 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -54,7 +54,7 @@ const SearchBoxDocument = makeInterface(documentSchema, searchSchema); @observer export class SearchBox extends ViewBoxBaseComponent(SearchBoxDocument) { - @computed get _searchString() { return this.layoutDoc.searchQuery; } + get _searchString() { return this.layoutDoc.searchQuery; } @computed set _searchString(value) { this.layoutDoc.searchQuery = (value); } @observable private _resultsOpen: boolean = false; @observable _searchbarOpen: boolean = false; @@ -691,7 +691,7 @@ export class SearchBox extends ViewBoxBaseComponent(["title", "author", "text", "lastModified"]); if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) { @@ -1039,7 +1039,7 @@ export class SearchBox extends ViewBoxBaseComponent { e.stopPropagation(); SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined); }} onClick={action(() => { this.filter = !this.filter && !this.scale; diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx index 6b06289c4..b61ed450f 100644 --- a/src/client/views/search/SearchItem.tsx +++ b/src/client/views/search/SearchItem.tsx @@ -143,13 +143,13 @@ const SearchDocument = makeInterface(documentSchema); @observer export class SearchItem extends ViewBoxBaseComponent(SearchDocument) { - + public static LayoutString(fieldKey: string) { return FieldView.LayoutString(SearchItem, fieldKey); } - constructor(props:any){ + constructor(props: any) { super(props); //this.rootDoc._viewType= CollectionViewType.Stacking; - this.props.Document._height=46; + this.props.Document._height = 46; if (!this.searchItemTemplate) { // create exactly one presElmentBox template to use by any and all presentations. Doc.UserDoc().searchItemTemplate = new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" })); // this script will be called by each presElement to get rendering-specific info that the PresBox knows about but which isn't written to the PresElement @@ -175,44 +175,46 @@ export class SearchItem extends ViewBoxBaseComponent this._useIcons, - el=> { - if (this.rootDoc.parent){ + el => { + if (this.rootDoc.parent) { parent = Cast(this.rootDoc.parent, Doc, null) as Doc; - height=(NumCast(parent._height)); + height = (NumCast(parent._height)); }; console.log(height); console.log(this._oldHeight); - setTimeout(() =>{this._mainRef.current?.getBoundingClientRect()? this.props.Document._height= this._mainRef.current?.getBoundingClientRect().height : null; - parent!==undefined? this._mainRef.current?.getBoundingClientRect()? parent._height= -this._oldHeight + height +this._mainRef.current?.getBoundingClientRect().height : null: null; - this._mainRef.current?.getBoundingClientRect()? this._oldHeight= this._mainRef.current?.getBoundingClientRect().height : null; - // this._oldHeight 55? this._oldHeight =55:null; - }, 1); - } + setTimeout(() => { + this._mainRef.current?.getBoundingClientRect() ? this.props.Document._height = this._mainRef.current?.getBoundingClientRect().height : null; + parent !== undefined ? this._mainRef.current?.getBoundingClientRect() ? parent._height = -this._oldHeight + height + this._mainRef.current?.getBoundingClientRect().height : null : null; + this._mainRef.current?.getBoundingClientRect() ? this._oldHeight = this._mainRef.current?.getBoundingClientRect().height : null; + // this._oldHeight 55? this._oldHeight =55:null; + }, 1); + } ); this._reactionDisposer3 = reaction( () => this._displayLines, - el=> { - if (this.rootDoc.parent){ + el => { + if (this.rootDoc.parent) { parent = Cast(this.rootDoc.parent, Doc, null) as Doc; - height=(NumCast(parent._height)); + height = (NumCast(parent._height)); }; - setTimeout(() =>{this._mainRef.current?.getBoundingClientRect()? this.props.Document._height= this._mainRef.current?.getBoundingClientRect().height : null; - parent!==undefined? this._mainRef.current?.getBoundingClientRect()? parent._height= -this._oldHeight + height +this._mainRef.current?.getBoundingClientRect().height : null: null; - this._mainRef.current?.getBoundingClientRect()? this._oldHeight= this._mainRef.current?.getBoundingClientRect().height : null; - }, 1); - } + setTimeout(() => { + this._mainRef.current?.getBoundingClientRect() ? this.props.Document._height = this._mainRef.current?.getBoundingClientRect().height : null; + parent !== undefined ? this._mainRef.current?.getBoundingClientRect() ? parent._height = -this._oldHeight + height + this._mainRef.current?.getBoundingClientRect().height : null : null; + this._mainRef.current?.getBoundingClientRect() ? this._oldHeight = this._mainRef.current?.getBoundingClientRect().height : null; + }, 1); + } ); Doc.SetSearchQuery(this.query); @@ -225,14 +227,14 @@ export class SearchItem extends ViewBoxBaseComponent
{ this._useIcons = false; this._displayDim = Number(SEARCH_THUMBNAIL_SIZE); })} >
-
{this.rootDoc.type ? this.rootDoc.type : "Other"}
+
{this.rootDoc.type ? this.rootDoc.type : "Other"}
- ; + ; } collectionRef = React.createRef(); @@ -304,8 +306,8 @@ export class SearchItem extends ViewBoxBaseComponent this.rootDoc!.searchMatch = true, 0); - this.rootDoc.searchIndex=NumCast(this.rootDoc.searchIndex); - this.length=NumCast(this.rootDoc!.length); + this.rootDoc.searchIndex = NumCast(this.rootDoc.searchIndex); + this.length = NumCast(this.rootDoc!.length); } @action @@ -317,12 +319,12 @@ export class SearchItem extends ViewBoxBaseComponent this.rootDoc!.searchMatch2 = true, 0); - this.rootDoc.searchIndex=NumCast(this.rootDoc.searchIndex); + this.rootDoc.searchIndex = NumCast(this.rootDoc.searchIndex); - this.length=NumCast(this.rootDoc!.length); + this.length = NumCast(this.rootDoc!.length); } - @observable length:number|undefined = 0; + @observable length: number | undefined = 0; highlightDoc = (e: React.PointerEvent) => { if (this.rootDoc!.type === DocumentType.LINK) { @@ -402,9 +404,9 @@ export class SearchItem extends ViewBoxBaseComponent this.layoutDoc._viewType === CollectionViewType.Stacking ? this.searchItemTemplate: undefined; + childLayoutTemplate = () => this.layoutDoc._viewType === CollectionViewType.Stacking ? this.searchItemTemplate : undefined; getTransform = () => { - return this.props.ScreenToLocalTransform().translate(-5, -65);// listBox padding-left and pres-box-cont minHeight + return this.props.ScreenToLocalTransform().translate(-5, -65);// listBox padding-left and pres-box-cont minHeight } panelHeight = () => { return this.props.PanelHeight(); @@ -413,60 +415,60 @@ export class SearchItem extends ViewBoxBaseComponent{ - if (StrCast(this.rootDoc.bucketfield)!=="results"){ - SearchBox.Instance._icons=[StrCast(this.rootDoc.bucketfield)]; - SearchBox.Instance._icons=SearchBox.Instance._icons; - } - else{ - SearchBox.Instance._icons=SearchBox.Instance._allIcons; - } - SearchBox.Instance.expandedBucket= true; - SearchBox.Instance.submitSearch(); - }) + newsearch() { + runInAction(() => { + if (StrCast(this.rootDoc.bucketfield) !== "results") { + SearchBox.Instance._icons = [StrCast(this.rootDoc.bucketfield)]; + SearchBox.Instance._icons = SearchBox.Instance._icons; + } + else { + SearchBox.Instance._icons = SearchBox.Instance._allIcons; + } + SearchBox.Instance.submitSearch(); + }) } - + @action - returnLines(){ - if ((Cast(this.rootDoc.lines, listSpec("string")))!.length>1){ - if (!this._displayLines) { - console.log(Cast(this.rootDoc.lines, listSpec("string"))); - return
{ - this._displayLines = !this._displayLines; - //this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE); - })} - //onPointerEnter={action(() => this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE))} - > - {Cast(this.rootDoc.lines, listSpec("string"))!.filter((m, i) => i).map((l, i) =>
{l}
)} -
;; + returnLines() { + if ((Cast(this.rootDoc.lines, listSpec("string")))!.length > 1) { + if (!this._displayLines) { + console.log(Cast(this.rootDoc.lines, listSpec("string"))); + return
{ + this._displayLines = !this._displayLines; + //this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE); + })} + //onPointerEnter={action(() => this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE))} + > + {Cast(this.rootDoc.lines, listSpec("string"))!.filter((m, i) => i).map((l, i) =>
{l}
)} +
;; + } } } - } - + //this._displayDim = Number(SEARCH_THUMBNAIL_SIZE); @observable _displayLines: boolean = true; - returnButtons(){ + returnButtons() { return
-
{ this.rootDoc!.type === DocumentType.PDF? this._displayLines = !this._displayLines : null; - })}> - {this.rootDoc!.type === DocumentType.PDF?"Expand Lines": null} - {NumCast(this.rootDoc!.length)>1?`Instance ${NumCast(this.rootDoc.searchIndex)===0? NumCast(this.rootDoc.length):NumCast(this.rootDoc.searchIndex) } of ${NumCast(this.rootDoc.length)}`: null} - - -
-
-
- {this.returnLines()} -
-
+
{ + this.rootDoc!.type === DocumentType.PDF ? this._displayLines = !this._displayLines : null; + })}> + {this.rootDoc!.type === DocumentType.PDF ? "Expand Lines" : null} + {NumCast(this.rootDoc!.length) > 1 ? `Instance ${NumCast(this.rootDoc.searchIndex) === 0 ? NumCast(this.rootDoc.length) : NumCast(this.rootDoc.searchIndex)} of ${NumCast(this.rootDoc.length)}` : null} + + +
+
+
+ {this.returnLines()} +
+
} @@ -476,79 +478,79 @@ export class SearchItem extends ViewBoxBaseComponent - + } - if (this.rootDoc.isBucket === true){ - this.props.Document._viewType=CollectionViewType.Stacking; - this.props.Document._chromeStatus='disabled'; - this.props.Document._height=this.rootDoc._height; + if (this.rootDoc.isBucket === true) { + this.props.Document._viewType = CollectionViewType.Stacking; + this.props.Document._chromeStatus = 'disabled'; + this.props.Document._height = this.rootDoc._height; return
- -
} - else if (this.rootDoc.isBucket === false){ - this.props.Document._chromeStatus='disabled'; - return
+ else if (this.rootDoc.isBucket === false) { + this.props.Document._chromeStatus = 'disabled'; + return
-
-
No Search Results
-
+
+
No Search Results
+
} else { - return
-
-
-
-
{StrCast(this.rootDoc.title)}
-
- {this.rootDoc.highlighting? StrCast(this.rootDoc.highlighting).length ? "Matched fields:" + StrCast(this.rootDoc.highlighting) : Cast(this.rootDoc.lines, listSpec("string"))!.length ? Cast(this.rootDoc.lines, listSpec("string"))![0] : "":null}
-
- {NumCast(this.rootDoc.length) > 1 || this.rootDoc!.type === DocumentType.PDF?this.returnButtons(): null} + return
+
+
+
+
{StrCast(this.rootDoc.title)}
+
+ {this.rootDoc.highlighting ? StrCast(this.rootDoc.highlighting).length ? "Matched fields:" + StrCast(this.rootDoc.highlighting) : Cast(this.rootDoc.lines, listSpec("string"))!.length ? Cast(this.rootDoc.lines, listSpec("string"))![0] : "" : null}
+
+ {NumCast(this.rootDoc.length) > 1 || this.rootDoc!.type === DocumentType.PDF ? this.returnButtons() : null} +
+
+
+
+
{this.DocumentIcon()}
-
-
-
-
{this.DocumentIcon()}
-
- {/*
+ {/*
{(doc1 instanceof Doc && doc2 instanceof Doc) && this.rootDoc!.type === DocumentType.LINK ? : this.contextButton}
*/} -
-
; +
+
; } } } \ No newline at end of file -- cgit v1.2.3-70-g09d2