Skip to content

Commit

Permalink
Merge pull request #636 from paulwarren-wk/target-document-search-filter
Browse files Browse the repository at this point in the history
Target document search filter
  • Loading branch information
austinmatherne-wk authored Mar 9, 2024
2 parents e856a7a + 30525a3 commit 969dbce
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 40 deletions.
14 changes: 13 additions & 1 deletion iXBRLViewerPlugin/viewer/src/html/inspector.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ <h3 class="collapsible-header">
</div>
</div>

<div id="search-filter-target-document" class="collapsible-section collapsible-only collapsed">
<h3 class="collapsible-header">
<span data-i18n="inspector.targetDocument">Target Document</span>
<span class="collapsible-subheader"></span>
</h3>
<div class="collapsible-body target-document" style="display: none;">
<span class="reset-multiselect"></span>
<select multiple>
</select>
</div>
</div>

<div id="search-filter-units" class="collapsible-section collapsible-only collapsed">
<h3 class="collapsible-header">
<span data-i18n="inspector.units">Units</span>
Expand Down Expand Up @@ -184,7 +196,7 @@ <h3 class="collapsible-header">
</div>
<div class="fact-selected-only">
<div class="tags">
<div class="target-document"></div>
<div class="target-document-tag"></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>
Expand Down
1 change: 1 addition & 0 deletions iXBRLViewerPlugin/viewer/src/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
},
"search": {
"concealedFact": "Concealed fact",
"default": "default",
"hiddenFact": "Hidden fact",
"noMatchFound": "No match found",
"selected": "selected",
Expand Down
19 changes: 17 additions & 2 deletions iXBRLViewerPlugin/viewer/src/js/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ export class Inspector {
spec.factValueFilter = $('#search-filter-fact-value').val();
spec.calculationsFilter = $('#search-filter-calculations select').val();
spec.dimensionTypeFilter = $('#search-filter-dimension-type select').val();
spec.targetDocumentFilter = $('#search-filter-target-document select').val();
return spec;
}

Expand All @@ -383,6 +384,18 @@ export class Inspector {
.text(`${prefix} (${this._reportSet.prefixMap()[prefix]})`)
.appendTo('#search-filter-namespaces select');
}
const targetDocuments = Array.from(this._reportSet.getTargetDocuments());
if (targetDocuments.length == 1 && targetDocuments[0] == null) {
$('#search-filter-target-document').hide();
}
else {
for (const targetDocument of targetDocuments) {
$("<option>")
.attr("value", targetDocument ?? ':default')
.text(targetDocument ?? `<${i18next.t("search.default")}>`)
.appendTo('#search-filter-target-document select');
}
}
for (const unit of this._reportSet.getUsedUnits()) {
$("<option>")
.attr("value", unit)
Expand Down Expand Up @@ -422,6 +435,7 @@ export class Inspector {
$("#search-hidden-fact-filter").prop("checked", true);
$("#search-visible-fact-filter").prop("checked", true);
$("#search-filter-namespaces select option:selected").prop("selected", false);
$("#search-filter-target-document select option:selected").prop("selected", false);
$("#search-filter-units select option:selected").prop("selected", false);
$("#search-filter-scales select option:selected").prop("selected", false);
this.search();
Expand Down Expand Up @@ -461,6 +475,7 @@ export class Inspector {
this.updateMultiSelectSubheader('search-filter-scales');
this.updateMultiSelectSubheader('search-filter-units');
this.updateMultiSelectSubheader('search-filter-namespaces');
this.updateMultiSelectSubheader('search-filter-target-document');
this.updateMultiSelectSubheader('search-filter-dimension-type');
this.updateMultiSelectSubheader('search-filter-calculations');
this.updateMultiSelectSubheader('search-filter-period');
Expand Down Expand Up @@ -1084,10 +1099,10 @@ export class Inspector {

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

}
Expand Down
9 changes: 9 additions & 0 deletions iXBRLViewerPlugin/viewer/src/js/reportset.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ export class ReportSet {
return this._usedPrefixes;
}

getTargetDocuments() {
if (this._targetDocuments === undefined) {
this._targetDocuments = new Set(Object.values(this._items)
.filter(f => f instanceof Fact)
.map(f => f.targetDocument()));
}
return this._targetDocuments;
}

/**
* Returns a set of OIM format unit strings used by facts on this report. Lazy-loaded.
* @return {Set[String]} Set of OIM format unit strings
Expand Down
8 changes: 8 additions & 0 deletions iXBRLViewerPlugin/viewer/src/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ export class ReportSearch {
);
}

targetDocumentFilter(s, item) {
return (
s.targetDocumentFilter.length === 0 ||
s.targetDocumentFilter.some(t => (item.targetDocument() ?? ':default') === t)
);
}

search(s) {
if (!this.ready) {
return;
Expand All @@ -172,6 +179,7 @@ export class ReportSearch {
this.namespacesFilter,
this.unitsFilter,
this.scalesFilter,
this.targetDocumentFilter
];

rr.forEach((r,_) => {
Expand Down
Loading

0 comments on commit 969dbce

Please sign in to comment.