mirror of
https://github.com/wekan/wekan.git
synced 2026-02-05 16:11:47 +01:00
Allow swimlane creation from template
Mix lists with same name to avoid duplicates
This commit is contained in:
parent
f888cfd565
commit
60be4df76e
10 changed files with 100 additions and 35 deletions
|
|
@ -463,6 +463,30 @@ Boards.helpers({
|
|||
return _id;
|
||||
},
|
||||
|
||||
searchSwimlanes(term) {
|
||||
check(term, Match.OneOf(String, null, undefined));
|
||||
|
||||
const query = { boardId: this._id };
|
||||
if (this.isTemplatesBoard()) {
|
||||
query.type = 'template-swimlane';
|
||||
query.archived = false;
|
||||
} else {
|
||||
query.type = {$nin: ['template-swimlane']};
|
||||
}
|
||||
const projection = { limit: 10, sort: { createdAt: -1 } };
|
||||
|
||||
if (term) {
|
||||
const regex = new RegExp(term, 'i');
|
||||
|
||||
query.$or = [
|
||||
{ title: regex },
|
||||
{ description: regex },
|
||||
];
|
||||
}
|
||||
|
||||
return Swimlanes.find(query, projection);
|
||||
},
|
||||
|
||||
searchLists(term) {
|
||||
check(term, Match.OneOf(String, null, undefined));
|
||||
|
||||
|
|
|
|||
|
|
@ -139,8 +139,17 @@ Lists.allow({
|
|||
Lists.helpers({
|
||||
copy() {
|
||||
const oldId = this._id;
|
||||
this._id = null;
|
||||
const _id = Lists.insert(this);
|
||||
let _id = null;
|
||||
existingListWithSameName = Lists.findOne({
|
||||
boardId: this.boardId,
|
||||
title: this.title,
|
||||
});
|
||||
if (existingListWithSameName) {
|
||||
_id = existingListWithSameName._id;
|
||||
} else {
|
||||
this._id = null;
|
||||
_id = Lists.insert(this);
|
||||
}
|
||||
|
||||
// Copy all cards in list
|
||||
Cards.find({
|
||||
|
|
@ -213,23 +222,20 @@ Lists.mutations({
|
|||
},
|
||||
|
||||
archive() {
|
||||
Cards.find({
|
||||
listId: this._id,
|
||||
archived: false,
|
||||
}).forEach((card) => {
|
||||
return card.archive();
|
||||
});
|
||||
if (this.isTemplateList()) {
|
||||
this.cards().forEach((card) => {
|
||||
return card.archive();
|
||||
});
|
||||
}
|
||||
return { $set: { archived: true } };
|
||||
},
|
||||
|
||||
restore() {
|
||||
cardsToRestore = Cards.find({
|
||||
listId: this._id,
|
||||
archived: true,
|
||||
});
|
||||
cardsToRestore.forEach((card) => {
|
||||
card.restore();
|
||||
});
|
||||
if (this.isTemplateList()) {
|
||||
this.allCards().forEach((card) => {
|
||||
return card.restore();
|
||||
});
|
||||
}
|
||||
return { $set: { archived: false } };
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -101,6 +101,23 @@ Swimlanes.allow({
|
|||
});
|
||||
|
||||
Swimlanes.helpers({
|
||||
copy() {
|
||||
const oldId = this._id;
|
||||
this._id = null;
|
||||
const _id = Swimlanes.insert(this);
|
||||
|
||||
// Copy all lists in swimlane
|
||||
Lists.find({
|
||||
swimlaneId: oldId,
|
||||
archived: false,
|
||||
}).forEach((list) => {
|
||||
list.type = 'list';
|
||||
list.swimlaneId = _id;
|
||||
list.boardId = this.boardId;
|
||||
list.copy();
|
||||
});
|
||||
},
|
||||
|
||||
cards() {
|
||||
return Cards.find(Filter.mongoSelector({
|
||||
swimlaneId: this._id,
|
||||
|
|
@ -115,6 +132,10 @@ Swimlanes.helpers({
|
|||
}), { sort: ['sort'] });
|
||||
},
|
||||
|
||||
allLists() {
|
||||
return Lists.find({ swimlaneId: this._id });
|
||||
},
|
||||
|
||||
allCards() {
|
||||
return Cards.find({ swimlaneId: this._id });
|
||||
},
|
||||
|
|
@ -159,10 +180,20 @@ Swimlanes.mutations({
|
|||
},
|
||||
|
||||
archive() {
|
||||
if (this.isTemplateSwimlane()) {
|
||||
this.lists().forEach((list) => {
|
||||
return list.archive();
|
||||
});
|
||||
}
|
||||
return { $set: { archived: true } };
|
||||
},
|
||||
|
||||
restore() {
|
||||
if (this.isTemplateSwimlane()) {
|
||||
this.allLists().forEach((list) => {
|
||||
return list.restore();
|
||||
});
|
||||
}
|
||||
return { $set: { archived: false } };
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue