diff --git a/vasl_templates/webapp/static/snippets.js b/vasl_templates/webapp/static/snippets.js
index b3a0892..a127699 100644
--- a/vasl_templates/webapp/static/snippets.js
+++ b/vasl_templates/webapp/static/snippets.js
@@ -177,14 +177,14 @@ function make_snippet( $btn, params, extra_params, show_date_warnings )
var data = $btn.parent().parent().data( "sortable2-data" ) ;
var key = (vo_type === "vehicles") ? "VEHICLE" : "ORDNANCE" ;
params[ key + "_NAME" ] = data.vo_entry.name ;
- if ( data.vo_note.substr( 0, 7 ) === "http://" )
+ if ( data.vo_note.substr( 0, 7 ) === "http://" ) {
+ // the vehicle/ordnance note is an image - just include it directly
params[ key + "_NOTE_HTML" ] = '' ;
- else {
+ } else {
+ // the vehicle/ordnance is HTML - check if we should show it as HTML or as an image
if ( gUserSettings["vo-notes-as-images"] ) {
// show the vehicle/ordnance note as an image
- var nat = params[ "PLAYER_" + player_no ] ;
- var url = APP_URL_BASE + "/" + vo_type + "/" + nat + "/note/" + get_vo_note_key(data.vo_entry) ;
- params[ key + "_NOTE_HTML" ] = '' ;
+ params[ key + "_NOTE_HTML" ] = '' ;
} else {
// insert the raw HTML into the snippet
params[ key + "_NOTE_HTML" ] = data.vo_note ;
diff --git a/vasl_templates/webapp/static/vo.js b/vasl_templates/webapp/static/vo.js
index c596876..55bf7e1 100644
--- a/vasl_templates/webapp/static/vo.js
+++ b/vasl_templates/webapp/static/vo.js
@@ -166,13 +166,18 @@ function do_add_vo( vo_type, player_no, vo_entry, vo_image_id, elite, custom_cap
] ;
var vo_note_key = get_vo_note_key( vo_entry ) ;
var vo_note = get_vo_note( vo_type, nat, vo_note_key ) ;
- if ( ! vo_note ) {
+ var vo_note_image_url = null ;
+ if ( vo_note )
+ vo_note_image_url = APP_URL_BASE + "/" + vo_type + "/" + nat + "/note/" + vo_note_key ;
+ else {
// NOTE: Note numbers seem to be distinct across all Allied Minor or all Axis Minor vehicles/ordnance,
// so if we don't find a note in a given nationality's normal vehicles/ordnance, we can get away with
// just checking their corresponding common vehicles/ordnance.
var nat_type = gTemplatePack.nationalities[ nat ].type ;
if ( ["allied-minor","axis-minor"].indexOf( nat_type ) !== -1 ) {
vo_note = get_vo_note( vo_type, nat_type, vo_note_key ) ;
+ if ( vo_note )
+ vo_note_image_url = APP_URL_BASE + "/" + vo_type + "/" + nat_type + "/note/" + vo_note_key ;
}
}
if ( vo_note ) {
@@ -184,6 +189,7 @@ function do_add_vo( vo_type, player_no, vo_entry, vo_image_id, elite, custom_cap
) ;
}
data.vo_note = vo_note ;
+ data.vo_note_image_url = vo_note_image_url ;
}
buf.push( "" ) ;
var $content = $( buf.join("") ) ;
diff --git a/vasl_templates/webapp/tests/fixtures/vo-notes/allied-minor/vehicles/201.png b/vasl_templates/webapp/tests/fixtures/vo-notes/greek/vehicles/201.png
similarity index 100%
rename from vasl_templates/webapp/tests/fixtures/vo-notes/allied-minor/vehicles/201.png
rename to vasl_templates/webapp/tests/fixtures/vo-notes/greek/vehicles/201.png
diff --git a/vasl_templates/webapp/tests/fixtures/vo-notes/allied-minor/vehicles/202.html b/vasl_templates/webapp/tests/fixtures/vo-notes/greek/vehicles/202.html
similarity index 100%
rename from vasl_templates/webapp/tests/fixtures/vo-notes/allied-minor/vehicles/202.html
rename to vasl_templates/webapp/tests/fixtures/vo-notes/greek/vehicles/202.html
diff --git a/vasl_templates/webapp/tests/fixtures/vo-notes/allied-minor/vehicles/203.html b/vasl_templates/webapp/tests/fixtures/vo-notes/greek/vehicles/203.html
similarity index 100%
rename from vasl_templates/webapp/tests/fixtures/vo-notes/allied-minor/vehicles/203.html
rename to vasl_templates/webapp/tests/fixtures/vo-notes/greek/vehicles/203.html
diff --git a/vasl_templates/webapp/tests/fixtures/vo-notes/allied-minor/vehicles/203.png b/vasl_templates/webapp/tests/fixtures/vo-notes/greek/vehicles/203.png
similarity index 100%
rename from vasl_templates/webapp/tests/fixtures/vo-notes/allied-minor/vehicles/203.png
rename to vasl_templates/webapp/tests/fixtures/vo-notes/greek/vehicles/203.png
diff --git a/vasl_templates/webapp/tests/test_vo_notes.py b/vasl_templates/webapp/tests/test_vo_notes.py
index a0f157c..86638d1 100644
--- a/vasl_templates/webapp/tests/test_vo_notes.py
+++ b/vasl_templates/webapp/tests/test_vo_notes.py
@@ -11,7 +11,8 @@ import lxml.etree
import tabulate
from vasl_templates.webapp.tests.utils import \
- init_webapp, get_nationalities, select_tab, set_player, find_child, find_children, wait_for, wait_for_clipboard
+ init_webapp, get_nationalities, select_tab, set_player, select_menu_option, click_dialog_button, \
+ find_child, find_children, wait_for, wait_for_clipboard
from vasl_templates.webapp.tests.test_scenario_persistence import load_scenario, save_scenario
from vasl_templates.webapp.tests.test_vehicles_ordnance import add_vo, delete_vo
@@ -132,7 +133,7 @@ def test_ma_html_notes( webapp, webdriver ):
# check the snippets
_check_vo_snippets( 1, "vehicles", [
- ( "PNG note", "vehicles/allied-minor/note/201" ),
+ ( "PNG note", "vehicles/greek/note/201" ),
"HTML note:
\nThis is an HTML vehicle note (202).\n |
",
"PNG + HTML notes: \nThis is an HTML vehicle note (203).\n |
",
] )
@@ -175,6 +176,38 @@ def test_common_vo_notes( webapp, webdriver ):
( "common axis minor ordnance", "ordnance/axis-minor/note/104" ),
] )
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+def test_common_vo_notes2( webapp, webdriver ):
+ """Test handling of Allied/Axis Minor common vehicles/ordnance (as images)."""
+
+ # initialize
+ init_webapp( webapp, webdriver, scenario_persistence=1,
+ reset = lambda ct: ct.set_vo_notes_dir( dtype="test" )
+ )
+
+ # load the test scenario
+ load_scenario( {
+ "PLAYER_1": "greek",
+ "OB_VEHICLES_1": [
+ { "name": "HTML note" },
+ { "name": "common allied minor vehicle" },
+ ],
+ } )
+
+ # enable "show vehicle/ordnance notes as images"
+ select_menu_option( "user_settings" )
+ elem = find_child( ".ui-dialog.user-settings input[name='vo-notes-as-images']" )
+ assert not elem.is_selected()
+ elem.click()
+ click_dialog_button( "OK" )
+
+ # check the snippets
+ _check_vo_snippets( 1, "vehicles", [
+ ( "HTML note", "vehicles/greek/note/202" ),
+ ( "common allied minor vehicle", "vehicles/allied-minor/note/101" ),
+ ] )
+
# ---------------------------------------------------------------------
def test_extra_ma_notes( webapp, webdriver ):