mirror of
https://github.com/wekan/wekan.git
synced 2026-01-31 05:35:16 +01:00
Allow description and member two way binding
This commit is contained in:
parent
a93de07fb9
commit
0a62089df0
6 changed files with 82 additions and 14 deletions
|
|
@ -406,6 +406,18 @@ Cards.helpers({
|
|||
return this.isImportedCard() || this.isImportedBoard();
|
||||
},
|
||||
|
||||
setDescription(description) {
|
||||
if (this.isImportedCard()) {
|
||||
const card = Cards.findOne({_id: this.importedId});
|
||||
return Cards.update({_id: this.importedId}, {$set: {description}});
|
||||
} else if (this.isImportedBoard()) {
|
||||
const board = Boards.findOne({_id: this.importedId});
|
||||
return Boards.update({_id: this.importedId}, {$set: {description}});
|
||||
} else {
|
||||
return {$set: {description}};
|
||||
}
|
||||
},
|
||||
|
||||
getDescription() {
|
||||
if (this.isImportedCard()) {
|
||||
const card = Cards.findOne({_id: this.importedId});
|
||||
|
|
@ -426,6 +438,62 @@ Cards.helpers({
|
|||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
getMembers() {
|
||||
if (this.isImportedCard()) {
|
||||
const card = Cards.findOne({_id: this.importedId});
|
||||
return card.members;
|
||||
} else if (this.isImportedBoard()) {
|
||||
const board = Boards.findOne({_id: this.importedId});
|
||||
return board.activeMembers().map((member) => {
|
||||
return member.userId;
|
||||
});
|
||||
} else {
|
||||
return this.members;
|
||||
}
|
||||
},
|
||||
|
||||
assignMember(memberId) {
|
||||
if (this.isImportedCard()) {
|
||||
return Cards.update(
|
||||
{ _id: this.importedId },
|
||||
{ $addToSet: { members: memberId }}
|
||||
);
|
||||
} else if (this.isImportedBoard()) {
|
||||
const board = Boards.findOne({_id: this.importedId});
|
||||
return board.addMember(memberId);
|
||||
} else {
|
||||
return Cards.update(
|
||||
{ _id: this._id },
|
||||
{ $addToSet: { members: memberId}}
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
unassignMember(memberId) {
|
||||
if (this.isImportedCard()) {
|
||||
return Cards.update(
|
||||
{ _id: this.importedId },
|
||||
{ $pull: { members: memberId }}
|
||||
);
|
||||
} else if (this.isImportedBoard()) {
|
||||
const board = Boards.findOne({_id: this.importedId});
|
||||
return board.removeMember(memberId);
|
||||
} else {
|
||||
return Cards.update(
|
||||
{ _id: this._id },
|
||||
{ $pull: { members: memberId}}
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
toggleMember(memberId) {
|
||||
if (this.getMembers() && this.getMembers().indexOf(memberId) > -1) {
|
||||
return this.unassignMember(memberId);
|
||||
} else {
|
||||
return this.assignMember(memberId);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Cards.mutations({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue