mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01: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).
34 lines
740 B
JavaScript
34 lines
740 B
JavaScript
// This collection shouldn't be manipulated directly by instead throw the
|
|
// `UnsavedEdits` API on the client.
|
|
UnsavedEditCollection = new Mongo.Collection('unsaved-edits');
|
|
|
|
UnsavedEditCollection.attachSchema(new SimpleSchema({
|
|
fieldName: {
|
|
type: String,
|
|
},
|
|
docId: {
|
|
type: String,
|
|
},
|
|
value: {
|
|
type: String,
|
|
},
|
|
userId: {
|
|
type: String,
|
|
},
|
|
}));
|
|
|
|
if (Meteor.isServer) {
|
|
function isAuthor(userId, doc, fieldNames = []) {
|
|
return userId === doc.userId && fieldNames.indexOf('userId') === -1;
|
|
}
|
|
UnsavedEditCollection.allow({
|
|
insert: isAuthor,
|
|
update: isAuthor,
|
|
remove: isAuthor,
|
|
fetch: ['userId'],
|
|
});
|
|
}
|
|
|
|
UnsavedEditCollection.before.insert((userId, doc) => {
|
|
doc.userId = userId;
|
|
});
|