1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-24 15:49:46 +02:00

Add preferences tab to user settings, add subscribe to own cards option

This commit is contained in:
Maksim Eltyshev 2020-04-10 00:11:34 +05:00
parent 9b4e3931a9
commit 88314e826d
13 changed files with 96 additions and 2 deletions

View file

@ -40,6 +40,9 @@ module.exports = {
isNotEmptyString: true,
allowNull: true,
},
subscribeToOwnCards: {
type: 'boolean',
},
},
exits: {
@ -59,6 +62,7 @@ module.exports = {
'username',
'phone',
'organization',
'subscribeToOwnCards',
]);
const user = await sails.helpers

View file

@ -32,6 +32,9 @@ module.exports = {
isNotEmptyString: true,
allowNull: true,
},
subscribeToOwnCards: {
type: 'boolean',
},
},
exits: {
@ -57,7 +60,14 @@ module.exports = {
throw Errors.USER_NOT_FOUND;
}
const values = _.pick(inputs, ['isAdmin', 'name', 'avatar', 'phone', 'organization']);
const values = _.pick(inputs, [
'isAdmin',
'name',
'avatar',
'phone',
'organization',
'subscribeToOwnCards',
]);
user = await sails.helpers.updateUser(user, values, this.req);

View file

@ -49,6 +49,17 @@ module.exports = {
boardId: inputs.list.boardId,
}).fetch();
if (inputs.user.subscribeToOwnCards) {
await CardSubscription.create({
cardId: card.id,
userId: inputs.user.id,
}).tolerate('E_UNIQUE');
card.isSubscribed = true;
} else {
card.isSubscribed = false;
}
sails.sockets.broadcast(
`board:${card.boardId}`,
'cardCreate',

View file

@ -52,6 +52,11 @@ module.exports = {
isNotEmptyString: true,
allowNull: true,
},
subscribeToOwnCards: {
type: 'boolean',
defaultsTo: false,
columnName: 'subscribe_to_own_cards',
},
deletedAt: {
type: 'ref',
columnName: 'deleted_at',