mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 05:27:14 -04:00
text custom fields are now editable using inlinedForm
This commit is contained in:
parent
6ff89b43b6
commit
caad952bc1
3 changed files with 43 additions and 10 deletions
|
@ -5,7 +5,7 @@ template(name="cardCustomFieldsPopup")
|
|||
a.name.js-select-field(href="#")
|
||||
span.full-name
|
||||
= name
|
||||
if isCardMember
|
||||
if hasCustomField
|
||||
i.fa.fa-check
|
||||
hr
|
||||
a.quiet-button.full.js-configure-custom-fields
|
||||
|
@ -14,10 +14,16 @@ template(name="cardCustomFieldsPopup")
|
|||
|
||||
template(name="cardCustomFieldText")
|
||||
if canModifyCard
|
||||
.item-title.js-open-inlined-form.is-editable
|
||||
if value
|
||||
+inlinedForm(classNames="js-card-customfield-text")
|
||||
+editor(autofocus=true)
|
||||
= value
|
||||
else
|
||||
| {{_ 'edit'}}
|
||||
else
|
||||
.item-title {{value}}
|
||||
.edit-controls.clearfix
|
||||
button.primary(type="submit") {{_ 'save'}}
|
||||
a.fa.fa-times-thin.js-close-inlined-form
|
||||
else
|
||||
a.js-open-inlined-form
|
||||
if value
|
||||
+viewer
|
||||
= value
|
||||
else
|
||||
| {{_ 'edit'}}
|
|
@ -1,3 +1,11 @@
|
|||
Template.cardCustomFieldsPopup.helpers({
|
||||
hasCustomField() {
|
||||
const card = Cards.findOne(Session.get('currentCard'));
|
||||
const customFieldId = this._id;
|
||||
return card.customFieldIndex(customFieldId) > -1;
|
||||
},
|
||||
});
|
||||
|
||||
Template.cardCustomFieldsPopup.events({
|
||||
'click .js-select-field'(evt) {
|
||||
const card = Cards.findOne(Session.get('currentCard'));
|
||||
|
@ -24,7 +32,7 @@ const CardCustomField = BlazeComponent.extendComponent({
|
|||
},
|
||||
|
||||
value() {
|
||||
return "this is the value";
|
||||
return this.data().value;
|
||||
},
|
||||
|
||||
showISODate() {
|
||||
|
@ -33,9 +41,20 @@ const CardCustomField = BlazeComponent.extendComponent({
|
|||
|
||||
events() {
|
||||
return [{
|
||||
'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);
|
||||
},
|
||||
'click .js-edit-date': Popup.open('editCardStartDate'),
|
||||
}];
|
||||
},
|
||||
|
||||
canModifyCard() {
|
||||
return Meteor.user() && Meteor.user().isBoardMember() && !Meteor.user().isCommentOnly();
|
||||
},
|
||||
});
|
||||
|
||||
CardCustomField.register('cardCustomField');
|
|
@ -279,12 +279,10 @@ Cards.mutations({
|
|||
},
|
||||
|
||||
assignCustomField(customFieldId) {
|
||||
console.log("assignCustomField", customFieldId);
|
||||
return {$addToSet: {customFields: {_id: customFieldId, value: null}}};
|
||||
},
|
||||
|
||||
unassignCustomField(customFieldId) {
|
||||
console.log("unassignCustomField", customFieldId);
|
||||
return {$pull: {customFields: {_id: customFieldId}}};
|
||||
},
|
||||
|
||||
|
@ -296,6 +294,16 @@ Cards.mutations({
|
|||
}
|
||||
},
|
||||
|
||||
setCustomField(customFieldId, value) {
|
||||
// todo
|
||||
const index = this.customFieldIndex(customFieldId);
|
||||
if (index > -1) {
|
||||
var update = {$set: {}};
|
||||
update.$set["customFields." + index + ".value"] = value;
|
||||
return update;
|
||||
}
|
||||
},
|
||||
|
||||
setCover(coverId) {
|
||||
return {$set: {coverId}};
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue