diff options
author | Andy Rickert <andrew_rickert@brown.edu> | 2020-04-22 14:40:45 -0700 |
---|---|---|
committer | Andy Rickert <andrew_rickert@brown.edu> | 2020-04-22 14:40:45 -0700 |
commit | d2884635f82f28e75c69ca25919800c9cd91f925 (patch) | |
tree | 25af39c2a36eec9f3ebd8f9d7d5524723396e2cb /src | |
parent | 0e192cd810be35c9c81cd93e8f4d550d8fe02d59 (diff) |
scripting buttons
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/search/SearchBox.scss | 8 | ||||
-rw-r--r-- | src/client/views/search/SearchBox.tsx | 71 | ||||
-rw-r--r-- | src/new_fields/Doc.ts | 10 |
3 files changed, 72 insertions, 17 deletions
diff --git a/src/client/views/search/SearchBox.scss b/src/client/views/search/SearchBox.scss index e3b3de898..af67f466c 100644 --- a/src/client/views/search/SearchBox.scss +++ b/src/client/views/search/SearchBox.scss @@ -103,14 +103,14 @@ .filter-header { - display: flex; + //display: flex; position: relative; - flex-wrap:wrap; + //flex-wrap:wrap; right: 1px; color: grey; - flex-direction: row-reverse; + //flex-direction: row-reverse; transform-origin: top; - justify-content: space-evenly; + //justify-content: space-evenly; margin-bottom: 5px; overflow:hidden; transition:height 0.3s ease-out; diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index f5be4f5aa..a33cb1e06 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -29,6 +29,7 @@ import { List } from '../../../new_fields/List'; import { faSearch, faFilePdf, faFilm, faImage, faObjectGroup, faStickyNote, faMusic, faLink, faChartBar, faGlobeAsia, faBan, faVideo, faCaretDown } from '@fortawesome/free-solid-svg-icons'; import { Transform } from '../../util/Transform'; import { MainView } from "../MainView"; +import { Scripting } from '../../util/Scripting'; library.add(faTimes); @@ -758,6 +759,44 @@ export class SearchBox extends React.Component<SearchProps> { return (null); } + @computed get defaultButtons() { + const defBtns = this.props.Document.defaultButtons; + let width = () => NumCast(this.props.Document.width); + if (this.props.sideBar===true){ + width = MainView.Instance.flyoutWidthFunc; + } + if (defBtns instanceof Doc) { + return <div id="hi" style={{height:"35px",}}> + <DocumentView + Document={defBtns} + DataDoc={undefined} + LibraryPath={emptyPath} + addDocument={undefined} + addDocTab={returnFalse} + rootSelected={returnTrue} + pinToPres={emptyFunction} + onClick={undefined} + removeDocument={undefined} + ScreenToLocalTransform={Transform.Identity} + ContentScaling={returnOne} + PanelWidth={width} + PanelHeight={() => 100} + renderDepth={0} + backgroundColor={returnEmptyString} + focus={emptyFunction} + parentActive={returnTrue} + whenActiveChanged={emptyFunction} + bringToFront={emptyFunction} + ContainingCollectionView={undefined} + ContainingCollectionDoc={undefined} + NativeHeight={()=>100} + NativeWidth={width} + /> + </div>; + } + return (null); + } + setupDocTypeButtons() { let doc = this.props.Document; const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({ ...opts, @@ -793,7 +832,7 @@ export class SearchBox extends React.Component<SearchProps> { fontSize: 7, }))as any as Doc; doc.title=button({ title: "Title", onClick:ScriptField.MakeScript("this.updateTitleStatus")}); - doc.deleted=button({ title: "Deleted", onClick:ScriptField.MakeScript(`this.handleNodeChange()`)}); + doc.deleted=button({ title: "Deleted", onClick:ScriptField.MakeScript(`handleNodeChange()`)}); doc.author = button({ title: "Author", onClick:ScriptField.MakeScript("this.updateTitleStatus")}); let buttons = [doc.title as Doc, doc.deleted as Doc, doc.author as Doc]; @@ -812,17 +851,15 @@ export class SearchBox extends React.Component<SearchProps> { borderRounding: "16px", border:"1px solid grey", color:"white", hovercolor: "rgb(170, 170, 163)", letterSpacing: "2px", fontSize: 7, }))as any as Doc; - doc.title=button({ title: "Title", onClick:ScriptField.MakeScript("this.updateTitleStatus")}); - doc.deleted=button({ title: "Deleted", onClick:ScriptField.MakeScript(`this.handleNodeChange`)}); + doc.keywords=button({ title: "Keywords", onClick:ScriptField.MakeScript("handleNodeChange(this)")}); + doc.keys=button({ title: "Keys", onClick:ScriptField.MakeScript(`this.handleNodeChange`)}); doc.nodes = button({ title: "Nodes", onClick:ScriptField.MakeScript("this.updateTitleStatus")}); - - let buttons = [doc.title as Doc, doc.deleted as Doc, doc.author as Doc]; - + let buttons = [doc.keywords as Doc, doc.keys as Doc, doc.nodes as Doc]; const dragCreators = Docs.Create.MasonryDocument(buttons, { - _width: 500, backgroundColor:"#121721", _autoHeight: true, columnWidth: 50, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons",_yMargin: 5 + _width: 500, backgroundColor:"#121721", _autoHeight: true, columnWidth: 60, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons",_yMargin: 5 //dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), }); - doc.keyButtons= dragCreators; + doc.defaultButtons= dragCreators; } render() { @@ -841,9 +878,10 @@ export class SearchBox extends React.Component<SearchProps> { <div id={`filterhead${this.props.id}`} className="filter-form" style={this._filterOpen && this._numTotalResults >0 ? {overflow:"visible"} : {overflow:"hidden"}}> <div id={`filterhead2${this.props.id}`} className="filter-header" > - <button className="filter-item" style={this._basicWordStatus ? { background: "#aaaaa3", } : {}} onClick={this.handleWordQueryChange}>Keywords</button> + {this.defaultButtons} + {/* <button className="filter-item" style={this._basicWordStatus ? { background: "#aaaaa3", } : {}} onClick={this.handleWordQueryChange}>Keywords</button> <button className="filter-item" style={this._keyStatus ? { background: "#aaaaa3" } : {}} onClick={this.handleKeyChange}>Keys</button> - <button className="filter-item" style={this._nodeStatus ? { background: "#aaaaa3" } : {}} onClick={this.handleNodeChange}>Nodes</button> + <button className="filter-item" style={this._nodeStatus ? { background: "#aaaaa3" } : {}} onClick={this.handleNodeChange}>Nodes</button> */} </div> <div id={`node${this.props.id}`} className="filter-body" style={this._nodeStatus ? { borderTop: "grey 1px solid" } : { borderTop: "0px" }}> {this.docButtons} @@ -853,7 +891,7 @@ export class SearchBox extends React.Component<SearchProps> { {/* <button className="filter-item" style={this._titleFieldStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateTitleStatus}>Title</button> <button className="filter-item" style={this._deletedDocsStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateDataStatus}>Deleted Docs</button> <button className="filter-item" style={this._authorFieldStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateAuthorStatus}>Author</button> */} - {this.keyButtons} + {this.keyButtons} </div> </div> <div className="searchBox-results" onScroll={this.resultsScrolled} style={{ @@ -866,4 +904,13 @@ export class SearchBox extends React.Component<SearchProps> { </div> ); } -}
\ No newline at end of file +} + +// Scripting.addGlobal(function handleNodeChange(doc: any) { +// console.log("oi"); +// doc.handleNodeChange(); + +// // const dv = DocumentManager.Instance.getDocumentView(doc); +// // if (dv?.props.Document.layoutKey === layoutKey) dv?.switchViews(otherKey !== "layout", otherKey.replace("layout_", "")); +// // else dv?.switchViews(true, layoutKey.replace("layout_", "")); +// });
\ No newline at end of file diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index bcf0d1aec..c54806f37 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -918,4 +918,12 @@ Scripting.addGlobal(function selectedDocs(container: Doc, excludeCollections: bo return docs.length ? new List(docs) : prevValue; }); Scripting.addGlobal(function setDocFilter(container: Doc, key: string, value: any, modifiers?: "check" | "x" | undefined) { Doc.setDocFilter(container, key, value, modifiers); }); -Scripting.addGlobal(function setDocFilterRange(container: Doc, key: string, range: number[]) { Doc.setDocFilterRange(container, key, range); });
\ No newline at end of file +Scripting.addGlobal(function setDocFilterRange(container: Doc, key: string, range: number[]) { Doc.setDocFilterRange(container, key, range); }); +Scripting.addGlobal(function handleNodeChange(doc: any) { + console.log("oi"); + doc.handleNodeChange(); + + // const dv = DocumentManager.Instance.getDocumentView(doc); + // if (dv?.props.Document.layoutKey === layoutKey) dv?.switchViews(otherKey !== "layout", otherKey.replace("layout_", "")); + // else dv?.switchViews(true, layoutKey.replace("layout_", "")); +});
\ No newline at end of file |