2023-01-16 23:00:10 +01:00
|
|
|
import { ReactiveCache } from '/imports/reactiveCache';
|
2021-07-10 10:55:54 +02:00
|
|
|
import { TAPi18n } from '/imports/i18n';
|
2025-10-10 18:52:30 +03:00
|
|
|
import { CustomFieldStringTemplate } from '/client/lib/customFields';
|
|
|
|
|
import { handleFileUpload } from './attachments';
|
2025-10-11 00:49:43 +03:00
|
|
|
import uploadProgressManager from '../../lib/uploadProgressManager';
|
2021-07-10 10:55:54 +02:00
|
|
|
|
2015-05-27 17:17:00 +02:00
|
|
|
// Template.cards.events({
|
|
|
|
|
// 'click .member': Popup.open('cardMember')
|
|
|
|
|
// });
|
|
|
|
|
|
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.minicard.helpers({
|
2020-05-25 16:02:37 +00:00
|
|
|
formattedCurrencyCustomFieldValue(definition) {
|
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 customField = this
|
2020-05-25 16:02:37 +00:00
|
|
|
.customFieldsWD()
|
|
|
|
|
.find(f => f._id === definition._id);
|
|
|
|
|
const customFieldTrueValue =
|
|
|
|
|
customField && customField.trueValue ? customField.trueValue : '';
|
|
|
|
|
|
2020-05-25 22:05:06 +00:00
|
|
|
const locale = TAPi18n.getLanguage();
|
|
|
|
|
return new Intl.NumberFormat(locale, {
|
|
|
|
|
style: 'currency',
|
|
|
|
|
currency: definition.settings.currencyCode,
|
|
|
|
|
}).format(customFieldTrueValue);
|
2020-05-25 16:02:37 +00:00
|
|
|
},
|
|
|
|
|
|
2021-04-07 16:11:19 +02:00
|
|
|
formattedStringtemplateCustomFieldValue(definition) {
|
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 customField = this
|
2021-04-07 16:11:19 +02:00
|
|
|
.customFieldsWD()
|
|
|
|
|
.find(f => f._id === definition._id);
|
|
|
|
|
|
2021-04-08 10:54:28 +02:00
|
|
|
const customFieldTrueValue =
|
2021-04-11 14:18:12 +02:00
|
|
|
customField && customField.trueValue ? customField.trueValue : [];
|
2021-04-07 16:11:19 +02:00
|
|
|
|
2022-04-23 19:46:56 +02:00
|
|
|
const ret = new CustomFieldStringTemplate(definition).getFormattedValue(customFieldTrueValue);
|
|
|
|
|
return ret;
|
2021-04-07 16:11:19 +02:00
|
|
|
},
|
|
|
|
|
|
2026-02-08 00:48:39 +02:00
|
|
|
showCreatorOnMinicard() {
|
|
|
|
|
// cache "board" to reduce the mini-mongodb access
|
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 board = this.board();
|
2026-02-08 00:48:39 +02:00
|
|
|
let ret = false;
|
|
|
|
|
if (board) {
|
|
|
|
|
ret = board.allowsCreatorOnMinicard ?? false;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
},
|
2025-04-24 11:53:08 +01:00
|
|
|
isWatching() {
|
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
|
|
|
return this.findWatcher(Meteor.userId());
|
2025-04-24 11:53:08 +01:00
|
|
|
},
|
2021-04-01 23:40:07 +02:00
|
|
|
|
2026-02-08 00:48:39 +02:00
|
|
|
showMembers() {
|
|
|
|
|
// cache "board" to reduce the mini-mongodb access
|
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 board = this.board();
|
2026-02-08 00:48:39 +02:00
|
|
|
let ret = false;
|
|
|
|
|
if (board) {
|
|
|
|
|
ret =
|
|
|
|
|
board.allowsMembers === null ||
|
|
|
|
|
board.allowsMembers === undefined ||
|
|
|
|
|
board.allowsMembers
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showAssignee() {
|
|
|
|
|
// cache "board" to reduce the mini-mongodb access
|
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 board = this.board();
|
2026-02-08 00:48:39 +02:00
|
|
|
let ret = false;
|
|
|
|
|
if (board) {
|
|
|
|
|
ret =
|
|
|
|
|
board.allowsAssignee === null ||
|
|
|
|
|
board.allowsAssignee === undefined ||
|
|
|
|
|
board.allowsAssignee
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
2021-11-25 22:27:19 +01:00
|
|
|
},
|
|
|
|
|
|
2019-08-07 18:11:34 +03:00
|
|
|
hiddenMinicardLabelText() {
|
2023-01-16 23:00:10 +01:00
|
|
|
const currentUser = ReactiveCache.getCurrentUser();
|
2019-11-19 14:09:36 +02:00
|
|
|
if (currentUser) {
|
|
|
|
|
return (currentUser.profile || {}).hiddenMinicardLabelText;
|
2020-10-28 15:45:37 +02:00
|
|
|
} else if (window.localStorage.getItem('hiddenMinicardLabelText')) {
|
2020-01-03 06:49:35 +02:00
|
|
|
return true;
|
New feature: Now there is popup selection of Lists/Swimlanes/Calendar/Roles.
New feature, not set visible yet, because switching to it does not
work properly yet: Collapsible Swimlanes #2804
Fix: Public board now loads correctly. When you select one of Lists/Swimlanes/Calendar view and
reload webbrowser page, it can change view. Closes #2311
Fix: List sorting commented out. Closes #2800
Fix: Errors hasHiddenMinicardText, hasShowDragHandles, showSort, hasSortBy, profile,
FirefoxAndroid/IE11/Vivaldi/Chromium browsers not working by using
cookies instead of database.
More details at https://github.com/wekan/wekan/issues/2643#issuecomment-554907955
Note: Cookie changes are not always immediate, if there is no effect,
you may need to reload webbrowser page.
Closes #2643 .
Thanks to xet7 !
2019-11-18 22:23:49 +02:00
|
|
|
} else {
|
2020-01-03 06:49:35 +02:00
|
|
|
return false;
|
New feature: Now there is popup selection of Lists/Swimlanes/Calendar/Roles.
New feature, not set visible yet, because switching to it does not
work properly yet: Collapsible Swimlanes #2804
Fix: Public board now loads correctly. When you select one of Lists/Swimlanes/Calendar view and
reload webbrowser page, it can change view. Closes #2311
Fix: List sorting commented out. Closes #2800
Fix: Errors hasHiddenMinicardText, hasShowDragHandles, showSort, hasSortBy, profile,
FirefoxAndroid/IE11/Vivaldi/Chromium browsers not working by using
cookies instead of database.
More details at https://github.com/wekan/wekan/issues/2643#issuecomment-554907955
Note: Cookie changes are not always immediate, if there is no effect,
you may need to reload webbrowser page.
Closes #2643 .
Thanks to xet7 !
2019-11-18 22:23:49 +02:00
|
|
|
}
|
2019-08-07 18:11:34 +03:00
|
|
|
},
|
2020-10-20 17:44:04 -05:00
|
|
|
// XXX resolve this nasty hack for https://github.com/veliovgroup/Meteor-Files/issues/763
|
|
|
|
|
sess() {
|
|
|
|
|
return Meteor.connection && Meteor.connection._lastSessionId
|
|
|
|
|
? Meteor.connection._lastSessionId
|
|
|
|
|
: null;
|
|
|
|
|
},
|
2025-10-10 21:46:07 +03:00
|
|
|
// Upload progress helpers
|
|
|
|
|
hasActiveUploads() {
|
|
|
|
|
return uploadProgressManager.hasActiveUploads(this._id);
|
|
|
|
|
},
|
|
|
|
|
uploads() {
|
|
|
|
|
return uploadProgressManager.getUploadsForCard(this._id);
|
|
|
|
|
},
|
|
|
|
|
uploadCount() {
|
|
|
|
|
return uploadProgressManager.getUploadCountForCard(this._id);
|
2025-10-11 11:31:57 +03:00
|
|
|
},
|
|
|
|
|
listName() {
|
|
|
|
|
const list = this.list();
|
|
|
|
|
return list ? list.title : '';
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
shouldShowListOnMinicard() {
|
2026-02-08 00:48:39 +02:00
|
|
|
// Show list name if either:
|
|
|
|
|
// 1. Board-wide setting is enabled, OR
|
|
|
|
|
// 2. This specific card has the setting enabled
|
|
|
|
|
const currentBoard = this.board();
|
|
|
|
|
if (!currentBoard) return false;
|
|
|
|
|
return currentBoard.allowsShowListsOnMinicard || this.showListOnMinicard;
|
2025-12-29 21:42:19 +02:00
|
|
|
},
|
2026-02-08 00:48:39 +02:00
|
|
|
|
|
|
|
|
shouldShowChecklistAtMinicard() {
|
|
|
|
|
// Return checklists that should be shown on minicard
|
|
|
|
|
const currentBoard = this.board();
|
|
|
|
|
if (!currentBoard) return [];
|
|
|
|
|
|
|
|
|
|
const checklists = this.checklists();
|
|
|
|
|
const visibleChecklists = [];
|
|
|
|
|
|
|
|
|
|
checklists.forEach(checklist => {
|
|
|
|
|
// Show checklist if either:
|
|
|
|
|
// 1. Board-wide setting is enabled, OR
|
|
|
|
|
// 2. This specific checklist has the setting enabled
|
|
|
|
|
if (currentBoard.allowsChecklistAtMinicard || checklist.showChecklistAtMinicard) {
|
|
|
|
|
visibleChecklists.push(checklist);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return visibleChecklists;
|
|
|
|
|
}
|
2019-08-07 18:11:34 +03:00
|
|
|
});
|
2021-10-12 14:53:08 +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.minicard.events({
|
|
|
|
|
'click .js-linked-link'() {
|
|
|
|
|
if (this.isLinkedCard()) Utils.goCardId(this.linkedId);
|
|
|
|
|
else if (this.isLinkedBoard())
|
|
|
|
|
Utils.goBoardId(this.linkedId);
|
|
|
|
|
},
|
|
|
|
|
'click .js-toggle-minicard-label-text'() {
|
|
|
|
|
if (window.localStorage.getItem('hiddenMinicardLabelText')) {
|
|
|
|
|
window.localStorage.removeItem('hiddenMinicardLabelText'); //true
|
|
|
|
|
} else {
|
|
|
|
|
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'(event, tpl) {
|
|
|
|
|
if (tpl.find('.js-card-label:hover')) {
|
|
|
|
|
Popup.open("cardLabels")(event, {dataContextIfCurrentDataIsUndefined: Template.currentData()});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
'click .js-open-minicard-details-menu'(event, tpl) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
const card = Template.currentData();
|
|
|
|
|
Popup.open('cardDetailsActions').call({currentData: () => card}, event);
|
|
|
|
|
},
|
|
|
|
|
// Drag and drop file upload handlers
|
|
|
|
|
'dragover .minicard'(event) {
|
|
|
|
|
// Only prevent default for file drags to avoid interfering with sortable
|
|
|
|
|
const dataTransfer = event.originalEvent.dataTransfer;
|
|
|
|
|
if (dataTransfer && dataTransfer.types && dataTransfer.types.includes('Files')) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
'dragenter .minicard'(event) {
|
|
|
|
|
const dataTransfer = event.originalEvent.dataTransfer;
|
|
|
|
|
if (dataTransfer && dataTransfer.types && dataTransfer.types.includes('Files')) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
const card = this;
|
|
|
|
|
const board = card.board();
|
|
|
|
|
// Only allow drag-and-drop if user can modify card and board allows attachments
|
|
|
|
|
if (Utils.canModifyCard() && board && board.allowsAttachments) {
|
|
|
|
|
$(event.currentTarget).addClass('is-dragging-over');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
'dragleave .minicard'(event) {
|
|
|
|
|
const dataTransfer = event.originalEvent.dataTransfer;
|
|
|
|
|
if (dataTransfer && dataTransfer.types && dataTransfer.types.includes('Files')) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
$(event.currentTarget).removeClass('is-dragging-over');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
'drop .minicard'(event) {
|
|
|
|
|
const dataTransfer = event.originalEvent.dataTransfer;
|
|
|
|
|
if (dataTransfer && dataTransfer.types && dataTransfer.types.includes('Files')) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
$(event.currentTarget).removeClass('is-dragging-over');
|
|
|
|
|
|
|
|
|
|
const card = this;
|
|
|
|
|
const board = card.board();
|
|
|
|
|
|
|
|
|
|
// Check permissions
|
|
|
|
|
if (!Utils.canModifyCard() || !board || !board.allowsAttachments) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if this is a file drop (not a card reorder)
|
|
|
|
|
if (!dataTransfer.files || dataTransfer.files.length === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const files = dataTransfer.files;
|
|
|
|
|
if (files && files.length > 0) {
|
|
|
|
|
handleFileUpload(card, files);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.minicardChecklist.helpers({
|
|
|
|
|
visibleItems() {
|
|
|
|
|
const checklist = this.checklist || this;
|
|
|
|
|
const items = checklist.items();
|
|
|
|
|
|
|
|
|
|
return items.filter(item => {
|
|
|
|
|
// Hide finished items if hideCheckedChecklistItems is true
|
|
|
|
|
if (item.isFinished && checklist.hideCheckedChecklistItems) {
|
|
|
|
|
return false;
|
2021-10-12 14:53:08 +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
|
|
|
// Hide all items if hideAllChecklistItems is true
|
|
|
|
|
if (checklist.hideAllChecklistItems) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.minicardChecklist.events({
|
|
|
|
|
'click .js-open-checklist-menu'(event) {
|
|
|
|
|
const data = Template.currentData();
|
|
|
|
|
const checklist = data.checklist || data;
|
|
|
|
|
const card = data.card || this;
|
|
|
|
|
const context = { currentData: () => ({ checklist, card }) };
|
|
|
|
|
Popup.open('checklistActions').call(context, event);
|
|
|
|
|
},
|
|
|
|
|
});
|
2022-10-02 18:45:55 +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.editCardSortOrderPopup.events({
|
|
|
|
|
'keydown input.js-edit-card-sort-popup'(evt, tpl) {
|
|
|
|
|
// enter = save
|
|
|
|
|
if (evt.keyCode === 13) {
|
|
|
|
|
tpl.find('button[type=submit]').click();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
'click button.js-submit-edit-card-sort-popup'(event, tpl) {
|
|
|
|
|
// save button pressed
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
const sort = tpl.$('.js-edit-card-sort-popup')[0]
|
|
|
|
|
.value
|
|
|
|
|
.trim();
|
|
|
|
|
if (!Number.isNaN(sort)) {
|
|
|
|
|
let card = this;
|
|
|
|
|
card.move(card.boardId, card.swimlaneId, card.listId, sort);
|
|
|
|
|
Popup.back();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|