Labels drag/drop

This commit is contained in:
Martin Filser 2021-10-25 12:32:03 +02:00
parent cb9b8d4f2b
commit c8b8fb83dc
4 changed files with 72 additions and 10 deletions

View file

@ -39,15 +39,58 @@ Template.createLabelPopup.helpers({
},
});
Template.cardLabelsPopup.events({
'click .js-select-label'(event) {
const card = Utils.getCurrentCard();
const labelId = this._id;
card.toggleLabel(labelId);
event.preventDefault();
BlazeComponent.extendComponent({
onRendered() {
const itemsSelector = 'li.js-card-label-item:not(.placeholder)';
const $labels = this.$('.edit-labels-pop-over');
$labels.sortable({
connectWith: '.edit-labels-pop-over',
tolerance: 'pointer',
appendTo: '.edit-labels-pop-over',
helper: 'clone',
distance: 7,
items: itemsSelector,
placeholder: 'card-label-wrapper placeholder',
start(evt, ui) {
ui.helper.css('z-index', 1000);
ui.placeholder.height(ui.helper.height());
EscapeActions.clickExecute(evt.target, 'inlinedForm');
},
stop(evt, ui) {
const newLabelOrderOnlyIds = ui.item.parent().children().toArray().map(_element => Blaze.getData(_element)._id)
const card = Blaze.getData(this);
card.board().setNewLabelOrder(newLabelOrderOnlyIds);
},
});
Utils.enableClickOnTouch(itemsSelector);
// Disable drag-dropping if the current user is not a board member or is comment only
this.autorun(() => {
if (Utils.isMiniScreen()) {
$labels.sortable({
handle: '.label-handle',
});
}
});
},
'click .js-edit-label': Popup.open('editLabel'),
'click .js-add-label': Popup.open('createLabel'),
events() {
return [
{
'click .js-select-label'(event) {
const card = Utils.getCurrentCard();
const labelId = this._id;
card.toggleLabel(labelId);
event.preventDefault();
},
'click .js-edit-label': Popup.open('editLabel'),
'click .js-add-label': Popup.open('createLabel'),
}
];
}
}).register('cardLabelsPopup');
Template.cardLabelsPopup.events({
});
Template.formLabel.events({