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';
|
2022-04-23 19:46:56 +02:00
|
|
|
import { CustomFieldStringTemplate } from '/client/lib/customFields'
|
2021-07-10 10:55:54 +02:00
|
|
|
|
2015-05-27 17:17:00 +02:00
|
|
|
// Template.cards.events({
|
|
|
|
// 'click .member': Popup.open('cardMember')
|
|
|
|
// });
|
|
|
|
|
|
|
|
BlazeComponent.extendComponent({
|
2015-09-03 23:12:46 +02:00
|
|
|
template() {
|
2015-05-27 17:17:00 +02:00
|
|
|
return 'minicard';
|
2015-09-03 23:12:46 +02:00
|
|
|
},
|
2018-04-20 23:52:13 -03:00
|
|
|
|
2020-05-25 16:02:37 +00:00
|
|
|
formattedCurrencyCustomFieldValue(definition) {
|
|
|
|
const customField = this.data()
|
|
|
|
.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) {
|
|
|
|
const customField = this.data()
|
|
|
|
.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
|
|
|
},
|
|
|
|
|
2021-04-01 23:40:07 +02:00
|
|
|
showCreator() {
|
2022-12-11 12:19:01 +01:00
|
|
|
// cache "board" to reduce the mini-mongodb access
|
|
|
|
const board = this.data().board();
|
|
|
|
let ret = false;
|
|
|
|
if (board) {
|
|
|
|
ret =
|
|
|
|
board.allowsCreator === null ||
|
|
|
|
board.allowsCreator === undefined ||
|
|
|
|
board.allowsCreator
|
|
|
|
;
|
2021-04-01 23:40:07 +02:00
|
|
|
}
|
2022-12-11 12:19:01 +01:00
|
|
|
return ret;
|
2021-04-01 23:40:07 +02:00
|
|
|
},
|
|
|
|
|
2021-11-25 22:27:19 +01:00
|
|
|
showMembers() {
|
2022-12-11 12:19:01 +01:00
|
|
|
// cache "board" to reduce the mini-mongodb access
|
|
|
|
const board = this.data().board();
|
|
|
|
let ret = false;
|
|
|
|
if (board) {
|
|
|
|
ret =
|
|
|
|
board.allowsMembers === null ||
|
|
|
|
board.allowsMembers === undefined ||
|
|
|
|
board.allowsMembers
|
|
|
|
;
|
2021-11-25 22:27:19 +01:00
|
|
|
}
|
2022-12-11 12:19:01 +01:00
|
|
|
return ret;
|
2021-11-25 22:27:19 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
showAssignee() {
|
2022-12-11 12:19:01 +01:00
|
|
|
// cache "board" to reduce the mini-mongodb access
|
|
|
|
const board = this.data().board();
|
|
|
|
let ret = false;
|
|
|
|
if (board) {
|
|
|
|
ret =
|
|
|
|
board.allowsAssignee === null ||
|
|
|
|
board.allowsAssignee === undefined ||
|
|
|
|
board.allowsAssigne
|
|
|
|
;
|
2021-11-25 22:27:19 +01:00
|
|
|
}
|
2022-12-11 12:19:01 +01:00
|
|
|
return ret;
|
2021-11-25 22:27:19 +01:00
|
|
|
},
|
|
|
|
|
2021-10-24 23:51:09 +02:00
|
|
|
/** 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')) {
|
2021-10-25 00:27:54 +02:00
|
|
|
Popup.open("cardLabels")(event, {dataContextIfCurrentDataIsUndefined: this.currentData()});
|
2021-10-24 23:51:09 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-04-20 23:52:13 -03:00
|
|
|
events() {
|
2019-06-28 12:52:09 -05:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
'click .js-linked-link'() {
|
|
|
|
if (this.data().isLinkedCard()) Utils.goCardId(this.data().linkedId);
|
|
|
|
else if (this.data().isLinkedBoard())
|
|
|
|
Utils.goBoardId(this.data().linkedId);
|
|
|
|
},
|
2019-08-07 18:11:34 +03:00
|
|
|
'click .js-toggle-minicard-label-text'() {
|
2020-10-28 15:45:37 +02:00
|
|
|
if (window.localStorage.getItem('hiddenMinicardLabelText')) {
|
|
|
|
window.localStorage.removeItem('hiddenMinicardLabelText'); //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-10-28 15:45:37 +02:00
|
|
|
window.localStorage.setItem('hiddenMinicardLabelText', 'true'); //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
|
|
|
}
|
2019-08-07 18:11:34 +03:00
|
|
|
},
|
2021-10-12 14:55:59 +02:00
|
|
|
'click span.badge-icon.fa.fa-sort, click span.badge-text.check-list-sort' : Popup.open("editCardSortOrder"),
|
2021-10-24 23:51:09 +02:00
|
|
|
'click .minicard-labels' : this.cardLabelsPopup,
|
2022-10-02 18:45:55 +03:00
|
|
|
'click .js-open-minicard-details-menu': Popup.open('minicardDetailsActions'),
|
2021-10-12 14:53:08 +02:00
|
|
|
}
|
2019-06-28 12:52:09 -05:00
|
|
|
];
|
2018-04-20 23:52:13 -03:00
|
|
|
},
|
2015-05-27 17:17:00 +02:00
|
|
|
}).register('minicard');
|
2019-08-07 18:11:34 +03:00
|
|
|
|
|
|
|
Template.minicard.helpers({
|
|
|
|
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;
|
|
|
|
},
|
2019-08-07 18:11:34 +03:00
|
|
|
});
|
2021-10-12 14:53:08 +02:00
|
|
|
|
|
|
|
BlazeComponent.extendComponent({
|
|
|
|
events() {
|
|
|
|
return [
|
|
|
|
{
|
2021-10-12 14:55:59 +02:00
|
|
|
'keydown input.js-edit-card-sort-popup'(evt) {
|
|
|
|
// enter = save
|
|
|
|
if (evt.keyCode === 13) {
|
|
|
|
this.find('button[type=submit]').click();
|
|
|
|
}
|
|
|
|
},
|
2021-10-12 14:53:08 +02:00
|
|
|
'click button.js-submit-edit-card-sort-popup'(event) {
|
|
|
|
// save button pressed
|
|
|
|
event.preventDefault();
|
|
|
|
const sort = this.$('.js-edit-card-sort-popup')[0]
|
|
|
|
.value
|
|
|
|
.trim();
|
|
|
|
if (!Number.isNaN(sort)) {
|
|
|
|
let card = this.data();
|
|
|
|
card.move(card.boardId, card.swimlaneId, card.listId, sort);
|
2021-10-21 10:35:16 +02:00
|
|
|
Popup.back();
|
2021-10-12 14:53:08 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}).register('editCardSortOrderPopup');
|
2022-10-02 18:45:55 +03:00
|
|
|
|
|
|
|
Template.minicardDetailsActionsPopup.events({
|
|
|
|
'click .js-due-date': Popup.open('editCardDueDate'),
|
|
|
|
'click .js-move-card': Popup.open('moveCard'),
|
|
|
|
'click .js-copy-card': Popup.open('copyCard'),
|
|
|
|
'click .js-set-card-color': Popup.open('setCardColor'),
|
|
|
|
'click .js-add-labels': Popup.open('cardLabels'),
|
|
|
|
'click .js-link': Popup.open('linkCard'),
|
|
|
|
'click .js-move-card-to-top'(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
const minOrder = this.getMinSort();
|
|
|
|
this.move(this.boardId, this.swimlaneId, this.listId, minOrder - 1);
|
|
|
|
Popup.back();
|
|
|
|
},
|
|
|
|
'click .js-move-card-to-bottom'(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
const maxOrder = this.getMaxSort();
|
|
|
|
this.move(this.boardId, this.swimlaneId, this.listId, maxOrder + 1);
|
|
|
|
Popup.back();
|
|
|
|
},
|
2023-02-26 01:35:42 +02:00
|
|
|
'click .js-archive': Popup.afterConfirm('cardArchive', function () {
|
|
|
|
Popup.close();
|
|
|
|
this.archive();
|
|
|
|
Utils.goBoardId(this.boardId);
|
|
|
|
}),
|
2022-10-02 18:45:55 +03:00
|
|
|
});
|