Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accumulated badge counter for mobile #664

Merged
merged 22 commits into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c172f62
Merge remote-tracking branch 'upstream/master'
maxmarkus May 15, 2019
c09690a
Merge remote-tracking branch 'upstream/master'
maxmarkus May 16, 2019
76fa8db
Merge remote-tracking branch 'upstream/master'
maxmarkus May 20, 2019
9c86254
Merge remote-tracking branch 'upstream/master'
maxmarkus May 23, 2019
640e287
Merge remote-tracking branch 'upstream/master'
maxmarkus May 23, 2019
2397ede
Merge remote-tracking branch 'upstream/master'
maxmarkus Jun 3, 2019
c052644
Merge remote-tracking branch 'upstream/master'
maxmarkus Jun 13, 2019
37b1b60
Merge remote-tracking branch 'upstream/master'
maxmarkus Jun 18, 2019
89e98c2
Merge remote-tracking branch 'upstream/master'
maxmarkus Jun 25, 2019
49ff5ee
Merge remote-tracking branch 'upstream/master'
maxmarkus Jun 27, 2019
07cad9b
Merge remote-tracking branch 'upstream/master'
maxmarkus Jul 5, 2019
5a4cff4
Merge remote-tracking branch 'upstream/master'
maxmarkus Jul 18, 2019
7394a4c
added support for mobile badge counter
maxmarkus Jul 18, 2019
ece04c8
Merge branch 'master' into 657-accumulated-counter-mobile
maxmarkus Jul 22, 2019
2079809
Merge branch 'master' into 657-accumulated-counter-mobile
pekura Jul 23, 2019
fe867e4
Merge branch 'master' into 657-accumulated-counter-mobile
pekura Jul 23, 2019
2d30ecb
Merge branch '657-accumulated-counter-mobile' of github.com:maxmarkus…
maxmarkus Jul 23, 2019
de5e5bf
fixed wrong category badge count
maxmarkus Jul 23, 2019
0dd67da
Merge branch 'master' into 657-accumulated-counter-mobile
pekura Jul 23, 2019
ad358cb
Merge branch 'master' into 657-accumulated-counter-mobile
maxmarkus Jul 25, 2019
0c6edb1
Merge branch 'master' into 657-accumulated-counter-mobile
maxmarkus Jul 26, 2019
e7c0f5d
Merge branch 'master' into 657-accumulated-counter-mobile
maxmarkus Jul 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions core/src/navigation/TopNav.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@
aria-haspopup="true"
on:click="toggleDropdownState('overflowPopover')"
data-cy="mobile-menu"
></button>
>
<BadgeCounter node="{totalBadgeNode}" special="true"/>
</button>
</div>
</div>
<div
Expand Down Expand Up @@ -305,7 +307,8 @@
component.set({
children: tnd.children,
selectedNode: tnd.selectedNode,
visibleNodeCount: tnd.visibleNodeCount
visibleNodeCount: tnd.visibleNodeCount,
totalBadgeNode: tnd.totalBadgeNode
});
window.TOPNAVDATA = tnd.children;
}
Expand Down
36 changes: 26 additions & 10 deletions core/src/utilities/helpers/navigation-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ class NavigationHelpersClass {
let visibleNodeCount = 0;
let cats = {};
const children = [];
rawChildren.forEach(async node => {
let badgeCountsToSumUp = [];

for (const node of rawChildren) {
current.pathData.forEach(n => {
if (!selectedNode && n === node) {
selectedNode = node;
Expand All @@ -137,13 +139,14 @@ class NavigationHelpersClass {
visibleNodeCount++;
}

let badgeCount;
const hasBadge = !!node.badgeCounter;
if (hasBadge) {
badgeCount = await node.badgeCounter.count();
}

if (node.category) {
const catLabel = node.category.label || node.category;
const hasBadge = !!node.badgeCounter;
let badgeCount;
if (hasBadge) {
badgeCount = await node.badgeCounter.count();
}
if (cats[catLabel]) {
if (!cats[catLabel].icon) {
cats[catLabel].icon = node.category.icon;
Expand All @@ -154,9 +157,8 @@ class NavigationHelpersClass {
count: () => badgeCount
};
} else if (hasBadge) {
const updatedCount =
cats[catLabel].badgeCounter.count() + badgeCount;
cats[catLabel].badgeCounter.count = () => updatedCount;
badgeCount = cats[catLabel].badgeCounter.count() + badgeCount;
cats[catLabel].badgeCounter.count = () => badgeCount;
}
} else {
cats[catLabel] = {
Expand All @@ -172,12 +174,26 @@ class NavigationHelpersClass {
} else {
children.push(node);
}
});

if (badgeCount) {
badgeCountsToSumUp.push(badgeCount);
}
}
const tnd = {
children,
selectedNode,
visibleNodeCount
};

if (badgeCountsToSumUp.length) {
const badgeCountSum = badgeCountsToSumUp.reduce((a, b) => a + b);
tnd.totalBadgeNode = {
badgeCounter: {
count: () => badgeCountSum,
label: ''
}
};
}
return tnd;
}

Expand Down