mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02:00

Replace the old (and broken) jshint + jscsrc by eslint and configure it to support some of the ES6 features. The command `eslint` currently has one error which is a bug that was discovered by its static analysis and should be fixed (usage of a dead object).
94 lines
1.8 KiB
JavaScript
94 lines
1.8 KiB
JavaScript
Lists = new Mongo.Collection('lists');
|
|
|
|
Lists.attachSchema(new SimpleSchema({
|
|
title: {
|
|
type: String,
|
|
},
|
|
archived: {
|
|
type: Boolean,
|
|
},
|
|
boardId: {
|
|
type: String,
|
|
},
|
|
createdAt: {
|
|
type: Date,
|
|
denyUpdate: true,
|
|
},
|
|
sort: {
|
|
type: Number,
|
|
decimal: true,
|
|
// XXX We should probably provide a default
|
|
optional: true,
|
|
},
|
|
updatedAt: {
|
|
type: Date,
|
|
denyInsert: true,
|
|
optional: true,
|
|
},
|
|
}));
|
|
|
|
if (Meteor.isServer) {
|
|
Lists.allow({
|
|
insert(userId, doc) {
|
|
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
|
},
|
|
update(userId, doc) {
|
|
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
|
},
|
|
remove(userId, doc) {
|
|
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
|
},
|
|
fetch: ['boardId'],
|
|
});
|
|
}
|
|
|
|
Lists.helpers({
|
|
cards() {
|
|
return Cards.find(Filter.mongoSelector({
|
|
listId: this._id,
|
|
archived: false,
|
|
}), { sort: ['sort'] });
|
|
},
|
|
board() {
|
|
return Boards.findOne(this.boardId);
|
|
},
|
|
});
|
|
|
|
// HOOKS
|
|
Lists.hookOptions.after.update = { fetchPrevious: false };
|
|
|
|
Lists.before.insert((userId, doc) => {
|
|
doc.createdAt = new Date();
|
|
doc.archived = false;
|
|
if (!doc.userId)
|
|
doc.userId = userId;
|
|
});
|
|
|
|
Lists.before.update((userId, doc, fieldNames, modifier) => {
|
|
modifier.$set = modifier.$set || {};
|
|
modifier.$set.modifiedAt = new Date();
|
|
});
|
|
|
|
if (Meteor.isServer) {
|
|
Lists.after.insert((userId, doc) => {
|
|
Activities.insert({
|
|
userId,
|
|
type: 'list',
|
|
activityType: 'createList',
|
|
boardId: doc.boardId,
|
|
listId: doc._id,
|
|
});
|
|
});
|
|
|
|
Lists.after.update((userId, doc) => {
|
|
if (doc.archived) {
|
|
Activities.insert({
|
|
userId,
|
|
type: 'list',
|
|
activityType: 'archivedList',
|
|
listId: doc._id,
|
|
boardId: doc.boardId,
|
|
});
|
|
}
|
|
});
|
|
}
|