Merge pull request #4079 from mfilser/minicard_label_popup

Minicard label popup
This commit is contained in:
Lauri Ojansivu 2021-10-25 23:54:46 +03:00 committed by GitHub
commit 7f78106211
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 8 deletions

View file

@ -658,7 +658,6 @@ Template.cardDetailsActionsPopup.events({
'click .js-export-card': Popup.open('exportCard'),
'click .js-members': Popup.open('cardMembers'),
'click .js-assignees': Popup.open('cardAssignees'),
'click .js-labels': Popup.open('cardLabels'),
'click .js-attachments': Popup.open('cardAttachments'),
'click .js-start-voting': Popup.open('cardStartVoting'),
'click .js-start-planning-poker': Popup.open('cardStartPlanningPoker'),

View file

@ -12,7 +12,7 @@ template(name="minicard")
.minicard-labels
each labels
unless hiddenMinicardLabelText
span.card-label(class="card-label-{{color}}" title=name)
span.js-card-label.card-label(class="card-label-{{color}}" title=name)
+viewer
= name
if hiddenMinicardLabelText

View file

@ -49,6 +49,16 @@ BlazeComponent.extendComponent({
return false;
},
/** opens the card label popup only if clicked onto a label
* <li> this is necessary to have the data context of the minicard.
* if .js-card-label is used at click event, then only the data context of the label itself is available at this.currentData()
*/
cardLabelsPopup(event) {
if (this.find('.js-card-label:hover')) {
Popup.open("cardLabels")(event, this.currentData());
}
},
events() {
return [
{
@ -57,8 +67,6 @@ BlazeComponent.extendComponent({
else if (this.data().isLinkedBoard())
Utils.goBoardId(this.data().linkedId);
},
},
{
'click .js-toggle-minicard-label-text'() {
if (window.localStorage.getItem('hiddenMinicardLabelText')) {
window.localStorage.removeItem('hiddenMinicardLabelText'); //true
@ -66,9 +74,8 @@ BlazeComponent.extendComponent({
window.localStorage.setItem('hiddenMinicardLabelText', 'true'); //true
}
},
},
{
'click span.badge-icon.fa.fa-sort, click span.badge-text.check-list-sort' : Popup.open("editCardSortOrder"),
'click .minicard-labels' : this.cardLabelsPopup,
}
];
},

View file

@ -30,7 +30,11 @@ window.Popup = new (class {
function clickFromPopup(evt) {
return $(evt.target).closest('.js-pop-over').length !== 0;
}
return function(evt) {
/** opens the popup
* @param evt the current event
* @param dataContextIfCurrentDataIsUndefined use this dataContext if this.currentData() is undefined
*/
return function(evt, dataContextIfCurrentDataIsUndefined) {
// If a popup is already opened, clicking again on the opener element
// should close it -- and interrupt the current `open` function.
if (self.isOpen()) {
@ -67,7 +71,7 @@ window.Popup = new (class {
title: self._getTitle(popupName),
depth: self._stack.length,
offset: self._getOffset(openerElement),
dataContext: (this && this.currentData && this.currentData()) || this,
dataContext: (this && this.currentData && this.currentData()) || dataContextIfCurrentDataIsUndefined || this,
});
// If there are no popup currently opened we use the Blaze API to render