Skip to content

Commit 4a78d71

Browse files
authored
Merge pull request #137 from TinkoffCreditSystems/bug/136
[#136] fixed bug with click by a personal WIP-limit for click by a personal WIP-limit: all languages (not only eng.); using choosing a few;
2 parents cf1561f + 93d49dc commit 4a78d71

File tree

1 file changed

+54
-23
lines changed

1 file changed

+54
-23
lines changed

src/person-limits/PersonLimits.js

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,20 @@ const isPersonLimitAppliedToIssue = (personLimit, assignee, columnId, swimlaneId
1717
);
1818
};
1919

20+
const getNameFromTooltip = tooltip => {
21+
return tooltip
22+
.split(':')[1]
23+
.split('[')[0]
24+
.trim(); // Assignee: Pavel [x]
25+
};
26+
2027
const getAssignee = avatar => {
2128
if (!avatar) return null;
2229

2330
const label = avatar.alt ?? avatar.dataset.tooltip;
2431
if (!label) return null;
2532

26-
return label
27-
.split(':')[1]
28-
.split('[')[0]
29-
.trim(); // Assignee: Pavel [x]
33+
return getNameFromTooltip(label);
3034
};
3135

3236
export default class extends PageModification {
@@ -59,6 +63,11 @@ export default class extends PageModification {
5963
width: 32px;
6064
height: 32px;
6165
border-radius: 10px;
66+
border: none;
67+
}
68+
69+
#avatars-limits .person-avatar img[view-my-cards="block"] {
70+
border: solid 1px red;
6271
}
6372
6473
#avatars-limits .person-avatar .limit-stats {
@@ -73,6 +82,10 @@ export default class extends PageModification {
7382
line-height: 12px;
7483
font-weight: 400;
7584
}
85+
86+
.ghx-issue.no-visibility {
87+
display: none!important;
88+
}
7689
</style>
7790
`;
7891
}
@@ -122,7 +135,7 @@ export default class extends PageModification {
122135
this.avatarsList.id = 'avatars-limits';
123136
this.avatarsList.innerHTML = html;
124137

125-
this.addEventListener(this.avatarsList, 'click', this.onClickAvatar);
138+
this.addEventListener(this.avatarsList, 'click', event => this.onClickAvatar(event));
126139
document.querySelector('#subnav-title').insertBefore(this.avatarsList, null);
127140
}
128141

@@ -136,28 +149,46 @@ export default class extends PageModification {
136149
}
137150

138151
onClickAvatar(event) {
139-
const name = event.target.title;
140-
const cardsNodeList = document.querySelectorAll('.ghx-issue');
141-
const cards = Array.from(cardsNodeList);
142-
let cardsVisibility = event.target.getAttribute('view-my-cards');
143-
144-
if (cardsVisibility !== 'none') {
145-
cardsVisibility = 'none';
146-
event.target.setAttribute('view-my-cards', cardsVisibility);
147-
event.target.style.border = 'solid 1px red';
152+
if (event.target.nodeName !== 'IMG') return;
153+
const cardsVisibility = event.target.getAttribute('view-my-cards');
154+
155+
if (!cardsVisibility) {
156+
event.target.setAttribute('view-my-cards', 'block');
148157
} else {
149-
cardsVisibility = 'block';
150-
event.target.setAttribute('view-my-cards', cardsVisibility);
151-
event.target.style.border = 'none';
158+
event.target.removeAttribute('view-my-cards');
152159
}
153160

154-
cards
155-
.filter(n => !n.querySelector(`[data-tooltip="Assignee: ${name}"]`))
156-
.forEach(n => {
157-
if (n instanceof HTMLElement) {
158-
n.style.display = cardsVisibility;
159-
}
161+
this.showOnlyChosen();
162+
}
163+
164+
showOnlyChosen() {
165+
const cards = Array.from(document.querySelectorAll('.ghx-issue'));
166+
const isHaveChoose = document.querySelectorAll('[view-my-cards="block"]').length > 0;
167+
168+
if (!isHaveChoose) {
169+
cards.forEach(node => {
170+
node.classList.remove('no-visibility');
160171
});
172+
return;
173+
}
174+
175+
const avatar = Array.from(document.querySelectorAll('[view-my-cards]'));
176+
const avaTitles = avatar.map(el => el.title);
177+
178+
cards.forEach(node => {
179+
const img = node.querySelector('.ghx-avatar img');
180+
if (!img) {
181+
node.classList.add('no-visibility');
182+
return;
183+
}
184+
185+
const name = getNameFromTooltip(img.getAttribute('data-tooltip'));
186+
if (avaTitles.indexOf(name) > -1) {
187+
node.classList.remove('no-visibility');
188+
} else {
189+
node.classList.add('no-visibility');
190+
}
191+
});
161192
}
162193

163194
hasCustomSwimlines() {

0 commit comments

Comments
 (0)