mirror of
https://github.com/wekan/wekan.git
synced 2025-04-24 14:08:31 -04:00
Add two way binding of activities, comments, and attachments
This commit is contained in:
parent
49c415f023
commit
74a01691e3
4 changed files with 46 additions and 10 deletions
|
@ -21,11 +21,18 @@ BlazeComponent.extendComponent({
|
|||
'submit .js-new-comment-form'(evt) {
|
||||
const input = this.getInput();
|
||||
const text = input.val().trim();
|
||||
const card = this.currentData();
|
||||
let boardId = card.boardId;
|
||||
let cardId = card._id;
|
||||
if (card.isImportedCard()) {
|
||||
boardId = Cards.findOne(card.importedId).boardId;
|
||||
cardId = card.importedId;
|
||||
}
|
||||
if (text) {
|
||||
CardComments.insert({
|
||||
text,
|
||||
boardId: this.currentData().boardId,
|
||||
cardId: this.currentData()._id,
|
||||
boardId,
|
||||
cardId,
|
||||
});
|
||||
resetCommentInput(input);
|
||||
Tracker.flush();
|
||||
|
|
|
@ -57,8 +57,13 @@ Template.cardAttachmentsPopup.events({
|
|||
const card = this;
|
||||
FS.Utility.eachFile(evt, (f) => {
|
||||
const file = new FS.File(f);
|
||||
file.boardId = card.boardId;
|
||||
file.cardId = card._id;
|
||||
if (card.isImportedCard()) {
|
||||
file.boardId = Cards.findOne(card.importedId).boardId;
|
||||
file.cardId = card.importedId;
|
||||
} else {
|
||||
file.boardId = card.boardId;
|
||||
file.cardId = card._id;
|
||||
}
|
||||
file.userId = Meteor.userId();
|
||||
|
||||
const attachment = Attachments.insert(file);
|
||||
|
|
|
@ -181,19 +181,33 @@ Cards.helpers({
|
|||
},
|
||||
|
||||
isAssigned(memberId) {
|
||||
return _.contains(this.members, memberId);
|
||||
return _.contains(this.getMembers(), memberId);
|
||||
},
|
||||
|
||||
activities() {
|
||||
return Activities.find({cardId: this._id}, {sort: {createdAt: -1}});
|
||||
if (this.isImportedCard()) {
|
||||
return Activities.find({cardId: this.importedId}, {sort: {createdAt: -1}});
|
||||
} else if (this.isImportedBoard()) {
|
||||
return Activities.find({boardId: this.importedId}, {sort: {createdAt: -1}});
|
||||
} else {
|
||||
return Activities.find({cardId: this._id}, {sort: {createdAt: -1}});
|
||||
}
|
||||
},
|
||||
|
||||
comments() {
|
||||
return CardComments.find({cardId: this._id}, {sort: {createdAt: -1}});
|
||||
if (this.isImportedCard()) {
|
||||
return CardComments.find({cardId: this.importedId}, {sort: {createdAt: -1}});
|
||||
} else {
|
||||
return CardComments.find({cardId: this._id}, {sort: {createdAt: -1}});
|
||||
}
|
||||
},
|
||||
|
||||
attachments() {
|
||||
return Attachments.find({cardId: this._id}, {sort: {uploadedAt: -1}});
|
||||
if (this.isImportedCard()) {
|
||||
return Attachments.find({cardId: this.importedId}, {sort: {uploadedAt: -1}});
|
||||
} else {
|
||||
return Attachments.find({cardId: this._id}, {sort: {uploadedAt: -1}});
|
||||
}
|
||||
},
|
||||
|
||||
cover() {
|
||||
|
|
|
@ -99,8 +99,18 @@ Meteor.publishRelations('board', function(boardId) {
|
|||
// And in the meantime our code below works pretty well -- it's not even a
|
||||
// hack!
|
||||
this.cursor(Cards.find({ boardId }), function(cardId, card) {
|
||||
this.cursor(Cards.find({_id: card.importedId}));
|
||||
this.cursor(Boards.find({_id: card.importedId}));
|
||||
if (card.type === 'cardType-importedCard') {
|
||||
const impCardId = card.importedId;
|
||||
this.cursor(Cards.find({ _id: impCardId }));
|
||||
this.cursor(CardComments.find({ cardId: impCardId }));
|
||||
this.cursor(Activities.find({ cardId: impCardId }));
|
||||
this.cursor(Attachments.find({ cardId: impCardId }));
|
||||
this.cursor(Checklists.find({ cardId: impCardId }));
|
||||
this.cursor(ChecklistItems.find({ cardId: impCardId }));
|
||||
} else if (card.type === 'cardType-importedBoard') {
|
||||
this.cursor(Boards.find({ _id: card.importedId}));
|
||||
}
|
||||
this.cursor(Activities.find({ cardId }));
|
||||
this.cursor(CardComments.find({ cardId }));
|
||||
this.cursor(Attachments.find({ cardId }));
|
||||
this.cursor(Checklists.find({ cardId }));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue