Added the HELP tab.

master
Pacman Ghost 6 years ago
parent 798ae19f0d
commit 03e6295bd0
  1. 13
      vasl_templates/webapp/main.py
  2. 16
      vasl_templates/webapp/static/help/index.html
  3. BIN
      vasl_templates/webapp/static/images/help.png
  4. 24
      vasl_templates/webapp/static/main.js
  5. 9
      vasl_templates/webapp/templates/index.html
  6. 31
      vasl_templates/webapp/tests/test_help.py

@ -3,8 +3,7 @@
import os
import json
from flask import request, render_template
from flask import jsonify
from flask import request, render_template, jsonify, redirect, url_for
from vasl_templates.webapp import app
from vasl_templates.webapp.config.constants import DATA_DIR
@ -18,6 +17,16 @@ def main():
# ---------------------------------------------------------------------
@app.route( "/help" )
def show_help():
"""Show the help page."""
url = url_for( "static", filename="help/index.html" )
if request.args.get( "embedded" ):
url += "?embedded=1"
return redirect( url, code=302 )
# ---------------------------------------------------------------------
default_scenario = None
@app.route( "/default-scenario" )

@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title> VASL Templates </title>
<style>
* { margin: 0 ; padding: 0 }
</style>
</head>
<body>
This is the help page.
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

@ -35,6 +35,8 @@ $(document).ready( function () {
save_scenario: { label: "Save scenario", action: on_save_scenario },
separator: { type: "separator" },
template_pack: { label: "Load template pack", action: on_template_pack },
separator2: { type: "separator" },
show_help: { label: "Help", action: show_help },
} ) ;
// nb: we only show the popmenu on left click (not the normal right-click)
$menu.off( "contextmenu" ) ;
@ -589,3 +591,25 @@ function adjust_footer_vspacers()
} ) ;
}
// --------------------------------------------------------------------
function show_help()
{
// check if we need to load the HELP tab
var $tab = $("#tabs-help") ;
if ( $tab.find( "iframe" ).length === 0 ) {
// yup - make it so
// NOTE: We show the help in an iframe so that we can use the same files elsewhere e.g. on the web site or Github.
var buf = [ "<iframe src='" + gHelpUrl + "?embedded=1'",
" style='width:100%;height:100%;border:none;'",
">",
"</iframe>"
] ;
$tab.append( buf.join("") ) ;
$("#tabs .ui-tabs-tab[aria-controls='tabs-help']").show() ;
}
// show the HELP tab
$("#tabs a[href='#tabs-help']").click() ;
}

@ -35,6 +35,7 @@
<li> <a href="#tabs-scenario"><img src="{{url_for('static',filename='images/scenario.png')}}">&nbsp;Scenario</a>
<li> <a href="#tabs-ob1"><div style="width:7em;">&nbsp;</div></a>
<li> <a href="#tabs-ob2"><div style="width:7em;">&nbsp;</div></a>
<li style="display:none;"> <a href="#tabs-help"><img src="{{url_for('static',filename='images/help.png')}}">&nbsp;Help</a>
</ul>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
@ -240,6 +241,13 @@
<div id="tabs-ob2"> <!-- nb: this will be created dynamically from the OB1 tab -->
</div>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<div id="tabs-help">
</div>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
</div>
<div id="watermark" style="display:none;">
@ -282,6 +290,7 @@ gGetTemplatePackUrl = "{{url_for('get_template_pack')}}" ;
gGetDefaultScenarioUrl = "{{url_for('get_default_scenario')}}" ;
gVehicleListingsUrl = "{{url_for('get_vehicle_listings')}}" ;
gOrdnanceListingsUrl = "{{url_for('get_ordnance_listings')}}" ;
gHelpUrl = "{{url_for('show_help')}}" ;
</script>
<script src="{{url_for('static',filename='main.js')}}"></script>
<script src="{{url_for('static',filename='snippets.js')}}"></script>

@ -0,0 +1,31 @@
""" Test the help page. """
from vasl_templates.webapp.tests.utils import \
init_webapp, select_menu_option, find_child, find_children
# ---------------------------------------------------------------------
def test_help( webapp, webdriver ):
"""Test the help page."""
# initialize
init_webapp( webapp, webdriver )
# make sure the HELP tab is not visible
def get_tabs():
"""Get the visible tabs."""
return [
c.get_attribute( "aria-controls" )
for c in find_children( "#tabs .ui-tabs-tab" )
if c.is_displayed()
]
assert "tabs-help" not in get_tabs()
# show the help
select_menu_option( "show_help" )
webdriver.switch_to.frame( find_child( "#tabs-help iframe" ) )
assert "This is the help page." in webdriver.page_source
webdriver.switch_to.default_content()
# make sure that the HELP tab is now visible
assert "tabs-help" in get_tabs()
Loading…
Cancel
Save