Skip to content

Commit

Permalink
Merge pull request #627 from paulwarren-wk/show-target-document
Browse files Browse the repository at this point in the history
Display the target document of facts in inspector and search
  • Loading branch information
austinmatherne-wk authored Feb 15, 2024
2 parents ebdc9d6 + 16bd5b5 commit 4bec74f
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 17 deletions.
5 changes: 3 additions & 2 deletions iXBRLViewerPlugin/iXBRLViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,11 @@ def getStubDocument(self):
with open(os.path.join(os.path.dirname(__file__),"stubviewer.html")) as fin:
return etree.parse(fin)

def newTargetReport(self):
def newTargetReport(self, target):
return {
"concepts": {},
"facts": {},
"target": target,
}

def addSourceReport(self):
Expand Down Expand Up @@ -425,7 +426,7 @@ def createViewer(

for n, report in enumerate(self.reports):
self.footnoteRelationshipSet = ModelRelationshipSet(report, "XBRL-footnotes")
self.currentTargetReport = self.newTargetReport()
self.currentTargetReport = self.newTargetReport(getattr(report, "ixdsTarget", None))
for f in report.facts:
self.addFact(report, f)
self.currentTargetReport["rels"] = self.getRelationships(report)
Expand Down
7 changes: 5 additions & 2 deletions iXBRLViewerPlugin/viewer/src/html/inspector.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,11 @@ <h3 class="collapsible-header">
<p class="title" data-i18n="inspector.noFactSelected">No Fact Selected</p>
</div>
<div class="fact-selected-only">
<div class="hidden-fact-tag" data-i18n="inspector.hiddenFact">Hidden Fact</div>
<div class="html-hidden-fact-tag" data-i18n="inspector.concealedFact">Concealed Fact</div>
<div class="tags">
<div class="target-document"></div>
<div class="hidden-fact-tag" data-i18n="inspector.hiddenFact">Hidden Fact</div>
<div class="html-hidden-fact-tag" data-i18n="inspector.concealedFact">Concealed Fact</div>
</div>
<div class="collapsible-section">
<div class="fact-inspector collapsible-body">
</div>
Expand Down
4 changes: 4 additions & 0 deletions iXBRLViewerPlugin/viewer/src/js/fact.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,8 @@ export class Fact {
}
return this.decimals() > of.decimals();
}

targetDocument() {
return this.report.targetDocument();
}
}
18 changes: 16 additions & 2 deletions iXBRLViewerPlugin/viewer/src/js/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,21 @@ export class Inspector {
.appendTo(row);
}
}
const tags = $("<div></div>").addClass("tags").appendTo(row);
if (f.targetDocument() !== null) {
$('<div class="hidden"></div>')
.text(f.targetDocument())
.appendTo(tags);
}
if (f.isHidden()) {
$('<div class="hidden"></div>')
.text(i18next.t("search.hiddenFact"))
.appendTo(row);
.appendTo(tags);
}
else if (f.isHTMLHidden()) {
$('<div class="hidden"></div>')
.text(i18next.t("search.concealedFact"))
.appendTo(row);
.appendTo(tags);
}
return row;
}
Expand Down Expand Up @@ -1076,6 +1082,14 @@ export class Inspector {
$('#inspector').addClass('html-hidden-fact');
}

const target = cf.targetDocument();
if (target !== null) {
$('#inspector .target-document').text(target).show();
}
else {
$('#inspector .target-document').hide();
}

}
else if (cf instanceof Footnote) {
$('#inspector').addClass('footnote-mode');
Expand Down
4 changes: 4 additions & 0 deletions iXBRLViewerPlugin/viewer/src/js/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export class XBRLReport {
return this.reportSet.factsForReport(this);
}

targetDocument() {
return this._reportData.target ?? null;
}

getChildRelationships(conceptName, arcrole) {
const rels = {}
const elrs = this._reportData.rels[arcrole] || {};
Expand Down
5 changes: 5 additions & 0 deletions iXBRLViewerPlugin/viewer/src/less/block-list.less
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
margin: 0.8rem 0;
}

// Contents of .tags provide 0.2rem of non-collapsing margin
& > .tags {
margin: 0.6rem 0;
}

&:hover {
background-color: @background-selected;
}
Expand Down
4 changes: 3 additions & 1 deletion iXBRLViewerPlugin/viewer/src/less/components.less
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// See COPYRIGHT.md for copyright information

.tag {
display: table;
display: inline-block;
text-transform: uppercase;
font-weight: bold;
background-color: @background-tag;
padding: 0.15em 0.5em;
color: #fff;
border-radius: 0.3em;
margin: 0.2rem 0.3rem 0.2rem 0;
white-space: nowrap;
}

.clickable {
Expand Down
14 changes: 10 additions & 4 deletions iXBRLViewerPlugin/viewer/src/less/inspector.less
Original file line number Diff line number Diff line change
Expand Up @@ -676,13 +676,19 @@
top: 1px;
}

.hidden-fact-tag,
.html-hidden-fact-tag {
.tag();

.inspector-body-fact .tags {
position: absolute;
top: 1.5rem;
right: 0.9rem;
}

.target-document {
.tag();
}

.hidden-fact-tag,
.html-hidden-fact-tag {
.tag();

&.html-hidden-fact-tag {
background-color: #c63018;
Expand Down
17 changes: 11 additions & 6 deletions tests/unit_tests/iXBRLViewerPlugin/test_iXBRLViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ def info_effect(info, msg):
"filepath":'a.html',
"objectIndex":0,
"type":Type.INLINEXBRL,
}
},
ixdsTarget=None,
)

self.modelDocumentInlineSet = Mock(
Expand All @@ -353,7 +354,8 @@ def info_effect(info, msg):
): [],
},
filepath=self.modelDocument.filepath,
type=Type.INLINEXBRLDOCUMENTSET
type=Type.INLINEXBRLDOCUMENTSET,
ixdsTarget=None,
)

error1 = logging.LogRecord("arelle", logging.ERROR, "", 0, "Error message", {}, None)
Expand Down Expand Up @@ -389,6 +391,7 @@ def urlDocEntry(path, docType, linkQName=None):
info=info_effect,
modelDocument=self.modelDocument,
modelManager=self.modelManager,
ixdsTarget=None,
urlDocs=dict((
urlDocEntry('/filesystem/local-inline.htm', Type.INLINEXBRL),
urlDocEntry('https://example.com/remote-inline.htm', Type.INLINEXBRL),
Expand Down Expand Up @@ -419,6 +422,7 @@ def urlDocEntry(path, docType, linkQName=None):
info=info_effect,
modelDocument=self.modelDocument,
modelManager=self.modelManager,
ixdsTarget=None,
urlDocs={}
)
self.modelXbrlDocSet = Mock(
Expand All @@ -430,6 +434,7 @@ def urlDocEntry(path, docType, linkQName=None):
info=info_effect,
modelDocument=self.modelDocumentInlineSet,
modelManager=self.modelManager,
ixdsTarget=None,
urlDocs={}
)

Expand All @@ -450,7 +455,7 @@ def urlDocEntry(path, docType, linkQName=None):
@patch('arelle.XbrlConst.conceptReference', 'http://www.xbrl.org/2003/arcrole/concept-reference')
def test_addConcept_simple_case(self):
builder = IXBRLViewerBuilder([self.modelXbrl_1])
builder.currentTargetReport = builder.newTargetReport()
builder.currentTargetReport = builder.newTargetReport(None)
builder.addSourceReport()["targetReports"].append(builder.currentTargetReport)
builder.addConcept(self.modelXbrl_1, self.cash_concept)
assert builder.taxonomyData["sourceReports"][0]["targetReports"][0].get('concepts').get('us-gaap:Cash')
Expand All @@ -467,7 +472,7 @@ def test_getRelationships_simple_case(self):
@patch('arelle.XbrlConst.summationItem', 'http://www.xbrl.org/2003/arcrole/summation-item')
def test_getRelationships_returns_a_rel(self):
builder = IXBRLViewerBuilder([self.modelXbrl_1])
builder.currentTargetReport = builder.newTargetReport()
builder.currentTargetReport = builder.newTargetReport(None)
result = builder.getRelationships(self.modelXbrl_1)
roleMap = builder.roleMap
siPrefix = roleMap.getPrefix('http://www.xbrl.org/2003/arcrole/summation-item')
Expand All @@ -479,7 +484,7 @@ def test_addELR_no_definition(self):
"""
elr = "http://example.com/unknownELR"
builder = IXBRLViewerBuilder([self.modelXbrl_1])
builder.currentTargetReport = builder.newTargetReport()
builder.currentTargetReport = builder.newTargetReport(None)
builder.addELR(self.modelXbrl_1, elr)
elrPrefix = builder.roleMap.getPrefix(elr)
assert builder.currentTargetReport.get('roleDefs').get(elrPrefix) is None
Expand All @@ -490,7 +495,7 @@ def test_addELR_with_definition(self):
"""
elr = "ELR"
builder = IXBRLViewerBuilder([self.modelXbrl_1])
builder.currentTargetReport = builder.newTargetReport()
builder.currentTargetReport = builder.newTargetReport(None)
builder.addELR(self.modelXbrl_1, elr)
elrPrefix = builder.roleMap.getPrefix(elr)
assert builder.currentTargetReport.get('roleDefs').get(elrPrefix).get("en") == "ELR Label"
Expand Down

0 comments on commit 4bec74f

Please sign in to comment.