2017-09-14 00:50:05 +02:00
|
|
|
Template.cardCustomFieldsPopup.helpers({
|
|
|
|
|
hasCustomField() {
|
|
|
|
|
const card = Cards.findOne(Session.get('currentCard'));
|
|
|
|
|
const customFieldId = this._id;
|
|
|
|
|
return card.customFieldIndex(customFieldId) > -1;
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2017-09-05 02:34:18 +02:00
|
|
|
Template.cardCustomFieldsPopup.events({
|
|
|
|
|
'click .js-select-field'(evt) {
|
|
|
|
|
const card = Cards.findOne(Session.get('currentCard'));
|
|
|
|
|
const customFieldId = this._id;
|
|
|
|
|
card.toggleCustomField(customFieldId);
|
|
|
|
|
evt.preventDefault();
|
|
|
|
|
},
|
2017-09-18 00:46:17 +02:00
|
|
|
'click .js-settings'(evt) {
|
2017-09-05 02:34:18 +02:00
|
|
|
EscapeActions.executeUpTo('detailsPane');
|
|
|
|
|
Sidebar.setView('customFields');
|
|
|
|
|
evt.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const CardCustomField = BlazeComponent.extendComponent({
|
2017-09-18 00:46:17 +02:00
|
|
|
|
|
|
|
|
getTemplate() {
|
|
|
|
|
return 'cardCustomField-' + this.data().definition.type;
|
2017-09-05 02:34:18 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onCreated() {
|
|
|
|
|
const self = this;
|
|
|
|
|
},
|
|
|
|
|
|
2017-09-18 00:46:17 +02:00
|
|
|
canModifyCard() {
|
|
|
|
|
return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly();
|
2017-09-05 02:34:18 +02:00
|
|
|
},
|
2017-09-18 00:46:17 +02:00
|
|
|
});
|
|
|
|
|
CardCustomField.register('cardCustomField');
|
2017-09-05 02:34:18 +02:00
|
|
|
|
2017-09-18 00:46:17 +02:00
|
|
|
(class extends CardCustomField {
|
|
|
|
|
|
|
|
|
|
onCreated() {
|
|
|
|
|
}
|
2017-09-05 02:34:18 +02:00
|
|
|
|
|
|
|
|
events() {
|
|
|
|
|
return [{
|
2017-09-14 00:50:05 +02:00
|
|
|
'submit .js-card-customfield-text'(evt) {
|
|
|
|
|
evt.preventDefault();
|
|
|
|
|
const card = Cards.findOne(Session.get('currentCard'));
|
|
|
|
|
const customFieldId = this.data()._id;
|
|
|
|
|
const value = this.currentComponent().getValue();
|
|
|
|
|
card.setCustomField(customFieldId,value);
|
|
|
|
|
},
|
2017-09-05 02:34:18 +02:00
|
|
|
}];
|
2017-09-18 00:46:17 +02:00
|
|
|
}
|
2017-09-14 00:50:05 +02:00
|
|
|
|
2017-09-18 00:46:17 +02:00
|
|
|
}).register('cardCustomField-text');
|
|
|
|
|
|
|
|
|
|
(class extends CardCustomField {
|
|
|
|
|
|
|
|
|
|
onCreated() {
|
|
|
|
|
this._items = this.data().definition.settings.dropdownItems;
|
|
|
|
|
this.items = this._items.slice(0);
|
|
|
|
|
this.items.unshift({
|
|
|
|
|
_id: "",
|
|
|
|
|
name: TAPi18n.__('custom-field-dropdown-none')
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
selectedItem() {
|
|
|
|
|
const selected = this._items.find((item) => {
|
|
|
|
|
return item._id == this.data().value;
|
|
|
|
|
});
|
|
|
|
|
return (selected) ? selected.name : TAPi18n.__('custom-field-dropdown-unknown');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
events() {
|
|
|
|
|
return [{
|
|
|
|
|
'submit .js-card-customfield-dropdown'(evt) {
|
|
|
|
|
evt.preventDefault();
|
|
|
|
|
const card = Cards.findOne(Session.get('currentCard'));
|
|
|
|
|
const customFieldId = this.data()._id;
|
|
|
|
|
const value = this.find('select').value;
|
|
|
|
|
card.setCustomField(customFieldId,value);
|
|
|
|
|
},
|
|
|
|
|
}];
|
|
|
|
|
}
|
2017-09-05 02:34:18 +02:00
|
|
|
|
2017-09-18 00:46:17 +02:00
|
|
|
}).register('cardCustomField-dropdown');
|