mirror of
https://github.com/wekan/wekan.git
synced 2025-04-24 22:17:16 -04:00
Replace the component bounded cachedValue
by a global UnsavedEdits
This new draft saving system is currently only implemented for the card description and comment. We need better a component inheritance/composition model to support this for all editable fields. Fixes #186
This commit is contained in:
parent
cc88e78483
commit
d644cba38f
13 changed files with 252 additions and 95 deletions
34
collections/unsavedEdits.js
Normal file
34
collections/unsavedEdits.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
// 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(function(userId, doc) {
|
||||
doc.userId = userId;
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue