mirror of
https://github.com/wekan/wekan.git
synced 2026-02-27 02:14:06 +01:00
Prepare to create card from template
This commit is contained in:
parent
7a6afb8aea
commit
0fec711545
7 changed files with 57 additions and 60 deletions
|
|
@ -473,6 +473,8 @@ Boards.helpers({
|
|||
if (this.isTemplatesBoard()) {
|
||||
query.type = 'template-card';
|
||||
query.archived = false;
|
||||
} else {
|
||||
query.type = {$nin: ['template-card']};
|
||||
}
|
||||
const projection = { limit: 10, sort: { createdAt: -1 } };
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,12 @@ CardComments.allow({
|
|||
});
|
||||
|
||||
CardComments.helpers({
|
||||
copy(newCardId) {
|
||||
this.cardId = newCardId;
|
||||
this._id = null;
|
||||
CardComments.insert(this);
|
||||
},
|
||||
|
||||
user() {
|
||||
return Users.findOne(this.userId);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -272,6 +272,31 @@ Cards.allow({
|
|||
});
|
||||
|
||||
Cards.helpers({
|
||||
copy() {
|
||||
const oldId = this._id;
|
||||
this._id = null;
|
||||
const _id = Cards.insert(this);
|
||||
|
||||
// copy checklists
|
||||
Checklists.find({cardId: oldId}).forEach((ch) => {
|
||||
ch.copy(_id);
|
||||
});
|
||||
|
||||
// copy subtasks
|
||||
Cards.find({parentId: oldId}).forEach((subtask) => {
|
||||
subtask.parentId = _id;
|
||||
subtask._id = null;
|
||||
Cards.insert(subtask);
|
||||
});
|
||||
|
||||
// copy card comments
|
||||
CardComments.find({cardId: oldId}).forEach((cmt) => {
|
||||
cmt.copy(_id);
|
||||
});
|
||||
|
||||
return _id;
|
||||
},
|
||||
|
||||
list() {
|
||||
return Lists.findOne(this.listId);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -48,6 +48,19 @@ Checklists.attachSchema(new SimpleSchema({
|
|||
}));
|
||||
|
||||
Checklists.helpers({
|
||||
copy(newCardId) {
|
||||
const oldChecklistId = this._id;
|
||||
this._id = null;
|
||||
this.cardId = newCardId;
|
||||
const newChecklistId = Checklists.insert(this);
|
||||
ChecklistItems.find({checklistId: oldChecklistId}).forEach((item) => {
|
||||
item._id = null;
|
||||
item.checklistId = newChecklistId;
|
||||
item.cardId = newCardId;
|
||||
ChecklistItems.insert(item);
|
||||
});
|
||||
},
|
||||
|
||||
itemCount() {
|
||||
return ChecklistItems.find({ checklistId: this._id }).count();
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue