diff --git a/vasl_templates/webapp/static/css/sortable.css b/vasl_templates/webapp/static/css/sortable.css index 5a414b2..f44b8c2 100644 --- a/vasl_templates/webapp/static/css/sortable.css +++ b/vasl_templates/webapp/static/css/sortable.css @@ -1,7 +1,6 @@ button.sortable-add { vertical-align: top ; height: 30px ; padding: 4px 10px ; } img.sortable-add { vertical-align: middle ; height: 15px ; margin-right: 0.25em ; } -.sortable { font-size: 80% ; } .sortable { list-style-type: none ; margin: 0 ; padding: 0 ; } .sortable li { margin-bottom: 2px ; padding: 5px ; } diff --git a/vasl_templates/webapp/static/css/tabs-ob.css b/vasl_templates/webapp/static/css/tabs-ob.css index a322f7c..8c4ab5e 100644 --- a/vasl_templates/webapp/static/css/tabs-ob.css +++ b/vasl_templates/webapp/static/css/tabs-ob.css @@ -2,6 +2,7 @@ .panel-ob_setups { height: 100% ; display: flex ; flex-direction: column ; } .panel-ob_setups .content { flex-grow: 1 ; } +.panel-ob_setups .sortable { font-size: 90% ; } .panel-ob_setups .footer { margin-top: 0.5em ; display: flex ; align-items: center ; } /* -------------------------------------------------------------------- */ @@ -14,17 +15,20 @@ .panel-ob_vehicles { height: 100% ; display: flex ; flex-direction: column ; } .panel-ob_vehicles .content { flex-grow: 1 ; } +.panel-ob_vehicles .sortable { font-size: 90% ; } .panel-ob_vehicles .footer { margin-top: 0.5em ; display: flex ; align-items: center ; } -.panel-ob_vehicles .sortable { font-size: 90% ; } -.panel-ob_vehicles .sortable img { display: inline-block ; vertical-align: middle ; height: 3.5em ; margin-right: 0.5em ; } +/* nb: the following CSS is shared by vehicles and ordnance */ +.panel-ob_vo .sortable .vo-entry { display: flex ; font-size: 90% ; } +.panel-ob_vo .sortable .vo-entry img.vasl-image { display: inline-block ; vertical-align: middle ; height: 3.5em ; margin-right: 0.5em ; } +.panel-ob_vo .sortable .vo-entry.small-piece img.vasl-image { height: 2.5em ; margin-left: 0.5em ; margin-right: 1em ; } +.panel-ob_vo .sortable .vo-entry .detail { flex-grow: 1 ; display: flex ; flex-direction: column ; justify-content: center ; } +.panel-ob_vo .sortable .vo-entry .detail .vo-name { font-size: 110% ; } +.panel-ob_vo .sortable .vo-entry .detail .vo-capabilities { max-height: 2.5em ; overflow: hidden ; font-size: 90% ; font-style: italic ; } +.panel-ob_vo .sortable .vo-entry .detail .vo-capability { margin-right: 0.5em ; color: #444 ; } /* -------------------------------------------------------------------- */ .panel-ob_ordnance { height: 100% ; display: flex ; flex-direction: column ; } .panel-ob_ordnance .content { flex-grow: 1 ; } .panel-ob_ordnance .footer { margin-top: 0.5em ; display: flex ; align-items: center ; } - -.panel-ob_ordnance .sortable { font-size: 90% ; } -.panel-ob_ordnance .sortable img { display: inline-block ; vertical-align: middle ; height: 3.5em ; margin-right: 0.5em ; } -.panel-ob_ordnance .sortable .small-piece img { height: 2.5em ; margin-left: 0.5em ; margin-right: 1em ; } diff --git a/vasl_templates/webapp/static/css/tabs-scenario.css b/vasl_templates/webapp/static/css/tabs-scenario.css index 3e32bd7..56d5950 100644 --- a/vasl_templates/webapp/static/css/tabs-scenario.css +++ b/vasl_templates/webapp/static/css/tabs-scenario.css @@ -24,11 +24,12 @@ #panel-scenario_notes { height: 100% ; display: flex ; flex-direction: column ; } #panel-scenario_notes .content { flex-grow: 1 ; } +#panel-scenario_notes .sortable { font-size: 90% ; } #panel-scenario_notes .footer { margin-top: 0.5em ; display: flex ; } /* -------------------------------------------------------------------- */ #panel-ssr { height: 100% ; display: flex ; flex-direction: column ; } #panel-ssr .content { flex-grow: 1 ; } - +#panel-ssr .sortable { font-size: 90% ; } #panel-ssr .footer { margin-top: 0.5em ; display: flex ; align-items: center ; } diff --git a/vasl_templates/webapp/static/snippets.js b/vasl_templates/webapp/static/snippets.js index 6bcdbc7..9737b9d 100644 --- a/vasl_templates/webapp/static/snippets.js +++ b/vasl_templates/webapp/static/snippets.js @@ -24,7 +24,7 @@ function generate_snippet( $btn, extra_params ) { // unload the template parameters var template_id = $btn.data( "id" ) ; - var params = unload_snippet_params( true ) ; + var params = unload_snippet_params( true, true ) ; // set player-specific parameters var curr_tab = $("#tabs .ui-tabs-active a").attr( "href" ) ; @@ -176,12 +176,12 @@ function generate_snippet( $btn, extra_params ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function unload_snippet_params( check_date_capabilities ) +function unload_snippet_params( unpack_scenario_date, show_warnings ) { var params = {} ; // extract the scenario date components - if ( check_date_capabilities ) { + if ( unpack_scenario_date ) { var scenario_date = $( "input[name='SCENARIO_DATE']" ).datepicker( "getDate" ) ; if ( scenario_date ) { params.SCENARIO_DAY_OF_MONTH = scenario_date.getDate() ; @@ -241,22 +241,22 @@ function unload_snippet_params( check_date_capabilities ) obj.capabilities = capabilities ; obj.custom_capabilities = capabilities.slice() ; } else { + // NOTE: We don't show warnings here; if there's something wrong, + // we will show the warnings when we make the raw capabilities. capabilities = make_capabilities( - vo_entry, - nat, - params.SCENARIO_THEATER, - params.SCENARIO_YEAR, params.SCENARIO_MONTH, check_date_capabilities, + false, + vo_entry, nat, + params.SCENARIO_THEATER, params.SCENARIO_YEAR, params.SCENARIO_MONTH, false ) ; if ( capabilities ) obj.capabilities = capabilities ; } capabilities = make_capabilities( - vo_entry, - nat, - params.SCENARIO_THEATER, - params.SCENARIO_YEAR, params.SCENARIO_MONTH, check_date_capabilities, - true + true, + vo_entry, nat, + params.SCENARIO_THEATER, params.SCENARIO_YEAR, params.SCENARIO_MONTH, + show_warnings ) ; if ( capabilities ) obj.raw_capabilities = capabilities ; @@ -275,7 +275,7 @@ function unload_snippet_params( check_date_capabilities ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function make_capabilities( vo_entry, nat, scenario_theater, scenario_year, scenario_month, check_date_capabilities, raw ) +function make_capabilities( raw, vo_entry, nat, scenario_theater, scenario_year, scenario_month, show_warnings ) { var capabilities = [] ; @@ -347,7 +347,7 @@ function make_capabilities( vo_entry, nat, scenario_theater, scenario_year, scen } } // check if there were any capabilities not set - if ( check_date_capabilities && indeterminate_caps.length > 0 ) { + if ( show_warnings && indeterminate_caps.length > 0 ) { showWarningMsg( makeBulletListMsg( "Can't determine capabilities without a scenario year:", indeterminate_caps @@ -893,7 +893,7 @@ function unload_params_for_save() } // unload the template parameters - var params = unload_snippet_params( false ) ; + var params = unload_snippet_params( false, false ) ; params.SCENARIO_NOTES = $("#scenario_notes-sortable").sortable2( "get-entry-data" ) ; params.OB_SETUPS_1 = $("#ob_setups-sortable_1").sortable2( "get-entry-data" ) ; params.OB_SETUPS_2 = $("#ob_setups-sortable_2").sortable2( "get-entry-data" ) ; @@ -1173,7 +1173,6 @@ function is_atmm_available() { return _is_scenario_after( 0, 1944 ) ; } function on_scenario_date_change() { - // update the UI // NOTE: We update the visual appearance of the buttons to indicate whether // the support weapons are available, but leave the buttons active since // the date restrictions are not strict, and the SW are sometimes available @@ -1189,6 +1188,17 @@ function on_scenario_date_change() update_ui( "psk", is_psk_available() ) ; update_ui( "baz", is_baz_available() ) ; update_ui( "atmm", is_atmm_available() ) ; + + var snippet_params = unload_snippet_params( true, false ) ; + function update_vo( $sortable2 ) { + $sortable2.children( "li" ).each( function() { + update_vo_sortable2_entry( $(this), snippet_params ) ; + } ) ; + } + for ( var player_no=1 ; player_no <= 2 ; ++player_no ) { + update_vo( $( "#ob_vehicles-sortable_" + player_no ) ) ; + update_vo( $( "#ob_ordnance-sortable_" + player_no ) ) ; + } } // -------------------------------------------------------------------- diff --git a/vasl_templates/webapp/static/utils.js b/vasl_templates/webapp/static/utils.js index eb60185..9aa6d74 100644 --- a/vasl_templates/webapp/static/utils.js +++ b/vasl_templates/webapp/static/utils.js @@ -15,12 +15,21 @@ function get_player_colors( player_no ) } function get_player_colors_for_element( $elem ) +{ + // get the player colors (if any) for the specified element + var player_no = get_player_no_for_element( $elem ) ; + if ( player_no === null ) + return null ; + return get_player_colors( player_no ) ; +} + +function get_player_no_for_element( $elem ) { // get the player colors (if any) for the specified element if ( $.contains( $("#tabs-ob1")[0], $elem[0] ) ) - return get_player_colors( 1 ) ; - else if ( $.contains( $("#tabs-ob2")[0], $elem[0] ) ) - return get_player_colors( 2 ) ; + return 1 ; + if ( $.contains( $("#tabs-ob2")[0], $elem[0] ) ) + return 2 ; return null ; } diff --git a/vasl_templates/webapp/static/vo.js b/vasl_templates/webapp/static/vo.js index bae11fd..60bb3f8 100644 --- a/vasl_templates/webapp/static/vo.js +++ b/vasl_templates/webapp/static/vo.js @@ -127,14 +127,13 @@ function do_add_vo( vo_type, player_no, vo_entry, vo_image_id, custom_capabiliti // NOTE: We set a fixed height for the sortable2 entries (based on the CSS settings in tabs-ob.css), // so that the vehicle/ordnance images won't get truncated if there are a lot of them. var $sortable2 = $( "#ob_" + vo_type + "-sortable_" + player_no ) ; - var div_tag = "