diff --git a/vasl_templates/main_window.py b/vasl_templates/main_window.py index 63f5e7d..e3c193c 100644 --- a/vasl_templates/main_window.py +++ b/vasl_templates/main_window.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" ) diff --git a/vasl_templates/web_channel.py b/vasl_templates/web_channel.py index 50c72b9..432749f 100644 --- a/vasl_templates/web_channel.py +++ b/vasl_templates/web_channel.py @@ -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 ) diff --git a/vasl_templates/webapp/static/main.js b/vasl_templates/webapp/static/main.js index 603a165..368efef 100644 --- a/vasl_templates/webapp/static/main.js +++ b/vasl_templates/webapp/static/main.js @@ -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 diff --git a/vasl_templates/webapp/static/snippets.js b/vasl_templates/webapp/static/snippets.js index 65c61ef..f7ad595 100644 --- a/vasl_templates/webapp/static/snippets.js +++ b/vasl_templates/webapp/static/snippets.js @@ -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 ) ; } diff --git a/vasl_templates/webapp/tests/test_scenario_persistence.py b/vasl_templates/webapp/tests/test_scenario_persistence.py index a98f661..928615b 100644 --- a/vasl_templates/webapp/tests/test_scenario_persistence.py +++ b/vasl_templates/webapp/tests/test_scenario_persistence.py @@ -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 )