Added permalinks for the menu items.

master
Pacman Ghost 4 years ago
parent 2517d27dc8
commit aadc5dc0b2
  1. 45
      web/src/App.js
  2. 9
      web/src/index.js

@ -78,18 +78,9 @@ export class App extends React.Component
const menu = ( <Menu id="app">
<MenuButton />
<MenuList>
<MenuItem id="menu-show-publishers"
onSelect = { () => this.runSpecialSearch( "/search/publishers", null,
() => { this.setWindowTitle( "All publishers" ) }
) } > Show publishers </MenuItem>
<MenuItem id="menu-search-technique"
onSelect = { () => this.runSpecialSearch( "/search/tag/technique", {randomize:1},
() => { this.setWindowTitle( "Technique" ) }
) } > Show technique </MenuItem>
<MenuItem id="menu-search-tips"
onSelect = { () => this.runSpecialSearch( "/search/tag/tips", {randomize:1},
() => { this.setWindowTitle( "Tips" ) }
) } > Show tips </MenuItem>
<MenuItem id="menu-show-publishers" onSelect={this._showPublishers.bind(this)}> Show publishers </MenuItem>
<MenuItem id="menu-search-technique" onSelect={this._showTechniqueArticles.bind(this)}> Show technique </MenuItem>
<MenuItem id="menu-search-tips" onSelect={this._showTipsArticles.bind(this)}> Show tips </MenuItem>
<div className="divider" />
<MenuItem id="menu-new-publisher"
onSelect = { () => PublisherSearchResult.onNewPublisher( this._onNewPublisher.bind(this) ) }
@ -231,13 +222,6 @@ export class App extends React.Component
}
this._doSearch( "/search", { query: query } ) ;
}
runSpecialSearch( url, args, onDone ) {
// run the search
this._searchFormRef.current.setState( { queryString: "" } ) ;
if ( ! args )
args = {} ;
this._doSearch( url, args, onDone ) ;
}
_doSearch( url, args, onDone ) {
// do the search
this.setWindowTitle( null ) ;
@ -258,6 +242,29 @@ export class App extends React.Component
} ) ;
}
runSpecialSearch( url, args, onDone ) {
// run the search
this._searchFormRef.current.setState( { queryString: "" } ) ;
if ( ! args )
args = {} ;
this._doSearch( url, args, onDone ) ;
}
_showPublishers() {
this.runSpecialSearch( "/search/publishers", null,
() => { this.setWindowTitle( "All publishers" ) }
)
}
_showTechniqueArticles() {
this.runSpecialSearch( "/search/tag/technique", {randomize:1},
() => { this.setWindowTitle( "Technique" ) }
)
}
_showTipsArticles() {
this.runSpecialSearch( "/search/tag/tips", {randomize:1},
() => { this.setWindowTitle( "Tips" ) }
)
}
_onNewPublisher( publ_id, vals ) { this._addNewSearchResult( vals, "publisher", "publ_id", publ_id ) ; }
_onNewPublication( pub_id, vals ) { this._addNewSearchResult( vals, "publication", "pub_id", pub_id ) ; }
_onNewArticle( article_id, vals ) { this._addNewSearchResult( vals, "article", "article_id", article_id ) ; }

@ -10,6 +10,15 @@ import "./index.css" ;
ReactDOM.render(
<BrowserRouter>
<Switch>
<Route path="/publishers" render={ (props) => <App {...props} key="publishers"
doSearch = { () => gAppRef._showPublishers() }
/> } />
<Route path="/technique" render={ (props) => <App {...props} key="technique"
doSearch = { () => gAppRef._showTechniqueArticles() }
/> } />
<Route path="/tips" render={ (props) => <App {...props} key="tips"
doSearch = { () => gAppRef._showTipsArticles() }
/> } />
<Route path="/publisher/:publId" render={ (props) => <App {...props} key={"publ:"+props.match.params.publId}
doSearch = { () => gAppRef.runSpecialSearch( "/search/publisher/"+gAppRef.props.match.params.publId, null,
() => gAppRef.setWindowTitleFromSearchResults( "publisher", "publ_id", gAppRef.props.match.params.publId, "publ_name" )

Loading…
Cancel
Save