Completely hide the UI controls if there are no vehicles/ordnance.

master
Pacman Ghost 2 years ago
parent dad7dab770
commit 0cbe6435cf
  1. 14
      vasl_templates/webapp/static/main.js
  2. 4
      vasl_templates/webapp/tests/test_vehicles_ordnance.py
  3. 30
      vasl_templates/webapp/tests/test_vo_notes.py

@ -802,13 +802,15 @@ function on_player_change( player_no )
$( "#ob_ordnance-sortable_" + player_no ).sortable2( "delete-all" ) ;
$("input[name='OB_ORDNANCE_WIDTH_"+player_no+"']").val( "" ) ;
// enable/disable the "add vehicle/ordnance" buttons
// disable the vehicles/ordnance panels if none are available
function update_add_vo_button( vo_type ) {
if ( ! gVehicleOrdnanceListings[ vo_type ] )
return ;
$( "#ob_"+vo_type+"-add_"+player_no ).button(
gVehicleOrdnanceListings[vo_type][player_nat] ? "enable": "disable"
) ;
var $panel = $( "#panel-ob_" + vo_type + "_" + player_no ) ;
if ( gVehicleOrdnanceListings[ vo_type ] !== undefined && gVehicleOrdnanceListings[vo_type][ player_nat ] !== undefined ) {
$panel.find( ".footer" ).show() ;
} else {
$panel.find( ".footer" ).hide() ;
$panel.find( ".sortable-hint" ).html( "There are no " + vo_type + " available." ) ;
}
}
update_add_vo_button( "vehicles" ) ;
update_add_vo_button( "ordnance" ) ;

@ -415,10 +415,10 @@ def test_common_vo( webapp, webdriver ): #pylint: disable=too-many-locals
# check if the nationality has any vehicles/ordnance
elem = find_child( "#ob_{}-add_1".format( vo_type ) )
if nat in ["thai","indonesian","anzac","burmese","filipino"]: # nb: these are in the BFP extension
assert not elem.is_enabled()
assert not elem.is_displayed()
continue
if nat == "kfw-cpva" and vo_type == "vehicles":
assert not elem.is_enabled()
assert not elem.is_displayed()
continue
if nat == "partisan":
continue

@ -447,29 +447,29 @@ def test_update_ui( webapp, webdriver ):
webapp.control_tests.set_vo_notes_dir( "{TEST}" )
init_webapp( webapp, webdriver )
def do_test( nat, veh_expected, ord_expected ):
def do_test( nat, veh_expected, ord_expected, ma_veh_expected, ma_ord_expected ):
"""Do the test."""
# set the specified player
set_player( 1, nat )
select_tab( "ob1" )
# check that the Multi-Applicable Notes controls are visible/hidden
# check that the controls are visible/hidden
fieldset = find_child( "#tabs-ob1 fieldset[name='ob_vehicles_1']" )
assert find_child( ".snippets-notes", fieldset ).is_displayed() == veh_expected
assert find_child( "label[for='ob']", fieldset ).is_displayed() == veh_expected
assert find_child( ".snippets-ob", fieldset ).is_displayed() == veh_expected
assert find_child( ".snippets-notes", fieldset ).is_displayed() == ma_veh_expected
assert find_child( "label[for='ob']", fieldset ).is_displayed() == ma_veh_expected
fieldset = find_child( "#tabs-ob1 fieldset[name='ob_ordnance_1']" )
assert find_child( ".snippets-notes", fieldset ).is_displayed() == ord_expected
assert find_child( "label[for='ob']", fieldset ).is_displayed() == ord_expected
# the OB snippet controls should always be visible
assert find_child( ".snippets-ob", fieldset ).is_displayed()
assert find_child( ".snippets-ob", fieldset ).is_displayed() == ord_expected
assert find_child( ".snippets-notes", fieldset ).is_displayed() == ma_ord_expected
assert find_child( "label[for='ob']", fieldset ).is_displayed() == ma_ord_expected
# do the tests
do_test( "german", True, True )
do_test( "russian", True, True )
do_test( "british", True, False )
do_test( "french", False, True )
do_test( "finnish", False, False )
do_test( "dutch", True, True ) # nb: because they are Allied Minor
do_test( "romanian", True, True ) # nb: because they are Axis Minor
do_test( "german", True, True, True, True )
do_test( "russian", True, True, True, True )
do_test( "british", True, True, True, False )
do_test( "french", False, False, False, False )
do_test( "finnish", False, False, False, False )
do_test( "dutch", True, True, True, True ) # nb: because they are Allied Minor
do_test( "romanian", True, True, True, True ) # nb: because they are Axis Minor
# ---------------------------------------------------------------------

Loading…
Cancel
Save