summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorAndrés Manelli <andresmanelli@gmail.com>2019-02-23 20:41:36 +0100
committerAndrés Manelli <andresmanelli@gmail.com>2019-02-24 00:05:00 +0100
commitf888cfd565b197903c24a07221f6a6a44e1b6223 (patch)
tree7745b9c3913ae62f2bc08fb0a1049ec9754f2d4d /models
parent044126188d28a24b0df5d67cf69d081ce7790886 (diff)
downloadwekan-f888cfd565b197903c24a07221f6a6a44e1b6223.tar.gz
wekan-f888cfd565b197903c24a07221f6a6a44e1b6223.tar.bz2
wekan-f888cfd565b197903c24a07221f6a6a44e1b6223.zip
Allow list creation from template
Diffstat (limited to 'models')
-rw-r--r--models/boards.js24
-rw-r--r--models/lists.js18
2 files changed, 42 insertions, 0 deletions
diff --git a/models/boards.js b/models/boards.js
index 25cf5e37..530a6f71 100644
--- a/models/boards.js
+++ b/models/boards.js
@@ -463,6 +463,30 @@ Boards.helpers({
return _id;
},
+ searchLists(term) {
+ check(term, Match.OneOf(String, null, undefined));
+
+ const query = { boardId: this._id };
+ if (this.isTemplatesBoard()) {
+ query.type = 'template-list';
+ query.archived = false;
+ } else {
+ query.type = {$nin: ['template-list']};
+ }
+ const projection = { limit: 10, sort: { createdAt: -1 } };
+
+ if (term) {
+ const regex = new RegExp(term, 'i');
+
+ query.$or = [
+ { title: regex },
+ { description: regex },
+ ];
+ }
+
+ return Lists.find(query, projection);
+ },
+
searchCards(term, excludeLinked) {
check(term, Match.OneOf(String, null, undefined));
diff --git a/models/lists.js b/models/lists.js
index 236432cc..e2ded36e 100644
--- a/models/lists.js
+++ b/models/lists.js
@@ -137,6 +137,24 @@ Lists.allow({
});
Lists.helpers({
+ copy() {
+ const oldId = this._id;
+ this._id = null;
+ const _id = Lists.insert(this);
+
+ // Copy all cards in list
+ Cards.find({
+ listId: oldId,
+ archived: false,
+ }).forEach((card) => {
+ card.type = 'cardType-card';
+ card.listId = _id;
+ card.boardId = this.boardId;
+ card.swimlaneId = this.swimlaneId;
+ card.copy();
+ });
+ },
+
cards(swimlaneId) {
const selector = {
listId: this._id,