Show the scenario ID in the window title.

master
Pacman Ghost 5 years ago
parent c102413d9c
commit 5c0136030e
  1. 6
      vasl_templates/main_window.py
  2. 4
      vasl_templates/web_channel.py
  3. 7
      vasl_templates/webapp/static/main.js
  4. 22
      vasl_templates/webapp/static/snippets.js
  5. 4
      vasl_templates/webapp/tests/test_scenario_persistence.py

@ -298,9 +298,9 @@ class MainWindow( QWidget ):
@pyqtSlot( str )
@catch_exceptions( caption="SLOT EXCEPTION" )
def on_scenario_name_change( self, val ):
"""Update the main window title to show the scenario name."""
self._web_channel_handler.on_scenario_name_change( val )
def on_scenario_details_change( self, val ):
"""Update the main window title to show the scenario details."""
self._web_channel_handler.on_scenario_details_change( val )
@pyqtSlot( str )
@catch_exceptions( caption="SLOT EXCEPTION" )

@ -53,8 +53,8 @@ class WebChannelHandler:
return None
return self.scenario_file_dialog.curr_fname
def on_scenario_name_change( self, val ):
"""Update the main window title to show the scenario name."""
def on_scenario_details_change( self, val ):
"""Update the main window title to show the scenario details."""
self.parent.setWindowTitle(
"{} - {}".format( APP_NAME, val ) if val else APP_NAME
)

@ -319,9 +319,12 @@ $(document).ready( function () {
.attr( "title", "Edit the template." )
.button( {} ) ;
// watch for changes to the scenario name
// watch for changes to the scenario details
$("input[name='SCENARIO_NAME']").on( "input propertychange paste", function() {
on_scenario_name_change() ;
on_scenario_details_change() ;
} ) ;
$("input[name='SCENARIO_ID']").on( "input propertychange paste", function() {
on_scenario_details_change() ;
} ) ;
// adjust the layout on resize

@ -1334,7 +1334,7 @@ function do_load_scenario_data( params )
// update the UI
$("#tabs").tabs( "option", "active", 0 ) ;
on_scenario_name_change() ;
on_scenario_details_change() ;
on_scenario_date_change() ;
}
@ -1806,13 +1806,23 @@ function on_scenario_date_change()
// --------------------------------------------------------------------
function on_scenario_name_change()
function on_scenario_details_change()
{
// update the document title to include the scenario name
var val = $("input[name='SCENARIO_NAME']").val().trim() ;
document.title = (val.length > 0) ? gAppName+" - "+val : gAppName ;
// update the document title to include the scenario details
var scenario_name = $("input[name='SCENARIO_NAME']").val().trim() ;
var scenario_id = $("input[name='SCENARIO_ID']").val().trim() ;
var caption = "" ;
if ( scenario_name && scenario_id )
caption = scenario_name + " (" + scenario_id + ")" ;
else if ( scenario_name )
caption = scenario_name ;
else if ( scenario_id )
caption = scenario_id ;
document.title = gAppName ;
if ( caption )
document.title += " - " + caption ;
// notify the PyQt wrapper application
if ( gWebChannelHandler )
gWebChannelHandler.on_scenario_name_change( val ) ;
gWebChannelHandler.on_scenario_details_change( caption ) ;
}

@ -108,7 +108,7 @@ def test_scenario_persistence( webapp, webdriver ): #pylint: disable=too-many-st
},
}
load_scenario_params( SCENARIO_PARAMS )
check_window_title( "my test scenario" )
check_window_title( "my test scenario (xyz123)" )
check_ob_tabs( "russian", "german" )
assert_scenario_params_complete( SCENARIO_PARAMS, True )
@ -180,7 +180,7 @@ def test_scenario_persistence( webapp, webdriver ): #pylint: disable=too-many-st
# load a scenario and make sure it was loaded into the UI correctly
load_scenario( saved_scenario )
check_window_title( "my test scenario" )
check_window_title( "my test scenario (xyz123)" )
check_ob_tabs( "russian", "german" )
for tab_id in SCENARIO_PARAMS:
select_tab( tab_id )

Loading…
Cancel
Save