2023-01-14 13:29:57 +01:00
|
|
|
import { ReactiveCache } from '/imports/reactiveCache';
|
2021-07-10 10:55:54 +02:00
|
|
|
import { TAPi18n } from '/imports/i18n';
|
2021-07-22 22:44:40 -03:00
|
|
|
import Cards from '/models/cards';
|
|
|
|
|
import Boards from '/models/boards';
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
import { BoardSwimlaneListCardDialog } from '/client/lib/dialogWithBoardSwimlaneListCard';
|
2021-07-22 22:44:40 -03:00
|
|
|
|
|
|
|
|
const subManager = new SubsManager();
|
2020-04-24 22:41:24 +02:00
|
|
|
const { calculateIndexData, capitalize } = Utils;
|
2018-03-19 15:03:44 -03:00
|
|
|
|
2026-02-08 00:48:39 +02:00
|
|
|
function initSorting(items) {
|
2017-09-12 10:38:03 +02:00
|
|
|
items.sortable({
|
|
|
|
|
tolerance: 'pointer',
|
|
|
|
|
helper: 'clone',
|
2019-10-03 04:23:33 +03:00
|
|
|
items: '.js-checklist-item:not(.placeholder)',
|
2018-03-19 15:03:44 -03:00
|
|
|
connectWith: '.js-checklist-items',
|
2020-12-26 12:38:24 +02:00
|
|
|
appendTo: 'parent',
|
2017-09-12 10:38:03 +02:00
|
|
|
distance: 7,
|
2019-10-03 04:23:33 +03:00
|
|
|
placeholder: 'checklist-item placeholder',
|
2021-10-29 17:06:12 +02:00
|
|
|
scroll: true,
|
2017-09-12 10:38:03 +02:00
|
|
|
start(evt, ui) {
|
|
|
|
|
ui.placeholder.height(ui.helper.height());
|
2021-10-21 09:41:47 +02:00
|
|
|
EscapeActions.clickExecute(evt.target, 'inlinedForm');
|
2017-09-12 10:38:03 +02:00
|
|
|
},
|
|
|
|
|
stop(evt, ui) {
|
|
|
|
|
const parent = ui.item.parents('.js-checklist-items');
|
2018-03-19 15:03:44 -03:00
|
|
|
const checklistId = Blaze.getData(parent.get(0)).checklist._id;
|
2019-10-03 04:23:33 +03:00
|
|
|
let prevItem = ui.item.prev('.js-checklist-item').get(0);
|
2018-03-19 15:03:44 -03:00
|
|
|
if (prevItem) {
|
|
|
|
|
prevItem = Blaze.getData(prevItem).item;
|
|
|
|
|
}
|
2019-10-03 04:23:33 +03:00
|
|
|
let nextItem = ui.item.next('.js-checklist-item').get(0);
|
2018-03-19 15:03:44 -03:00
|
|
|
if (nextItem) {
|
|
|
|
|
nextItem = Blaze.getData(nextItem).item;
|
2017-09-12 10:38:03 +02:00
|
|
|
}
|
2018-03-19 15:03:44 -03:00
|
|
|
const nItems = 1;
|
|
|
|
|
const sortIndex = calculateIndexData(prevItem, nextItem, nItems);
|
|
|
|
|
const checklistDomElement = ui.item.get(0);
|
|
|
|
|
const checklistData = Blaze.getData(checklistDomElement);
|
|
|
|
|
const checklistItem = checklistData.item;
|
|
|
|
|
|
|
|
|
|
items.sortable('cancel');
|
|
|
|
|
|
|
|
|
|
checklistItem.move(checklistId, sortIndex.base);
|
2017-09-12 10:38:03 +02:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
Template.checklistDetail.onRendered(function () {
|
|
|
|
|
const tpl = this;
|
|
|
|
|
tpl.itemsDom = this.$('.js-checklist-items');
|
|
|
|
|
initSorting(tpl.itemsDom);
|
|
|
|
|
tpl.itemsDom.mousedown(function (evt) {
|
|
|
|
|
evt.stopPropagation();
|
|
|
|
|
});
|
2018-03-19 16:47:07 -03:00
|
|
|
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
function userIsMember() {
|
|
|
|
|
return ReactiveCache.getCurrentUser()?.isBoardMember();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Disable sorting if the current user is not a board member
|
|
|
|
|
tpl.autorun(() => {
|
|
|
|
|
const $itemsDom = $(tpl.itemsDom);
|
|
|
|
|
if ($itemsDom.data('uiSortable') || $itemsDom.data('sortable')) {
|
|
|
|
|
$(tpl.itemsDom).sortable('option', 'disabled', !userIsMember());
|
|
|
|
|
if (Utils.isTouchScreenOrShowDesktopDragHandles()) {
|
|
|
|
|
$(tpl.itemsDom).sortable({
|
|
|
|
|
handle: 'span.fa.checklistitem-handle',
|
|
|
|
|
});
|
2020-02-07 03:16:16 +02:00
|
|
|
}
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2018-03-19 16:47:07 -03:00
|
|
|
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
Template.checklistDetail.helpers({
|
2022-01-15 15:48:55 +01:00
|
|
|
/** returns the finished percent of the checklist */
|
|
|
|
|
finishedPercent() {
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
const ret = this.checklist.finishedPercent();
|
2022-01-15 15:48:55 +01:00
|
|
|
return ret;
|
|
|
|
|
},
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
});
|
2017-09-12 10:38:03 +02:00
|
|
|
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
Template.checklists.helpers({
|
|
|
|
|
checklists() {
|
|
|
|
|
const card = ReactiveCache.getCard(this.cardId);
|
|
|
|
|
const ret = card.checklists();
|
|
|
|
|
return ret;
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.checklists.events({
|
|
|
|
|
'click .js-open-checklist-details-menu': Popup.open('checklistActions'),
|
|
|
|
|
'submit .js-add-checklist'(event, tpl) {
|
2017-01-20 21:05:48 +08:00
|
|
|
event.preventDefault();
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
const textarea = tpl.find('textarea.js-add-checklist-item');
|
2017-01-20 21:05:48 +08:00
|
|
|
const title = textarea.value.trim();
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
let cardId = Template.currentData().cardId;
|
2022-12-16 16:36:47 +01:00
|
|
|
const card = ReactiveCache.getCard(cardId);
|
|
|
|
|
if (card.isLinkedCard()) {
|
|
|
|
|
cardId = card.linkedId;
|
|
|
|
|
}
|
2017-07-01 23:03:54 +09:00
|
|
|
|
2022-05-04 23:19:19 +02:00
|
|
|
let sortIndex;
|
|
|
|
|
let checklistItemIndex;
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
if (Template.currentData().position === 'top') {
|
2022-05-04 23:19:19 +02:00
|
|
|
sortIndex = Utils.calculateIndexData(null, card.firstChecklist()).base;
|
|
|
|
|
checklistItemIndex = 0;
|
|
|
|
|
} else {
|
|
|
|
|
sortIndex = Utils.calculateIndexData(card.lastChecklist(), null).base;
|
|
|
|
|
checklistItemIndex = -1;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-01 23:03:54 +09:00
|
|
|
if (title) {
|
|
|
|
|
Checklists.insert({
|
|
|
|
|
cardId,
|
|
|
|
|
title,
|
2022-05-04 23:19:19 +02:00
|
|
|
sort: sortIndex,
|
2017-07-01 23:03:54 +09:00
|
|
|
});
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
tpl.$('.js-close-inlined-form').click();
|
2017-07-01 23:03:54 +09:00
|
|
|
setTimeout(() => {
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
tpl.$('.add-checklist-item')
|
2022-05-04 23:19:19 +02:00
|
|
|
.eq(checklistItemIndex)
|
2019-06-28 12:52:09 -05:00
|
|
|
.click();
|
2017-07-01 23:03:54 +09:00
|
|
|
}, 100);
|
|
|
|
|
}
|
2017-01-20 21:05:48 +08:00
|
|
|
},
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
'submit .js-edit-checklist-title'(event, tpl) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
const textarea = tpl.find('textarea.js-edit-checklist-item');
|
|
|
|
|
const title = textarea.value.trim();
|
|
|
|
|
const checklist = Template.currentData().checklist;
|
|
|
|
|
checklist.setTitle(title);
|
|
|
|
|
},
|
|
|
|
|
'submit .js-add-checklist-item'(event, tpl) {
|
2017-01-20 21:05:48 +08:00
|
|
|
event.preventDefault();
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
const textarea = tpl.find('textarea.js-add-checklist-item');
|
|
|
|
|
const newlineBecomesNewChecklistItem = tpl.find('input#toggleNewlineBecomesNewChecklistItem');
|
|
|
|
|
const newlineBecomesNewChecklistItemOriginOrder = tpl.find('input#toggleNewlineBecomesNewChecklistItemOriginOrder');
|
2017-01-20 21:05:48 +08:00
|
|
|
const title = textarea.value.trim();
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
const checklist = Template.currentData().checklist;
|
2017-06-30 10:10:42 +09:00
|
|
|
|
2017-07-01 23:03:54 +09:00
|
|
|
if (title) {
|
2022-01-14 18:05:19 +01:00
|
|
|
let checklistItems = [title];
|
|
|
|
|
if (newlineBecomesNewChecklistItem.checked) {
|
|
|
|
|
checklistItems = title.split('\n').map(_value => _value.trim());
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
if (Template.currentData().position === 'top') {
|
2024-05-27 21:37:09 +02:00
|
|
|
if (newlineBecomesNewChecklistItemOriginOrder.checked === false) {
|
|
|
|
|
checklistItems = checklistItems.reverse();
|
|
|
|
|
}
|
2022-05-15 16:50:32 +02:00
|
|
|
}
|
2022-01-14 18:05:19 +01:00
|
|
|
}
|
2024-11-12 09:58:57 +01:00
|
|
|
let addIndex;
|
|
|
|
|
let sortIndex;
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
if (Template.currentData().position === 'top') {
|
2024-11-12 09:58:57 +01:00
|
|
|
sortIndex = Utils.calculateIndexData(null, checklist.firstItem()).base;
|
|
|
|
|
addIndex = -1;
|
|
|
|
|
} else {
|
|
|
|
|
sortIndex = Utils.calculateIndexData(checklist.lastItem(), null).base;
|
|
|
|
|
addIndex = 1;
|
|
|
|
|
}
|
2022-01-14 18:05:19 +01:00
|
|
|
for (let checklistItem of checklistItems) {
|
|
|
|
|
ChecklistItems.insert({
|
|
|
|
|
title: checklistItem,
|
|
|
|
|
checklistId: checklist._id,
|
|
|
|
|
cardId: checklist.cardId,
|
2022-05-15 16:50:32 +02:00
|
|
|
sort: sortIndex,
|
2022-01-14 18:05:19 +01:00
|
|
|
});
|
2024-11-12 09:58:57 +01:00
|
|
|
sortIndex += addIndex;
|
2022-01-14 18:05:19 +01:00
|
|
|
}
|
2017-07-01 23:03:54 +09:00
|
|
|
}
|
2017-06-30 10:10:42 +09:00
|
|
|
// We keep the form opened, empty it.
|
|
|
|
|
textarea.value = '';
|
|
|
|
|
textarea.focus();
|
2017-01-20 21:05:48 +08:00
|
|
|
},
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
'submit .js-edit-checklist-item'(event, tpl) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
const textarea = tpl.find('textarea.js-edit-checklist-item');
|
|
|
|
|
const title = textarea.value.trim();
|
|
|
|
|
const item = Template.currentData().item;
|
|
|
|
|
item.setTitle(title);
|
|
|
|
|
},
|
|
|
|
|
'click .js-convert-checklist-item-to-card': Popup.open('convertChecklistItemToCard'),
|
|
|
|
|
async 'click .js-delete-checklist-item'() {
|
|
|
|
|
const checklist = Template.currentData().checklist;
|
|
|
|
|
const item = Template.currentData().item;
|
2026-01-28 12:59:07 +02:00
|
|
|
if (checklist && item && item._id) {
|
|
|
|
|
ChecklistItems.remove(item._id);
|
|
|
|
|
}
|
|
|
|
|
},
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
'focus .js-add-checklist-item'(event) {
|
|
|
|
|
// If a new checklist is created, pre-fill the title and select it.
|
|
|
|
|
const checklist = Template.currentData().checklist;
|
|
|
|
|
if (!checklist) {
|
|
|
|
|
const textarea = event.target;
|
|
|
|
|
textarea.value = capitalize(TAPi18n.__('r-checklist'));
|
|
|
|
|
textarea.select();
|
|
|
|
|
}
|
2017-01-20 21:05:48 +08:00
|
|
|
},
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
// add and delete checklist / checklist-item
|
|
|
|
|
'click .js-open-inlined-form'(event, tpl) {
|
|
|
|
|
tpl.$('.js-close-inlined-form').click();
|
|
|
|
|
},
|
|
|
|
|
'click #toggleHideFinishedChecklist'(event) {
|
2017-01-20 21:05:48 +08:00
|
|
|
event.preventDefault();
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
Template.currentData().card.toggleHideFinishedChecklist();
|
2017-01-20 21:05:48 +08:00
|
|
|
},
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
keydown(event) {
|
2017-11-14 20:57:36 -06:00
|
|
|
//If user press enter key inside a form, submit it
|
|
|
|
|
//Unless the user is also holding down the 'shift' key
|
2017-11-14 20:41:05 -06:00
|
|
|
if (event.keyCode === 13 && !event.shiftKey) {
|
2017-01-20 21:05:48 +08:00
|
|
|
event.preventDefault();
|
|
|
|
|
const $form = $(event.currentTarget).closest('form');
|
|
|
|
|
$form.find('button[type=submit]').click();
|
|
|
|
|
}
|
|
|
|
|
},
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
});
|
2017-01-20 21:05:48 +08:00
|
|
|
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
// NOTE: boardsSwimlanesAndLists template was removed from jade but JS was left behind.
|
|
|
|
|
// This is dead code — the template no longer exists in any jade file.
|
2021-10-19 21:27:47 +02:00
|
|
|
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
Template.addChecklistItemForm.onRendered(function () {
|
|
|
|
|
autosize(this.$('textarea.js-add-checklist-item'));
|
|
|
|
|
});
|
2017-02-03 01:49:58 +02:00
|
|
|
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
Template.addChecklistItemForm.events({
|
|
|
|
|
'click a.fa.fa-copy'(event, tpl) {
|
|
|
|
|
const $editor = tpl.$('textarea');
|
|
|
|
|
const promise = Utils.copyTextToClipboard($editor[0].value);
|
2021-07-22 22:44:40 -03:00
|
|
|
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
const $tooltip = tpl.$('.copied-tooltip');
|
|
|
|
|
Utils.showCopied(promise, $tooltip);
|
2021-07-22 22:44:40 -03:00
|
|
|
},
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
});
|
2021-07-22 22:44:40 -03:00
|
|
|
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
Template.checklistActionsPopup.events({
|
|
|
|
|
'click .js-delete-checklist': Popup.afterConfirm('checklistDelete', function () {
|
|
|
|
|
Popup.back(2);
|
|
|
|
|
const checklist = this.checklist;
|
|
|
|
|
if (checklist && checklist._id) {
|
|
|
|
|
Checklists.remove(checklist._id);
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
'click .js-move-checklist': Popup.open('moveChecklist'),
|
|
|
|
|
'click .js-copy-checklist': Popup.open('copyChecklist'),
|
|
|
|
|
'click .js-hide-checked-checklist-items'(event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
Template.currentData().checklist.toggleHideCheckedChecklistItems();
|
|
|
|
|
Popup.back();
|
2021-07-22 22:44:40 -03:00
|
|
|
},
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
'click .js-hide-all-checklist-items'(event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
Template.currentData().checklist.toggleHideAllChecklistItems();
|
|
|
|
|
Popup.back();
|
2021-07-22 22:44:40 -03:00
|
|
|
},
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
});
|
2021-07-22 22:44:40 -03:00
|
|
|
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
Template.editChecklistItemForm.onRendered(function () {
|
|
|
|
|
autosize(this.$('textarea.js-edit-checklist-item'));
|
2020-06-09 23:32:00 +02:00
|
|
|
});
|
|
|
|
|
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
Template.editChecklistItemForm.events({
|
|
|
|
|
'click a.fa.fa-copy'(event, tpl) {
|
|
|
|
|
const $editor = tpl.$('textarea');
|
|
|
|
|
const promise = Utils.copyTextToClipboard($editor[0].value);
|
2022-01-11 19:26:44 +01:00
|
|
|
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
const $tooltip = tpl.$('.copied-tooltip');
|
|
|
|
|
Utils.showCopied(promise, $tooltip);
|
2021-11-19 13:08:11 +01:00
|
|
|
},
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
});
|
2020-12-30 10:39:40 +01:00
|
|
|
|
2018-06-24 17:42:58 +03:00
|
|
|
Template.checklistItemDetail.helpers({
|
2017-03-18 18:49:39 -04:00
|
|
|
});
|
|
|
|
|
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
Template.checklistItemDetail.events({
|
|
|
|
|
'click .js-checklist-item .check-box-container'() {
|
|
|
|
|
const checklist = Template.currentData().checklist;
|
|
|
|
|
const item = Template.currentData().item;
|
2017-02-03 01:49:58 +02:00
|
|
|
if (checklist && item && item._id) {
|
2026-01-28 12:59:07 +02:00
|
|
|
item.toggleItem();
|
2017-02-03 01:49:58 +02:00
|
|
|
}
|
|
|
|
|
},
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helper to find the dialog instance from a parent popup template.
|
|
|
|
|
* copyAndMoveChecklist is included inside moveChecklistPopup / copyChecklistPopup,
|
|
|
|
|
* so we traverse up the view hierarchy to find the parent template's dialog.
|
|
|
|
|
*/
|
|
|
|
|
function getParentDialog(tpl) {
|
|
|
|
|
let view = tpl.view.parentView;
|
|
|
|
|
while (view) {
|
|
|
|
|
if (view.templateInstance && view.templateInstance() && view.templateInstance().dialog) {
|
|
|
|
|
return view.templateInstance().dialog;
|
|
|
|
|
}
|
|
|
|
|
view = view.parentView;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Shared helpers for copyAndMoveChecklist sub-template */
|
|
|
|
|
Template.copyAndMoveChecklist.helpers({
|
|
|
|
|
boards() {
|
|
|
|
|
const dialog = getParentDialog(Template.instance());
|
|
|
|
|
return dialog ? dialog.boards() : [];
|
|
|
|
|
},
|
|
|
|
|
swimlanes() {
|
|
|
|
|
const dialog = getParentDialog(Template.instance());
|
|
|
|
|
return dialog ? dialog.swimlanes() : [];
|
|
|
|
|
},
|
|
|
|
|
lists() {
|
|
|
|
|
const dialog = getParentDialog(Template.instance());
|
|
|
|
|
return dialog ? dialog.lists() : [];
|
2017-02-03 01:49:58 +02:00
|
|
|
},
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
cards() {
|
|
|
|
|
const dialog = getParentDialog(Template.instance());
|
|
|
|
|
return dialog ? dialog.cards() : [];
|
|
|
|
|
},
|
|
|
|
|
isDialogOptionBoardId(boardId) {
|
|
|
|
|
const dialog = getParentDialog(Template.instance());
|
|
|
|
|
return dialog ? dialog.isDialogOptionBoardId(boardId) : false;
|
|
|
|
|
},
|
|
|
|
|
isDialogOptionSwimlaneId(swimlaneId) {
|
|
|
|
|
const dialog = getParentDialog(Template.instance());
|
|
|
|
|
return dialog ? dialog.isDialogOptionSwimlaneId(swimlaneId) : false;
|
|
|
|
|
},
|
|
|
|
|
isDialogOptionListId(listId) {
|
|
|
|
|
const dialog = getParentDialog(Template.instance());
|
|
|
|
|
return dialog ? dialog.isDialogOptionListId(listId) : false;
|
|
|
|
|
},
|
|
|
|
|
isDialogOptionCardId(cardId) {
|
|
|
|
|
const dialog = getParentDialog(Template.instance());
|
|
|
|
|
return dialog ? dialog.isDialogOptionCardId(cardId) : false;
|
|
|
|
|
},
|
|
|
|
|
isTitleDefault(title) {
|
|
|
|
|
const dialog = getParentDialog(Template.instance());
|
|
|
|
|
return dialog ? dialog.isTitleDefault(title) : title;
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helper: register standard card dialog events on a checklist popup template.
|
|
|
|
|
* Events bubble up from the copyAndMoveChecklist sub-template to the parent popup.
|
|
|
|
|
*/
|
|
|
|
|
function registerChecklistDialogEvents(templateName) {
|
|
|
|
|
Template[templateName].events({
|
|
|
|
|
async 'click .js-done'(event, tpl) {
|
|
|
|
|
const dialog = tpl.dialog;
|
|
|
|
|
const boardSelect = tpl.$('.js-select-boards')[0];
|
|
|
|
|
const boardId = boardSelect.options[boardSelect.selectedIndex].value;
|
|
|
|
|
|
|
|
|
|
const listSelect = tpl.$('.js-select-lists')[0];
|
|
|
|
|
const listId = listSelect.options[listSelect.selectedIndex].value;
|
|
|
|
|
|
|
|
|
|
const swimlaneSelect = tpl.$('.js-select-swimlanes')[0];
|
|
|
|
|
const swimlaneId = swimlaneSelect.options[swimlaneSelect.selectedIndex].value;
|
|
|
|
|
|
|
|
|
|
const cardSelect = tpl.$('.js-select-cards')[0];
|
|
|
|
|
const cardId = cardSelect.options.length > 0
|
|
|
|
|
? cardSelect.options[cardSelect.selectedIndex].value
|
|
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
const options = { boardId, swimlaneId, listId, cardId };
|
|
|
|
|
try {
|
|
|
|
|
await dialog.setDone(cardId, options);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('Error in card dialog operation:', e);
|
|
|
|
|
}
|
|
|
|
|
Popup.back(2);
|
|
|
|
|
},
|
|
|
|
|
'change .js-select-boards'(event, tpl) {
|
|
|
|
|
tpl.dialog.getBoardData($(event.currentTarget).val());
|
|
|
|
|
},
|
|
|
|
|
'change .js-select-swimlanes'(event, tpl) {
|
|
|
|
|
tpl.dialog.selectedSwimlaneId.set($(event.currentTarget).val());
|
|
|
|
|
tpl.dialog.setFirstListId();
|
|
|
|
|
},
|
|
|
|
|
'change .js-select-lists'(event, tpl) {
|
|
|
|
|
tpl.dialog.selectedListId.set($(event.currentTarget).val());
|
|
|
|
|
tpl.dialog.selectedCardId.set('');
|
|
|
|
|
},
|
|
|
|
|
'change .js-select-cards'(event, tpl) {
|
|
|
|
|
tpl.dialog.selectedCardId.set($(event.currentTarget).val());
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-01-11 19:42:57 +01:00
|
|
|
|
2022-01-30 12:32:52 +01:00
|
|
|
/** Move Checklist Dialog */
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
Template.moveChecklistPopup.onCreated(function () {
|
|
|
|
|
this.dialog = new BoardSwimlaneListCardDialog(this, {
|
|
|
|
|
getDialogOptions() {
|
|
|
|
|
return ReactiveCache.getCurrentUser().getMoveChecklistDialogOptions();
|
|
|
|
|
},
|
|
|
|
|
async setDone(cardId, options) {
|
|
|
|
|
ReactiveCache.getCurrentUser().setMoveChecklistDialogOption(this.currentBoardId, options);
|
|
|
|
|
await Template.currentData().checklist.move(cardId);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
registerChecklistDialogEvents('moveChecklistPopup');
|
2022-01-30 12:32:52 +01:00
|
|
|
|
|
|
|
|
/** Copy Checklist Dialog */
|
Migrate card components from BlazeComponent to Template
Convert cardDetails, cardCustomFields, cardDate, cardTime,
cardDescription, attachments, checklists, labels, minicard,
resultCard, and subtasks to use native Meteor Template pattern.
2026-03-08 11:01:13 +02:00
|
|
|
Template.copyChecklistPopup.onCreated(function () {
|
|
|
|
|
this.dialog = new BoardSwimlaneListCardDialog(this, {
|
|
|
|
|
getDialogOptions() {
|
|
|
|
|
return ReactiveCache.getCurrentUser().getCopyChecklistDialogOptions();
|
|
|
|
|
},
|
|
|
|
|
async setDone(cardId, options) {
|
|
|
|
|
ReactiveCache.getCurrentUser().setCopyChecklistDialogOption(this.currentBoardId, options);
|
|
|
|
|
await Template.currentData().checklist.copy(cardId);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
registerChecklistDialogEvents('copyChecklistPopup');
|