diff options
| author | Andy Rickert <andrew_rickert@brown.edu> | 2020-04-15 20:02:58 -0700 |
|---|---|---|
| committer | Andy Rickert <andrew_rickert@brown.edu> | 2020-04-15 20:02:58 -0700 |
| commit | 1d5c4510dff326a0f12b914868ac8614ab460e83 (patch) | |
| tree | 7173f465175c6eb6b5bbfe96c932b49fd621f0b0 /src/client/views/search/SearchBox.tsx | |
| parent | c7c146adbd0b188eba56139ab914edaf73774d3f (diff) | |
| parent | e0f16b89cba102a4fcd156bb3d4148432eca2ab7 (diff) | |
merge
Diffstat (limited to 'src/client/views/search/SearchBox.tsx')
| -rw-r--r-- | src/client/views/search/SearchBox.tsx | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index 532b151c5..90f995a8c 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -125,9 +125,7 @@ export class SearchBox extends React.Component<SearchProps> { @action - getViews = async (doc: Doc) => { - return await SearchUtil.GetViewsOfDocument(doc); - } + getViews = (doc: Doc) => SearchUtil.GetViewsOfDocument(doc) @action.bound onChange(e: React.ChangeEvent<HTMLInputElement>) { @@ -166,23 +164,18 @@ export class SearchBox extends React.Component<SearchProps> { } } - public _allIcons: string[] = [DocumentType.AUDIO, DocumentType.COL, DocumentType.IMG, DocumentType.LINK, DocumentType.PDF, DocumentType.TEXT, DocumentType.VID, DocumentType.WEB, DocumentType.TEMPLATE]; + public _allIcons: string[] = [DocumentType.AUDIO, DocumentType.COL, DocumentType.IMG, DocumentType.LINK, DocumentType.PDF, DocumentType.RTF, DocumentType.VID, DocumentType.WEB]; //if true, any keywords can be used. if false, all keywords are required. //this also serves as an indicator if the word status filter is applied @observable private _filterOpen: boolean = false; //if icons = all icons, then no icon filter is applied @observable private _icons: string[] = this._allIcons; //if all of these are true, no key filter is applied - @observable private _anyKeywordStatus: boolean = true; - @observable private _allKeywordStatus: boolean = true; @observable private _titleFieldStatus: boolean = true; @observable private _authorFieldStatus: boolean = true; - @observable private _dataFieldStatus: boolean = true; //this also serves as an indicator if the collection status filter is applied @observable public _deletedDocsStatus: boolean = false; @observable private _collectionStatus = false; - @observable private _collectionSelfStatus = true; - @observable private _collectionParentStatus = true; getFinalQuery(query: string): string { @@ -223,7 +216,7 @@ export class SearchBox extends React.Component<SearchProps> { @action filterDocsByType(docs: Doc[]) { - if (this._icons.length === 9) { + if (this._icons.length === this._allIcons.length) { return docs; } const finalDocs: Doc[] = []; @@ -254,7 +247,7 @@ export class SearchBox extends React.Component<SearchProps> { } get filterTypes() { - return this._icons.length === 9 ? undefined : this._icons; + return this._icons.length === this._allIcons.length ? undefined : this._icons; } @action.bound @@ -332,7 +325,7 @@ export class SearchBox extends React.Component<SearchProps> { @action submitSearch = async () => { - let query = this._searchString; + const query = this._searchString; this.getFinalQuery(query); this._results = []; this._resultsSet.clear(); @@ -359,8 +352,10 @@ export class SearchBox extends React.Component<SearchProps> { private get filterQuery() { const types = this.filterTypes; - const includeDeleted = this.getDataStatus(); - return "NOT baseProto_b:true" + (includeDeleted ? "" : " AND NOT deleted_b:true") + (types ? ` AND (${types.map(type => `({!join from=id to=proto_i}type_t:"${type}" AND NOT type_t:*) OR type_t:"${type}" OR type_t:"extension"`).join(" ")})` : ""); + const includeDeleted = this.getDataStatus() ? "" : " AND NOT deleted_b:true"; + const includeIcons = this.getDataStatus() ? "" : " AND NOT type_t:fonticonbox"; + // fq: type_t:collection OR {!join from=id to=proto_i}type_t:collection q:text_t:hello + return "NOT baseProto_b:true" + includeDeleted + includeIcons + (types ? ` AND (${types.map(type => `({!join from=id to=proto_i}type_t:"${type}" AND NOT type_t:*) OR type_t:"${type}"`).join(" ")})` : ""); } getDataStatus() { return this._deletedDocsStatus; } @@ -569,10 +564,10 @@ export class SearchBox extends React.Component<SearchProps> { handleNodeChange = () => { this._nodeStatus = !this._nodeStatus; if (this._nodeStatus) { - this.expandSection(`node${this.props.id}`) + this.expandSection(`node${this.props.id}`); } else { - this.collapseSection(`node${this.props.id}`) + this.collapseSection(`node${this.props.id}`); } } @@ -608,13 +603,13 @@ export class SearchBox extends React.Component<SearchProps> { collapseSection(thing: string) { - let id = this.props.id; - let element = document.getElementById(thing)!; + const id = this.props.id; + const element = document.getElementById(thing)!; // get the height of the element's inner content, regardless of its actual size - var sectionHeight = element.scrollHeight; + const sectionHeight = element.scrollHeight; // temporarily disable all css transitions - var elementTransition = element.style.transition; + const elementTransition = element.style.transition; element.style.transition = ''; // on the next frame (as soon as the previous style change has taken effect), @@ -628,7 +623,7 @@ export class SearchBox extends React.Component<SearchProps> { // have the element transition to height: 0 requestAnimationFrame(function () { element.style.height = 0 + 'px'; - thing == `filterhead${id}` ? document.getElementById(`filterhead${id}`)!.style.padding = "0" : null; + thing === `filterhead${id}` ? document.getElementById(`filterhead${id}`)!.style.padding = "0" : null; }); }); @@ -638,12 +633,11 @@ export class SearchBox extends React.Component<SearchProps> { expandSection(thing: string) { console.log("expand"); - let element = document.getElementById(thing)!; + const element = document.getElementById(thing)!; // get the height of the element's inner content, regardless of its actual size - var sectionHeight = element.scrollHeight; + const sectionHeight = element.scrollHeight; // have the element transition to the height of its inner content - let temp = element.style.height; element.style.height = sectionHeight + 'px'; // when the next css transition finishes (which should be the one we just triggered) @@ -663,7 +657,7 @@ export class SearchBox extends React.Component<SearchProps> { } autoset(thing: string) { - let element = document.getElementById(thing)!; + const element = document.getElementById(thing)!; console.log("autoset"); element.removeEventListener('transitionend', function (e) { }); @@ -715,8 +709,8 @@ export class SearchBox extends React.Component<SearchProps> { bringToFront={emptyFunction} ContainingCollectionView={undefined} ContainingCollectionDoc={undefined} - zoomToScale={emptyFunction} - getScale={returnOne} + NativeHeight={()=>100} + NativeWidth={width} /> </div>; } @@ -725,10 +719,10 @@ export class SearchBox extends React.Component<SearchProps> { setupDocTypeButtons() { let doc = this.props.Document; - const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({ ...opts, dontDecorateSelection: true, backgroundColor: "#121721", dropAction: "alias", removeDropProperties: new List<string>(["dropAction"]), _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100 })) as any as Doc; + const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({ ...opts, backgroundColor: "#121721", dropAction: "alias", removeDropProperties: new List<string>(["dropAction"]), _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100 })) as any as Doc; const blist = (opts: DocumentOptions, docs: Doc[]) => new PrefetchProxy(Docs.Create.LinearDocument(docs, { ...opts, - _gridGap: 5, _xMargin: 5, _yMargin: 5, _height: 42, _width: 100, boxShadow: "0 0", dontDecorateSelection: true, forceActive: true, + _gridGap: 5, _xMargin: 5, _yMargin: 5, _height: 42, _width: 100, boxShadow: "0 0", forceActive: true, dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), backgroundColor: "black", treeViewPreventOpen: true, lockedPosition: true, _chromeStatus: "disabled", linearViewIsExpanded: true })) as any as Doc; |
