2021-07-10 10:55:54 +02:00
|
|
|
import { TAPi18n } from '/imports/i18n';
|
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 Cards from '/models/cards';
|
|
|
|
|
import { getCurrentCardIdFromContext } from '/client/lib/currentCard';
|
2021-07-10 10:55:54 +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
|
|
|
function getCardId() {
|
|
|
|
|
return getCurrentCardIdFromContext();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Template.editCardSpentTimePopup.onCreated(function () {
|
|
|
|
|
this.error = new ReactiveVar('');
|
|
|
|
|
this.card = Cards.findOne(getCardId());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.editCardSpentTimePopup.helpers({
|
|
|
|
|
error() {
|
|
|
|
|
return Template.instance().error;
|
2017-11-20 22:26:31 +07: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
|
|
|
card() {
|
|
|
|
|
return Cards.findOne(getCardId());
|
2017-11-20 22:26:31 +07: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
|
|
|
getIsOvertime() {
|
|
|
|
|
const card = Cards.findOne(getCardId());
|
|
|
|
|
return card?.getIsOvertime ? card.getIsOvertime() : false;
|
2017-11-20 22:26:31 +07: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
|
|
|
});
|
2017-11-20 22:26:31 +07: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.editCardSpentTimePopup.events({
|
|
|
|
|
//TODO : need checking this portion
|
|
|
|
|
'submit .edit-time'(evt, tpl) {
|
|
|
|
|
evt.preventDefault();
|
|
|
|
|
const card = Cards.findOne(getCardId());
|
|
|
|
|
if (!card) return;
|
2017-11-20 22:26:31 +07: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 spentTime = parseFloat(evt.target.time.value);
|
|
|
|
|
let isOvertime = false;
|
|
|
|
|
if ($('#overtime').attr('class').indexOf('is-checked') >= 0) {
|
|
|
|
|
isOvertime = true;
|
|
|
|
|
}
|
|
|
|
|
if (spentTime >= 0) {
|
|
|
|
|
card.setSpentTime(spentTime);
|
|
|
|
|
card.setIsOvertime(isOvertime);
|
|
|
|
|
Popup.back();
|
|
|
|
|
} else {
|
|
|
|
|
tpl.error.set('invalid-time');
|
|
|
|
|
evt.target.time.focus();
|
|
|
|
|
}
|
2017-11-20 22:26:31 +07: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-delete-time'(evt) {
|
|
|
|
|
evt.preventDefault();
|
|
|
|
|
const card = Cards.findOne(getCardId());
|
|
|
|
|
if (!card) return;
|
|
|
|
|
card.setSpentTime(null);
|
|
|
|
|
card.setIsOvertime(false);
|
|
|
|
|
Popup.back();
|
|
|
|
|
},
|
|
|
|
|
'click a.js-toggle-overtime'(evt) {
|
|
|
|
|
const card = Cards.findOne(getCardId());
|
|
|
|
|
if (!card) return;
|
|
|
|
|
card.setIsOvertime(!card.getIsOvertime());
|
|
|
|
|
$('#overtime .materialCheckBox').toggleClass('is-checked');
|
|
|
|
|
$('#overtime').toggleClass('is-checked');
|
2017-11-20 22:26:31 +07: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.cardSpentTime.helpers({
|
2017-11-20 22:26:31 +07:00
|
|
|
showTitle() {
|
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 card = Cards.findOne(this._id) || this;
|
|
|
|
|
if (card.getIsOvertime && card.getIsOvertime()) {
|
2019-06-28 12:52:09 -05:00
|
|
|
return `${TAPi18n.__(
|
|
|
|
|
'overtime',
|
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
|
|
|
)} ${card.getSpentTime()} ${TAPi18n.__('hours')}`;
|
|
|
|
|
} else if (card.getSpentTime) {
|
2019-06-28 12:52:09 -05:00
|
|
|
return `${TAPi18n.__(
|
|
|
|
|
'card-spent',
|
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
|
|
|
)} ${card.getSpentTime()} ${TAPi18n.__('hours')}`;
|
2017-11-20 22:40:02 +07: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
|
|
|
return '';
|
2017-11-20 22:26:31 +07:00
|
|
|
},
|
|
|
|
|
showTime() {
|
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 card = Cards.findOne(this._id) || this;
|
|
|
|
|
return card.getSpentTime ? card.getSpentTime() : '';
|
2017-11-20 22:26:31 +07: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
|
|
|
getIsOvertime() {
|
|
|
|
|
const card = Cards.findOne(this._id) || this;
|
|
|
|
|
return card.getIsOvertime ? card.getIsOvertime() : false;
|
2017-11-20 22:26:31 +07: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.cardSpentTime.events({
|
|
|
|
|
'click .js-edit-time': Popup.open('editCardSpentTime'),
|
|
|
|
|
});
|