Allow the webapp to startup with an initial search query.

master
Pacman Ghost 3 years ago
parent 3d775f9b3c
commit c5c0249c70
  1. 2
      asl_rulebook2/webapp/startup.py
  2. 15
      asl_rulebook2/webapp/static/SearchPane.js

@ -40,7 +40,7 @@ def init_webapp():
def get_app_config():
"""Return the app config."""
result = {}
for key in [ "DISABLE_AUTO_SHOW_RULE_INFO" ]:
for key in [ "INITIAL_QUERY_STRING", "DISABLE_AUTO_SHOW_RULE_INFO" ]:
val = app.config.get( key )
if val is not None:
result[ key ] = parse_int( val, val )

@ -1,4 +1,4 @@
import { gMainApp, gEventBus } from "./MainApp.js" ;
import { gMainApp, gAppConfig, gEventBus } from "./MainApp.js" ;
import { findTargets, getPrimaryTarget, fixupSearchHilites } from "./utils.js" ;
// --------------------------------------------------------------------
@ -23,6 +23,19 @@ gMainApp.component( "search-box", {
<button @click="$emit('search',this.queryString)" ref="submit"> Go </button>
</div>`,
created() {
// check if we should start off with a query (for debugging porpoises)
gEventBus.on( "app-loaded", () => {
if ( gAppConfig.INITIAL_QUERY_STRING )
gEventBus.emit( "search-for", gAppConfig.INITIAL_QUERY_STRING ) ;
} ) ;
gEventBus.on( "search-for", (queryString) => {
// search for the specified query string
this.queryString = queryString ;
this.$refs.submit.click() ;
} ) ;
},
mounted: function() {
// initialize
$( this.$refs.queryString ).addClass( "ui-widget ui-state-default ui-corner-all" ) ;

Loading…
Cancel
Save