Skip to content

Commit

Permalink
[Vue] make sure transcluded content is processed before query selecto…
Browse files Browse the repository at this point in the history
…rs in EnrichedHeadline (#18242)

* make sure transcluded content is processed before query selectors in EnrichedHeadline

* do not add map files in buildvue workflow

* built vue files

Co-authored-by: sgiehl <stefan@matomo.org>
  • Loading branch information
diosmosis and sgiehl authored Oct 30, 2021
1 parent 53b3c8c commit 2b2dd18
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/buildvue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ jobs:
if [[ $( git diff --numstat plugins/*/vue/dist/*.js plugins/*/vue/dist/*.map ) ]]
then
cd $GITHUB_WORKSPACE
git add plugins/*/vue/dist/*.js plugins/*/vue/dist/*.map
git add plugins/*/vue/dist/*.js
git commit -m "built vue files"
git push
fi
Expand Down
70 changes: 36 additions & 34 deletions plugins/CoreHome/vue/dist/CoreHome.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/CoreHome/vue/dist/CoreHome.umd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 33 additions & 30 deletions plugins/CoreHome/vue/src/EnrichedHeadline/EnrichedHeadline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,41 +161,44 @@ export default defineComponent({
mounted() {
const { root } = this.$refs;

if (!this.actualInlineHelp) {
let helpNode = root.querySelector('.title .inlineHelp');
if (!helpNode && root.parentElement.nextElementSibling) {
// hack for reports :(
helpNode = (root.parentElement.nextElementSibling as HTMLElement)
.querySelector('.reportDocumentation');
}
// timeout used since angularjs does not fill out the transclude at this point
setTimeout(() => {
if (!this.actualInlineHelp) {
let helpNode = root.querySelector('.title .inlineHelp');
if (!helpNode && root.parentElement.nextElementSibling) {
// hack for reports :(
helpNode = (root.parentElement.nextElementSibling as HTMLElement)
.querySelector('.reportDocumentation');
}

if (helpNode) {
// hackish solution to get binded html of p tag within the help node
// at this point the ng-bind-html is not yet converted into html when report is not
// initially loaded. Using $compile doesn't work. So get and set it manually
const helpDocs = helpNode.getAttribute('data-content').trim();
if (helpDocs.length) {
this.actualInlineHelp = `<p>${helpDocs}</p>`;
setTimeout(() => helpNode.remove(), 0);
if (helpNode) {
// hackish solution to get binded html of p tag within the help node
// at this point the ng-bind-html is not yet converted into html when report is not
// initially loaded. Using $compile doesn't work. So get and set it manually
const helpDocs = helpNode.getAttribute('data-content').trim();
if (helpDocs.length) {
this.actualInlineHelp = `<p>${helpDocs}</p>`;
setTimeout(() => helpNode.remove(), 0);
}
}
}
}

if (!this.actualFeatureName) {
this.actualFeatureName = root.querySelector('.title').textContent;
}
if (!this.actualFeatureName) {
this.actualFeatureName = root.querySelector('.title').textContent;
}

if (this.reportGenerated
&& Periods.parse(Matomo.period, Matomo.currentDateString).containsToday()
) {
window.$(root.querySelector('.report-generated')).tooltip({
track: true,
content: this.reportGenerated,
items: 'div',
show: false,
hide: false,
});
}
if (this.reportGenerated
&& Periods.parse(Matomo.period, Matomo.currentDateString).containsToday()
) {
window.$(root.querySelector('.report-generated')).tooltip({
track: true,
content: this.reportGenerated,
items: 'div',
show: false,
hide: false,
});
}
});
},
});
</script>

0 comments on commit 2b2dd18

Please sign in to comment.