Allow chapter sections to link to a page.

master
Pacman Ghost 3 years ago
parent 4b56a726d2
commit c03872210b
  1. 2
      asl_rulebook2/webapp/static/ContentPane.js
  2. 9
      asl_rulebook2/webapp/static/NavPane.js
  3. 1
      asl_rulebook2/webapp/tests/fixtures/content-sets/content set 1.chapters
  4. 7
      asl_rulebook2/webapp/tests/test_content_sets.py
  5. 7
      asl_rulebook2/webapp/tests/utils.py

@ -171,7 +171,7 @@ gMainApp.component( "content-doc", {
} ; },
template: `
<div class="content-doc" :data-ruleid=ruleid >
<div class="content-doc" :data-ruleid=ruleid :data-pageno=pageNo >
<div v-if=noContent class="disabled">
<div style='margin-bottom:0.25em;'>&mdash;&mdash;&mdash; Content disabled &mdash;&mdash;&mdash; </div>
{{cdoc.title}}

@ -148,11 +148,16 @@ gMainApp.component( "nav-pane-chapters", {
onChapterEntryClicked( paneKey, entry ) {
// show the chapter entry's target
gEventBus.emit( "show-target", paneKey[0], entry.ruleid, true ) ;
if ( entry.ruleid )
gEventBus.emit( "show-target", paneKey[0], entry.ruleid, true ) ;
else if ( entry.page_no )
gEventBus.emit( "show-page", paneKey[0], entry.page_no, true ) ;
else
console.log( "ERROR: Don't know how to show chapter section:", entry ) ;
},
getEntryKey( entry ) { return entry.ruleid ; },
getEntryKey( entry ) { return entry.ruleid || entry.page_no ; },
makeBorderClass( chapter ) { return chapter[1].chapter_id ? "chapter-" + chapter[1].chapter_id.toLowerCase() : null ; },
},

@ -13,6 +13,7 @@
{ "caption": "Top of the page", "ruleid": "4a" },
{ "caption": "Middle of the page", "ruleid": "5a" },
{ "caption": "Bottom of the page", "ruleid": "6a" },
{ "caption": "Link to page 2", "page_no": 2 },
{ "caption": "No ruleid" }
]
}

@ -75,7 +75,7 @@ def test_chapters( webapp, webdriver ):
"entries": [ "Top of the page", "Middle of the page", "Bottom of the page" ]
},
{ "title": "Page 2",
"entries": [ "Top of the page", "Middle of the page", "Bottom of the page", "No ruleid" ]
"entries": [ "Top of the page", "Middle of the page", "Bottom of the page", "Link to page 2", "No ruleid" ]
},
{ "title": "Linked document - Page 1",
"entries": [ "Top of the page", "Middle of the page", "Bottom of the page" ]
@ -95,8 +95,8 @@ def test_chapters( webapp, webdriver ):
elems = find_children( "#accordian-chapters .accordian-pane" )
assert len(elems) == 6
elems = find_children( ".entry", elems[1] )
assert len(elems) == 4
elem = elems[3]
assert len(elems) == 5
elem = elems[4]
assert find_child( "a", elem ) is None
def do_test( chapter_no, entry_no, expected ):
@ -119,6 +119,7 @@ def test_chapters( webapp, webdriver ):
do_test( 1, 2, ( "content-set-1!", "6a" ) )
do_test( 4, 0, ( "content-set-2!", "cs2a" ) )
do_test( 2, 1, ( "content-set-1!linked", "2b" ) )
do_test( 1, 3, ( "content-set-1!", 2 ) )
# try to show an unknown target
do_test( 3, 3, "Unknown ruleid:" )

@ -113,7 +113,12 @@ def get_curr_target():
# check the current ruleid
elem = find_child( "#content .tabbed-page[data-tabid='{}'] .content-doc".format( tab_id ) )
ruleid = elem.get_attribute( "data-ruleid" )
return ( tab_id, ruleid )
if ruleid:
return ( tab_id, ruleid )
page_no = elem.get_attribute( "data-pageno" )
if page_no:
return ( tab_id, int(page_no) )
return tab_id
def check_sr_filters( expected ):
"""Check the search result filter checkboxes."""

Loading…
Cancel
Save