Skip to content

Commit 8b75649

Browse files
author
Павел Ахметчанов
committed
hide or show cards on board by click on avatar of personal wip limits
1 parent eed54c5 commit 8b75649

File tree

1 file changed

+40
-13
lines changed

1 file changed

+40
-13
lines changed

src/person-limits/PersonLimits.js

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export default class extends PageModification {
4848
}
4949
5050
#avatars-limits .person-avatar {
51-
position: relative;
51+
cursor: pointer;
52+
position: relative;
5253
margin-right: 4px;
5354
width: 32px;
5455
height: 32px;
@@ -104,26 +105,25 @@ export default class extends PageModification {
104105
});
105106

106107
if (!this.avatarsList || !document.body.contains(this.avatarsList)) {
107-
this.avatarsList = this.insertHTML(
108-
document.querySelector('#subnav-title'),
109-
'beforeend',
110-
`
111-
<div id="avatars-limits">
112-
${stats
108+
const html = stats
113109
.map(
114110
personLimit => `
115111
<div class="person-avatar">
116112
<img src="${personLimit.person.avatar}" title="${personLimit.person.displayName}" class="jira-tooltip" />
117113
<div class="limit-stats">
118114
<span class="stats-current"></span>/<span>${personLimit.limit}</span>
119115
</div>
120-
</div>
121-
`
116+
</div>`
122117
)
123-
.join('')}
124-
</div>
125-
`
126-
);
118+
.join('');
119+
120+
this.avatarsList = document.createElement('div');
121+
122+
this.avatarsList.id = 'avatars-limits';
123+
this.avatarsList.innerHTML = html;
124+
125+
this.avatarsList.onclick = this.onClickByAvatar();
126+
document.querySelector('#subnav-title').insertBefore(this.avatarsList, null);
127127
}
128128

129129
this.avatarsList.querySelectorAll('.limit-stats').forEach((stat, index) => {
@@ -135,6 +135,33 @@ export default class extends PageModification {
135135
});
136136
}
137137

138+
onClickByAvatar() {
139+
return event => {
140+
const name = event.target.title;
141+
const cardsNodeList = document.querySelectorAll('.ghx-issue');
142+
const cards = Array.from(cardsNodeList);
143+
let cardsVisibility = event.target.getAttribute('view-my-cards');
144+
145+
if (cardsVisibility !== 'none') {
146+
cardsVisibility = 'none';
147+
event.target.setAttribute('view-my-cards', cardsVisibility);
148+
event.target.style.border = 'solid 1px red';
149+
} else {
150+
cardsVisibility = 'block';
151+
event.target.setAttribute('view-my-cards', cardsVisibility);
152+
event.target.style.border = 'none';
153+
}
154+
155+
cards
156+
.filter(n => !n.querySelector(`[data-tooltip="Assignee: ${name}"]`))
157+
.forEach(n => {
158+
if (n instanceof HTMLElement) {
159+
n.style.display = cardsVisibility;
160+
}
161+
});
162+
};
163+
}
164+
138165
hasCustomSwimlines() {
139166
const someSwimline = document.querySelector(DOM.swimlaneHeaderContainer);
140167

0 commit comments

Comments
 (0)