——— Content disabled ———
{{cdoc.title}}
-
target = {{target}}
+
ruleid = {{ruleid}}
page = {{pageNo}}
@@ -52,18 +52,18 @@ gMainApp.component( "content-doc", {
created() {
- gEventBus.on( "show-target", (cdocId, target) => {
- if ( cdocId != this.cdoc.cdoc_id || !target )
+ gEventBus.on( "show-target", (cdocId, ruleid) => {
+ if ( cdocId != this.cdoc.cdoc_id || !ruleid )
return ;
- let targets = findTargets( target, this.cdoc.parent_cset_id ) ;
+ let targets = findTargets( ruleid, this.cdoc.parent_cset_id ) ;
if ( ! targets || targets.length == 0 ) {
- showErrorMsg( "Unknown target: " + target ) ;
+ showErrorMsg( "Unknown ruleid: " + ruleid ) ;
return ;
}
- // scroll to the specified target
- // FUDGE! We give the tab time to show itself before we scroll to the target.
+ // scroll to the specified ruleid
+ // FUDGE! We give the tab time to show itself before we scroll to the ruleid.
setTimeout( () => {
- this.target = target ;
+ this.ruleid = ruleid ;
this.pageNo = null ;
}, 50 ) ;
} ) ;
@@ -72,10 +72,10 @@ gMainApp.component( "content-doc", {
if ( cdocId != this.cdoc.cdoc_id )
return ;
// scroll to the specified page
- // FUDGE! We give the tab time to show itself before we scroll to the target.
+ // FUDGE! We give the tab time to show itself before we scroll to the page.
setTimeout( () => {
this.pageNo = pageNo ;
- this.target = null ;
+ this.ruleid = null ;
}, 50 ) ;
} ) ;
@@ -85,8 +85,8 @@ gMainApp.component( "content-doc", {
makeDocUrl() {
let url = this.cdoc.url ;
- if ( this.target )
- url += "#nameddest=" + this.target ;
+ if ( this.ruleid )
+ url += "#nameddest=" + this.ruleid ;
else if ( this.pageNo )
url += "#page=" + this.pageNo ;
return url ;
diff --git a/asl_rulebook2/webapp/static/MainApp.js b/asl_rulebook2/webapp/static/MainApp.js
index bb7ab06..30bf61e 100644
--- a/asl_rulebook2/webapp/static/MainApp.js
+++ b/asl_rulebook2/webapp/static/MainApp.js
@@ -115,14 +115,14 @@ gMainApp.component( "main-app", {
Object.values( contentDocs ).forEach( (cdoc) => {
if ( ! cdoc.targets )
return ;
- for ( let target in cdoc.targets ) {
- let key = target.toLowerCase() ;
- if ( ! gTargetIndex[ key ] )
- gTargetIndex[ key ] = [] ;
- gTargetIndex[ key ].push( {
+ for ( let ruleid in cdoc.targets ) {
+ let ruleidLC = ruleid.toLowerCase() ;
+ if ( ! gTargetIndex[ ruleidLC ] )
+ gTargetIndex[ ruleidLC ] = [] ;
+ gTargetIndex[ ruleidLC ].push( {
cset_id: cdoc.parent_cset_id,
cdoc_id: cdoc.cdoc_id,
- target: target
+ ruleid: ruleid
} ) ;
}
} ) ;
diff --git a/asl_rulebook2/webapp/static/NavPane.js b/asl_rulebook2/webapp/static/NavPane.js
index cfdfb05..9a865b2 100644
--- a/asl_rulebook2/webapp/static/NavPane.js
+++ b/asl_rulebook2/webapp/static/NavPane.js
@@ -25,21 +25,21 @@ gMainApp.component( "nav-pane", {
created() {
// show any Q+A and annotations when a target is opened
- gEventBus.on( "show-target", (cdocId, target) => {
+ gEventBus.on( "show-target", (cdocId, ruleid) => {
if ( gAppConfig.DISABLE_AUTO_SHOW_RULE_INFO )
return ;
// get the rule info for the target being opened
- // NOTE: Targets are associated with a content doc, but the Q+A is global, which is not quite
- // the right thing to do - what if there is a ruleid that is the same multiple content docs,
+ // NOTE: Targets are associated with a content set, but the Q+A is global, which is not quite
+ // the right thing to do - what if there is a ruleid that exists in multiple content set,
// but is referenced in the Q+A? Hopefully, this will never happen... :-/
- let url = gGetRuleInfoUrl.replace( "RULEID", target ) ; //eslint-disable-line no-undef
+ let url = gGetRuleInfoUrl.replace( "RULEID", ruleid ) ; //eslint-disable-line no-undef
$.getJSON( url, (resp) => {
if ( resp.length > 0 ) {
// install the rule info entries
this.ruleInfo = resp ;
}
} ).fail( (xhr, status, errorMsg) => {
- showWarningMsg( "Couldn't get the Q+A for " + target + ".
" + errorMsg + "
" ) ;
+ showWarningMsg( "Couldn't get the Q+A for " + ruleid + ".
" + errorMsg + "
" ) ;
} ) ;
} ) ;
diff --git a/asl_rulebook2/webapp/static/SearchPane.js b/asl_rulebook2/webapp/static/SearchPane.js
index e5ad52d..06576a2 100644
--- a/asl_rulebook2/webapp/static/SearchPane.js
+++ b/asl_rulebook2/webapp/static/SearchPane.js
@@ -73,12 +73,12 @@ gMainApp.component( "search-results", {
Vue.nextTick( () => { gEventBus.emit( "search-done" ) ; } ) ;
}
- // check if the query string is just a target
+ // check if the query string is just a ruleid
let targets = findTargets( queryString, null ) ;
if ( targets && targets.length > 0 ) {
// yup - just show it directly (first one, if multiple)
this.searchResults = null ;
- gEventBus.emit( "show-target", targets[0].cdoc_id, targets[0].target ) ;
+ gEventBus.emit( "show-target", targets[0].cdoc_id, targets[0].ruleid ) ;
onSearchDone() ;
return ;
}
@@ -106,7 +106,7 @@ gMainApp.component( "search-results", {
if ( resp.length > 0 && resp[0].sr_type == "index" ) {
let target = getPrimaryTarget( resp[0] ) ;
if ( target )
- gEventBus.emit( "show-target", target.cdoc_id, target.target ) ;
+ gEventBus.emit( "show-target", target.cdoc_id, target.ruleid ) ;
}
// flag that the search was completed
onSearchDone() ;
diff --git a/asl_rulebook2/webapp/static/SearchResult.js b/asl_rulebook2/webapp/static/SearchResult.js
index a78dbb8..e990efe 100644
--- a/asl_rulebook2/webapp/static/SearchResult.js
+++ b/asl_rulebook2/webapp/static/SearchResult.js
@@ -86,7 +86,7 @@ gMainApp.component( "index-sr", {
// open the search result's primary target
let target = getPrimaryTarget( this.sr ) ;
if ( target )
- gEventBus.emit( "show-target", target.cdoc_id, target.target ) ;
+ gEventBus.emit( "show-target", target.cdoc_id, target.ruleid ) ;
},
onToggleRulerefs() {
@@ -127,9 +127,9 @@ gMainApp.component( "index-sr", {
let target = getPrimaryTarget( this.sr ) ;
if ( ! target )
return null ;
- target = target.target ;
- if ( isRuleid( target ) )
- return target[0] ;
+ let ruleid = target.ruleid ;
+ if ( isRuleid( ruleid ) )
+ return ruleid[0] ; // nb: we assume the 1st letter of the ruleid is the chapter ID
return null ;
},
@@ -143,11 +143,11 @@ gMainApp.component( "ruleid", {
props: [ "csetId", "ruleId" ],
data() { return {
- cdocId: null, target: null,
+ cdocId: null, ruleid: null,
} ; },
// NOTE: This bit of HTML is sensitive to spaces :-/
- template: `
[{{ruleId}}{{ruleId}}]`,
+ template: `
[{{ruleId}}{{ruleId}}]`,
created() {
// check if the rule is one we know about
@@ -157,14 +157,14 @@ gMainApp.component( "ruleid", {
// ever adds Chapter Z stuff to the main index, but we'll cross that bridge if and when we come to it.
// TBH, that stuff would probably be better off as a separate content set, anyway.
this.cdocId = targets[0].cdoc_id ;
- this.target = targets[0].target ;
+ this.ruleid = targets[0].ruleid ;
}
},
methods: {
onClick() {
// show the target
- gEventBus.emit( "show-target", this.cdocId, this.target ) ;
+ gEventBus.emit( "show-target", this.cdocId, this.ruleid ) ;
},
},
diff --git a/asl_rulebook2/webapp/static/utils.js b/asl_rulebook2/webapp/static/utils.js
index 166b866..176146e 100644
--- a/asl_rulebook2/webapp/static/utils.js
+++ b/asl_rulebook2/webapp/static/utils.js
@@ -16,15 +16,21 @@ export function getPrimaryTarget( indexSearchResult )
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-export function findTargets( target, csetId )
+export function findTargets( ruleid, csetId )
{
- // check if the target is known to us
- let pos = target.indexOf( "-" ) ;
+ // NOTE: A "ruleid" is a rule ID (e.g. "A1.23") within a specific document. Hopefully, these will
+ // be unique across the entire corpus, but we can't guarantee that (Chapter Z, anyone? :-/), so we
+ // also have the concept of a "target", which is a ruleid plus the content set it's in.
+ // One can only hope that ruleid's are unique in this context, even if there are multiple documents
+ // in each content set...
+
+ // check if the ruleid is known to us
+ let pos = ruleid.indexOf( "-" ) ;
if ( pos >= 0 ) {
// NOTE: For ruleid's of the form "A12.3-.4", we want to target "A12.3".
- target = target.substring( 0, pos ) ;
+ ruleid = ruleid.substring( 0, pos ) ;
}
- let targets = gTargetIndex[ target.toLowerCase() ] ;
+ let targets = gTargetIndex[ ruleid.toLowerCase() ] ;
if ( targets && csetId )
targets = targets.filter( (m) => m.cset_id == csetId ) ;
return targets ;
diff --git a/asl_rulebook2/webapp/tests/test_content_sets.py b/asl_rulebook2/webapp/tests/test_content_sets.py
index 25c0018..cc2e2ee 100644
--- a/asl_rulebook2/webapp/tests/test_content_sets.py
+++ b/asl_rulebook2/webapp/tests/test_content_sets.py
@@ -51,7 +51,7 @@ def test_targets( webapp, webdriver ):
ruleid_elems[ ruleid ].click()
wait_for( 2, lambda: get_curr_target() == (expected, ruleid) )
- # test clicking on ruleid targets
+ # test clicking on ruleid's
do_test( "4b", "content-set-1!linked" )
do_test( "1a", "content-set-1" )
do_test( "cs2d", "content-set-2" )
@@ -91,7 +91,7 @@ def test_chapters( webapp, webdriver ):
},
]
- # check that the chapter section with a missing ruleid is not clickable
+ # check that the chapter section with a missing target is not clickable
elems = find_children( "#nav .tabbed-page[data-tabid='chapters'] .accordian-pane" )
assert len(elems) == 6
elems = find_children( ".entry", elems[1] )
@@ -120,7 +120,7 @@ def test_chapters( webapp, webdriver ):
do_test( 2, 1, ( "content-set-1!linked", "2b" ) )
# try to show an unknown target
- do_test( 3, 3, "Unknown target:" )
+ do_test( 3, 3, "Unknown ruleid:" )
# ---------------------------------------------------------------------
diff --git a/asl_rulebook2/webapp/tests/utils.py b/asl_rulebook2/webapp/tests/utils.py
index 68a93a9..a586e0b 100644
--- a/asl_rulebook2/webapp/tests/utils.py
+++ b/asl_rulebook2/webapp/tests/utils.py
@@ -81,10 +81,10 @@ def get_curr_target():
if not elem:
return ( None, None )
tab_id = elem.get_attribute( "data-tabid" )
- # check the current target
+ # check the current ruleid
elem = find_child( "#content .tabbed-page[data-tabid='{}'] .content-doc".format( tab_id ) )
- target = elem.get_attribute( "data-target" )
- return ( tab_id, target )
+ ruleid = elem.get_attribute( "data-ruleid" )
+ return ( tab_id, ruleid )
# ---------------------------------------------------------------------