Disable snippet-width textbox's when disabling snippet buttons.

master
Pacman Ghost 2 years ago
parent e479bf2a76
commit feebe9f63c
  1. 15
      vasl_templates/webapp/static/main.js
  2. 5
      vasl_templates/webapp/static/snippets.js
  3. 13
      vasl_templates/webapp/tests/test_template_packs.py

@ -795,9 +795,20 @@ function install_template_pack( data )
if ( template_id.match( /^ob_(vehicles|ordnance).*_[12]$/ ) )
template_id = template_id.substring( 0, template_id.length-2 ) ;
var enable = is_template_available( template_id ) ;
if ( $btn.parent().hasClass( "snippet-control" ) )
if ( $btn.parent().hasClass( "snippet-control" ) ) {
$btn.parent().controlgroup( enable ? "enable" : "disable" ) ;
else
// check if there's a corresponding "snippet-width" textbox
var sel = $btn.attr( "data-id" ) ;
if ( sel.match( /_[12]$/ ) )
sel = sel.substr( 0, sel.length-2 ) + "_width" + sel.substr( sel.length-2 ) ;
else
sel += "_width" ;
var $width = $( "input.snippet-width[name='" + sel.toUpperCase() + "']" ) ;
if ( $width.length > 0 ) {
// yup - update it as well
$width.val( "" ).prop( "disabled", !enable ) ;
}
} else
$btn.button( enable ? "enable": "disable" ) ;
}
$( "button.generate" ).each( function() { update_button( $(this) ) ; } ) ;

@ -1733,7 +1733,10 @@ function do_load_scenario_data( params )
}
}
else {
$elem.val( params[key] ) ;
if ( $elem.prop( "disabled" ) )
$elem.val( "" ) ;
else
$elem.val( params[key] ) ;
if ( key === "ASA_ID" )
updateForConnectedScenario( params[key], params.ROAR_ID ) ;
}

@ -204,13 +204,13 @@ def test_missing_templates( webapp, webdriver ):
# check the UI state of the next button
template_id = adjust_template_id( btn.get_attribute( "data-id" ) )
if fname == "national-capabilities.json":
expected = False # nb: this is the JSON file, not the template file, and so doesn't effect buttons
expected = False # nb: this is the JSON file, not the template file, and so doesn't affect buttons
elif fname == "nat_caps.j2":
expected = template_id.startswith( "nat_caps_" )
else:
expected = os.path.splitext( fname )[0] == template_id
disabled = webdriver.execute_script( "return $(arguments[0]).button('option','disabled')", btn )
assert expected == disabled
assert disabled == expected
# check that snippet control groups have been enabled/disabled correctly
parent = btn.find_element( By.XPATH, ".." )
parent_classes = get_css_classes( parent )
@ -224,6 +224,15 @@ def test_missing_templates( webapp, webdriver ):
assert "ui-selectmenu-disabled" not in elem_classes
else:
assert "snippet-control" not in parent_classes
# check if the button has an associated "snippet-width" textbox
sel = btn.get_attribute( "data-id" )
if sel.endswith( ( "_1", "_2" ) ):
sel = sel[:-2] + "_width" + sel[-2:]
else:
sel = sel + "_width"
elem = find_child( "input.snippet-width[name='{}']".format( sel.upper() ) )
if elem:
assert not elem.is_enabled() == expected
# upload the template pack, with one file missing each time
for fname in files:

Loading…
Cancel
Save